Whamcloud - gitweb
debugfs: use ss_safe_getenv() instead of getenv()
authorTheodore Ts'o <tytso@mit.edu>
Tue, 14 Feb 2012 22:01:48 +0000 (17:01 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 15 Feb 2012 21:18:29 +0000 (16:18 -0500)
In the case where debugfs (or rdebugfs) is installed setgid disk, or
some such, we need to disable the use of environment variables for the
obvious reasons.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
debugfs/util.c
lib/ss/ss.h

index 7cbf34d..f43b470 100644 (file)
@@ -26,6 +26,7 @@ extern char *optarg;
 extern int optreset;           /* defined by BSD, but not others */
 #endif
 
+#include "ss/ss.h"
 #include "debugfs.h"
 
 /*
@@ -79,14 +80,14 @@ static const char *find_pager(char *buf)
 FILE *open_pager(void)
 {
        FILE *outfile = 0;
-       const char *pager = getenv("DEBUGFS_PAGER");
+       const char *pager = ss_safe_getenv("DEBUGFS_PAGER");
        char buf[80];
 
        signal(SIGPIPE, SIG_IGN);
        if (!isatty(1))
                return stdout;
        if (!pager)
-               pager = getenv("PAGER");
+               pager = ss_safe_getenv("PAGER");
        if (!pager)
                pager = find_pager(buf);
        if (!pager ||
@@ -197,7 +198,7 @@ char *time_to_string(__u32 cl)
 
        if (do_gmt == -1) {
                /* The diet libc doesn't respect the TZ environemnt variable */
-               tz = getenv("TZ");
+               tz = ss_safe_getenv("TZ");
                if (!tz)
                        tz = "";
                do_gmt = !strcmp(tz, "GMT");
index 6cc050b..7333ffc 100644 (file)
@@ -90,6 +90,7 @@ void ss_unimplemented(int argc, const char * const *argv,
 void ss_set_prompt(int sci_idx, char *new_prompt);
 char *ss_get_prompt(int sci_idx);
 void ss_get_readline(int sci_idx);
+char *ss_safe_getenv(const char *arg);
 
 extern ss_request_table ss_std_requests;
 #endif /* _ss_h */