X-Git-Url: http://git.ozlabs.org/?p=ppp.git;a=blobdiff_plain;f=pppd%2Foptions.c;h=cc7002352b330a7db1dee2a76b11b625aee43c74;hp=6078dcc041c55dcf6ea72887235fa3826b90b14b;hb=ac19750e0fb64986870e9bd9bad52d5ae46e2551;hpb=8a68ed35b0312fe46436a3490097a4fdc5af1c95 diff --git a/pppd/options.c b/pppd/options.c index 6078dcc..cc70023 100644 --- a/pppd/options.c +++ b/pppd/options.c @@ -18,7 +18,7 @@ */ #ifndef lint -static char rcsid[] = "$Id: options.c,v 1.47 1999/03/02 05:59:21 paulus Exp $"; +static char rcsid[] = "$Id: options.c,v 1.49 1999/03/08 01:47:24 paulus Exp $"; #endif #include @@ -222,7 +222,7 @@ option_t general_options[] = { #endif static char *usage_string = "\ -pppd version %s patch level %d%s\n\ +pppd version %s.%d%s\n\ Usage: %s [ options ], where options are:\n\ Communicate over the named device\n\ Set the baud rate to \n\ @@ -342,17 +342,24 @@ options_from_file(filename, must_exist, check_prot, priv) char args[MAXARGS][MAXWORDLEN]; char cmd[MAXWORDLEN]; - if ((f = fopen(filename, "r")) == NULL) { + if (check_prot) + seteuid(getuid()); + f = fopen(filename, "r"); + if (check_prot) + seteuid(0); + if (f == NULL) { if (!must_exist && errno == ENOENT) return 1; option_error("Can't open options file %s: %m", filename); return 0; } +#if 0 /* check done by setting effective UID above */ if (check_prot && !readable(fileno(f))) { option_error("Can't open options file %s: access denied", filename); fclose(f); return 0; } +#endif oldpriv = privileged_option; privileged_option = priv; @@ -416,7 +423,7 @@ options_from_user() int ret; struct passwd *pw; - pw = getpwuid(uid); + pw = getpwuid(getuid()); if (pw == NULL || (user = pw->pw_dir) == NULL || user[0] == 0) return 1; file = _PATH_USEROPT; @@ -649,7 +656,7 @@ showversion(argv) char **argv; { if (phase == PHASE_INITIALIZE) { - fprintf(stderr, "pppd version %s patch level %d%s\n", + fprintf(stderr, "pppd version %s.%d%s\n", VERSION, PATCHLEVEL, IMPLEMENTATION); exit(0); } @@ -688,10 +695,12 @@ int readable(fd) int fd; { + uid_t uid; int ngroups, i; struct stat sbuf; GIDSET_TYPE groups[NGROUPS_MAX]; + uid = getuid(); if (uid == 0) return 1; if (fstat(fd, &sbuf) != 0)