intervals like we do otherwise.
We now return a non zero exit code on SIGTERM and SIGINT if we have not
forked into the background.
When NIS and/or NTP servers are updated, we restart the service for them
if we can.
+For infinite timeout, we now resent the last request at TIMEOUT_MINI
+intervals like we do otherwise.
+We now return a non zero exit code on SIGTERM and SIGINT if we have not
+forked into the background.
+When NIS and/or NTP servers are updated, we restart the service for them
+if we can.
+
dhcpcd-3.0.9
Add static routes before any default routes as a router may require a host
route in the static routes.
# Should work for both GNU make and BSD make
-VERSION = 3.0.9
+VERSION = 3.0.10_pre1
CFLAGS ?= -O2 -pipe
$(INSTALL) -m 0755 $(MAN8_TARGETS) $(MANDIR)/man8
clean:
- rm -f $(TARGET) $(dhcpcd_H) *.o *~
+ rm -f $(TARGET) $(dhcpcd_H) *.o *~ *.core
dist:
$(INSTALL) -m 0755 -d /tmp/dhcpcd-$(VERSION)
/*
* dhcpcd - DHCP client daemon -
- * Copyright (C) 2006 Roy Marples <uberlord@gentoo.org>
+ * Copyright 2006-2007 Roy Marples <uberlord@gentoo.org>
*
* dhcpcd is an RFC2131 compliant DHCP client daemon.
*
/*
* dhcpcd - DHCP client daemon -
- * Copyright (C) 2005 - 2006 Roy Marples <uberlord@gentoo.org>
+ * Copyright 2005 - 2007 Roy Marples <uberlord@gentoo.org>
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
/*
* dhcpcd - DHCP client daemon -
- * Copyright (C) 2006 Roy Marples <uberlord@gentoo.org>
+ * Copyright 2006-2007 Roy Marples <uberlord@gentoo.org>
*
* dhcpcd is an RFC2131 compliant DHCP client daemon.
*
if (options->timeout == 0 || dhcp->leasetime == (unsigned) -1)
{
logger (LOG_DEBUG, "waiting on select for infinity");
- maxfd = signal_fd_set (&rset, iface->fd);
- retval = select (maxfd + 1, &rset, NULL, NULL, NULL);
+ retval = 0;
+ while (retval == 0)
+ {
+ tv.tv_sec = TIMEOUT_MINI;
+ tv.tv_usec = 0;
+ maxfd = signal_fd_set (&rset, iface->fd);
+ retval = select (maxfd + 1, &rset, NULL, NULL, &tv);
+ if (retval == 0)
+ SEND_MESSAGE (last_type);
+ }
}
else
{
{
case SIGINT:
logger (LOG_INFO, "receieved SIGINT, stopping");
- retval = 0;
+ retval = (! daemonised);
goto eexit;
case SIGTERM:
logger (LOG_INFO, "receieved SIGTERM, stopping");
- retval = 0;
+ retval = (! daemonised);
goto eexit;
case SIGALRM:
/*
* dhcpcd - DHCP client daemon -
- * Copyright (C) 2006 Roy Marples <uberlord@gentoo.org>
+ * Copyright 2007 Roy Marples <uberlord@gentoo.org>
*
* dhcpcd is an RFC2131 compliant DHCP client daemon.
*
/*
* dhcpcd - DHCP client daemon -
- * Copyright (C) 2006 Roy Marples <uberlord@gentoo.org>
+ * Copyright 2006-2007 Roy Marples <uberlord@gentoo.org>
*
* dhcpcd is an RFC2131 compliant DHCP client daemon.
*
/*
* dhcpcd - DHCP client daemon -
- * Copyright (C) 2006 Roy Marples <uberlord@gentoo.org>
+ * Copyright 2006-2007 Roy Marples <uberlord@gentoo.org>
*
* dhcpcd is an RFC2131 compliant DHCP client daemon.
*
/*
* dhcpcd - DHCP client daemon -
- * Copyright (C) 2005 - 2006 Roy Marples <uberlord@gentoo.org>
+ * Copyright 2006-2007 Roy Marples <uberlord@gentoo.org>
*
* dhcpcd is an RFC2131 compliant DHCP client daemon.
*
#include <errno.h>
#include <netdb.h>
#include <resolv.h>
+#include <stdarg.h>
#include <stdlib.h>
#include <unistd.h>
return b;
}
+/* IMPORTANT: Ensure that the last parameter is NULL when calling */
+static int exec_cmd (const char *cmd, const char *args, ...)
+{
+ va_list va;
+ pid_t pid;
+ char **argv;
+ int n = 1;
+
+ va_start (va, args);
+ while (va_arg (va, char *) != NULL)
+ n++;
+ va_end (va);
+ argv = alloca ((n + 1) * sizeof (*argv));
+ if (argv == NULL)
+ {
+ errno = ENOMEM;
+ return -1;
+ }
+
+ va_start (va, args);
+ n = 2;
+ argv[0] = (char *) cmd;
+ argv[1] = (char *) args;
+ while ((argv[n] = va_arg (va, char *)) != NULL)
+ n++;
+ va_end (va);
+
+ if ((pid = fork ()) == 0)
+ {
+ if (execve (cmd, argv, NULL) && errno != ENOENT)
+ logger (LOG_ERR, "error executing \"%s\": %s",
+ cmd, strerror (errno));
+ exit (0);
+ }
+ else if (pid == -1)
+ logger (LOG_ERR, "fork: %s", strerror (errno));
+
+ return 0;
+}
+
static void exec_script (const char *script, const char *infofile,
const char *arg)
{
struct stat buf;
- pid_t pid;
if (! script || ! infofile || ! arg)
return;
}
logger (LOG_DEBUG, "exec \"%s %s %s\"", script, infofile, arg);
-
- /* We don't wait for the user script to finish - do we trust it? */
- /* Don't use vfork as we lose our memory when dhcpcd exits
- causing the script to fail */
- if ((pid = fork ()) == 0)
- {
- if (execle (script, script, infofile, arg, NULL, NULL))
- logger (LOG_ERR, "error executing \"%s %s %s\": %s",
- script, infofile, arg, strerror (errno));
- exit (0);
- }
- else if (pid == -1)
- logger (LOG_ERR, "fork: %s", strerror (errno));
+ exec_cmd (script, infofile, arg, NULL);
}
static int make_resolv (const char *ifname, const dhcp_t *dhcp)
static void restore_resolv(const char *ifname)
{
struct stat buf;
- pid_t pid;
if (stat (RESOLVCONF, &buf) < 0)
return;
logger (LOG_DEBUG, "removing information from resolvconf");
-
- /* Don't wait around here as we should only be called when
- dhcpcd is closing down and something may do a kill -9
- if we take too long */
- /* Don't use vfork as we lose our memory when dhcpcd exits
- causing the script to fail */
- if ((pid = fork ()) == 0)
- {
- if (execle (RESOLVCONF, RESOLVCONF, "-d", ifname, NULL, NULL))
- logger (LOG_ERR, "error executing \"%s -d %s\": %s",
- RESOLVCONF, ifname, strerror (errno));
- exit (0);
- }
- else if (pid == -1)
- logger (LOG_ERR, "fork: %s", strerror (errno));
+ exec_cmd (RESOLVCONF, "-d", ifname, NULL);
}
static int make_ntp (const char *ifname, const dhcp_t *dhcp)
fprintf (f, "driftfile " NTPDRIFTFILE "\n");
fprintf (f, "logfile " NTPLOGFILE "\n");
fclose (f);
+
+ exec_cmd (NTPSERVICE, NTPRESTARTARGS, NULL);
return 0;
}
fclose (f);
+ exec_cmd (NISSERVICE, NISRESTARTARGS, NULL);
return 0;
}
/*
* dhcpcd - DHCP client daemon -
- * Copyright (C) 2005 - 2006 Roy Marples <uberlord@gentoo.org>
+ * Copyright 2006-2007 Roy Marples <uberlord@gentoo.org>
*
* dhcpcd is an RFC2131 compliant DHCP client daemon.
*
/*
* dhcpcd - DHCP client daemon -
- * Copyright (C) 2005 - 2006 Roy Marples <uberlord@gentoo.org>
+ * Copyright 2006-2007 Roy Marples <uberlord@gentoo.org>
*
* dhcpcd is an RFC2131 compliant DHCP client daemon.
*
/*
* dhcpcd - DHCP client daemon -
- * Copyright (C) 2005 - 2006 Roy Marples <uberlord@gentoo.org>
+ * Copyright 2006-2007 Roy Marples <uberlord@gentoo.org>
*
* dhcpcd is an RFC2131 compliant DHCP client daemon.
*
/*
* dhcpcd - DHCP client daemon -
- * Copyright (C) 2005 - 2006 Roy Marples <uberlord@gentoo.org>
+ * Copyright 2006-2007 Roy Marples <uberlord@gentoo.org>
*
* dhcpcd is an RFC2131 compliant DHCP client daemon.
*
/*
* dhcpcd - DHCP client daemon -
- * Copyright (C) 2005 - 2006 Roy Marples <uberlord@gentoo.org>
+ * Copyright 2006-2007 Roy Marples <uberlord@gentoo.org>
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
/*
* dhcpcd - DHCP client daemon -
- * Copyright (C) 2006 Roy Marples <uberlord@gentoo.org>
+ * Copyright 2006-2007 Roy Marples <uberlord@gentoo.org>
*
* dhcpcd is an RFC2131 compliant DHCP client daemon.
*
/*
* dhcpcd - DHCP client daemon -
- * Copyright (C) 2006 Roy Marples <uberlord@gentoo.org>
+ * Copyright 2006-2007 Roy Marples <uberlord@gentoo.org>
*
* dhcpcd is an RFC2131 compliant DHCP client daemon.
*
/*
* dhcpcd - DHCP client daemon -
- * Copyright (C) 2006 Roy Marples <uberlord@gentoo.org>
+ * Copyright 2006-2007 Roy Marples <uberlord@gentoo.org>
*
* dhcpcd is an RFC2131 compliant DHCP client daemon.
*
/*
* dhcpcd - DHCP client daemon -
- * Copyright (C) 2006 Roy Marples <uberlord@gentoo.org>
+ * Copyright 2006-2007 Roy Marples <uberlord@gentoo.org>
*
* dhcpcd is an RFC2131 compliant DHCP client daemon.
*
/*
* dhcpcd - DHCP client daemon -
- * Copyright (C) 2005 - 2006 Roy Marples <uberlord@gentoo.org>
+ * Copyright 2005 - 2007 Roy Marples <uberlord@gentoo.org>
*
* dhcpcd is an RFC2131 compliant DHCP client daemon.
*
#define ETCDIR "/etc"
#define RESOLVFILE ETCDIR "/resolv.conf"
+
#define NISFILE ETCDIR "/yp.conf"
+#define NISSERVICE ETCDIR "/init.d/ypbind"
+#define NISRESTARTARGS "--quiet", "conditionalrestart"
+
#define NTPFILE ETCDIR "/ntp.conf"
#define NTPDRIFTFILE ETCDIR "/ntp.drift"
+#define NTPLOGFILE "/var/log/ntp.log"
+#define NTPSERVICE ETCDIR "/init.d/ntpd"
+#define NTPRESTARTARGS "--quiet", "conditionalrestart"
+
#define DEFAULT_SCRIPT ETCDIR "/" PACKAGE ".sh"
#define STATEDIR "/var"
#define CONFIGDIR STATEDIR "/lib/" PACKAGE
#define INFOFILE CONFIGDIR "/" PACKAGE "-%s.info"
-#define NTPLOGFILE "/var/log/ntp.log"
-
#endif
/*
- * Copyright (C) 2006 Roy Marples <uberlord@gentoo.org>
+ * Copyright 2006-2007 Roy Marples <uberlord@gentoo.org>
* although a lot was lifted from udhcp
*
* dhcpcd is an RFC2131 compliant DHCP client daemon.
/*
* dhcpcd - DHCP client daemon -
- * Copyright (C) 2006 Roy Marples <uberlord@gentoo.org>
+ * Copyright 2006-2007 Roy Marples <uberlord@gentoo.org>
* although a lot was lifted from udhcp
*
* dhcpcd is an RFC2131 compliant DHCP client daemon.