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

[tor-commits] [tor/master] Make test_glob() pass even when run as root.



commit 7b4716a7624b73e60f70485ac577ef6cf884e67c
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Wed Aug 12 20:36:23 2020 -0400

    Make test_glob() pass even when run as root.
    
    Previously the test relied on not being able to look inside 000
    directories, which is a thing root _can_ do.
    
    Bug not in any released Tor version.
---
 src/test/test_util.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/test/test_util.c b/src/test/test_util.c
index 230f2c7034..0e2550d5c5 100644
--- a/src/test/test_util.c
+++ b/src/test/test_util.c
@@ -4622,11 +4622,14 @@ test_util_glob(void *ptr)
   TEST("\\*");
   EXPECT_EMPTY();
 
-  // test forbidden directory
-  tor_asprintf(&pattern, "%s"PATH_SEPARATOR"*"PATH_SEPARATOR"*", dirname);
-  results = tor_glob(pattern);
-  tor_free(pattern);
-  tt_assert(!results);
+  if (getuid() != 0) {
+    // test forbidden directory, if we're not root.
+    // (Root will be able to see this directory anyway.)
+    tor_asprintf(&pattern, "%s"PATH_SEPARATOR"*"PATH_SEPARATOR"*", dirname);
+    results = tor_glob(pattern);
+    tor_free(pattern);
+    tt_assert(!results);
+  }
 #endif
 
 #undef TEST

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