]> granicus.if.org Git - sudo/commitdiff
o Add T_PATH flag to allow simple sanity checks for default values that
authorTodd C. Miller <Todd.Miller@courtesan.com>
Sun, 10 Oct 1999 17:56:02 +0000 (17:56 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Sun, 10 Oct 1999 17:56:02 +0000 (17:56 +0000)
  are supposed to be pathnames.
o Fix a duplicate free when visudo finds an error.

defaults.c
defaults.h

index 3287cc73370a999d437a5acd99a568a50d837f48..c10b48b602a08e61598000f3f0a8648d4ca900d8 100644 (file)
@@ -195,10 +195,10 @@ struct sudo_defs_types sudo_defs_table[] = {
        "umask", T_MODE|T_BOOL, { 0 },
        "Umask to use or 0777 to use user's: 0%o"
     }, {
-       "logfile", T_STR|T_BOOL, { 0 },
+       "logfile", T_STR|T_BOOL|T_PATH, { 0 },
        "Path to log file: %s"
     }, {
-       "mailerpath", T_STR|T_BOOL, { 0 },
+       "mailerpath", T_STR|T_BOOL|T_PATH, { 0 },
        "Path to mail program: %s"
     }, {
        "mailerflags", T_STR|T_BOOL, { 0 },
@@ -213,7 +213,7 @@ struct sudo_defs_types sudo_defs_table[] = {
        "badpass_message", T_STR, { 0 },
        "Incorrect password message: %s"
     }, {
-       "timestampdir", T_STR, { 0 },
+       "timestampdir", T_STR|T_PATH, { 0 },
        "Path to authentication timestamp dir: %s"
     }, {
        "exempt_group", T_STR|T_BOOL, { 0 },
@@ -354,6 +354,12 @@ set_default(var, val, op)
                    return(FALSE);
                }
            }
+           if ((cur->type & T_PATH) && *val != '/') {
+               (void) fprintf(stderr,
+                   "%s: values for `%s' must start with a '/'\n", Argv[0],
+                   var);
+               return(FALSE);
+           }
            if (!store_str(val, cur, op)) {
                (void) fprintf(stderr,
                    "%s: value '%s' is invalid for option '%s'\n", Argv[0],
@@ -426,8 +432,10 @@ init_defaults()
                case T_STR:
                case T_LOGFAC:
                case T_LOGPRI:
-                   if (def->sd_un.str)
+                   if (def->sd_un.str) {
                        free(def->sd_un.str);
+                       def->sd_un.str = NULL;
+                   }
                    break;
            }
     }
index 76d12f4413b1e734b485e9c555cdf4e08ff5d8c5..e5d61ba3988f7098bbba59dd87c750e2af17a03a 100644 (file)
@@ -65,6 +65,7 @@ struct sudo_defs_types {
 #define T_LOGPRI       0x006
 #define T_MASK         0x0FF
 #define T_BOOL         0x100
+#define T_PATH         0x200
 
 /*
  * Indexes into sudo_defs_table