[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] 11291: Fix warnings, add changes file, rename 'mask'.



commit 8f645befba4c1c5df9c6f4ef832d217b1fdfed76
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Wed Nov 5 14:09:59 2014 -0500

    11291: Fix warnings, add changes file, rename 'mask'.
---
 changes/ticket-11291     |    4 ++++
 src/common/util.c        |   11 +++++------
 src/test/test_checkdir.c |    1 +
 3 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/changes/ticket-11291 b/changes/ticket-11291
new file mode 100644
index 0000000..4c19f3c
--- /dev/null
+++ b/changes/ticket-11291
@@ -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".
diff --git a/src/common/util.c b/src/common/util.c
index b616d1f..50097da 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -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));
diff --git a/src/test/test_checkdir.c b/src/test/test_checkdir.c
index 7bf735e..409ba80 100644
--- a/src/test/test_checkdir.c
+++ b/src/test/test_checkdir.c
@@ -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;

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits