mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
Merge remote-tracking branch 'weasel/bug18458'
This commit is contained in:
+6
-2
@@ -2063,7 +2063,6 @@ check_private_dir(const char *dirname, cpd_check_t check,
|
||||
|
||||
#ifndef _WIN32
|
||||
int fd;
|
||||
unsigned unwanted_bits = 0;
|
||||
const struct passwd *pw = NULL;
|
||||
uid_t running_uid;
|
||||
gid_t running_gid;
|
||||
@@ -2200,12 +2199,17 @@ check_private_dir(const char *dirname, cpd_check_t check,
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
unsigned unwanted_bits = 0;
|
||||
if (check & (CPD_GROUP_OK|CPD_GROUP_READ)) {
|
||||
unwanted_bits = 0027;
|
||||
} else {
|
||||
unwanted_bits = 0077;
|
||||
}
|
||||
if ((st.st_mode & unwanted_bits) != 0) {
|
||||
unsigned check_bits_filter = ~0;
|
||||
if (check & CPD_RELAX_DIRMODE_CHECK) {
|
||||
check_bits_filter = 0022;
|
||||
}
|
||||
if ((st.st_mode & unwanted_bits & check_bits_filter) != 0) {
|
||||
unsigned new_mode;
|
||||
if (check & CPD_CHECK_MODE_ONLY) {
|
||||
log_warn(LD_FS, "Permissions on directory %s are too permissive.",
|
||||
|
||||
+7
-6
@@ -357,12 +357,13 @@ file_status_t file_status(const char *filename);
|
||||
/** Possible behaviors for check_private_dir() on encountering a nonexistent
|
||||
* directory; see that function's documentation for details. */
|
||||
typedef unsigned int cpd_check_t;
|
||||
#define CPD_NONE 0
|
||||
#define CPD_CREATE 1
|
||||
#define CPD_CHECK 2
|
||||
#define CPD_GROUP_OK 4
|
||||
#define CPD_GROUP_READ 8
|
||||
#define CPD_CHECK_MODE_ONLY 16
|
||||
#define CPD_NONE 0
|
||||
#define CPD_CREATE (1u << 0)
|
||||
#define CPD_CHECK (1u << 1)
|
||||
#define CPD_GROUP_OK (1u << 2)
|
||||
#define CPD_GROUP_READ (1u << 3)
|
||||
#define CPD_CHECK_MODE_ONLY (1u << 4)
|
||||
#define CPD_RELAX_DIRMODE_CHECK (1u << 5)
|
||||
int check_private_dir(const char *dirname, cpd_check_t check,
|
||||
const char *effective_user);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user