From: Todd C. Miller Date: Wed, 14 Apr 2010 12:41:53 +0000 (-0400) Subject: Add a "noninteractive" boolean to the settings passed in to the plugin's X-Git-Tag: SUDO_1_8_0~720 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bc813db528a5597b0d0a290047c32f62535d7418;p=sudo Add a "noninteractive" boolean to the settings passed in to the plugin's open function that is set when the user specifies the -n flag. --- diff --git a/doc/sudo_plugin.cat b/doc/sudo_plugin.cat index d4ad795ea..5a25cf69c 100644 --- a/doc/sudo_plugin.cat +++ b/doc/sudo_plugin.cat @@ -61,7 +61,7 @@ SSuuddoo PPlluuggiinn AAPPII -1.8.0a1 April 13, 2010 1 +1.8.0a1 April 14, 2010 1 @@ -127,7 +127,7 @@ SUDO_PLUGIN(1m) MAINTENANCE COMMANDS SUDO_PLUGIN(1m) -1.8.0a1 April 13, 2010 2 +1.8.0a1 April 14, 2010 2 @@ -193,7 +193,7 @@ SUDO_PLUGIN(1m) MAINTENANCE COMMANDS SUDO_PLUGIN(1m) -1.8.0a1 April 13, 2010 3 +1.8.0a1 April 14, 2010 3 @@ -205,6 +205,12 @@ SUDO_PLUGIN(1m) MAINTENANCE COMMANDS SUDO_PLUGIN(1m) command, indicating that the user wishes to ignore any cached authentication credentials. + noninteractive=bool + Set to true if the user specified the -n flag, indicating + that ssuuddoo should operate in non-interactive mode. The + plugin may reject a command run in non-interactive mode if + user interaction is required. + login_class=string BSD login class to use when setting resource limits and nice value, if specified by the -c flag. @@ -250,16 +256,10 @@ SUDO_PLUGIN(1m) MAINTENANCE COMMANDS SUDO_PLUGIN(1m) The user's supplementary group list formatted as a string of comma-separated group IDs. - cwd=string - The user's current working directory. - - tty=string - The path to the user's terminal device. If the user has no - terminal device associated with the session, the value will -1.8.0a1 April 13, 2010 4 +1.8.0a1 April 14, 2010 4 @@ -268,6 +268,12 @@ SUDO_PLUGIN(1m) MAINTENANCE COMMANDS SUDO_PLUGIN(1m) SUDO_PLUGIN(1m) MAINTENANCE COMMANDS SUDO_PLUGIN(1m) + cwd=string + The user's current working directory. + + tty=string + The path to the user's terminal device. If the user has no + terminal device associated with the session, the value will be empty, as in tty=. host=string @@ -316,16 +322,10 @@ SUDO_PLUGIN(1m) MAINTENANCE COMMANDS SUDO_PLUGIN(1m) int (*show_version)(int verbose); The show_version function is called by ssuuddoo when the user specifies - the -V option. The plugin may display its version information to - the user via the conversation function using SUDO_CONV_INFO_MSG. - If the user requests detailed version information, the verbose flag - will be set. - - -1.8.0a1 April 13, 2010 5 +1.8.0a1 April 14, 2010 5 @@ -334,6 +334,11 @@ SUDO_PLUGIN(1m) MAINTENANCE COMMANDS SUDO_PLUGIN(1m) SUDO_PLUGIN(1m) MAINTENANCE COMMANDS SUDO_PLUGIN(1m) + the -V option. The plugin may display its version information to + the user via the conversation function using SUDO_CONV_INFO_MSG. + If the user requests detailed version information, the verbose flag + will be set. + check_policy int (*check_policy)(int argc, char * const argv[] char *env_add[], char **command_info[], @@ -383,15 +388,10 @@ SUDO_PLUGIN(1m) MAINTENANCE COMMANDS SUDO_PLUGIN(1m) runas_uid=uid User ID to run the command as. - runas_euid=uid - Effective user ID to run the command as. If not specified, - the value of _r_u_n_a_s___u_i_d is used. - - -1.8.0a1 April 13, 2010 6 +1.8.0a1 April 14, 2010 6 @@ -400,6 +400,10 @@ SUDO_PLUGIN(1m) MAINTENANCE COMMANDS SUDO_PLUGIN(1m) SUDO_PLUGIN(1m) MAINTENANCE COMMANDS SUDO_PLUGIN(1m) + runas_euid=uid + Effective user ID to run the command as. If not specified, + the value of _r_u_n_a_s___u_i_d is used. + runas_gid=gid Group ID to run the command as. @@ -451,13 +455,9 @@ SUDO_PLUGIN(1m) MAINTENANCE COMMANDS SUDO_PLUGIN(1m) Unsupported values will be ignored. - argv_out - The NULL-terminated argument vector to pass to the _e_x_e_c_v_e_(_) - system call when executing the command. The plugin is - -1.8.0a1 April 13, 2010 7 +1.8.0a1 April 14, 2010 7 @@ -466,6 +466,9 @@ SUDO_PLUGIN(1m) MAINTENANCE COMMANDS SUDO_PLUGIN(1m) SUDO_PLUGIN(1m) MAINTENANCE COMMANDS SUDO_PLUGIN(1m) + argv_out + The NULL-terminated argument vector to pass to the _e_x_e_c_v_e_(_) + system call when executing the command. The plugin is responsible for allocating and populating the vector. user_env_out @@ -517,13 +520,10 @@ SUDO_PLUGIN(1m) MAINTENANCE COMMANDS SUDO_PLUGIN(1m) Returns 1 on success, 0 on failure and -1 on error. On error, the plugin may optionally call the conversation function with - SUDO_CONF_ERROR_MSG to present additional error information to the - user. - -1.8.0a1 April 13, 2010 8 +1.8.0a1 April 14, 2010 8 @@ -532,6 +532,9 @@ SUDO_PLUGIN(1m) MAINTENANCE COMMANDS SUDO_PLUGIN(1m) SUDO_PLUGIN(1m) MAINTENANCE COMMANDS SUDO_PLUGIN(1m) + SUDO_CONF_ERROR_MSG to present additional error information to the + user. + invalidate void (*invalidate)(int remove); @@ -586,10 +589,7 @@ SUDO_PLUGIN(1m) MAINTENANCE COMMANDS SUDO_PLUGIN(1m) - - - -1.8.0a1 April 13, 2010 9 +1.8.0a1 April 14, 2010 9 @@ -655,7 +655,7 @@ SUDO_PLUGIN(1m) MAINTENANCE COMMANDS SUDO_PLUGIN(1m) -1.8.0a1 April 13, 2010 10 +1.8.0a1 April 14, 2010 10 @@ -721,7 +721,7 @@ SUDO_PLUGIN(1m) MAINTENANCE COMMANDS SUDO_PLUGIN(1m) -1.8.0a1 April 13, 2010 11 +1.8.0a1 April 14, 2010 11 @@ -787,7 +787,7 @@ SUDO_PLUGIN(1m) MAINTENANCE COMMANDS SUDO_PLUGIN(1m) -1.8.0a1 April 13, 2010 12 +1.8.0a1 April 14, 2010 12 @@ -853,6 +853,6 @@ SUDO_PLUGIN(1m) MAINTENANCE COMMANDS SUDO_PLUGIN(1m) -1.8.0a1 April 13, 2010 13 +1.8.0a1 April 14, 2010 13 diff --git a/doc/sudo_plugin.man.in b/doc/sudo_plugin.man.in index 572dc89ef..11006f33c 100644 --- a/doc/sudo_plugin.man.in +++ b/doc/sudo_plugin.man.in @@ -139,7 +139,7 @@ .\" ======================================================================== .\" .IX Title "SUDO_PLUGIN @mansectsu@" -.TH SUDO_PLUGIN @mansectsu@ "April 13, 2010" "1.8.0a1" "MAINTENANCE COMMANDS" +.TH SUDO_PLUGIN @mansectsu@ "April 14, 2010" "1.8.0a1" "MAINTENANCE COMMANDS" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l @@ -316,6 +316,12 @@ based on the runas user. Set to true if the user specified the \f(CW\*(C`\-k\*(C'\fR flag along with a command, indicating that the user wishes to ignore any cached authentication credentials. +.IP "noninteractive=bool" 4 +.IX Item "noninteractive=bool" +Set to true if the user specified the \f(CW\*(C`\-n\*(C'\fR flag, indicating that +\&\fBsudo\fR should operate in non-interactive mode. The plugin may +reject a command run in non-interactive mode if user interaction +is required. .IP "login_class=string" 4 .IX Item "login_class=string" \&\s-1BSD\s0 login class to use when setting resource limits and nice value, diff --git a/doc/sudo_plugin.pod b/doc/sudo_plugin.pod index 3282908e6..1bf0f7ae3 100644 --- a/doc/sudo_plugin.pod +++ b/doc/sudo_plugin.pod @@ -204,6 +204,13 @@ Set to true if the user specified the C<-k> flag along with a command, indicating that the user wishes to ignore any cached authentication credentials. +=item noninteractive=bool + +Set to true if the user specified the C<-n> flag, indicating that +B should operate in non-interactive mode. The plugin may +reject a command run in non-interactive mode if user interaction +is required. + =item login_class=string BSD login class to use when setting resource limits and nice value, diff --git a/src/parse_args.c b/src/parse_args.c index 68c89a7ec..ecf5a664f 100644 --- a/src/parse_args.c +++ b/src/parse_args.c @@ -105,7 +105,9 @@ static struct sudo_settings { { "implied_shell" }, #define ARG_PRESERVE_GROUPS 14 { "preserve_groups" }, -#define NUM_SETTINGS 15 +#define ARG_NONINTERACTIVE 15 + { "noninteractive" }, +#define NUM_SETTINGS 16 { NULL } }; @@ -235,6 +237,7 @@ parse_args(int argc, char **argv, int *nargc, char ***nargv, char ***settingsp, break; case 'n': SET(flags, MODE_NONINTERACTIVE); + sudo_settings[ARG_NONINTERACTIVE].value = "true"; break; case 'P': sudo_settings[ARG_PRESERVE_GROUPS].value = "true";