Add support for long options and fix inclusion of sudo_usage.h with

modern gcc broken in 8597:1fcb7ba13018.
This commit is contained in:
Todd C. Miller
2013-07-18 16:51:56 -06:00
parent fbfd0ad630
commit 6e56e6d8c8
7 changed files with 264 additions and 217 deletions

View File

@@ -5,15 +5,15 @@ NNAAMMEE
SSYYNNOOPPSSIISS
ssuuddoo --hh | --KK | --kk | --VV
ssuuddoo --vv [--AAkknnSS] [--aa _a_u_t_h___t_y_p_e] [--gg _g_r_o_u_p _n_a_m_e | _#_g_i_d] [--pp _p_r_o_m_p_t]
[--uu _u_s_e_r _n_a_m_e | _#_u_i_d]
ssuuddoo --ll[_l] [--AAkknnSS] [--aa _a_u_t_h___t_y_p_e] [--gg _g_r_o_u_p _n_a_m_e | _#_g_i_d] [--hh _h_o_s_t _n_a_m_e]
ssuuddoo --vv [--AAkknnSS] [--aa _a_u_t_h___t_y_p_e] [--gg _g_r_o_u_p _n_a_m_e | _#_g_i_d] [--hh _r_e_m_o_t_e _h_o_s_t]
[--pp _p_r_o_m_p_t] [--uu _u_s_e_r _n_a_m_e | _#_u_i_d]
ssuuddoo --ll[_l] [--AAkknnSS] [--aa _a_u_t_h___t_y_p_e] [--gg _g_r_o_u_p _n_a_m_e | _#_g_i_d] [--hh _r_e_m_o_t_e _h_o_s_t]
[--pp _p_r_o_m_p_t] [--UU _u_s_e_r _n_a_m_e] [--uu _u_s_e_r _n_a_m_e | _#_u_i_d] [_c_o_m_m_a_n_d]
ssuuddoo [--AAbbEEHHnnPPSS] [--aa _a_u_t_h___t_y_p_e] [--CC _f_d] [--cc _c_l_a_s_s | _-]
[--gg _g_r_o_u_p _n_a_m_e | _#_g_i_d] [--hh _h_o_s_t _n_a_m_e] [--pp _p_r_o_m_p_t] [--rr _r_o_l_e]
[--gg _g_r_o_u_p _n_a_m_e | _#_g_i_d] [--hh _r_e_m_o_t_e _h_o_s_t] [--pp _p_r_o_m_p_t] [--rr _r_o_l_e]
[--tt _t_y_p_e] [--uu _u_s_e_r _n_a_m_e | _#_u_i_d] [VVAARR=_v_a_l_u_e] --ii | --ss [_c_o_m_m_a_n_d]
ssuuddooeeddiitt [--AAnnSS] [--aa _a_u_t_h___t_y_p_e] [--CC _f_d] [--cc _c_l_a_s_s | _-]
[--gg _g_r_o_u_p _n_a_m_e | _#_g_i_d] [--hh _h_o_s_t _n_a_m_e] [--pp _p_r_o_m_p_t]
[--gg _g_r_o_u_p _n_a_m_e | _#_g_i_d] [--hh _r_e_m_o_t_e _h_o_s_t] [--pp _p_r_o_m_p_t]
[--uu _u_s_e_r _n_a_m_e | _#_u_i_d] file ...
DDEESSCCRRIIPPTTIIOONN
@@ -48,7 +48,8 @@ DDEESSCCRRIIPPTTIIOONN
The options are as follows:
--AA Normally, if ssuuddoo requires a password, it will read it from
--AA, ----aasskkppaassss
Normally, if ssuuddoo requires a password, it will read it from
the user's terminal. If the --AA (_a_s_k_p_a_s_s) option is
specified, a (possibly graphical) helper program is executed
to read the user's password and output the password to the
@@ -63,7 +64,8 @@ DDEESSCCRRIIPPTTIIOONN
If no askpass program is available, ssuuddoo will exit with an
error.
--aa _t_y_p_e The --aa (_a_u_t_h_e_n_t_i_c_a_t_i_o_n _t_y_p_e) option causes ssuuddoo to use the
--aa, ----aauutthh--ttyyppee _a_u_t_h___t_y_p_e
The --aa (_a_u_t_h_e_n_t_i_c_a_t_i_o_n _t_y_p_e) option causes ssuuddoo to use the
specified authentication type when validating the user, as
allowed by _/_e_t_c_/_l_o_g_i_n_._c_o_n_f. The system administrator may
specify a list of sudo-specific authentication methods by
@@ -71,13 +73,15 @@ DDEESSCCRRIIPPTTIIOONN
option is only available on systems that support BSD
authentication.
--bb The --bb (_b_a_c_k_g_r_o_u_n_d) option tells ssuuddoo to run the given
--bb, ----bbaacckkggrroouunndd
The --bb (_b_a_c_k_g_r_o_u_n_d) option tells ssuuddoo to run the given
command in the background. Note that if you use the --bb
option you cannot use shell job control to manipulate the
process. Most interactive commands will fail to work
properly in background mode.
--CC _f_d Normally, ssuuddoo will close all open file descriptors other
--CC, ----cclloossee--ffrroomm _f_d
Normally, ssuuddoo will close all open file descriptors other
than standard input, standard output and standard error. The
--CC (_c_l_o_s_e _f_r_o_m) option allows the user to specify a starting
point above the standard error (file descriptor three).
@@ -86,7 +90,8 @@ DDEESSCCRRIIPPTTIIOONN
The _s_u_d_o_e_r_s policy only permits use of the --CC option when the
administrator has enabled the _c_l_o_s_e_f_r_o_m___o_v_e_r_r_i_d_e option.
--cc _c_l_a_s_s The --cc (_c_l_a_s_s) option causes ssuuddoo to run the specified
--cc, ----llooggiinn--ccllaassss _c_l_a_s_s
The --cc (_c_l_a_s_s) option causes ssuuddoo to run the specified
command with resources limited by the specified login class.
The _c_l_a_s_s argument can be either a class name as defined in
_/_e_t_c_/_l_o_g_i_n_._c_o_n_f, or a single `-' character. Specifying a
@@ -98,13 +103,14 @@ DDEESSCCRRIIPPTTIIOONN
This option is only available on systems with BSD login
classes.
--EE The --EE (_p_r_e_s_e_r_v_e _e_n_v_i_r_o_n_m_e_n_t) option indicates to the
--EE, ----pprreesseerrvvee--eennvv
The --EE (_p_r_e_s_e_r_v_e _e_n_v_i_r_o_n_m_e_n_t) option indicates to the
security policy that the user wishes to preserve their
existing environment variables. The security policy may
return an error if the --EE option is specified and the user
does not have permission to preserve the environment.
--ee The --ee (_e_d_i_t) option indicates that, instead of running a
--ee, ----eeddiitt The --ee (_e_d_i_t) option indicates that, instead of running a
command, the user wishes to edit one or more files. In lieu
of a command, the string "sudoedit" is used when consulting
the security policy. If the user is authorized by the
@@ -131,32 +137,35 @@ DDEESSCCRRIIPPTTIIOONN
version, the user will receive a warning and the edited copy
will remain in a temporary file.
--gg _g_r_o_u_p Normally, ssuuddoo runs a command with the primary group set to
--gg, ----ggrroouupp _g_r_o_u_p
Normally, ssuuddoo runs a command with the primary group set to
the one specified by the password database for the user the
command is being run as (by default, root). The --gg (_g_r_o_u_p)
option causes ssuuddoo to run the command with the primary group
set to _g_r_o_u_p instead. To specify a _g_i_d instead of a _g_r_o_u_p
_n_a_m_e, use _#_g_i_d. When running commands as a _g_i_d, many shells
require that the `#' be escaped with a backslash (`\'). If
no --uu option is specified, the command will be run as the
invoking user (not root). In either case, the primary group
will be set to _g_r_o_u_p.
set to _g_r_o_u_p instead. To specify a numeric group ID (gid)
instead of a group name, use _#_g_i_d. When running commands as
a gid, many shells require that the `#' be escaped with a
backslash (`\'). If no --uu option is specified, the command
will be run as the invoking user (not root). In either case,
the primary group will be set to _g_r_o_u_p.
--HH The --HH (_H_O_M_E) option requests that the security policy set
--HH, ----sseett--hhoommee
The --HH (_H_O_M_E) option requests that the security policy set
the HOME environment variable to the home directory of the
target user (root by default) as specified by the password
database. Depending on the policy, this may be the default
behavior.
--hh [_h_o_s_t _n_a_m_e]
If a _h_o_s_t _n_a_m_e is specified and the policy plugin supports
--hh, ----hheellpp The --hh (_h_e_l_p) option causes ssuuddoo will print a short help
message to the standard output and exit.
--hh, ----hhoosstt _r_e_m_o_t_e _h_o_s_t
If a _r_e_m_o_t_e _h_o_s_t is specified and the policy plugin supports
it, the command will be run on the specified remote host.
Note that the _s_u_d_o_e_r_s plugin does not currently support
running remote commands. If no _h_o_s_t _n_a_m_e is specified, ssuuddoo
will print a short help message to the standard output and
exit.
running remote commands.
--ii [_c_o_m_m_a_n_d]
--ii, ----llooggiinn [_c_o_m_m_a_n_d]
The --ii (_s_i_m_u_l_a_t_e _i_n_i_t_i_a_l _l_o_g_i_n) option runs the shell
specified by the password database entry of the target user
as a login shell. This means that login-specific resource
@@ -172,13 +181,14 @@ DDEESSCCRRIIPPTTIIOONN
environment in which a command is run when the _s_u_d_o_e_r_s policy
is in use.
--KK The --KK (sure _k_i_l_l) option is like --kk except that it removes
--KK, ----rreemmoovvee--ttiimmeessttaammpp
The --KK (sure _k_i_l_l) option is like --kk except that it removes
the user's cached credentials entirely and may not be used in
conjunction with a command or other option. This option does
not require a password. Not all security policies support
credential caching.
--kk [_c_o_m_m_a_n_d]
--kk, ----rreesseett--ttiimmeessttaammpp [_c_o_m_m_a_n_d]
When used alone, the --kk (_k_i_l_l) option to ssuuddoo invalidates the
user's cached credentials. The next time ssuuddoo is run a
password will be required. This option does not require a
@@ -192,7 +202,7 @@ DDEESSCCRRIIPPTTIIOONN
for a password (if one is required by the security policy)
and will not update the user's cached credentials.
--ll[ll] [_c_o_m_m_a_n_d]
--ll[ll], ----lliisstt [_c_o_m_m_a_n_d]
If no _c_o_m_m_a_n_d is specified, the --ll (_l_i_s_t) option will list
the allowed (and forbidden) commands for the invoking user
(or the user specified by the --UU option) on the current host.
@@ -204,17 +214,20 @@ DDEESSCCRRIIPPTTIIOONN
--llll), or if --ll is specified multiple times, a longer list
format is used.
--nn The --nn (_n_o_n_-_i_n_t_e_r_a_c_t_i_v_e) option prevents ssuuddoo from prompting
--nn, ----nnoonn--iinntteerraaccttiivvee
The --nn (_n_o_n_-_i_n_t_e_r_a_c_t_i_v_e) option prevents ssuuddoo from prompting
the user for a password. If a password is required for the
command to run, ssuuddoo will display an error message and exit.
--PP The --PP (_p_r_e_s_e_r_v_e _g_r_o_u_p _v_e_c_t_o_r) option causes ssuuddoo to preserve
--PP, ----pprreesseerrvvee--ggrroouuppss
The --PP (_p_r_e_s_e_r_v_e _g_r_o_u_p _v_e_c_t_o_r) option causes ssuuddoo to preserve
the invoking user's group vector unaltered. By default, the
_s_u_d_o_e_r_s policy will initialize the group vector to the list
of groups the target user is in. The real and effective
group IDs, however, are still set to match the target user.
--pp _p_r_o_m_p_t The --pp (_p_r_o_m_p_t) option allows you to override the default
--pp, ----pprroommpptt _p_r_o_m_p_t
The --pp (_p_r_o_m_p_t) option allows you to override the default
password prompt and use a custom one. The following percent
(`%') escapes are supported by the _s_u_d_o_e_r_s policy:
@@ -241,49 +254,56 @@ DDEESSCCRRIIPPTTIIOONN
system password prompt on systems that support PAM unless the
_p_a_s_s_p_r_o_m_p_t___o_v_e_r_r_i_d_e flag is disabled in _s_u_d_o_e_r_s.
--rr _r_o_l_e The --rr (_r_o_l_e) option causes the new (SELinux) security
context to have the role specified by _r_o_l_e.
--rr, ----rroollee _r_o_l_e
The --rr (_r_o_l_e) option causes the new SELinux security context
to have the role specified by _r_o_l_e.
--SS The --SS (_s_t_d_i_n) option causes ssuuddoo to read the password from
--SS, ----ssttddiinn
The --SS (_s_t_d_i_n) option causes ssuuddoo to read the password from
the standard input instead of the terminal device. The
password must be followed by a newline character.
--ss [_c_o_m_m_a_n_d]
--ss, ----sshheellll [_c_o_m_m_a_n_d]
The --ss (_s_h_e_l_l) option runs the shell specified by the SHELL
environment variable if it is set or the shell as specified
in the password database. If a command is specified, it is
passed to the shell for execution via the shell's --cc option.
If no command is specified, an interactive shell is executed.
--tt _t_y_p_e The --tt (_t_y_p_e) option causes the new (SELinux) security
context to have the type specified by _t_y_p_e. If no type is
specified, the default type is derived from the specified
role.
--tt, ----ttyyppee _t_y_p_e
The --tt (_t_y_p_e) option causes the new SELinux security context
to have the type specified by _t_y_p_e. If no type is specified,
the default type is derived from the specified role.
--UU _u_s_e_r The --UU (_o_t_h_e_r _u_s_e_r) option is used in conjunction with the --ll
--UU, ----ootthheerr--uusseerr _u_s_e_r
The --UU (_o_t_h_e_r _u_s_e_r) option is used in conjunction with the --ll
option to specify the user whose privileges should be listed.
The security policy may restrict listing other users'
privileges. The _s_u_d_o_e_r_s policy only allows root or a user
with the ALL privilege on the current host to use this
option.
--uu _u_s_e_r The --uu (_u_s_e_r) option causes ssuuddoo to run the specified command
as a user other than _r_o_o_t. To specify a _u_i_d instead of a
_u_s_e_r _n_a_m_e, _#_u_i_d. When running commands as a _u_i_d, many shells
require that the `#' be escaped with a backslash (`\').
Security policies may restrict _u_i_ds to those listed in the
password database. The _s_u_d_o_e_r_s policy allows _u_i_ds that are
not in the password database as long as the _t_a_r_g_e_t_p_w option
is not set. Other security policies may not support this.
--uu, ----uusseerr _u_s_e_r
The --uu (_u_s_e_r) option causes ssuuddoo to run the specified command
as a user other than _r_o_o_t. To specify a numeric user ID
(uid) instead of a user name, use _#_u_i_d. When running
commands as a uid, many shells require that the `#' be
escaped with a backslash (`\'). Some security policies may
restrict uids to those listed in the password database. The
_s_u_d_o_e_r_s policy allows uids that are not in the password
database as long as the _t_a_r_g_e_t_p_w option is not set. Other
security policies may not support this.
--VV The --VV (_v_e_r_s_i_o_n) option causes ssuuddoo to print its version
--VV, ----vveerrssiioonn
The --VV (_v_e_r_s_i_o_n) option causes ssuuddoo to print its version
string and the version string of the security policy plugin
and any I/O plugins. If the invoking user is already root
the --VV option will display the arguments passed to configure
when ssuuddoo was built and plugins may display more verbose
information such as default options.
--vv When given the --vv (_v_a_l_i_d_a_t_e) option, ssuuddoo will update the
--vv, ----vvaalliiddaattee
When given the --vv (_v_a_l_i_d_a_t_e) option, ssuuddoo will update the
user's cached credentials, authenticating the user's password
if necessary. For the _s_u_d_o_e_r_s plugin, this extends the ssuuddoo
timeout for another 5 minutes (or whatever the timeout is set
@@ -304,10 +324,10 @@ DDEESSCCRRIIPPTTIIOONN
CCOOMMMMAANNDD EEXXEECCUUTTIIOONN
When ssuuddoo executes a command, the security policy specifies the execution
environment for the command. Typically, the real and effective uid and
gid are set to match those of the target user, as specified in the
password database, and the group vector is initialized based on the group
database (unless the --PP option was specified).
environment for the command. Typically, the real and effective user and
group and IDs are set to match those of the target user, as specified in
the password database, and the group vector is initialized based on the
group database (unless the --PP option was specified).
The following parameters may be specified by security policy: