Allow quiet and nobackground to work in dhcpcd.conf

This commit is contained in:
Roy Marples 2008-09-11 08:28:39 +00:00
parent 9d94cb7804
commit 03c2c87907
2 changed files with 16 additions and 17 deletions

View File

@ -1002,9 +1002,6 @@ main(int argc, char **argv)
while ((opt = getopt_long(argc, argv, IF_OPTS, cf_options, &oi)) != -1) while ((opt = getopt_long(argc, argv, IF_OPTS, cf_options, &oi)) != -1)
{ {
switch (opt) { switch (opt) {
case 'b':
options |= DHCPCD_BACKGROUND;
break;
case 'd': case 'd':
setlogmask(LOG_UPTO(LOG_DEBUG)); setlogmask(LOG_UPTO(LOG_DEBUG));
break; break;
@ -1017,16 +1014,9 @@ main(int argc, char **argv)
case 'n': case 'n':
sig = SIGALRM; sig = SIGALRM;
break; break;
case 'q':
setlogmask(LOG_UPTO(LOG_WARNING));
options |= DHCPCD_QUIET;
break;
case 'x': case 'x':
sig = SIGTERM; sig = SIGTERM;
break; break;
case 'B':
options &= ~DHCPCD_DAEMONISE;
break;
case 'T': case 'T':
options |= DHCPCD_TEST | DHCPCD_PERSISTENT; options |= DHCPCD_TEST | DHCPCD_PERSISTENT;
break; break;
@ -1047,6 +1037,13 @@ main(int argc, char **argv)
exit(EXIT_FAILURE); 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 /* If we have any other args, we should run as a single dhcpcd instance
* for that interface. */ * for that interface. */
len = strlen(PIDFILE) + IF_NAMESIZE + 2; len = strlen(PIDFILE) + IF_NAMESIZE + 2;
@ -1057,10 +1054,6 @@ main(int argc, char **argv)
snprintf(pidfile, len, PIDFILE, "", ""); snprintf(pidfile, len, PIDFILE, "", "");
options |= DHCPCD_MASTER; options |= DHCPCD_MASTER;
} }
#ifdef THERE_IS_NO_FORK
options &= ~DHCPCD_DAEMONISE;
#endif
chdir("/"); chdir("/");
umask(022); umask(022);

View File

@ -257,15 +257,15 @@ parse_option(struct if_options *ifo, int opt, const char *arg)
struct in_addr addr; struct in_addr addr;
switch(opt) { switch(opt) {
case 'b': /* FALLTHROUGH */
case 'd': /* FALLTHROUGH */ case 'd': /* FALLTHROUGH */
case 'k': /* FALLTHROUGH */ case 'k': /* FALLTHROUGH */
case 'n': /* FALLTHROUGH */ case 'n': /* FALLTHROUGH */
case 'q': /* FALLTHROUGH */
case 'x': /* FALLTHROUGH */ case 'x': /* FALLTHROUGH */
case 'B': /* FALLTHROUGH */
case 'T': /* We need to handle non interface options */ case 'T': /* We need to handle non interface options */
break; break;
case 'b':
ifo->options |= DHCPCD_BACKGROUND;
break;
case 'c': case 'c':
strlcpy(ifo->script, arg, sizeof(ifo->script)); strlcpy(ifo->script, arg, sizeof(ifo->script));
break; break;
@ -326,6 +326,9 @@ parse_option(struct if_options *ifo, int opt, const char *arg)
case 'p': case 'p':
ifo->options |= DHCPCD_PERSISTENT; ifo->options |= DHCPCD_PERSISTENT;
break; break;
case 'q':
ifo->options |= DHCPCD_QUIET;
break;
case 's': case 's':
ifo->options |= DHCPCD_INFORM; ifo->options |= DHCPCD_INFORM;
ifo->options |= DHCPCD_PERSISTENT; ifo->options |= DHCPCD_PERSISTENT;
@ -419,6 +422,9 @@ parse_option(struct if_options *ifo, int opt, const char *arg)
/* IPv4LL requires ARP */ /* IPv4LL requires ARP */
ifo->options &= ~DHCPCD_IPV4LL; ifo->options &= ~DHCPCD_IPV4LL;
break; break;
case 'B':
ifo->options &= ~DHCPCD_DAEMONISE;
break;
case 'C': case 'C':
/* Commas to spaces for shell */ /* Commas to spaces for shell */
while ((p = strchr(arg, ','))) while ((p = strchr(arg, ',')))