Overload -h option to specify an optional hostname for remote access.

This is future-proofing; no policy plugins currently support this.
This commit is contained in:
Todd C. Miller
2013-07-16 16:31:05 -06:00
parent 1e4497331c
commit c2860cce57
3 changed files with 19 additions and 13 deletions

View File

@@ -19,7 +19,7 @@
/* API version major/minor */ /* API version major/minor */
#define SUDO_API_VERSION_MAJOR 1 #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_MKVERSION(x, y) ((x << 16) | y)
#define SUDO_API_VERSION SUDO_API_MKVERSION(SUDO_API_VERSION_MAJOR, SUDO_API_VERSION_MINOR) #define SUDO_API_VERSION SUDO_API_MKVERSION(SUDO_API_VERSION_MAJOR, SUDO_API_VERSION_MINOR)

View File

@@ -111,7 +111,9 @@ static struct sudo_settings {
{ "max_groups" }, { "max_groups" },
#define ARG_PLUGIN_DIR 21 #define ARG_PLUGIN_DIR 21
{ "plugin_dir" }, { "plugin_dir" },
#define NUM_SETTINGS 22 #define ARG_REMOTE_HOST 22
{ "remote_host" },
#define NUM_SETTINGS 23
{ NULL } { 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 * Some trickiness is required to allow environment variables
* to be interspersed with command line options. * 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) { switch (ch) {
case 'A': case 'A':
SET(tgetpass_flags, TGP_ASKPASS); 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"; sudo_settings[ARG_SET_HOME].value = "true";
break; break;
case 'h': case 'h':
if (mode && mode != MODE_HELP) { if (optarg != NULL) {
if (strcmp(getprogname(), "sudoedit") != 0) sudo_settings[ARG_REMOTE_HOST].value = optarg;
usage_excl(1); } 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; break;
case 'i': case 'i':
sudo_settings[ARG_LOGIN_SHELL].value = "true"; sudo_settings[ARG_LOGIN_SHELL].value = "true";

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2007-2010 Todd C. Miller <Todd.Miller@courtesan.com> * Copyright (c) 2007-2010, 2013 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
@@ -24,10 +24,10 @@
* need to be able to substitute values from configure. * need to be able to substitute values from configure.
*/ */
#define SUDO_USAGE1 " [-D level] -h | -K | -k | -V" #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_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] [-p prompt] [-U user name] [-u user name|#uid] [-g groupname|#gid] [command]" #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] [-p prompt] [-u user name|#uid] [-g groupname|#gid] [VAR=value] [-i|-s] [<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] [<command>]"
#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_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. * Configure script arguments used to build sudo.