]> git.ozlabs.org Git - ppp.git/blobdiff - pppd/options.c
Put in a have_route_to cobbled up from stuff sent by Sowmini.
[ppp.git] / pppd / options.c
index 346430d454f0037d2450e444ba7865ad03c77147..cc7002352b330a7db1dee2a76b11b625aee43c74 100644 (file)
@@ -18,7 +18,7 @@
  */
 
 #ifndef lint
-static char rcsid[] = "$Id: options.c,v 1.45 1999/01/20 00:00:35 paulus Exp $";
+static char rcsid[] = "$Id: options.c,v 1.49 1999/03/08 01:47:24 paulus Exp $";
 #endif
 
 #include <ctype.h>
@@ -133,7 +133,6 @@ static int setactivefilter __P((char **));
 static option_t *find_option __P((char *name));
 static int process_option __P((option_t *, char **));
 static int n_arguments __P((option_t *));
-static int readable __P((int fd));
 
 /*
  * Valid arguments.
@@ -223,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\
        <device>        Communicate over the named device\n\
        <speed>         Set the baud rate to <speed>\n\
@@ -343,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;
@@ -650,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);
     }
@@ -685,7 +691,7 @@ option_error __V((char *fmt, ...))
 /*
  * readable - check if a file is readable by the real user.
  */
-static int
+int
 readable(fd)
     int fd;
 {
@@ -1184,15 +1190,11 @@ setdevname(cp, quiet)
        return -1;
     }
 
-    if (!privileged_option) {
-       if (!quiet)
-           option_error("setting the device name requires root privilege");
-       return -1;
-    }
-
     (void) strncpy(devnam, cp, MAXPATHLEN);
     devnam[MAXPATHLEN-1] = 0;
     default_device = FALSE;
+    devnam_info.priv = privileged_option;
+    devnam_info.source = option_source;
   
     return 1;
 }