|
|
26a25c |
diff -up dhcp-4.3.3b1/client/clparse.c.cloexec dhcp-4.3.3b1/client/clparse.c
|
|
|
26a25c |
--- dhcp-4.3.3b1/client/clparse.c.cloexec 2015-08-10 10:46:20.264755543 +0200
|
|
|
26a25c |
+++ dhcp-4.3.3b1/client/clparse.c 2015-08-10 10:46:20.274755510 +0200
|
|
|
26a25c |
@@ -247,7 +247,7 @@ int read_client_conf_file (const char *n
|
|
|
26a25c |
int token;
|
|
|
26a25c |
isc_result_t status;
|
|
|
26a25c |
|
|
|
26a25c |
- if ((file = open (name, O_RDONLY)) < 0)
|
|
|
26a25c |
+ if ((file = open (name, O_RDONLY | O_CLOEXEC)) < 0)
|
|
|
26a25c |
return uerr2isc (errno);
|
|
|
26a25c |
|
|
|
26a25c |
cfile = NULL;
|
|
|
26a25c |
@@ -323,7 +323,7 @@ void read_client_leases ()
|
|
|
26a25c |
|
|
|
26a25c |
/* Open the lease file. If we can't open it, just return -
|
|
|
26a25c |
we can safely trust the server to remember our state. */
|
|
|
26a25c |
- if ((file = open (path_dhclient_db, O_RDONLY)) < 0)
|
|
|
26a25c |
+ if ((file = open (path_dhclient_db, O_RDONLY | O_CLOEXEC)) < 0)
|
|
|
26a25c |
return;
|
|
|
26a25c |
|
|
|
26a25c |
cfile = NULL;
|
|
|
26a25c |
diff -up dhcp-4.3.3b1/client/dhclient.c.cloexec dhcp-4.3.3b1/client/dhclient.c
|
|
|
26a25c |
--- dhcp-4.3.3b1/client/dhclient.c.cloexec 2015-08-10 10:46:20.260755556 +0200
|
|
|
26a25c |
+++ dhcp-4.3.3b1/client/dhclient.c 2015-08-10 10:46:20.275755506 +0200
|
|
|
26a25c |
@@ -153,11 +153,11 @@ main(int argc, char **argv) {
|
|
|
26a25c |
/* Make sure that file descriptors 0 (stdin), 1, (stdout), and
|
|
|
26a25c |
2 (stderr) are open. To do this, we assume that when we
|
|
|
26a25c |
open a file the lowest available file descriptor is used. */
|
|
|
26a25c |
- fd = open("/dev/null", O_RDWR);
|
|
|
26a25c |
+ fd = open("/dev/null", O_RDWR | O_CLOEXEC);
|
|
|
26a25c |
if (fd == 0)
|
|
|
26a25c |
- fd = open("/dev/null", O_RDWR);
|
|
|
26a25c |
+ fd = open("/dev/null", O_RDWR | O_CLOEXEC);
|
|
|
26a25c |
if (fd == 1)
|
|
|
26a25c |
- fd = open("/dev/null", O_RDWR);
|
|
|
26a25c |
+ fd = open("/dev/null", O_RDWR | O_CLOEXEC);
|
|
|
26a25c |
if (fd == 2)
|
|
|
26a25c |
log_perror = 0; /* No sense logging to /dev/null. */
|
|
|
26a25c |
else if (fd != -1)
|
|
|
26a25c |
@@ -519,7 +519,7 @@ main(int argc, char **argv) {
|
|
|
26a25c |
long temp;
|
|
|
26a25c |
int e;
|
|
|
26a25c |
|
|
|
26a25c |
- if ((pidfd = fopen(path_dhclient_pid, "r")) != NULL) {
|
|
|
26a25c |
+ if ((pidfd = fopen(path_dhclient_pid, "re")) != NULL) {
|
|
|
26a25c |
e = fscanf(pidfd, "%ld\n", &temp);
|
|
|
26a25c |
oldpid = (pid_t)temp;
|
|
|
26a25c |
|
|
|
26a25c |
@@ -574,7 +574,7 @@ main(int argc, char **argv) {
|
|
|
26a25c |
strncpy(new_path_dhclient_pid, path_dhclient_pid, pfx);
|
|
|
26a25c |
sprintf(new_path_dhclient_pid + pfx, "-%s.pid", ip->name);
|
|
|
26a25c |
|
|
|
26a25c |
- if ((pidfd = fopen(new_path_dhclient_pid, "r")) != NULL) {
|
|
|
26a25c |
+ if ((pidfd = fopen(new_path_dhclient_pid, "re")) != NULL) {
|
|
|
26a25c |
e = fscanf(pidfd, "%ld\n", &temp);
|
|
|
26a25c |
oldpid = (pid_t)temp;
|
|
|
26a25c |
|
|
|
26a25c |
@@ -599,7 +599,7 @@ main(int argc, char **argv) {
|
|
|
26a25c |
int dhc_running = 0;
|
|
|
26a25c |
char procfn[256] = "";
|
|
|
26a25c |
|
|
|
26a25c |
- if ((pidfp = fopen(path_dhclient_pid, "r")) != NULL) {
|
|
|
26a25c |
+ if ((pidfp = fopen(path_dhclient_pid, "re")) != NULL) {
|
|
|
26a25c |
if ((fscanf(pidfp, "%ld", &temp)==1) && ((dhcpid=(pid_t)temp) > 0)) {
|
|
|
26a25c |
snprintf(procfn,256,"/proc/%u",dhcpid);
|
|
|
26a25c |
dhc_running = (access(procfn, F_OK) == 0);
|
|
|
26a25c |
@@ -3120,7 +3120,7 @@ void rewrite_client_leases ()
|
|
|
26a25c |
|
|
|
26a25c |
if (leaseFile != NULL)
|
|
|
26a25c |
fclose (leaseFile);
|
|
|
26a25c |
- leaseFile = fopen (path_dhclient_db, "w");
|
|
|
26a25c |
+ leaseFile = fopen (path_dhclient_db, "we");
|
|
|
26a25c |
if (leaseFile == NULL) {
|
|
|
26a25c |
log_error ("can't create %s: %m", path_dhclient_db);
|
|
|
26a25c |
return;
|
|
|
26a25c |
@@ -3313,7 +3313,7 @@ write_duid(struct data_string *duid)
|
|
|
26a25c |
return DHCP_R_INVALIDARG;
|
|
|
26a25c |
|
|
|
26a25c |
if (leaseFile == NULL) { /* XXX? */
|
|
|
26a25c |
- leaseFile = fopen(path_dhclient_db, "w");
|
|
|
26a25c |
+ leaseFile = fopen(path_dhclient_db, "we");
|
|
|
26a25c |
if (leaseFile == NULL) {
|
|
|
26a25c |
log_error("can't create %s: %m", path_dhclient_db);
|
|
|
26a25c |
return ISC_R_IOERROR;
|
|
|
26a25c |
@@ -3493,7 +3493,7 @@ int write_client_lease (client, lease, r
|
|
|
26a25c |
return 1;
|
|
|
26a25c |
|
|
|
26a25c |
if (leaseFile == NULL) { /* XXX */
|
|
|
26a25c |
- leaseFile = fopen (path_dhclient_db, "w");
|
|
|
26a25c |
+ leaseFile = fopen (path_dhclient_db, "we");
|
|
|
26a25c |
if (leaseFile == NULL) {
|
|
|
26a25c |
log_error ("can't create %s: %m", path_dhclient_db);
|
|
|
26a25c |
return 0;
|
|
|
26a25c |
@@ -4011,9 +4011,9 @@ void go_daemon ()
|
|
|
26a25c |
(void) close(2);
|
|
|
26a25c |
|
|
|
26a25c |
/* Reopen them on /dev/null. */
|
|
|
26a25c |
- (void) open("/dev/null", O_RDWR);
|
|
|
26a25c |
- (void) open("/dev/null", O_RDWR);
|
|
|
26a25c |
- (void) open("/dev/null", O_RDWR);
|
|
|
26a25c |
+ (void) open("/dev/null", O_RDWR | O_CLOEXEC);
|
|
|
26a25c |
+ (void) open("/dev/null", O_RDWR | O_CLOEXEC);
|
|
|
26a25c |
+ (void) open("/dev/null", O_RDWR | O_CLOEXEC);
|
|
|
26a25c |
|
|
|
26a25c |
write_client_pid_file ();
|
|
|
26a25c |
|
|
|
26a25c |
@@ -4030,14 +4030,14 @@ void write_client_pid_file ()
|
|
|
26a25c |
return;
|
|
|
26a25c |
}
|
|
|
26a25c |
|
|
|
26a25c |
- pfdesc = open (path_dhclient_pid, O_CREAT | O_TRUNC | O_WRONLY, 0644);
|
|
|
26a25c |
+ pfdesc = open (path_dhclient_pid, O_CREAT | O_TRUNC | O_WRONLY | O_CLOEXEC, 0644);
|
|
|
26a25c |
|
|
|
26a25c |
if (pfdesc < 0) {
|
|
|
26a25c |
log_error ("Can't create %s: %m", path_dhclient_pid);
|
|
|
26a25c |
return;
|
|
|
26a25c |
}
|
|
|
26a25c |
|
|
|
26a25c |
- pf = fdopen (pfdesc, "w");
|
|
|
26a25c |
+ pf = fdopen (pfdesc, "we");
|
|
|
26a25c |
if (!pf) {
|
|
|
26a25c |
close(pfdesc);
|
|
|
26a25c |
log_error ("Can't fdopen %s: %m", path_dhclient_pid);
|
|
|
26a25c |
diff -up dhcp-4.3.3b1/common/bpf.c.cloexec dhcp-4.3.3b1/common/bpf.c
|
|
|
26a25c |
--- dhcp-4.3.3b1/common/bpf.c.cloexec 2015-07-30 15:17:16.000000000 +0200
|
|
|
26a25c |
+++ dhcp-4.3.3b1/common/bpf.c 2015-08-10 10:46:20.275755506 +0200
|
|
|
26a25c |
@@ -95,7 +95,7 @@ int if_register_bpf (info)
|
|
|
26a25c |
for (b = 0; 1; b++) {
|
|
|
26a25c |
/* %Audit% 31 bytes max. %2004.06.17,Safe% */
|
|
|
26a25c |
sprintf(filename, BPF_FORMAT, b);
|
|
|
26a25c |
- sock = open (filename, O_RDWR, 0);
|
|
|
26a25c |
+ sock = open (filename, O_RDWR | O_CLOEXEC, 0);
|
|
|
26a25c |
if (sock < 0) {
|
|
|
26a25c |
if (errno == EBUSY) {
|
|
|
26a25c |
continue;
|
|
|
26a25c |
diff -up dhcp-4.3.3b1/common/dlpi.c.cloexec dhcp-4.3.3b1/common/dlpi.c
|
|
|
26a25c |
--- dhcp-4.3.3b1/common/dlpi.c.cloexec 2015-07-30 15:17:16.000000000 +0200
|
|
|
26a25c |
+++ dhcp-4.3.3b1/common/dlpi.c 2015-08-10 10:46:20.275755506 +0200
|
|
|
26a25c |
@@ -804,7 +804,7 @@ dlpiopen(const char *ifname) {
|
|
|
26a25c |
}
|
|
|
26a25c |
*dp = '\0';
|
|
|
26a25c |
|
|
|
26a25c |
- return open (devname, O_RDWR, 0);
|
|
|
26a25c |
+ return open (devname, O_RDWR | O_CLOEXEC, 0);
|
|
|
26a25c |
}
|
|
|
26a25c |
|
|
|
26a25c |
/*
|
|
|
26a25c |
diff -up dhcp-4.3.3b1/common/nit.c.cloexec dhcp-4.3.3b1/common/nit.c
|
|
|
26a25c |
--- dhcp-4.3.3b1/common/nit.c.cloexec 2015-07-30 15:17:16.000000000 +0200
|
|
|
26a25c |
+++ dhcp-4.3.3b1/common/nit.c 2015-08-10 10:46:20.275755506 +0200
|
|
|
26a25c |
@@ -75,7 +75,7 @@ int if_register_nit (info)
|
|
|
26a25c |
struct strioctl sio;
|
|
|
26a25c |
|
|
|
26a25c |
/* Open a NIT device */
|
|
|
26a25c |
- sock = open ("/dev/nit", O_RDWR);
|
|
|
26a25c |
+ sock = open ("/dev/nit", O_RDWR | O_CLOEXEC);
|
|
|
26a25c |
if (sock < 0)
|
|
|
26a25c |
log_fatal ("Can't open NIT device for %s: %m", info -> name);
|
|
|
26a25c |
|
|
|
26a25c |
diff -up dhcp-4.3.3b1/common/resolv.c.cloexec dhcp-4.3.3b1/common/resolv.c
|
|
|
26a25c |
--- dhcp-4.3.3b1/common/resolv.c.cloexec 2015-07-30 15:17:16.000000000 +0200
|
|
|
26a25c |
+++ dhcp-4.3.3b1/common/resolv.c 2015-08-10 10:46:20.276755503 +0200
|
|
|
26a25c |
@@ -44,7 +44,7 @@ void read_resolv_conf (parse_time)
|
|
|
26a25c |
struct domain_search_list *dp, *dl, *nd;
|
|
|
26a25c |
isc_result_t status;
|
|
|
26a25c |
|
|
|
26a25c |
- if ((file = open (path_resolv_conf, O_RDONLY)) < 0) {
|
|
|
26a25c |
+ if ((file = open (path_resolv_conf, O_RDONLY | O_CLOEXEC)) < 0) {
|
|
|
26a25c |
log_error ("Can't open %s: %m", path_resolv_conf);
|
|
|
26a25c |
return;
|
|
|
26a25c |
}
|
|
|
26a25c |
diff -up dhcp-4.3.3b1/common/upf.c.cloexec dhcp-4.3.3b1/common/upf.c
|
|
|
26a25c |
--- dhcp-4.3.3b1/common/upf.c.cloexec 2015-07-30 15:17:16.000000000 +0200
|
|
|
26a25c |
+++ dhcp-4.3.3b1/common/upf.c 2015-08-10 10:46:20.276755503 +0200
|
|
|
26a25c |
@@ -71,7 +71,7 @@ int if_register_upf (info)
|
|
|
26a25c |
/* %Audit% Cannot exceed 36 bytes. %2004.06.17,Safe% */
|
|
|
26a25c |
sprintf(filename, "/dev/pf/pfilt%d", b);
|
|
|
26a25c |
|
|
|
26a25c |
- sock = open (filename, O_RDWR, 0);
|
|
|
26a25c |
+ sock = open (filename, O_RDWR | O_CLOEXEC, 0);
|
|
|
26a25c |
if (sock < 0) {
|
|
|
26a25c |
if (errno == EBUSY) {
|
|
|
26a25c |
continue;
|
|
|
26a25c |
diff -up dhcp-4.3.3b1/omapip/trace.c.cloexec dhcp-4.3.3b1/omapip/trace.c
|
|
|
26a25c |
--- dhcp-4.3.3b1/omapip/trace.c.cloexec 2015-07-30 15:17:16.000000000 +0200
|
|
|
26a25c |
+++ dhcp-4.3.3b1/omapip/trace.c 2015-08-10 10:46:20.276755503 +0200
|
|
|
26a25c |
@@ -138,10 +138,10 @@ isc_result_t trace_begin (const char *fi
|
|
|
26a25c |
return DHCP_R_INVALIDARG;
|
|
|
26a25c |
}
|
|
|
26a25c |
|
|
|
26a25c |
- traceoutfile = open (filename, O_CREAT | O_WRONLY | O_EXCL, 0600);
|
|
|
26a25c |
+ traceoutfile = open (filename, O_CREAT | O_WRONLY | O_EXCL | O_CLOEXEC, 0600);
|
|
|
26a25c |
if (traceoutfile < 0 && errno == EEXIST) {
|
|
|
26a25c |
log_error ("WARNING: Overwriting trace file \"%s\"", filename);
|
|
|
26a25c |
- traceoutfile = open (filename, O_WRONLY | O_EXCL | O_TRUNC,
|
|
|
26a25c |
+ traceoutfile = open (filename, O_WRONLY | O_EXCL | O_TRUNC | O_CLOEXEC,
|
|
|
26a25c |
0600);
|
|
|
26a25c |
}
|
|
|
26a25c |
|
|
|
26a25c |
@@ -429,7 +429,7 @@ void trace_file_replay (const char *file
|
|
|
26a25c |
isc_result_t result;
|
|
|
26a25c |
int len;
|
|
|
26a25c |
|
|
|
26a25c |
- traceinfile = fopen (filename, "r");
|
|
|
26a25c |
+ traceinfile = fopen (filename, "re");
|
|
|
26a25c |
if (!traceinfile) {
|
|
|
26a25c |
log_error("Can't open tracefile %s: %m", filename);
|
|
|
26a25c |
return;
|
|
|
26a25c |
diff -up dhcp-4.3.3b1/relay/dhcrelay.c.cloexec dhcp-4.3.3b1/relay/dhcrelay.c
|
|
|
26a25c |
--- dhcp-4.3.3b1/relay/dhcrelay.c.cloexec 2015-07-30 15:17:16.000000000 +0200
|
|
|
26a25c |
+++ dhcp-4.3.3b1/relay/dhcrelay.c 2015-08-10 10:46:20.276755503 +0200
|
|
|
26a25c |
@@ -187,11 +187,11 @@ main(int argc, char **argv) {
|
|
|
26a25c |
/* Make sure that file descriptors 0(stdin), 1,(stdout), and
|
|
|
26a25c |
2(stderr) are open. To do this, we assume that when we
|
|
|
26a25c |
open a file the lowest available file descriptor is used. */
|
|
|
26a25c |
- fd = open("/dev/null", O_RDWR);
|
|
|
26a25c |
+ fd = open("/dev/null", O_RDWR | O_CLOEXEC);
|
|
|
26a25c |
if (fd == 0)
|
|
|
26a25c |
- fd = open("/dev/null", O_RDWR);
|
|
|
26a25c |
+ fd = open("/dev/null", O_RDWR | O_CLOEXEC);
|
|
|
26a25c |
if (fd == 1)
|
|
|
26a25c |
- fd = open("/dev/null", O_RDWR);
|
|
|
26a25c |
+ fd = open("/dev/null", O_RDWR | O_CLOEXEC);
|
|
|
26a25c |
if (fd == 2)
|
|
|
26a25c |
log_perror = 0; /* No sense logging to /dev/null. */
|
|
|
26a25c |
else if (fd != -1)
|
|
|
26a25c |
@@ -558,13 +558,13 @@ main(int argc, char **argv) {
|
|
|
26a25c |
|
|
|
26a25c |
if (no_pid_file == ISC_FALSE) {
|
|
|
26a25c |
pfdesc = open(path_dhcrelay_pid,
|
|
|
26a25c |
- O_CREAT | O_TRUNC | O_WRONLY, 0644);
|
|
|
26a25c |
+ O_CREAT | O_TRUNC | O_WRONLY | O_CLOEXEC, 0644);
|
|
|
26a25c |
|
|
|
26a25c |
if (pfdesc < 0) {
|
|
|
26a25c |
log_error("Can't create %s: %m",
|
|
|
26a25c |
path_dhcrelay_pid);
|
|
|
26a25c |
} else {
|
|
|
26a25c |
- pf = fdopen(pfdesc, "w");
|
|
|
26a25c |
+ pf = fdopen(pfdesc, "we");
|
|
|
26a25c |
if (!pf)
|
|
|
26a25c |
log_error("Can't fdopen %s: %m",
|
|
|
26a25c |
path_dhcrelay_pid);
|
|
|
26a25c |
diff -up dhcp-4.3.3b1/server/confpars.c.cloexec dhcp-4.3.3b1/server/confpars.c
|
|
|
26a25c |
--- dhcp-4.3.3b1/server/confpars.c.cloexec 2015-07-30 15:17:16.000000000 +0200
|
|
|
26a25c |
+++ dhcp-4.3.3b1/server/confpars.c 2015-08-10 10:46:20.277755500 +0200
|
|
|
26a25c |
@@ -111,7 +111,7 @@ isc_result_t read_conf_file (const char
|
|
|
26a25c |
}
|
|
|
26a25c |
#endif
|
|
|
26a25c |
|
|
|
26a25c |
- if ((file = open (filename, O_RDONLY)) < 0) {
|
|
|
26a25c |
+ if ((file = open (filename, O_RDONLY | O_CLOEXEC)) < 0) {
|
|
|
26a25c |
if (leasep) {
|
|
|
26a25c |
log_error ("Can't open lease database %s: %m --",
|
|
|
26a25c |
path_dhcpd_db);
|
|
|
26a25c |
diff -up dhcp-4.3.3b1/server/db.c.cloexec dhcp-4.3.3b1/server/db.c
|
|
|
26a25c |
--- dhcp-4.3.3b1/server/db.c.cloexec 2015-07-30 15:17:16.000000000 +0200
|
|
|
26a25c |
+++ dhcp-4.3.3b1/server/db.c 2015-08-10 10:47:32.644518358 +0200
|
|
|
26a25c |
@@ -1072,7 +1072,7 @@ void db_startup (testp)
|
|
|
26a25c |
}
|
|
|
26a25c |
#endif
|
|
|
26a25c |
if (!testp) {
|
|
|
26a25c |
- db_file = fopen (path_dhcpd_db, "a");
|
|
|
26a25c |
+ db_file = fopen (path_dhcpd_db, "ae");
|
|
|
26a25c |
if (!db_file)
|
|
|
26a25c |
log_fatal ("Can't open %s for append.", path_dhcpd_db);
|
|
|
26a25c |
expire_all_pools ();
|
|
|
26a25c |
@@ -1120,7 +1120,7 @@ int new_lease_file ()
|
|
|
26a25c |
path_dhcpd_db, (int)t) >= sizeof newfname)
|
|
|
26a25c |
log_fatal("new_lease_file: lease file path too long");
|
|
|
26a25c |
|
|
|
26a25c |
- db_fd = open (newfname, O_WRONLY | O_TRUNC | O_CREAT, 0664);
|
|
|
26a25c |
+ db_fd = open (newfname, O_WRONLY | O_TRUNC | O_CREAT | O_CLOEXEC, 0664);
|
|
|
26a25c |
if (db_fd < 0) {
|
|
|
26a25c |
log_error ("Can't create new lease file: %m");
|
|
|
26a25c |
return 0;
|
|
|
26a25c |
@@ -1141,7 +1141,7 @@ int new_lease_file ()
|
|
|
26a25c |
}
|
|
|
26a25c |
#endif /* PARANOIA */
|
|
|
26a25c |
|
|
|
26a25c |
- if ((new_db_file = fdopen(db_fd, "w")) == NULL) {
|
|
|
26a25c |
+ if ((new_db_file = fdopen(db_fd, "we")) == NULL) {
|
|
|
26a25c |
log_error("Can't fdopen new lease file: %m");
|
|
|
26a25c |
close(db_fd);
|
|
|
26a25c |
goto fdfail;
|
|
|
26a25c |
diff -up dhcp-4.3.3b1/server/dhcpd.c.cloexec dhcp-4.3.3b1/server/dhcpd.c
|
|
|
26a25c |
--- dhcp-4.3.3b1/server/dhcpd.c.cloexec 2015-07-30 15:17:16.000000000 +0200
|
|
|
26a25c |
+++ dhcp-4.3.3b1/server/dhcpd.c 2015-08-10 10:46:20.278755497 +0200
|
|
|
26a25c |
@@ -194,11 +194,11 @@ main(int argc, char **argv) {
|
|
|
26a25c |
/* Make sure that file descriptors 0 (stdin), 1, (stdout), and
|
|
|
26a25c |
2 (stderr) are open. To do this, we assume that when we
|
|
|
26a25c |
open a file the lowest available file descriptor is used. */
|
|
|
26a25c |
- fd = open("/dev/null", O_RDWR);
|
|
|
26a25c |
+ fd = open("/dev/null", O_RDWR | O_CLOEXEC);
|
|
|
26a25c |
if (fd == 0)
|
|
|
26a25c |
- fd = open("/dev/null", O_RDWR);
|
|
|
26a25c |
+ fd = open("/dev/null", O_RDWR | O_CLOEXEC);
|
|
|
26a25c |
if (fd == 1)
|
|
|
26a25c |
- fd = open("/dev/null", O_RDWR);
|
|
|
26a25c |
+ fd = open("/dev/null", O_RDWR | O_CLOEXEC);
|
|
|
26a25c |
if (fd == 2)
|
|
|
26a25c |
log_perror = 0; /* No sense logging to /dev/null. */
|
|
|
26a25c |
else if (fd != -1)
|
|
|
26a25c |
@@ -743,7 +743,7 @@ main(int argc, char **argv) {
|
|
|
26a25c |
* appropriate.
|
|
|
26a25c |
*/
|
|
|
26a25c |
if (no_pid_file == ISC_FALSE) {
|
|
|
26a25c |
- i = open(path_dhcpd_pid, O_WRONLY|O_CREAT|O_TRUNC, 0644);
|
|
|
26a25c |
+ i = open(path_dhcpd_pid, O_WRONLY|O_CREAT|O_TRUNC|O_CLOEXEC, 0644);
|
|
|
26a25c |
if (i >= 0) {
|
|
|
26a25c |
sprintf(pbuf, "%d\n", (int) getpid());
|
|
|
26a25c |
IGNORE_RET(write(i, pbuf, strlen(pbuf)));
|
|
|
26a25c |
@@ -787,9 +787,9 @@ main(int argc, char **argv) {
|
|
|
26a25c |
(void) close(2);
|
|
|
26a25c |
|
|
|
26a25c |
/* Reopen them on /dev/null. */
|
|
|
26a25c |
- (void) open("/dev/null", O_RDWR);
|
|
|
26a25c |
- (void) open("/dev/null", O_RDWR);
|
|
|
26a25c |
- (void) open("/dev/null", O_RDWR);
|
|
|
26a25c |
+ (void) open("/dev/null", O_RDWR | O_CLOEXEC);
|
|
|
26a25c |
+ (void) open("/dev/null", O_RDWR | O_CLOEXEC);
|
|
|
26a25c |
+ (void) open("/dev/null", O_RDWR | O_CLOEXEC);
|
|
|
26a25c |
log_perror = 0; /* No sense logging to /dev/null. */
|
|
|
26a25c |
|
|
|
26a25c |
IGNORE_RET (chdir("/"));
|
|
|
26a25c |
diff -up dhcp-4.3.3b1/server/ldap.c.cloexec dhcp-4.3.3b1/server/ldap.c
|
|
|
26a25c |
--- dhcp-4.3.3b1/server/ldap.c.cloexec 2015-07-30 21:03:40.000000000 +0200
|
|
|
26a25c |
+++ dhcp-4.3.3b1/server/ldap.c 2015-08-10 10:46:20.279755493 +0200
|
|
|
26a25c |
@@ -1442,7 +1442,7 @@ ldap_start (void)
|
|
|
26a25c |
|
|
|
26a25c |
if (ldap_debug_file != NULL && ldap_debug_fd == -1)
|
|
|
26a25c |
{
|
|
|
26a25c |
- if ((ldap_debug_fd = open (ldap_debug_file, O_CREAT | O_TRUNC | O_WRONLY,
|
|
|
26a25c |
+ if ((ldap_debug_fd = open (ldap_debug_file, O_CREAT | O_TRUNC | O_WRONLY | O_CLOEXEC,
|
|
|
26a25c |
S_IRUSR | S_IWUSR)) < 0)
|
|
|
26a25c |
log_error ("Error opening debug LDAP log file %s: %s", ldap_debug_file,
|
|
|
26a25c |
strerror (errno));
|