|
version 1.1.1.1, 2012/02/21 16:23:02
|
version 1.1.1.2, 2012/05/29 12:26:49
|
|
Line 1
|
Line 1
|
| /* |
/* |
| * Copyright (c) 1993-1996, 1998-2011 Todd C. Miller <Todd.Miller@courtesan.com> | * Copyright (c) 1993-1996, 1998-2012 Todd C. Miller <Todd.Miller@courtesan.com> |
| * |
* |
| * Permission to use, copy, modify, and distribute this software for any |
* Permission to use, copy, modify, and distribute this software for any |
| * purpose with or without fee is hereby granted, provided that the above |
* purpose with or without fee is hereby granted, provided that the above |
|
Line 72 static struct sudo_settings {
|
Line 72 static struct sudo_settings {
|
| { "bsdauth_type" }, |
{ "bsdauth_type" }, |
| #define ARG_LOGIN_CLASS 1 |
#define ARG_LOGIN_CLASS 1 |
| { "login_class" }, |
{ "login_class" }, |
| #define ARG_DEBUG_LEVEL 2 | #define ARG_DEBUG_FLAGS 2 |
| { "debug_level" }, | { "debug_flags" }, |
| #define ARG_PRESERVE_ENVIRONMENT 3 |
#define ARG_PRESERVE_ENVIRONMENT 3 |
| { "preserve_environment" }, |
{ "preserve_environment" }, |
| #define ARG_RUNAS_GROUP 4 |
#define ARG_RUNAS_GROUP 4 |
|
Line 126 parse_args(int argc, char **argv, int *nargc, char ***
|
Line 126 parse_args(int argc, char **argv, int *nargc, char ***
|
| int valid_flags, ch; |
int valid_flags, ch; |
| int i, j; |
int i, j; |
| char *cp, **env_add, **settings; |
char *cp, **env_add, **settings; |
| |
const char *debug_flags; |
| int nenv = 0; |
int nenv = 0; |
| int env_size = 32; |
int env_size = 32; |
| |
debug_decl(parse_args, SUDO_DEBUG_ARGS) |
| |
|
| env_add = emalloc2(env_size, sizeof(char *)); |
env_add = emalloc2(env_size, sizeof(char *)); |
| |
|
|
Line 144 parse_args(int argc, char **argv, int *nargc, char ***
|
Line 146 parse_args(int argc, char **argv, int *nargc, char ***
|
| if (get_net_ifs(&cp) > 0) |
if (get_net_ifs(&cp) > 0) |
| sudo_settings[ARG_NET_ADDRS].value = cp; |
sudo_settings[ARG_NET_ADDRS].value = cp; |
| |
|
| |
/* Set debug file and flags from sudo.conf. */ |
| |
debug_flags = sudo_conf_debug_flags(); |
| |
if (debug_flags != NULL) |
| |
sudo_settings[ARG_DEBUG_FLAGS].value = debug_flags; |
| |
|
| /* Returns true if the last option string was "--" */ |
/* Returns true if the last option string was "--" */ |
| #define got_end_of_args (optind > 1 && argv[optind - 1][0] == '-' && \ |
#define got_end_of_args (optind > 1 && argv[optind - 1][0] == '-' && \ |
| argv[optind - 1][1] == '-' && argv[optind - 1][2] == '\0') |
argv[optind - 1][1] == '-' && argv[optind - 1][2] == '\0') |
|
Line 188 parse_args(int argc, char **argv, int *nargc, char ***
|
Line 195 parse_args(int argc, char **argv, int *nargc, char ***
|
| break; |
break; |
| #endif |
#endif |
| case 'D': |
case 'D': |
| if ((debug_level = atoi(optarg)) < 1 || debug_level > 9) { | /* Ignored for backwards compatibility. */ |
| warningx(_("the argument to -D must be between 1 and 9 inclusive")); | |
| usage(1); | |
| } | |
| sudo_settings[ARG_DEBUG_LEVEL].value = optarg; | |
| break; |
break; |
| case 'E': |
case 'E': |
| sudo_settings[ARG_PRESERVE_ENVIRONMENT].value = "true"; |
sudo_settings[ARG_PRESERVE_ENVIRONMENT].value = "true"; |
|
Line 314 parse_args(int argc, char **argv, int *nargc, char ***
|
Line 317 parse_args(int argc, char **argv, int *nargc, char ***
|
| if (!mode) { |
if (!mode) { |
| /* Defer -k mode setting until we know whether it is a flag or not */ |
/* Defer -k mode setting until we know whether it is a flag or not */ |
| if (sudo_settings[ARG_IGNORE_TICKET].value != NULL) { |
if (sudo_settings[ARG_IGNORE_TICKET].value != NULL) { |
| if (argc == 0) { | if (argc == 0 && !(flags & (MODE_SHELL|MODE_LOGIN_SHELL))) { |
| mode = MODE_INVALIDATE; /* -k by itself */ |
mode = MODE_INVALIDATE; /* -k by itself */ |
| sudo_settings[ARG_IGNORE_TICKET].value = NULL; |
sudo_settings[ARG_IGNORE_TICKET].value = NULL; |
| valid_flags = 0; |
valid_flags = 0; |
|
Line 421 parse_args(int argc, char **argv, int *nargc, char ***
|
Line 424 parse_args(int argc, char **argv, int *nargc, char ***
|
| settings = emalloc2(NUM_SETTINGS + 1, sizeof(char *)); |
settings = emalloc2(NUM_SETTINGS + 1, sizeof(char *)); |
| for (i = 0, j = 0; i < NUM_SETTINGS; i++) { |
for (i = 0, j = 0; i < NUM_SETTINGS; i++) { |
| if (sudo_settings[i].value) { |
if (sudo_settings[i].value) { |
| sudo_debug(9, "settings: %s=%s", sudo_settings[i].name, | sudo_debug_printf(SUDO_DEBUG_INFO, "settings: %s=%s", |
| sudo_settings[i].value); | sudo_settings[i].name, sudo_settings[i].value); |
| settings[j] = fmt_string(sudo_settings[i].name, |
settings[j] = fmt_string(sudo_settings[i].name, |
| sudo_settings[i].value); |
sudo_settings[i].value); |
| if (settings[j] == NULL) |
if (settings[j] == NULL) |
|
Line 447 parse_args(int argc, char **argv, int *nargc, char ***
|
Line 450 parse_args(int argc, char **argv, int *nargc, char ***
|
| *env_addp = env_add; |
*env_addp = env_add; |
| *nargc = argc; |
*nargc = argc; |
| *nargv = argv; |
*nargv = argv; |
| return mode | flags; | debug_return_int(mode | flags); |
| } |
} |
| |
|
| static int |
static int |
|
Line 510 usage(int fatal)
|
Line 513 usage(int fatal)
|
| static void |
static void |
| usage_excl(int fatal) |
usage_excl(int fatal) |
| { |
{ |
| |
debug_decl(usage_excl, SUDO_DEBUG_ARGS) |
| |
|
| warningx(_("Only one of the -e, -h, -i, -K, -l, -s, -v or -V options may be specified")); |
warningx(_("Only one of the -e, -h, -i, -K, -l, -s, -v or -V options may be specified")); |
| usage(fatal); |
usage(fatal); |
| } |
} |
|
Line 520 help(void)
|
Line 525 help(void)
|
| struct lbuf lbuf; |
struct lbuf lbuf; |
| int indent = 16; |
int indent = 16; |
| const char *pname = getprogname(); |
const char *pname = getprogname(); |
| |
debug_decl(help, SUDO_DEBUG_ARGS) |
| |
|
| lbuf_init(&lbuf, usage_out, indent, NULL, user_details.ts_cols); |
lbuf_init(&lbuf, usage_out, indent, NULL, user_details.ts_cols); |
| if (strcmp(pname, "sudoedit") == 0) |
if (strcmp(pname, "sudoedit") == 0) |
|
Line 593 help(void)
|
Line 599 help(void)
|
| _("stop processing command line arguments\n")); |
_("stop processing command line arguments\n")); |
| lbuf_print(&lbuf); |
lbuf_print(&lbuf); |
| lbuf_destroy(&lbuf); |
lbuf_destroy(&lbuf); |
| |
sudo_debug_exit_int(__func__, __FILE__, __LINE__, sudo_debug_subsys, 0); |
| exit(0); |
exit(0); |
| } |
} |