aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2020-08-12 20:36:23 -0400
committerNick Mathewson <nickm@torproject.org>2020-08-12 20:36:23 -0400
commit7b4716a7624b73e60f70485ac577ef6cf884e67c (patch)
tree8b02757797a168e84cd7a7513854dd713f6ee1aa /src
parenteffc9739bfb3c91171be47673c67ec2bd05c2758 (diff)
downloadtor-7b4716a7624b73e60f70485ac577ef6cf884e67c.tar.gz
tor-7b4716a7624b73e60f70485ac577ef6cf884e67c.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/test/test_util.c13
1 files 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