]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Allow quiet and nobackground to work in dhcpcd.conf
authorRoy Marples <roy@marples.name>
Thu, 11 Sep 2008 08:28:39 +0000 (08:28 +0000)
committerRoy Marples <roy@marples.name>
Thu, 11 Sep 2008 08:28:39 +0000 (08:28 +0000)
dhcpcd.c
if-options.c

index 9cfa1009961dcd81c4fa1c127a3306ed4fbe5cb4..9992b41e42a8089071695fcdf3df2751426dede9 100644 (file)
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -1002,9 +1002,6 @@ main(int argc, char **argv)
        while ((opt = getopt_long(argc, argv, IF_OPTS, cf_options, &oi)) != -1)
        {
                switch (opt) {
-               case 'b':
-                       options |= DHCPCD_BACKGROUND;
-                       break;
                case 'd':
                        setlogmask(LOG_UPTO(LOG_DEBUG));
                        break;
@@ -1017,16 +1014,9 @@ main(int argc, char **argv)
                case 'n':
                        sig = SIGALRM;
                        break;
-               case 'q':
-                       setlogmask(LOG_UPTO(LOG_WARNING));
-                       options |= DHCPCD_QUIET;
-                       break;
                case 'x':
                        sig = SIGTERM;
                        break;
-               case 'B':
-                       options &= ~DHCPCD_DAEMONISE;
-                       break;
                case 'T':
                        options |= DHCPCD_TEST | DHCPCD_PERSISTENT;
                        break;
@@ -1047,6 +1037,13 @@ main(int argc, char **argv)
                exit(EXIT_FAILURE);
        }
 
+#ifdef THERE_IS_NO_FORK
+       options &= ~DHCPCD_DAEMONISE;
+#endif
+
+       if (ifo->options & DHCPCD_QUIET)
+               setlogmask(LOG_UPTO(LOG_WARNING));
+
        /* If we have any other args, we should run as a single dhcpcd instance
         * for that interface. */
        len = strlen(PIDFILE) + IF_NAMESIZE + 2;
@@ -1057,10 +1054,6 @@ main(int argc, char **argv)
                snprintf(pidfile, len, PIDFILE, "", "");
                options |= DHCPCD_MASTER;
        }
-       
-#ifdef THERE_IS_NO_FORK
-       options &= ~DHCPCD_DAEMONISE;
-#endif
 
        chdir("/");
        umask(022);
index 1f8ff8f12bab10b84f70d5bbfb58698481b47f7e..3c45b0de0aceb0cc75e108386b2dde79cc8f6a19 100644 (file)
@@ -257,15 +257,15 @@ parse_option(struct if_options *ifo, int opt, const char *arg)
        struct in_addr addr;
 
        switch(opt) {
-       case 'b': /* FALLTHROUGH */
        case 'd': /* FALLTHROUGH */
        case 'k': /* FALLTHROUGH */
        case 'n': /* FALLTHROUGH */
-       case 'q': /* FALLTHROUGH */
        case 'x': /* FALLTHROUGH */
-       case 'B': /* FALLTHROUGH */
        case 'T': /* We need to handle non interface options */
                break;
+       case 'b':
+               ifo->options |= DHCPCD_BACKGROUND;
+               break;
        case 'c':
                strlcpy(ifo->script, arg, sizeof(ifo->script));
                break;
@@ -326,6 +326,9 @@ parse_option(struct if_options *ifo, int opt, const char *arg)
        case 'p':
                ifo->options |= DHCPCD_PERSISTENT;
                break;
+       case 'q':
+               ifo->options |= DHCPCD_QUIET;
+               break;
        case 's':
                ifo->options |= DHCPCD_INFORM;
                ifo->options |= DHCPCD_PERSISTENT;
@@ -419,6 +422,9 @@ parse_option(struct if_options *ifo, int opt, const char *arg)
                /* IPv4LL requires ARP */
                ifo->options &= ~DHCPCD_IPV4LL;
                break;
+       case 'B':
+               ifo->options &= ~DHCPCD_DAEMONISE;
+               break;
        case 'C':
                /* Commas to spaces for shell */
                while ((p = strchr(arg, ',')))