diff options
author | David Stainton <dstainton415@gmail.com> | 2014-09-02 22:46:46 +0000 |
---|---|---|
committer | David Stainton <dstainton415@gmail.com> | 2014-09-03 03:53:32 +0000 |
commit | 7203040835f6b9379ab6c8a730a18409f07bfc53 (patch) | |
tree | ab62b5680f9bfffffadd55488ed1380b0c76bd88 /src/common/util.c | |
parent | a6f2d2091b4abd7a699d75e6c89ebbbb2384cc8e (diff) | |
download | tor-7203040835f6b9379ab6c8a730a18409f07bfc53.tar.gz tor-7203040835f6b9379ab6c8a730a18409f07bfc53.zip |
Fix regression nickm pointed out
Diffstat (limited to 'src/common/util.c')
-rw-r--r-- | src/common/util.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/common/util.c b/src/common/util.c index c5b47b13f8..791ca136c3 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -1889,6 +1889,8 @@ check_private_dir(const char *dirname, cpd_check_t check, struct stat st; char *f; #ifndef _WIN32 + int mask = 0; + int perm = 0; const struct passwd *pw = NULL; uid_t running_uid; gid_t running_gid; @@ -1986,29 +1988,31 @@ check_private_dir(const char *dirname, cpd_check_t check, tor_free(process_groupname); return -1; } - if (check & CPD_CHECK_MODE_ONLY) { - if (st.st_mode & 0077) { - log_warn(LD_FS, "Permissions on directory %s are too permissive.", - dirname); - return -1; + if(check & CPD_CHECK_MODE_ONLY) { + if(check & CPD_GROUP_OK || check & CPD_GROUP_READ) { + if (!st.st_mode & 0027) { + log_warn(LD_FS, "Incorrect permissions on directory %s a.", dirname); + return -1; + } } } else { log_warn(LD_FS, "Fixing permissions on directory %s", dirname); unsigned new_mode; + new_mode = 0700; + if (check & CPD_GROUP_OK) { + new_mode = 0700; + } if (check & CPD_GROUP_READ) { new_mode = 0750; - } else { - new_mode = 0700; } if (chmod(dirname, new_mode)) { log_warn(LD_FS, "Could not chmod directory %s: %s", dirname, - strerror(errno)); + strerror(errno)); return -1; } else { return 0; } } - #endif return 0; } |