changeset 967:862f53237052 draft

Allow quiet and nobackground to work in dhcpcd.conf
author Roy Marples <roy@marples.name>
date Thu, 11 Sep 2008 08:28:39 +0000
parents e3e131f496fb
children fda8caac3a0c
files dhcpcd.c if-options.c
diffstat 2 files changed, 16 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/dhcpcd.c	Wed Sep 10 12:39:20 2008 +0000
+++ b/dhcpcd.c	Thu Sep 11 08:28:39 2008 +0000
@@ -1002,9 +1002,6 @@
 	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 @@
 		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 @@
 		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 @@
 		snprintf(pidfile, len, PIDFILE, "", "");
 		options |= DHCPCD_MASTER;
 	}
-	
-#ifdef THERE_IS_NO_FORK
-	options &= ~DHCPCD_DAEMONISE;
-#endif
 
 	chdir("/");
 	umask(022);
--- a/if-options.c	Wed Sep 10 12:39:20 2008 +0000
+++ b/if-options.c	Thu Sep 11 08:28:39 2008 +0000
@@ -257,15 +257,15 @@
 	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 @@
 	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 @@
 		/* 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, ',')))