From: Paul Mackerras Date: Tue, 8 Oct 1996 06:43:49 +0000 (+0000) Subject: check we're running as root X-Git-Tag: RELEASE_2_3_6~270 X-Git-Url: http://git.ozlabs.org/?p=ppp.git;a=commitdiff_plain;h=c8cda9f67448845b4a81c1a0c8dc13e73d297692 check we're running as root --- diff --git a/pppd/main.c b/pppd/main.c index 273e90a..e462420 100644 --- a/pppd/main.c +++ b/pppd/main.c @@ -18,7 +18,7 @@ */ #ifndef lint -static char rcsid[] = "$Id: main.c,v 1.38 1996/10/08 04:35:03 paulus Exp $"; +static char rcsid[] = "$Id: main.c,v 1.39 1996/10/08 06:43:49 paulus Exp $"; #endif #include @@ -178,7 +178,7 @@ main(argc, argv) #endif if (gethostname(hostname, MAXNAMELEN) < 0 ) { - syslog(LOG_ERR, "couldn't get hostname: %m"); + option_error("Couldn't get hostname: %m"); die(1); } hostname[MAXNAMELEN-1] = 0; @@ -209,6 +209,15 @@ main(argc, argv) exit(1); } + /* + * Check that we are running as root. + */ + if (geteuid() != 0) { + option_error("must be root to run %s, since it is not setuid-root", + argv[0]); + die(1); + } + /* * Check that the options given are valid and consistent. */