X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=pppd%2Fmain.c;h=e4624209e5155ef57083639270428be0d32c96e3;hb=2f62c9d24ea396247101d301960dd12aef2891ad;hp=0ce1d95efea8082709562e3931a2a660ae9d9b6b;hpb=c0ef0c559adaaf56a3afd48bab0a674312b70eb7;p=ppp.git diff --git a/pppd/main.c b/pppd/main.c index 0ce1d95..e462420 100644 --- a/pppd/main.c +++ b/pppd/main.c @@ -18,7 +18,7 @@ */ #ifndef lint -static char rcsid[] = "$Id: main.c,v 1.36 1996/09/14 05:15:41 paulus Exp $"; +static char rcsid[] = "$Id: main.c,v 1.39 1996/10/08 06:43:49 paulus Exp $"; #endif #include @@ -52,6 +52,10 @@ static char rcsid[] = "$Id: main.c,v 1.36 1996/09/14 05:15:41 paulus Exp $"; #include "pathnames.h" #include "patchlevel.h" +#ifdef CBCP_SUPPORT +#include "cbcp.h" +#endif + #if defined(SUNOS4) extern char *strerror(); #endif @@ -120,7 +124,7 @@ extern char *getlogin __P((void)); #define O_NONBLOCK O_NDELAY #endif -#ifdef PRIMITIVE_SYSLOG +#ifdef ULTRIX #define setlogmask(x) #endif @@ -133,6 +137,9 @@ struct protent *protocols[] = { &lcp_protent, &pap_protent, &chap_protent, +#ifdef CBCP_SUPPORT + &cbcp_protent, +#endif &ipcp_protent, &ccp_protent, #ifdef IPX_CHANGE @@ -163,7 +170,7 @@ main(argc, argv) strcpy(default_devnam, devnam); /* Initialize syslog facilities */ -#ifdef PRIMITIVE_SYSLOG +#ifdef ULTRIX openlog("pppd", LOG_PID); #else openlog("pppd", LOG_PID | LOG_NDELAY, LOG_PPP); @@ -171,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; @@ -202,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. */ @@ -515,14 +531,9 @@ main(argc, argv) * real serial device back to its normal mode of operation. */ clean_check(); -#ifdef _linux_ - disestablish_ppp(ttyfd); -#endif if (demand) restore_loop(); -#ifndef _linux_ disestablish_ppp(ttyfd); -#endif /* * Run disconnector script, if requested. @@ -1317,7 +1328,11 @@ fmtmsg __V((char *buf, int buflen, char *fmt, ...)) #define OUTCHAR(c) (buflen > 0? (--buflen, *buf++ = (c)): 0) int -vfmtmsg(char *buf, int buflen, char *fmt, va_list args) +vfmtmsg(buf, buflen, fmt, args) + char *buf; + int buflen; + char *fmt; + va_list args; { int c, i, n; int width, prec, fillch; @@ -1328,7 +1343,7 @@ vfmtmsg(char *buf, int buflen, char *fmt, va_list args) void *a; char num[32]; time_t t; - static char hexchars[16] = "0123456789abcdef"; + static char hexchars[] = "0123456789abcdef"; buf0 = buf; --buflen;