From: nekral-guest Date: Tue, 21 Apr 2009 22:46:01 +0000 (+0000) Subject: * src/login.c: Check if login is run with effective root X-Git-Tag: 4.1.4~143 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=efcbbc3d74b99fa98d2b402534064905e9dd0317;p=shadow * src/login.c: Check if login is run with effective root privileges. This should be more helpful to users than a failure to find an utmp entry or failure to access a file. --- diff --git a/ChangeLog b/ChangeLog index 1b668be7..573e6873 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-04-22 Nicolas François + + * src/login.c: Check if login is run with effective root + privileges. This should be more helpful to users than a failure to + find an utmp entry or failure to access a file. + 2009-04-22 Nicolas François * libmisc/utmp.c: Reworked. Get rid of Linux specific stuff. Get rid diff --git a/src/login.c b/src/login.c index 1e0a39ed..3f2068e0 100644 --- a/src/login.c +++ b/src/login.c @@ -510,6 +510,11 @@ int main (int argc, char **argv) amroot = (getuid () == 0); Prog = Basename (argv[0]); + if (geteuid() != 0) { + fprintf (stderr, _("%s: Cannot possibly work without effective root\n"), Prog); + exit (1); + } + process_flags (argc, argv); if ((isatty (0) == 0) || (isatty (1) == 0) || (isatty (2) == 0)) {