mirror of git://git.suckless.org/sbase
su: set default 'root', fixes a uninitialised variable warning
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
This commit is contained in:
parent
68c3146a9d
commit
96af28da60
7
su.c
7
su.c
|
@ -28,7 +28,7 @@ static int pflag = 0;
|
||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
char *usr, *pass, *cryptpass;
|
char *usr = "root", *pass, *cryptpass;
|
||||||
char * const *newargv;
|
char * const *newargv;
|
||||||
struct spwd *spw;
|
struct spwd *spw;
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
|
@ -47,14 +47,12 @@ main(int argc, char **argv)
|
||||||
} ARGEND;
|
} ARGEND;
|
||||||
|
|
||||||
if (argc < 1)
|
if (argc < 1)
|
||||||
usr = "root";
|
;
|
||||||
else if (argc == 1)
|
else if (argc == 1)
|
||||||
usr = argv[0];
|
usr = argv[0];
|
||||||
else
|
else
|
||||||
usage();
|
usage();
|
||||||
|
|
||||||
uid = getuid();
|
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
spw = getspnam(usr);
|
spw = getspnam(usr);
|
||||||
if (errno)
|
if (errno)
|
||||||
|
@ -72,6 +70,7 @@ main(int argc, char **argv)
|
||||||
enprintf(EXIT_FAILURE, "Invalid shadow record\n");
|
enprintf(EXIT_FAILURE, "Invalid shadow record\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uid = getuid();
|
||||||
if (uid) {
|
if (uid) {
|
||||||
pass = getpass("Password: ");
|
pass = getpass("Password: ");
|
||||||
if (!pass)
|
if (!pass)
|
||||||
|
|
Loading…
Reference in New Issue