|
|
324fcf |
diff -up dhcp-4.3.0a1/client/dhclient.c.ifup dhcp-4.3.0a1/client/dhclient.c
|
|
|
324fcf |
--- dhcp-4.3.0a1/client/dhclient.c.ifup 2013-12-19 14:53:08.817760677 +0100
|
|
|
324fcf |
+++ dhcp-4.3.0a1/client/dhclient.c 2013-12-19 15:05:16.290518574 +0100
|
|
|
324fcf |
@@ -521,9 +521,81 @@ main(int argc, char **argv) {
|
|
|
324fcf |
}
|
|
|
324fcf |
}
|
|
|
324fcf |
fclose(pidfd);
|
|
|
324fcf |
+ } else {
|
|
|
324fcf |
+ /* handle release for interfaces requested with Red Hat
|
|
|
324fcf |
+ * /sbin/ifup - pidfile will be /var/run/dhclient-$interface.pid
|
|
|
324fcf |
+ */
|
|
|
324fcf |
+
|
|
|
324fcf |
+ if ((path_dhclient_pid == NULL) || (*path_dhclient_pid == '\0'))
|
|
|
324fcf |
+ path_dhclient_pid = "/var/run/dhclient.pid";
|
|
|
324fcf |
+
|
|
|
324fcf |
+ char *new_path_dhclient_pid;
|
|
|
324fcf |
+ struct interface_info *ip;
|
|
|
324fcf |
+ int pdp_len = strlen(path_dhclient_pid), pfx, dpfx;
|
|
|
324fcf |
+
|
|
|
324fcf |
+ /* find append point: beginning of any trailing '.pid'
|
|
|
324fcf |
+ * or '-$IF.pid' */
|
|
|
324fcf |
+ for (pfx=pdp_len; (pfx >= 0) && (path_dhclient_pid[pfx] != '.') && (path_dhclient_pid[pfx] != '/'); pfx--);
|
|
|
324fcf |
+ if (pfx == -1)
|
|
|
324fcf |
+ pfx = pdp_len;
|
|
|
324fcf |
+
|
|
|
324fcf |
+ if (path_dhclient_pid[pfx] == '/')
|
|
|
324fcf |
+ pfx += 1;
|
|
|
324fcf |
+
|
|
|
324fcf |
+ for (dpfx=pfx; (dpfx >= 0) && (path_dhclient_pid[dpfx] != '-') && (path_dhclient_pid[dpfx] != '/'); dpfx--);
|
|
|
324fcf |
+ if ((dpfx > -1) && (path_dhclient_pid[dpfx] != '/'))
|
|
|
324fcf |
+ pfx = dpfx;
|
|
|
324fcf |
+
|
|
|
324fcf |
+ for (ip = interfaces; ip; ip = ip->next) {
|
|
|
324fcf |
+ if (interfaces_requested && (ip->flags & (INTERFACE_REQUESTED))) {
|
|
|
324fcf |
+ int n_len = strlen(ip->name);
|
|
|
324fcf |
+
|
|
|
324fcf |
+ new_path_dhclient_pid = (char*) malloc(pfx + n_len + 6);
|
|
|
324fcf |
+ strncpy(new_path_dhclient_pid, path_dhclient_pid, pfx);
|
|
|
324fcf |
+ sprintf(new_path_dhclient_pid + pfx, "-%s.pid", ip->name);
|
|
|
324fcf |
+
|
|
|
324fcf |
+ if ((pidfd = fopen(new_path_dhclient_pid, "r")) != NULL) {
|
|
|
324fcf |
+ e = fscanf(pidfd, "%ld\n", &temp);
|
|
|
324fcf |
+ oldpid = (pid_t)temp;
|
|
|
324fcf |
+
|
|
|
324fcf |
+ if (e != 0 && e != EOF) {
|
|
|
324fcf |
+ if (oldpid) {
|
|
|
324fcf |
+ if (kill(oldpid, SIGTERM) == 0)
|
|
|
324fcf |
+ unlink(path_dhclient_pid);
|
|
|
324fcf |
+ }
|
|
|
324fcf |
+ }
|
|
|
324fcf |
+
|
|
|
324fcf |
+ fclose(pidfd);
|
|
|
324fcf |
+ }
|
|
|
324fcf |
+
|
|
|
324fcf |
+ free(new_path_dhclient_pid);
|
|
|
324fcf |
+ }
|
|
|
324fcf |
+ }
|
|
|
324fcf |
+ }
|
|
|
324fcf |
+ } else {
|
|
|
324fcf |
+ FILE *pidfp = NULL;
|
|
|
324fcf |
+ long temp = 0;
|
|
|
324fcf |
+ pid_t dhcpid = 0;
|
|
|
324fcf |
+ int dhc_running = 0;
|
|
|
324fcf |
+ char procfn[256] = "";
|
|
|
324fcf |
+
|
|
|
324fcf |
+ if ((pidfp = fopen(path_dhclient_pid, "r")) != NULL) {
|
|
|
324fcf |
+ if ((fscanf(pidfp, "%ld", &temp)==1) && ((dhcpid=(pid_t)temp) > 0)) {
|
|
|
324fcf |
+ snprintf(procfn,256,"/proc/%u",dhcpid);
|
|
|
324fcf |
+ dhc_running = (access(procfn, F_OK) == 0);
|
|
|
324fcf |
+ }
|
|
|
324fcf |
+
|
|
|
324fcf |
+ fclose(pidfp);
|
|
|
324fcf |
+ }
|
|
|
324fcf |
+
|
|
|
324fcf |
+ if (dhc_running) {
|
|
|
324fcf |
+ log_fatal("dhclient(%u) is already running - exiting. ", dhcpid);
|
|
|
324fcf |
+ return(1);
|
|
|
324fcf |
}
|
|
|
324fcf |
}
|
|
|
324fcf |
|
|
|
324fcf |
+ write_client_pid_file();
|
|
|
324fcf |
+
|
|
|
324fcf |
if (!quiet) {
|
|
|
324fcf |
log_info("%s %s", message, PACKAGE_VERSION);
|
|
|
324fcf |
log_info(copyright);
|