Merge pull request #103 from HarmtH/be-predictable
su.c: be more predictable
This commit is contained in:
commit
164dcfe65b
41
man/su.1.xml
41
man/su.1.xml
@ -85,12 +85,16 @@
|
|||||||
<cmdsynopsis>
|
<cmdsynopsis>
|
||||||
<command>su</command>
|
<command>su</command>
|
||||||
<arg choice='opt'>
|
<arg choice='opt'>
|
||||||
<replaceable>options</replaceable>
|
<replaceable>options</replaceable>
|
||||||
</arg>
|
</arg>
|
||||||
<arg choice='opt'>
|
<arg choice='opt'>
|
||||||
<arg choice='plain'>
|
<replaceable>-</replaceable>
|
||||||
<replaceable>username</replaceable>
|
</arg>
|
||||||
</arg>
|
<arg choice='opt'>
|
||||||
|
<replaceable>username</replaceable>
|
||||||
|
<arg choice='opt'>
|
||||||
|
<replaceable>args</replaceable>
|
||||||
|
</arg>
|
||||||
</arg>
|
</arg>
|
||||||
</cmdsynopsis>
|
</cmdsynopsis>
|
||||||
</refsynopsisdiv>
|
</refsynopsisdiv>
|
||||||
@ -98,26 +102,21 @@
|
|||||||
<refsect1 id='description'>
|
<refsect1 id='description'>
|
||||||
<title>DESCRIPTION</title>
|
<title>DESCRIPTION</title>
|
||||||
<para>
|
<para>
|
||||||
The <command>su</command> command is used to become another user during
|
The <command>su</command> command is used to become another user during a
|
||||||
a login session. Invoked without a <option>username</option>,
|
login session. Invoked without a <option>username</option>,
|
||||||
<command>su</command> defaults to
|
<command>su</command> defaults to becoming the superuser. The
|
||||||
becoming the superuser. The optional argument <option>-</option> may
|
<option>-</option> option may be used to provide an environment similar
|
||||||
be used to provide an environment similar to what the user would
|
to what the user would expect had the user logged in directly. The
|
||||||
expect had the user logged in directly.
|
<option>-c</option> option may be used to treat the next argument as a
|
||||||
|
command by most shells.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
Additional arguments may be provided after the username, in which case
|
Options are recognized everywhere in the argument list. You can use the
|
||||||
they are supplied to the user's login shell. In particular, an
|
<option>--</option> argument to stop option parsing. The
|
||||||
argument of <option>-c</option> will cause the next argument to be
|
<option>-</option> option is special: it is also recognized after
|
||||||
treated as a command by most command interpreters. The command will be
|
<option>--</option>, but has to be placed before
|
||||||
executed by the shell specified in <filename>/etc/passwd</filename>
|
<option>username</option>.
|
||||||
for the target user.
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
You can use the <option>--</option> argument to separate
|
|
||||||
<command>su</command> options from the arguments supplied to the shell.
|
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>The user will be prompted for a password, if appropriate. Invalid
|
<para>The user will be prompted for a password, if appropriate. Invalid
|
||||||
|
13
src/su.c
13
src/su.c
@ -436,7 +436,7 @@ static void prepare_pam_close_session (void)
|
|||||||
static void usage (int status)
|
static void usage (int status)
|
||||||
{
|
{
|
||||||
(void)
|
(void)
|
||||||
fputs (_("Usage: su [options] [LOGIN]\n"
|
fputs (_("Usage: su [options] [-] [username [args]]\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Options:\n"
|
"Options:\n"
|
||||||
" -c, --command COMMAND pass COMMAND to the invoked shell\n"
|
" -c, --command COMMAND pass COMMAND to the invoked shell\n"
|
||||||
@ -446,7 +446,8 @@ static void usage (int status)
|
|||||||
" --preserve-environment do not reset environment variables, and\n"
|
" --preserve-environment do not reset environment variables, and\n"
|
||||||
" keep the same shell\n"
|
" keep the same shell\n"
|
||||||
" -s, --shell SHELL use SHELL instead of the default in passwd\n"
|
" -s, --shell SHELL use SHELL instead of the default in passwd\n"
|
||||||
"\n"), (E_SUCCESS != status) ? stderr : stdout);
|
"\n"
|
||||||
|
"If no username is given, assume root.\n"), (E_SUCCESS != status) ? stderr : stdout);
|
||||||
exit (status);
|
exit (status);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -811,13 +812,7 @@ static void process_flags (int argc, char **argv)
|
|||||||
optind++;
|
optind++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
if (optind < argc) {
|
||||||
* The next argument must be either a user ID, or some flag to a
|
|
||||||
* subshell. Pretty sticky since you can't have an argument which
|
|
||||||
* doesn't start with a "-" unless you specify the new user name.
|
|
||||||
* Any remaining arguments will be passed to the user's login shell.
|
|
||||||
*/
|
|
||||||
if ((optind < argc) && ('-' != argv[optind][0])) {
|
|
||||||
STRFCPY (name, argv[optind++]); /* use this login id */
|
STRFCPY (name, argv[optind++]); /* use this login id */
|
||||||
}
|
}
|
||||||
if ('\0' == name[0]) { /* use default user */
|
if ('\0' == name[0]) { /* use default user */
|
||||||
|
Loading…
Reference in New Issue
Block a user