ubase

suckless linux base utils
git clone git://git.2f30.org/ubase
Log | Files | Refs | README | LICENSE

commit 96af28da605a7c6a9f30f047af3686d1a9e09aad
parent 68c3146a9def993741f2e4dab515aa8bfb1fb4e1
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Fri, 14 Feb 2014 14:49:34 +0100

su: set default 'root', fixes a uninitialised variable warning

Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>

Diffstat:
Msu.c | 7+++----
1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/su.c b/su.c @@ -28,7 +28,7 @@ static int pflag = 0; int main(int argc, char **argv) { - char *usr, *pass, *cryptpass; + char *usr = "root", *pass, *cryptpass; char * const *newargv; struct spwd *spw; struct passwd *pw; @@ -47,14 +47,12 @@ main(int argc, char **argv) } ARGEND; if (argc < 1) - usr = "root"; + ; else if (argc == 1) usr = argv[0]; else usage(); - uid = getuid(); - errno = 0; spw = getspnam(usr); if (errno) @@ -72,6 +70,7 @@ main(int argc, char **argv) enprintf(EXIT_FAILURE, "Invalid shadow record\n"); } + uid = getuid(); if (uid) { pass = getpass("Password: "); if (!pass)