]> git.ozlabs.org Git - ppp.git/blobdiff - pppd/options.c
pppd: Obfuscate password argument string
[ppp.git] / pppd / options.c
index c06a2b4ad8ed4560501dfeb61902946c14ea7d96..aecb930249b636035ab6a47330dac4637f4bc865 100644 (file)
@@ -79,7 +79,6 @@
 char *strdup __P((char *));
 #endif
 
-static const char rcsid[] = RCSID;
 
 struct option_value {
     struct option_value *next;
@@ -97,6 +96,9 @@ char  devnam[MAXPATHLEN];     /* Device name */
 bool   nodetach = 0;           /* Don't detach from controlling tty */
 bool   updetach = 0;           /* Detach once link is up */
 bool   master_detach;          /* Detach when we're (only) multilink master */
+#ifdef SYSTEMD
+bool   up_sdnotify = 0;        /* Notify systemd once link is up */
+#endif
 int    maxconnect = 0;         /* Maximum connect time */
 char   user[MAXNAMELEN];       /* Username for PAP */
 char   passwd[MAXSECRETLEN];   /* Password for PAP */
@@ -114,6 +116,7 @@ char        linkname[MAXPATHLEN];   /* logical name for link */
 bool   tune_kernel;            /* may alter kernel settings */
 int    connect_delay = 1000;   /* wait this many ms after connect script */
 int    req_unit = -1;          /* requested interface unit */
+char   req_ifname[MAXIFNAMELEN];       /* requested interface name */
 bool   multilink = 0;          /* Enable multilink operation */
 char   *bundle_name = NULL;    /* bundle name for multilink */
 bool   dump_options;           /* print out option values */
@@ -208,6 +211,11 @@ option_t general_options[] = {
       "Don't detach from controlling tty", OPT_PRIO | 1 },
     { "-detach", o_bool, &nodetach,
       "Don't detach from controlling tty", OPT_ALIAS | OPT_PRIOSUB | 1 },
+#ifdef SYSTEMD
+    { "up_sdnotify", o_bool, &up_sdnotify,
+      "Notify systemd once link is up (implies nodetach)",
+      OPT_PRIOSUB | OPT_A2COPY | 1, &nodetach },
+#endif
     { "updetach", o_bool, &updetach,
       "Detach from controlling tty once link is up",
       OPT_PRIOSUB | OPT_A2CLR | 1, &nodetach },
@@ -284,6 +292,10 @@ option_t general_options[] = {
       "PPP interface unit number to use if possible",
       OPT_PRIO | OPT_LLIMIT, 0, 0 },
 
+    { "ifname", o_string, req_ifname,
+      "Set PPP interface name",
+      OPT_PRIO | OPT_PRIV | OPT_STATIC, NULL, MAXIFNAMELEN },
+
     { "dump", o_bool, &dump_options,
       "Print out option values after parsing all options", 1 },
     { "dryrun", o_bool, &dryrun,
@@ -789,6 +801,11 @@ process_option(opt, cmd, argv)
                free(*optptr);
            *optptr = sv;
        }
+       /* obfuscate original argument for things like password */
+       if (opt->flags & OPT_HIDE) {
+           memset(*argv, '?', strlen(*argv));
+           *argv = "********";
+       }
        break;
 
     case o_special_noarg:
@@ -979,7 +996,7 @@ print_option(opt, mainopt, printer, arg)
                        p = (char *) opt->addr2;
                        if ((opt->flags & OPT_STATIC) == 0)
                                p = *(char **)p;
-                       printer("%q", p);
+                       printer(arg, "%q", p);
                } else if (opt->flags & OPT_A2LIST) {
                        struct option_value *ovp;
 
@@ -1345,6 +1362,7 @@ getword(f, word, newlinep, filename)
 
        c = getc(f);
     }
+    word[MAXWORDLEN-1] = 0;    /* make sure word is null-terminated */
 
     /*
      * End of the word: check for errors.
@@ -1740,7 +1758,7 @@ user_unsetenv(argv)
        option_error("unexpected = in name: %s", arg);
        return 0;
     }
-    if (arg == '\0') {
+    if (*arg == '\0') {
        option_error("missing variable name for unset");
        return 0;
     }