dhcdbd patches.



Hey,

Two dhcdbd patches are attached, against dhcdbd 1.9.

dhcdbd-use-daemon.patch - use daemon(3), rather than hand-coded
daemonizing code, when becoming a daemon.  aside from being cleaner,
this has the effect of redirecting stdout and stderr to /dev/null
instead of /dev/console.  daemons should not write all over the console
and, additionally, we want to launch dhclient in with these file
descriptors redirected (as it, too, is a daemon).  this avoids the
current spew all over the console.

dhcdbd-quiet-dhclient.patch - pass "-q" to dhclient.  less needed with
the above, but prevents it from logging its advertisements and such.
only errors are printed now.

	Robert Love

--- dhcdbd.c.orig	2005-10-31 13:40:56.000000000 -0500
+++ dhcdbd.c	2005-10-31 13:44:07.000000000 -0500
@@ -729,7 +729,7 @@ static 
 int dhcdbd_run_dhclient( DHC_IF *d_if )
 {
     char **dhc_args, **dhc_envp, *xtra_arg=0L;
-    uint8_t n_args=11, arg;
+    uint8_t n_args=12, arg;
     DHC_IF *rel_if=0L;
     int i;
     sigset_t ss;
@@ -909,6 +909,10 @@ int dhcdbd_run_dhclient( DHC_IF *d_if )
 
 	if((dhc_args[++arg] = (char*)malloc( 3 )) == 0L)
 	    return -1;
+	strcpy(dhc_args[arg], "-q");
+
+	if((dhc_args[++arg] = (char*)malloc( 3 )) == 0L)
+	    return -1;
 	strcpy(dhc_args[arg], "-e");
 	if((dhc_args[++arg] = (char*)malloc( strlen("dhc_dbus=xx")+1 )) == 0L)
 	    return -1;
--- dhcdbd.c.orig	2005-10-31 13:58:27.000000000 -0500
+++ dhcdbd.c	2005-10-31 13:58:38.000000000 -0500
@@ -2739,26 +2739,11 @@ int dhcdbd_run( D_BUS_TYPE bus )
     DBUS_SVC dbus;
     DHCO     dhco;
     struct   sigaction sa;
-    pid_t pid;
     char path[1024];
     int fd, l;
 
-    if( dhcdbd_daemonize )
-    {
-	if ( (pid = fork()) == -1 )
+    if( dhcdbd_daemonize && daemon ( 0, 0 ) == -1 )
 	    return errno;
-	else
-	if (pid > 0)
-	    exit(0);
-	ioctl(0,TIOCNOTTY,0);
-	close(0);
-	close(1);
-	close(2);
-	open("/dev/null", O_RDONLY);
-	open("/dev/console",O_WRONLY);
-	open("/dev/console",O_WRONLY);
-	setsid();
-    }
 
     openlog( "dhcdbd", LOG_NDELAY | LOG_CONS, LOG_USER );
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]