From: Todd C. Miller Date: Tue, 16 Jul 2013 22:31:05 +0000 (-0600) Subject: Overload -h option to specify an optional hostname for remote access. X-Git-Tag: SUDO_1_8_8^2~110 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c2860cce57f6e20a4070bb1366e16b0c2a0828c8;p=sudo Overload -h option to specify an optional hostname for remote access. This is future-proofing; no policy plugins currently support this. --- diff --git a/include/sudo_plugin.h b/include/sudo_plugin.h index 6cab9597b..deabf0c05 100644 --- a/include/sudo_plugin.h +++ b/include/sudo_plugin.h @@ -19,7 +19,7 @@ /* API version major/minor */ #define SUDO_API_VERSION_MAJOR 1 -#define SUDO_API_VERSION_MINOR 3 +#define SUDO_API_VERSION_MINOR 4 #define SUDO_API_MKVERSION(x, y) ((x << 16) | y) #define SUDO_API_VERSION SUDO_API_MKVERSION(SUDO_API_VERSION_MAJOR, SUDO_API_VERSION_MINOR) diff --git a/src/parse_args.c b/src/parse_args.c index 819e432fe..56aab32f9 100644 --- a/src/parse_args.c +++ b/src/parse_args.c @@ -111,7 +111,9 @@ static struct sudo_settings { { "max_groups" }, #define ARG_PLUGIN_DIR 21 { "plugin_dir" }, -#define NUM_SETTINGS 22 +#define ARG_REMOTE_HOST 22 + { "remote_host" }, +#define NUM_SETTINGS 23 { NULL } }; @@ -181,7 +183,7 @@ parse_args(int argc, char **argv, int *nargc, char ***nargv, char ***settingsp, * Some trickiness is required to allow environment variables * to be interspersed with command line options. */ - if ((ch = getopt(argc, argv, "+Aa:bC:c:D:Eeg:HhiKklnPp:r:Sst:U:u:Vv")) != -1) { + if ((ch = getopt(argc, argv, "+Aa:bC:c:D:Eeg:Hh::iKklnPp:r:Sst:U:u:Vv")) != -1) { switch (ch) { case 'A': SET(tgetpass_flags, TGP_ASKPASS); @@ -227,12 +229,16 @@ parse_args(int argc, char **argv, int *nargc, char ***nargv, char ***settingsp, sudo_settings[ARG_SET_HOME].value = "true"; break; case 'h': - if (mode && mode != MODE_HELP) { - if (strcmp(getprogname(), "sudoedit") != 0) - usage_excl(1); + if (optarg != NULL) { + sudo_settings[ARG_REMOTE_HOST].value = optarg; + } else { + if (mode && mode != MODE_HELP) { + if (strcmp(getprogname(), "sudoedit") != 0) + usage_excl(1); + } + mode = MODE_HELP; + valid_flags = 0; } - mode = MODE_HELP; - valid_flags = 0; break; case 'i': sudo_settings[ARG_LOGIN_SHELL].value = "true"; diff --git a/src/sudo_usage.h.in b/src/sudo_usage.h.in index 4f6288b30..b78198803 100644 --- a/src/sudo_usage.h.in +++ b/src/sudo_usage.h.in @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2010 Todd C. Miller + * Copyright (c) 2007-2010, 2013 Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -24,10 +24,10 @@ * need to be able to substitute values from configure. */ #define SUDO_USAGE1 " [-D level] -h | -K | -k | -V" -#define SUDO_USAGE2 " -v [-AknS] @BSDAUTH_USAGE@[-D level] [-g groupname|#gid] [-p prompt] [-u user name|#uid]" -#define SUDO_USAGE3 " -l[l] [-AknS] @BSDAUTH_USAGE@[-D level] [-g groupname|#gid] [-p prompt] [-U user name] [-u user name|#uid] [-g groupname|#gid] [command]" -#define SUDO_USAGE4 " [-AbEHknPS] @BSDAUTH_USAGE@@SELINUX_USAGE@[-C fd] [-D level] @LOGINCAP_USAGE@[-g groupname|#gid] [-p prompt] [-u user name|#uid] [-g groupname|#gid] [VAR=value] [-i|-s] []" -#define SUDO_USAGE5 " -e [-AknS] @BSDAUTH_USAGE@@SELINUX_USAGE@[-C fd] [-D level] @LOGINCAP_USAGE@[-g groupname|#gid] [-p prompt] [-u user name|#uid] file ..." +#define SUDO_USAGE2 " -v [-AknS] @BSDAUTH_USAGE@[-D level] [-g groupname|#gid] [-h hostname] [-p prompt] [-u user name|#uid]" +#define SUDO_USAGE3 " -l[l] [-AknS] @BSDAUTH_USAGE@[-D level] [-g groupname|#gid] [-h hostname] [-p prompt] [-U user name] [-u user name|#uid] [command]" +#define SUDO_USAGE4 " [-AbEHknPS] @BSDAUTH_USAGE@@SELINUX_USAGE@[-C fd] [-D level] @LOGINCAP_USAGE@[-g groupname|#gid] [-h hostname] [-p prompt] [-u user name|#uid] [VAR=value] [-i|-s] []" +#define SUDO_USAGE5 " -e [-AknS] @BSDAUTH_USAGE@@SELINUX_USAGE@[-C fd] [-D level] @LOGINCAP_USAGE@[-g groupname|#gid] [-h hostname] [-p prompt] [-u user name|#uid] file ..." /* * Configure script arguments used to build sudo.