123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349 |
- Index: dhcp-4.4.3/client/clparse.c
- ===================================================================
- --- dhcp-4.4.3.orig/client/clparse.c
- +++ dhcp-4.4.3/client/clparse.c
- @@ -265,7 +265,7 @@ int read_client_conf_file (const char *n
- int token;
- isc_result_t status;
-
- - if ((file = open (name, O_RDONLY)) < 0)
- + if ((file = open (name, O_RDONLY | O_CLOEXEC)) < 0)
- return uerr2isc (errno);
-
- cfile = NULL;
- @@ -341,7 +341,7 @@ void read_client_leases ()
-
- /* Open the lease file. If we can't open it, just return -
- we can safely trust the server to remember our state. */
- - if ((file = open (path_dhclient_db, O_RDONLY)) < 0)
- + if ((file = open (path_dhclient_db, O_RDONLY | O_CLOEXEC)) < 0)
- return;
-
- cfile = NULL;
- Index: dhcp-4.4.3/client/dhclient.c
- ===================================================================
- --- dhcp-4.4.3.orig/client/dhclient.c
- +++ dhcp-4.4.3/client/dhclient.c
- @@ -255,11 +255,11 @@ main(int argc, char **argv) {
- /* Make sure that file descriptors 0 (stdin), 1, (stdout), and
- 2 (stderr) are open. To do this, we assume that when we
- open a file the lowest available file descriptor is used. */
- - fd = open("/dev/null", O_RDWR);
- + fd = open("/dev/null", O_RDWR | O_CLOEXEC);
- if (fd == 0)
- - fd = open("/dev/null", O_RDWR);
- + fd = open("/dev/null", O_RDWR | O_CLOEXEC);
- if (fd == 1)
- - fd = open("/dev/null", O_RDWR);
- + fd = open("/dev/null", O_RDWR | O_CLOEXEC);
- if (fd == 2)
- log_perror = 0; /* No sense logging to /dev/null. */
- else if (fd != -1)
- @@ -664,7 +664,7 @@ main(int argc, char **argv) {
- long temp;
- int e;
-
- - if ((pidfd = fopen(path_dhclient_pid, "r")) != NULL) {
- + if ((pidfd = fopen(path_dhclient_pid, "re")) != NULL) {
- e = fscanf(pidfd, "%ld\n", &temp);
- oldpid = (pid_t)temp;
-
- @@ -3721,7 +3721,7 @@ void rewrite_client_leases ()
-
- if (leaseFile != NULL)
- fclose (leaseFile);
- - leaseFile = fopen (path_dhclient_db, "w");
- + leaseFile = fopen (path_dhclient_db, "we");
- if (leaseFile == NULL) {
- log_error ("can't create %s: %m", path_dhclient_db);
- return;
- @@ -3916,7 +3916,7 @@ write_duid(struct data_string *duid)
- return DHCP_R_INVALIDARG;
-
- if (leaseFile == NULL) { /* XXX? */
- - leaseFile = fopen(path_dhclient_db, "w");
- + leaseFile = fopen(path_dhclient_db, "we");
- if (leaseFile == NULL) {
- log_error("can't create %s: %m", path_dhclient_db);
- return ISC_R_IOERROR;
- @@ -3961,7 +3961,7 @@ write_client6_lease(struct client_state
- return DHCP_R_INVALIDARG;
-
- if (leaseFile == NULL) { /* XXX? */
- - leaseFile = fopen(path_dhclient_db, "w");
- + leaseFile = fopen(path_dhclient_db, "we");
- if (leaseFile == NULL) {
- log_error("can't create %s: %m", path_dhclient_db);
- return ISC_R_IOERROR;
- @@ -4120,7 +4120,7 @@ int write_client_lease (client, lease, r
- return 1;
-
- if (leaseFile == NULL) { /* XXX */
- - leaseFile = fopen (path_dhclient_db, "w");
- + leaseFile = fopen (path_dhclient_db, "we");
- if (leaseFile == NULL) {
- log_error ("can't create %s: %m", path_dhclient_db);
- return 0;
- @@ -4706,9 +4706,9 @@ void detach ()
- (void) close(2);
-
- /* Reopen them on /dev/null. */
- - (void) open("/dev/null", O_RDWR);
- - (void) open("/dev/null", O_RDWR);
- - (void) open("/dev/null", O_RDWR);
- + (void) open("/dev/null", O_RDWR | O_CLOEXEC);
- + (void) open("/dev/null", O_RDWR | O_CLOEXEC);
- + (void) open("/dev/null", O_RDWR | O_CLOEXEC);
-
- write_client_pid_file ();
-
- @@ -4726,14 +4726,14 @@ void write_client_pid_file ()
- return;
- }
-
- - pfdesc = open (path_dhclient_pid, O_CREAT | O_TRUNC | O_WRONLY, 0644);
- + pfdesc = open (path_dhclient_pid, O_CREAT | O_TRUNC | O_WRONLY | O_CLOEXEC, 0644);
-
- if (pfdesc < 0) {
- log_error ("Can't create %s: %m", path_dhclient_pid);
- return;
- }
-
- - pf = fdopen (pfdesc, "w");
- + pf = fdopen (pfdesc, "we");
- if (!pf) {
- close(pfdesc);
- log_error ("Can't fdopen %s: %m", path_dhclient_pid);
- Index: dhcp-4.4.3/common/bpf.c
- ===================================================================
- --- dhcp-4.4.3.orig/common/bpf.c
- +++ dhcp-4.4.3/common/bpf.c
- @@ -94,7 +94,7 @@ int if_register_bpf (info)
- for (b = 0; 1; b++) {
- /* %Audit% 31 bytes max. %2004.06.17,Safe% */
- sprintf(filename, BPF_FORMAT, b);
- - sock = open (filename, O_RDWR, 0);
- + sock = open (filename, O_RDWR | O_CLOEXEC, 0);
- if (sock < 0) {
- if (errno == EBUSY) {
- continue;
- Index: dhcp-4.4.3/common/dlpi.c
- ===================================================================
- --- dhcp-4.4.3.orig/common/dlpi.c
- +++ dhcp-4.4.3/common/dlpi.c
- @@ -817,7 +817,7 @@ dlpiopen(const char *ifname) {
- }
- *dp = '\0';
-
- - return open (devname, O_RDWR, 0);
- + return open (devname, O_RDWR | O_CLOEXEC, 0);
- }
-
- /*
- Index: dhcp-4.4.3/common/nit.c
- ===================================================================
- --- dhcp-4.4.3.orig/common/nit.c
- +++ dhcp-4.4.3/common/nit.c
- @@ -75,7 +75,7 @@ int if_register_nit (info)
- struct strioctl sio;
-
- /* Open a NIT device */
- - sock = open ("/dev/nit", O_RDWR);
- + sock = open ("/dev/nit", O_RDWR | O_CLOEXEC);
- if (sock < 0)
- log_fatal ("Can't open NIT device for %s: %m", info -> name);
-
- Index: dhcp-4.4.3/common/resolv.c
- ===================================================================
- --- dhcp-4.4.3.orig/common/resolv.c
- +++ dhcp-4.4.3/common/resolv.c
- @@ -43,7 +43,7 @@ void read_resolv_conf (parse_time)
- struct domain_search_list *dp, *dl, *nd;
- isc_result_t status;
-
- - if ((file = open (path_resolv_conf, O_RDONLY)) < 0) {
- + if ((file = open (path_resolv_conf, O_RDONLY | O_CLOEXEC)) < 0) {
- log_error ("Can't open %s: %m", path_resolv_conf);
- return;
- }
- Index: dhcp-4.4.3/common/upf.c
- ===================================================================
- --- dhcp-4.4.3.orig/common/upf.c
- +++ dhcp-4.4.3/common/upf.c
- @@ -71,7 +71,7 @@ int if_register_upf (info)
- /* %Audit% Cannot exceed 36 bytes. %2004.06.17,Safe% */
- sprintf(filename, "/dev/pf/pfilt%d", b);
-
- - sock = open (filename, O_RDWR, 0);
- + sock = open (filename, O_RDWR | O_CLOEXEC, 0);
- if (sock < 0) {
- if (errno == EBUSY) {
- continue;
- Index: dhcp-4.4.3/omapip/trace.c
- ===================================================================
- --- dhcp-4.4.3.orig/omapip/trace.c
- +++ dhcp-4.4.3/omapip/trace.c
- @@ -136,10 +136,10 @@ isc_result_t trace_begin (const char *fi
- return DHCP_R_INVALIDARG;
- }
-
- - traceoutfile = open (filename, O_CREAT | O_WRONLY | O_EXCL, 0600);
- + traceoutfile = open (filename, O_CREAT | O_WRONLY | O_EXCL | O_CLOEXEC, 0600);
- if (traceoutfile < 0 && errno == EEXIST) {
- log_error ("WARNING: Overwriting trace file \"%s\"", filename);
- - traceoutfile = open (filename, O_WRONLY | O_EXCL | O_TRUNC,
- + traceoutfile = open (filename, O_WRONLY | O_EXCL | O_TRUNC | O_CLOEXEC,
- 0600);
- }
-
- @@ -427,7 +427,7 @@ void trace_file_replay (const char *file
- isc_result_t result;
- int len;
-
- - traceinfile = fopen (filename, "r");
- + traceinfile = fopen (filename, "re");
- if (!traceinfile) {
- log_error("Can't open tracefile %s: %m", filename);
- return;
- Index: dhcp-4.4.3/relay/dhcrelay.c
- ===================================================================
- --- dhcp-4.4.3.orig/relay/dhcrelay.c
- +++ dhcp-4.4.3/relay/dhcrelay.c
- @@ -305,11 +305,11 @@ main(int argc, char **argv) {
- /* Make sure that file descriptors 0(stdin), 1,(stdout), and
- 2(stderr) are open. To do this, we assume that when we
- open a file the lowest available file descriptor is used. */
- - fd = open("/dev/null", O_RDWR);
- + fd = open("/dev/null", O_RDWR | O_CLOEXEC);
- if (fd == 0)
- - fd = open("/dev/null", O_RDWR);
- + fd = open("/dev/null", O_RDWR | O_CLOEXEC);
- if (fd == 1)
- - fd = open("/dev/null", O_RDWR);
- + fd = open("/dev/null", O_RDWR | O_CLOEXEC);
- if (fd == 2)
- log_perror = 0; /* No sense logging to /dev/null. */
- else if (fd != -1)
- @@ -800,13 +800,13 @@ main(int argc, char **argv) {
- /* Create the pid file. */
- if (no_pid_file == ISC_FALSE) {
- pfdesc = open(path_dhcrelay_pid,
- - O_CREAT | O_TRUNC | O_WRONLY, 0644);
- + O_CREAT | O_TRUNC | O_WRONLY | O_CLOEXEC, 0644);
-
- if (pfdesc < 0) {
- log_error("Can't create %s: %m",
- path_dhcrelay_pid);
- } else {
- - pf = fdopen(pfdesc, "w");
- + pf = fdopen(pfdesc, "we");
- if (!pf)
- log_error("Can't fdopen %s: %m",
- path_dhcrelay_pid);
- Index: dhcp-4.4.3/server/confpars.c
- ===================================================================
- --- dhcp-4.4.3.orig/server/confpars.c
- +++ dhcp-4.4.3/server/confpars.c
- @@ -118,7 +118,7 @@ isc_result_t read_conf_file (const char
- }
- #endif
-
- - if ((file = open (filename, O_RDONLY)) < 0) {
- + if ((file = open (filename, O_RDONLY | O_CLOEXEC)) < 0) {
- if (leasep) {
- log_error ("Can't open lease database %s: %m --",
- path_dhcpd_db);
- Index: dhcp-4.4.3/server/db.c
- ===================================================================
- --- dhcp-4.4.3.orig/server/db.c
- +++ dhcp-4.4.3/server/db.c
- @@ -1105,7 +1105,7 @@ void db_startup (int test_mode)
- * Therefore, in test mode we need to point db_file to a disposable
- * file to protect the original lease file. */
- current_db_path = (test_mode ? "/dev/null" : path_dhcpd_db);
- - db_file = fopen (current_db_path, "a");
- + db_file = fopen (current_db_path, "ae");
- if (!db_file) {
- log_fatal ("Can't open %s for append.", current_db_path);
- }
- @@ -1154,7 +1154,7 @@ int new_lease_file (int test_mode)
- path_dhcpd_db, (int)t) >= sizeof newfname)
- log_fatal("new_lease_file: lease file path too long");
-
- - db_fd = open (newfname, O_WRONLY | O_TRUNC | O_CREAT, 0664);
- + db_fd = open (newfname, O_WRONLY | O_TRUNC | O_CREAT | O_CLOEXEC, 0664);
- if (db_fd < 0) {
- log_error ("Can't create new lease file: %m");
- return 0;
- @@ -1175,7 +1175,7 @@ int new_lease_file (int test_mode)
- }
- #endif /* PARANOIA */
-
- - if ((new_db_file = fdopen(db_fd, "w")) == NULL) {
- + if ((new_db_file = fdopen(db_fd, "we")) == NULL) {
- log_error("Can't fdopen new lease file: %m");
- close(db_fd);
- goto fdfail;
- Index: dhcp-4.4.3/server/dhcpd.c
- ===================================================================
- --- dhcp-4.4.3.orig/server/dhcpd.c
- +++ dhcp-4.4.3/server/dhcpd.c
- @@ -300,11 +300,11 @@ main(int argc, char **argv) {
- /* Make sure that file descriptors 0 (stdin), 1, (stdout), and
- 2 (stderr) are open. To do this, we assume that when we
- open a file the lowest available file descriptor is used. */
- - fd = open("/dev/null", O_RDWR);
- + fd = open("/dev/null", O_RDWR | O_CLOEXEC);
- if (fd == 0)
- - fd = open("/dev/null", O_RDWR);
- + fd = open("/dev/null", O_RDWR | O_CLOEXEC);
- if (fd == 1)
- - fd = open("/dev/null", O_RDWR);
- + fd = open("/dev/null", O_RDWR | O_CLOEXEC);
- if (fd == 2)
- log_perror = 0; /* No sense logging to /dev/null. */
- else if (fd != -1)
- @@ -865,7 +865,7 @@ main(int argc, char **argv) {
- */
- if ((lftest == 0) && (no_pid_file == ISC_FALSE)) {
- /*Read previous pid file. */
- - if ((i = open(path_dhcpd_pid, O_RDONLY)) >= 0) {
- + if ((i = open(path_dhcpd_pid, O_RDONLY|O_CLOEXEC)) >= 0) {
- status = read(i, pbuf, (sizeof pbuf) - 1);
- close(i);
- if (status > 0) {
- @@ -975,7 +975,7 @@ main(int argc, char **argv) {
- * appropriate.
- */
- if (no_pid_file == ISC_FALSE) {
- - i = open(path_dhcpd_pid, O_WRONLY|O_CREAT|O_TRUNC, 0644);
- + i = open(path_dhcpd_pid, O_WRONLY|O_CREAT|O_TRUNC|O_CLOEXEC, 0644);
- if (i >= 0) {
- sprintf(pbuf, "%d\n", (int) getpid());
- IGNORE_RET(write(i, pbuf, strlen(pbuf)));
- @@ -1028,9 +1028,9 @@ main(int argc, char **argv) {
- (void) close(2);
-
- /* Reopen them on /dev/null. */
- - (void) open("/dev/null", O_RDWR);
- - (void) open("/dev/null", O_RDWR);
- - (void) open("/dev/null", O_RDWR);
- + (void) open("/dev/null", O_RDWR | O_CLOEXEC);
- + (void) open("/dev/null", O_RDWR | O_CLOEXEC);
- + (void) open("/dev/null", O_RDWR | O_CLOEXEC);
- log_perror = 0; /* No sense logging to /dev/null. */
-
- IGNORE_RET (chdir("/"));
- Index: dhcp-4.4.3/server/ldap.c
- ===================================================================
- --- dhcp-4.4.3.orig/server/ldap.c
- +++ dhcp-4.4.3/server/ldap.c
- @@ -1447,7 +1447,7 @@ ldap_start (void)
-
- if (ldap_debug_file != NULL && ldap_debug_fd == -1)
- {
- - if ((ldap_debug_fd = open (ldap_debug_file, O_CREAT | O_TRUNC | O_WRONLY,
- + if ((ldap_debug_fd = open (ldap_debug_file, O_CREAT | O_TRUNC | O_WRONLY | O_CLOEXEC,
- S_IRUSR | S_IWUSR)) < 0)
- log_error ("Error opening debug LDAP log file %s: %s", ldap_debug_file,
- strerror (errno));
|