2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-09-01 14:55:12 +00:00

Error out if syslog parameters are given without a value. For Ultrix or

4.2BSD "syslog" is allowed without a value since there are no facilities
in the 4.2BSD syslog.
This commit is contained in:
Todd C. Miller
1999-10-16 17:56:31 +00:00
parent 041188d02f
commit be02f53eae

View File

@@ -96,6 +96,8 @@ static struct strmap priorities[] = {
{ NULL, -1 } { NULL, -1 }
}; };
extern int sudolineno;
/* /*
* Local prototypes. * Local prototypes.
*/ */
@@ -316,7 +318,6 @@ set_default(var, val, op)
int op; /* TRUE or FALSE */ int op; /* TRUE or FALSE */
{ {
struct sudo_defs_types *cur; struct sudo_defs_types *cur;
extern int sudolineno;
for (cur = sudo_defs_table; cur->name; cur++) { for (cur = sudo_defs_table; cur->name; cur++) {
if (strcmp(var, cur->name) == 0) if (strcmp(var, cur->name) == 0)
@@ -332,17 +333,27 @@ set_default(var, val, op)
switch (cur->type & T_MASK) { switch (cur->type & T_MASK) {
case T_LOGFAC: case T_LOGFAC:
if (!store_syslogfac(val, cur, op)) { if (!store_syslogfac(val, cur, op)) {
(void) fprintf(stderr, if (val)
"%s: value '%s' is invalid for option '%s'\n", Argv[0], (void) fprintf(stderr,
val, var); "%s: value '%s' is invalid for option '%s'\n", Argv[0],
val, var);
else
(void) fprintf(stderr,
"%s: no value specified for `%s' on line %d\n", Argv[0],
var, sudolineno);
return(FALSE); return(FALSE);
} }
break; break;
case T_LOGPRI: case T_LOGPRI:
if (!store_syslogpri(val, cur, op)) { if (!store_syslogpri(val, cur, op)) {
(void) fprintf(stderr, if (val)
"%s: value '%s' is invalid for option '%s'\n", Argv[0], (void) fprintf(stderr,
val, var); "%s: value '%s' is invalid for option '%s'\n", Argv[0],
val, var);
else
(void) fprintf(stderr,
"%s: no value specified for `%s' on line %d\n", Argv[0],
var, sudolineno);
return(FALSE); return(FALSE);
} }
break; break;
@@ -592,8 +603,9 @@ store_syslogfac(val, def, op)
def->sd_un.str = NULL; def->sd_un.str = NULL;
return(TRUE); return(TRUE);
} }
#ifdef LOG_NFACILITIES #ifdef LOG_NFACILITIES
if (!val)
return(FALSE);
for (fac = facilities; fac->name && strcmp(val, fac->name); fac++) for (fac = facilities; fac->name && strcmp(val, fac->name); fac++)
; ;
if (fac->name == NULL) if (fac->name == NULL)
@@ -604,6 +616,10 @@ store_syslogfac(val, def, op)
free(def->sd_un.str); free(def->sd_un.str);
def->sd_un.str = estrdup(fac->name); def->sd_un.str = estrdup(fac->name);
sudo_defs_table[I_LOGFAC].sd_un.ival = fac->num; sudo_defs_table[I_LOGFAC].sd_un.ival = fac->num;
#else
if (def->sd_un.str)
free(def->sd_un.str);
def->sd_un.str = estrdup("default");
#endif /* LOG_NFACILITIES */ #endif /* LOG_NFACILITIES */
return(TRUE); return(TRUE);
} }
@@ -617,7 +633,7 @@ store_syslogpri(val, def, op)
struct strmap *pri; struct strmap *pri;
struct sudo_defs_types *idef; struct sudo_defs_types *idef;
if (op == FALSE) if (op == FALSE || !val)
return(FALSE); return(FALSE);
if (def == &sudo_defs_table[I_GOODPRISTR]) if (def == &sudo_defs_table[I_GOODPRISTR])
idef = &sudo_defs_table[I_GOODPRI]; idef = &sudo_defs_table[I_GOODPRI];