11291: Fix warnings, add changes file, rename 'mask'.

This commit is contained in:
Nick Mathewson 2014-11-05 14:09:59 -05:00
parent 4df419a4b1
commit 8f645befba
3 changed files with 10 additions and 6 deletions

4
changes/ticket-11291 Normal file
View File

@ -0,0 +1,4 @@
o Minor features (hidden services):
- New HiddenServiceDirGroupReadable option to cause hidden service
directories and hostname files to be created group-readable.
Patch from "anon", David Stainton, and "meejah".

View File

@ -2012,8 +2012,7 @@ check_private_dir(const char *dirname, cpd_check_t check,
struct stat st;
char *f;
#ifndef _WIN32
int mask = 0;
int perm = 0;
unsigned unwanted_bits = 0;
const struct passwd *pw = NULL;
uid_t running_uid;
gid_t running_gid;
@ -2112,11 +2111,11 @@ check_private_dir(const char *dirname, cpd_check_t check,
return -1;
}
if (check & (CPD_GROUP_OK|CPD_GROUP_READ)) {
mask = 0027;
unwanted_bits = 0027;
} else {
mask = 0077;
unwanted_bits = 0077;
}
if (st.st_mode & mask) {
if ((st.st_mode & unwanted_bits) != 0) {
unsigned new_mode;
if (check & CPD_CHECK_MODE_ONLY) {
log_warn(LD_FS, "Permissions on directory %s are too permissive.",
@ -2129,7 +2128,7 @@ check_private_dir(const char *dirname, cpd_check_t check,
if (check & CPD_GROUP_READ) {
new_mode |= 0050; /* Group should have rx */
}
new_mode &= ~mask; /* Clear the other bits that we didn't want set...*/
new_mode &= ~unwanted_bits; /* Clear the bits that we didn't want set...*/
if (chmod(dirname, new_mode)) {
log_warn(LD_FS, "Could not chmod directory %s: %s", dirname,
strerror(errno));

View File

@ -12,6 +12,7 @@
static void
test_checkdir_perms(void *testdata)
{
(void)testdata;
or_options_t *options = get_options_mutable();
const char *subdir = "test_checkdir";
char *testdir;