[hackers] [ubase] Implement -p for su(1) || sin
commit acb9ae197e8e71c94c8fa16bc315930d9cbc6dcd
Author: sin <sin_AT_2f30.org>
Date: Fri Oct 18 14:26:14 2013 +0100
Implement -p for su(1)
diff --git a/su.c b/su.c
index 9d8f550..1218a13 100644
--- a/su.c
+++ b/su.c
_AT_@ -18,10 +18,11 @@ static void dologin(struct passwd *);
static void
usage(void)
{
- eprintf("usage: %s [-l] [username]
", argv0);
+ eprintf("usage: %s [-lp] [username]
", argv0);
}
static int lflag = 0;
+static int pflag = 0;
int
main(int argc, char **argv)
_AT_@ -37,6 +38,9 @@ main(int argc, char **argv)
case 'l':
lflag = 1;
break;
+ case 'p':
+ pflag = 1;
+ break;
default:
usage();
} ARGEND;
_AT_@ -100,11 +104,13 @@ main(int argc, char **argv)
dologin(pw);
} else {
newargv = (char *const[]){pw->pw_shell, NULL};
- setenv("HOME", pw->pw_dir, 1);
- setenv("SHELL", pw->pw_dir, 1);
- if (strcmp(pw->pw_name, "root") != 0) {
- setenv("USER", pw->pw_name, 1);
- setenv("LOGNAME", pw->pw_name, 1);
+ if (!pflag) {
+ setenv("HOME", pw->pw_dir, 1);
+ setenv("SHELL", pw->pw_dir, 1);
+ if (strcmp(pw->pw_name, "root") != 0) {
+ setenv("USER", pw->pw_name, 1);
+ setenv("LOGNAME", pw->pw_name, 1);
+ }
}
execve(pw->pw_shell, newargv, environ);
}
Received on Fri Oct 18 2013 - 15:26:45 CEST
This archive was generated by hypermail 2.3.0
: Fri Oct 18 2013 - 15:36:27 CEST