1 --- dhcp-3.0.5/client/dhclient.c.release 2007-03-30 15:30:14.000000000 -0400
2 +++ dhcp-3.0.5/client/dhclient.c 2007-03-30 15:29:58.000000000 -0400
8 + /* handle release for interfaces requested with Red Hat
9 + * /sbin/ifup - pidfile will be /var/run/dhclient-$interface.pid
12 + if ((path_dhclient_pid == NULL) || (*path_dhclient_pid == '\0'))
13 + path_dhclient_pid = "/var/run/dhclient.pid";
15 + char *new_path_dhclient_pid;
16 + struct interface_info *ip;
17 + int pdp_len = strlen(path_dhclient_pid), pfx, dpfx;
19 + /* find append point: beginning of any trailing '.pid'
21 + for (pfx=pdp_len; (pfx >= 0) && (path_dhclient_pid[pfx] != '.') && (path_dhclient_pid[pfx] != '/'); pfx--);
25 + if (path_dhclient_pid[pfx] == '/')
28 + for (dpfx=pfx; (dpfx >= 0) && (path_dhclient_pid[dpfx] != '-') && (path_dhclient_pid[dpfx] != '/'); dpfx--);
29 + if ((dpfx > -1) && (path_dhclient_pid[dpfx] != '/'))
32 + for (ip = interfaces; ip; ip = ip->next) {
33 + if (interfaces_requested && (ip->flags & (INTERFACE_REQUESTED)) && (ip->name != NULL)) {
34 + int n_len = strlen(ip->name);
36 + new_path_dhclient_pid = (char*) malloc(pfx + n_len + 6);
37 + strncpy(new_path_dhclient_pid, path_dhclient_pid, pfx);
38 + sprintf(new_path_dhclient_pid + pfx, "-%s.pid", ip->name);
40 + if ((pidfd = fopen(new_path_dhclient_pid, "r")) != NULL) {
41 + e = fscanf(pidfd, "%ld\n", &temp);
42 + oldpid = (pid_t)temp;
44 + if (e != 0 && e != EOF) {
46 + if (kill(oldpid, SIGTERM) == 0)
47 + unlink(path_dhclient_pid);
54 + free(new_path_dhclient_pid);
62 + int dhc_running = 0;
63 + char procfn[256] = "";
65 + if ((pidfp = fopen(path_dhclient_pid, "r")) != NULL) {
66 + if ((fscanf(pidfp, "%ld", &temp)==1) && ((dhcpid=(pid_t)temp) > 0)) {
67 + snprintf(procfn,256,"/proc/%u",dhcpid);
68 + dhc_running = (access(procfn, F_OK) == 0);
75 + log_fatal("dhclient(%u) is already running - exiting. ", dhcpid);
80 + write_client_pid_file();
83 log_info ("%s %s", message, DHCP_VERSION);