version 1.8, 2002/01/03 03:49:16 |
version 1.9, 2003/04/03 19:15:34 |
|
|
/* |
/* |
* Copyright (c) 1999-2001 Todd C. Miller <Todd.Miller@courtesan.com> |
* Copyright (c) 1999-2001, 2003 Todd C. Miller <Todd.Miller@courtesan.com> |
* All rights reserved. |
* All rights reserved. |
* |
* |
* Redistribution and use in source and binary forms, with or without |
* Redistribution and use in source and binary forms, with or without |
|
|
# ifdef HAVE_UNISTD_H |
# ifdef HAVE_UNISTD_H |
#include <unistd.h> |
#include <unistd.h> |
#endif /* HAVE_UNISTD_H */ |
#endif /* HAVE_UNISTD_H */ |
|
#ifdef HAVE_ERR_H |
|
# include <err.h> |
|
#else |
|
# include "emul/err.h" |
|
#endif /* HAVE_ERR_H */ |
#include <ctype.h> |
#include <ctype.h> |
|
|
#include "sudo.h" |
#include "sudo.h" |
|
|
#ifndef lint |
#ifndef lint |
static const char rcsid[] = "$Sudo: defaults.c,v 1.38 2001/12/30 18:40:09 millert Exp $"; |
static const char rcsid[] = "$Sudo: defaults.c,v 1.39 2003/04/02 18:25:19 millert Exp $"; |
#endif /* lint */ |
#endif /* lint */ |
|
|
/* |
/* |
|
|
break; |
break; |
} |
} |
if (!cur->name) { |
if (!cur->name) { |
(void) fprintf(stderr, |
warnx("unknown defaults entry `%s' referenced near line %d", |
"%s: unknown defaults entry `%s' referenced near line %d\n", Argv[0], |
|
var, sudolineno); |
var, sudolineno); |
return(FALSE); |
return(FALSE); |
} |
} |
|
|
case T_LOGFAC: |
case T_LOGFAC: |
if (!store_syslogfac(val, cur, op)) { |
if (!store_syslogfac(val, cur, op)) { |
if (val) |
if (val) |
(void) fprintf(stderr, |
warnx("value `%s' is invalid for option `%s'", val, var); |
"%s: value '%s' is invalid for option '%s'\n", Argv[0], |
|
val, var); |
|
else |
else |
(void) fprintf(stderr, |
warnx("no value specified for `%s' on line %d", |
"%s: no value specified for `%s' on line %d\n", Argv[0], |
|
var, sudolineno); |
var, sudolineno); |
return(FALSE); |
return(FALSE); |
} |
} |
|
|
case T_LOGPRI: |
case T_LOGPRI: |
if (!store_syslogpri(val, cur, op)) { |
if (!store_syslogpri(val, cur, op)) { |
if (val) |
if (val) |
(void) fprintf(stderr, |
warnx("value `%s' is invalid for option `%s'", val, var); |
"%s: value '%s' is invalid for option '%s'\n", Argv[0], |
|
val, var); |
|
else |
else |
(void) fprintf(stderr, |
warnx("no value specified for `%s' on line %d", |
"%s: no value specified for `%s' on line %d\n", Argv[0], |
|
var, sudolineno); |
var, sudolineno); |
return(FALSE); |
return(FALSE); |
} |
} |
|
|
case T_PWFLAG: |
case T_PWFLAG: |
if (!store_pwflag(val, cur, op)) { |
if (!store_pwflag(val, cur, op)) { |
if (val) |
if (val) |
(void) fprintf(stderr, |
warnx("value `%s' is invalid for option `%s'", val, var); |
"%s: value '%s' is invalid for option '%s'\n", Argv[0], |
|
val, var); |
|
else |
else |
(void) fprintf(stderr, |
warnx("no value specified for `%s' on line %d", |
"%s: no value specified for `%s' on line %d\n", Argv[0], |
|
var, sudolineno); |
var, sudolineno); |
return(FALSE); |
return(FALSE); |
} |
} |
|
|
if (!val) { |
if (!val) { |
/* Check for bogus boolean usage or lack of a value. */ |
/* Check for bogus boolean usage or lack of a value. */ |
if (!(cur->type & T_BOOL) || op != FALSE) { |
if (!(cur->type & T_BOOL) || op != FALSE) { |
(void) fprintf(stderr, |
warnx("no value specified for `%s' on line %d", |
"%s: no value specified for `%s' on line %d\n", Argv[0], |
|
var, sudolineno); |
var, sudolineno); |
return(FALSE); |
return(FALSE); |
} |
} |
} |
} |
if ((cur->type & T_PATH) && val && *val != '/') { |
if ((cur->type & T_PATH) && val && *val != '/') { |
(void) fprintf(stderr, |
warnx("values for `%s' must start with a '/'", var); |
"%s: values for `%s' must start with a '/'\n", Argv[0], |
|
var); |
|
return(FALSE); |
return(FALSE); |
} |
} |
if (!store_str(val, cur, op)) { |
if (!store_str(val, cur, op)) { |
(void) fprintf(stderr, |
warnx("value `%s' is invalid for option `%s'", val, var); |
"%s: value '%s' is invalid for option '%s'\n", Argv[0], |
|
val, var); |
|
return(FALSE); |
return(FALSE); |
} |
} |
break; |
break; |
|
|
if (!val) { |
if (!val) { |
/* Check for bogus boolean usage or lack of a value. */ |
/* Check for bogus boolean usage or lack of a value. */ |
if (!(cur->type & T_BOOL) || op != FALSE) { |
if (!(cur->type & T_BOOL) || op != FALSE) { |
(void) fprintf(stderr, |
warnx("no value specified for `%s' on line %d", |
"%s: no value specified for `%s' on line %d\n", Argv[0], |
|
var, sudolineno); |
var, sudolineno); |
return(FALSE); |
return(FALSE); |
} |
} |
} |
} |
if (!store_int(val, cur, op)) { |
if (!store_int(val, cur, op)) { |
(void) fprintf(stderr, |
warnx("value `%s' is invalid for option `%s'", val, var); |
"%s: value '%s' is invalid for option '%s'\n", Argv[0], |
|
val, var); |
|
return(FALSE); |
return(FALSE); |
} |
} |
break; |
break; |
|
|
if (!val) { |
if (!val) { |
/* Check for bogus boolean usage or lack of a value. */ |
/* Check for bogus boolean usage or lack of a value. */ |
if (!(cur->type & T_BOOL) || op != FALSE) { |
if (!(cur->type & T_BOOL) || op != FALSE) { |
(void) fprintf(stderr, |
warnx("no value specified for `%s' on line %d", |
"%s: no value specified for `%s' on line %d\n", Argv[0], |
|
var, sudolineno); |
var, sudolineno); |
return(FALSE); |
return(FALSE); |
} |
} |
} |
} |
if (!store_uint(val, cur, op)) { |
if (!store_uint(val, cur, op)) { |
(void) fprintf(stderr, |
warnx("value `%s' is invalid for option `%s'", val, var); |
"%s: value '%s' is invalid for option '%s'\n", Argv[0], |
|
val, var); |
|
return(FALSE); |
return(FALSE); |
} |
} |
break; |
break; |
|
|
if (!val) { |
if (!val) { |
/* Check for bogus boolean usage or lack of a value. */ |
/* Check for bogus boolean usage or lack of a value. */ |
if (!(cur->type & T_BOOL) || op != FALSE) { |
if (!(cur->type & T_BOOL) || op != FALSE) { |
(void) fprintf(stderr, |
warnx("no value specified for `%s' on line %d", |
"%s: no value specified for `%s' on line %d\n", Argv[0], |
|
var, sudolineno); |
var, sudolineno); |
return(FALSE); |
return(FALSE); |
} |
} |
} |
} |
if (!store_mode(val, cur, op)) { |
if (!store_mode(val, cur, op)) { |
(void) fprintf(stderr, |
warnx("value `%s' is invalid for option `%s'", val, var); |
"%s: value '%s' is invalid for option '%s'\n", Argv[0], |
|
val, var); |
|
return(FALSE); |
return(FALSE); |
} |
} |
break; |
break; |
case T_FLAG: |
case T_FLAG: |
if (val) { |
if (val) { |
(void) fprintf(stderr, |
warnx("option `%s' does not take a value on line %d", |
"%s: option `%s' does not take a value on line %d\n", |
var, sudolineno); |
Argv[0], var, sudolineno); |
|
return(FALSE); |
return(FALSE); |
} |
} |
cur->sd_un.flag = op; |
cur->sd_un.flag = op; |
|
|
if (!val) { |
if (!val) { |
/* Check for bogus boolean usage or lack of a value. */ |
/* Check for bogus boolean usage or lack of a value. */ |
if (!(cur->type & T_BOOL) || op != FALSE) { |
if (!(cur->type & T_BOOL) || op != FALSE) { |
(void) fprintf(stderr, |
warnx("no value specified for `%s' on line %d", |
"%s: no value specified for `%s' on line %d\n", Argv[0], |
|
var, sudolineno); |
var, sudolineno); |
return(FALSE); |
return(FALSE); |
} |
} |
} |
} |
if (!store_list(val, cur, op)) { |
if (!store_list(val, cur, op)) { |
(void) fprintf(stderr, |
warnx("value `%s' is invalid for option `%s'", val, var); |
"%s: value '%s' is invalid for option '%s'\n", Argv[0], |
|
val, var); |
|
return(FALSE); |
return(FALSE); |
} |
} |
} |
} |