mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2025-02-25 15:10:48 +01:00
Fix regression nickm pointed out
This commit is contained in:
parent
a6f2d2091b
commit
7203040835
1 changed files with 13 additions and 9 deletions
|
@ -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,19 +1988,22 @@ 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);
|
||||
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,
|
||||
|
@ -2008,7 +2013,6 @@ check_private_dir(const char *dirname, cpd_check_t check,
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue