#ifndef lint
static char ocopyright[] =
-"$Id: dhclient.c,v 1.152 2007/06/06 22:57:32 each Exp $ Copyright (c) 2004-2007 Internet Systems Consortium. All rights reserved.\n";
+"$Id: dhclient.c,v 1.153 2007/06/07 15:29:30 each Exp $ Copyright (c) 2004-2007 Internet Systems Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
else
log_fatal("Impossible condition at %s:%d.", MDL);
- /* first kill of any currently running client */
+ /*
+ * convert relative path names to absolute, for files that need
+ * to be reopened after chdir() has been called
+ */
+ if (path_dhclient_db[0] != '/') {
+ char *path = dmalloc(PATH_MAX, MDL);
+ if (path == NULL)
+ log_fatal("No memory for filename\n");
+ path_dhclient_db = realpath(path_dhclient_db, path);
+ if (path_dhclient_db == NULL)
+ log_fatal("%s: %s", path, strerror(errno));
+ }
+
+ if (path_dhclient_script[0] != '/') {
+ char *path = dmalloc(PATH_MAX, MDL);
+ if (path == NULL)
+ log_fatal("No memory for filename\n");
+ path_dhclient_script = realpath(path_dhclient_script, path);
+ if (path_dhclient_script == NULL)
+ log_fatal("%s: %s", path, strerror(errno));
+ }
+
+ /* first kill off any currently running client */
if (release_mode || exit_mode) {
FILE *pidfd;
pid_t oldpid;
open("/dev/null", O_RDWR);
write_client_pid_file ();
+
+ chdir("/");
}
void write_client_pid_file ()
#ifndef lint
static char ocopyright[] =
-"$Id: dhcpd.c,v 1.126 2007/05/29 18:11:56 each Exp $ Copyright 2004-2007 Internet Systems Consortium.";
+"$Id: dhcpd.c,v 1.127 2007/06/07 15:29:31 each Exp $ Copyright 2004-2007 Internet Systems Consortium.";
#endif
static char copyright[] =
#include "dhcpd.h"
#include <omapip/omapip_p.h>
#include <syslog.h>
+#include <errno.h>
static void usage PROTO ((void));
path_dhcpd_pid = s;
}
+ /*
+ * convert relative path names to absolute, for files that need
+ * to be reopened after chdir() has been called
+ */
+ if (path_dhcpd_db[0] != '/') {
+ char *path = dmalloc(PATH_MAX, MDL);
+ if (path == NULL)
+ log_fatal("No memory for filename\n");
+ path_dhcpd_db = realpath(path_dhcpd_db, path);
+ if (path_dhcpd_db == NULL)
+ log_fatal("%s: %s", path, strerror(errno));
+ }
+
if (!quiet) {
log_info("%s %s", message, PACKAGE_VERSION);
log_info (copyright);
else
log_perror = 0;
+ /* If we didn't write the pid file earlier because we found a
+ process running the logged pid, but we made it to here,
+ meaning nothing is listening on the bootp port, then write
+ the pid file out - what's in it now is bogus anyway. */
+ if (!pidfilewritten) {
+ unlink (path_dhcpd_pid);
+ if ((i = open (path_dhcpd_pid,
+ O_WRONLY | O_CREAT, 0644)) >= 0) {
+ sprintf (pbuf, "%d\n", (int)getpid ());
+ write (i, pbuf, strlen (pbuf));
+ close (i);
+ pidfilewritten = 1;
+ }
+ }
+
if (daemon) {
/* Become session leader and get pid... */
pid = setsid();
open("/dev/null", O_RDWR);
open("/dev/null", O_RDWR);
log_perror = 0; /* No sense logging to /dev/null. */
- }
- /* If we didn't write the pid file earlier because we found a
- process running the logged pid, but we made it to here,
- meaning nothing is listening on the bootp port, then write
- the pid file out - what's in it now is bogus anyway. */
- if (!pidfilewritten) {
- unlink (path_dhcpd_pid);
- if ((i = open (path_dhcpd_pid,
- O_WRONLY | O_CREAT, 0644)) >= 0) {
- sprintf (pbuf, "%d\n", (int)getpid ());
- write (i, pbuf, strlen (pbuf));
- close (i);
- pidfilewritten = 1;
- }
+ chdir("/");
}
#endif /* !DEBUG */