diff options
-rw-r--r-- | lib/libc/gen/glob.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/libc/gen/glob.c b/lib/libc/gen/glob.c index f58fd8d..0c6fe5d 100644 --- a/lib/libc/gen/glob.c +++ b/lib/libc/gen/glob.c @@ -358,10 +358,11 @@ globtilde(pattern, patbuf, patbuf_len, pglob) if (((char *) patbuf)[0] == EOS) { /* - * handle a plain ~ or ~/ by expanding $HOME - * first and then trying the password file + * handle a plain ~ or ~/ by expanding $HOME first (iff + * we're not running setuid or setgid) and then trying + * the password file */ - if ((h = getenv("HOME")) == NULL) { + if (issetugid() != 0 || (h = getenv("HOME")) == NULL) { if ((pwd = getpwuid(getuid())) == NULL) return pattern; else |