summaryrefslogtreecommitdiffstats
path: root/login-utils/su.c
diff options
context:
space:
mode:
authorJim Meyering1993-10-12 02:52:24 +0100
committerJim Meyering1993-10-12 02:52:24 +0100
commit9fd214f804e02532c5e7df216077146b0003a05e (patch)
tree322cfbb83be738f5237c66f2a6b08457426a6908 /login-utils/su.c
parentmerge with 1.8.1 + partial --version and --help (diff)
downloadkernel-qcow2-util-linux-9fd214f804e02532c5e7df216077146b0003a05e.tar.gz
kernel-qcow2-util-linux-9fd214f804e02532c5e7df216077146b0003a05e.tar.xz
kernel-qcow2-util-linux-9fd214f804e02532c5e7df216077146b0003a05e.zip
merge with 1.8.1b
Diffstat (limited to 'login-utils/su.c')
-rw-r--r--login-utils/su.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/login-utils/su.c b/login-utils/su.c
index c94db90f0..7252a07e1 100644
--- a/login-utils/su.c
+++ b/login-utils/su.c
@@ -73,6 +73,7 @@
#include <getopt.h>
#include <sys/types.h>
#include <pwd.h>
+#include <grp.h>
#include "system.h"
#ifdef HAVE_SYSLOG_H
@@ -115,6 +116,8 @@ uid_t getuid ();
#include <shadow.h>
#endif
+#include "version.h"
+
/* The default PATH for simulated logins to non-superuser accounts. */
#define DEFAULT_LOGIN_PATH ":/usr/ucb:/bin:/usr/bin"
@@ -153,6 +156,12 @@ extern char **environ;
/* The name this program was run with. */
char *program_name;
+/* If non-zero, display usage information and exit. */
+static int show_help;
+
+/* If non-zero, print the version on standard output and exit. */
+static int show_version;
+
/* If nonzero, pass the `-f' option to the subshell. */
static int fast_startup;
@@ -166,9 +175,11 @@ static struct option const longopts[] =
{
{"command", required_argument, 0, 'c'},
{"fast", no_argument, &fast_startup, 1},
+ {"help", no_argument, &show_help, 1},
{"login", no_argument, &simulate_login, 1},
{"preserve-environment", no_argument, &change_environment, 0},
{"shell", required_argument, 0, 's'},
+ {"version", no_argument, &show_version, 1},
{0, 0, 0, 0}
};
@@ -196,26 +207,42 @@ main (argc, argv)
{
case 0:
break;
+
case 'c':
command = optarg;
break;
+
case 'f':
fast_startup = 1;
break;
+
case 'l':
simulate_login = 1;
break;
+
case 'm':
case 'p':
change_environment = 0;
break;
+
case 's':
shell = optarg;
break;
+
default:
usage ();
}
}
+
+ if (show_version)
+ {
+ printf ("%s\n", version_string);
+ exit (0);
+ }
+
+ if (show_help)
+ usage ();
+
if (optind < argc && !strcmp (argv[optind], "-"))
{
simulate_login = 1;