2010-08-04 14:50:25 +00:00
|
|
|
diff -up iptables-1.4.9/extensions/libipt_realm.c.cloexec iptables-1.4.9/extensions/libipt_realm.c
|
|
|
|
--- iptables-1.4.9/extensions/libipt_realm.c.cloexec 2010-08-03 16:54:25.000000000 +0200
|
|
|
|
+++ iptables-1.4.9/extensions/libipt_realm.c 2010-08-04 12:17:51.000000000 +0200
|
|
|
|
@@ -48,7 +48,7 @@ static void load_realms(void)
|
2009-09-17 09:13:09 +00:00
|
|
|
int id;
|
|
|
|
struct realmname *oldnm = NULL, *newnm = NULL;
|
|
|
|
|
|
|
|
- fil = fopen(rfnm, "r");
|
|
|
|
+ fil = fopen(rfnm, "re");
|
|
|
|
if (!fil) {
|
|
|
|
rdberr = 1;
|
|
|
|
return;
|
2010-08-04 14:50:25 +00:00
|
|
|
diff -up iptables-1.4.9/extensions/libxt_set.h.cloexec iptables-1.4.9/extensions/libxt_set.h
|
|
|
|
--- iptables-1.4.9/extensions/libxt_set.h.cloexec 2010-08-03 16:54:25.000000000 +0200
|
|
|
|
+++ iptables-1.4.9/extensions/libxt_set.h 2010-08-04 12:19:48.000000000 +0200
|
2009-09-17 09:13:09 +00:00
|
|
|
@@ -2,6 +2,7 @@
|
2010-08-04 14:50:25 +00:00
|
|
|
#define _LIBXT_SET_H
|
2009-09-17 09:13:09 +00:00
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
+#include <fcntl.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <errno.h>
|
2010-08-04 14:50:25 +00:00
|
|
|
@@ -23,6 +24,12 @@ get_version(unsigned *version)
|
2009-09-17 09:13:09 +00:00
|
|
|
xtables_error(OTHER_PROBLEM,
|
2010-08-04 14:50:25 +00:00
|
|
|
"Can't open socket to ipset.\n");
|
2009-09-17 09:13:09 +00:00
|
|
|
|
|
|
|
+ if (fcntl(sockfd, F_SETFD, FD_CLOEXEC) == -1) {
|
|
|
|
+ xtables_error(OTHER_PROBLEM,
|
|
|
|
+ "Could not set close on exec: %s\n",
|
|
|
|
+ strerror(errno));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
req_version.op = IP_SET_OP_VERSION;
|
|
|
|
res = getsockopt(sockfd, SOL_IP, SO_IP_SET, &req_version, &size);
|
|
|
|
if (res != 0)
|
2010-08-04 14:50:25 +00:00
|
|
|
diff -up iptables-1.4.9/ip6tables-restore.c.cloexec iptables-1.4.9/ip6tables-restore.c
|
|
|
|
--- iptables-1.4.9/ip6tables-restore.c.cloexec 2010-08-03 16:54:25.000000000 +0200
|
|
|
|
+++ iptables-1.4.9/ip6tables-restore.c 2010-08-04 12:17:51.000000000 +0200
|
2009-09-17 09:13:09 +00:00
|
|
|
@@ -169,7 +169,7 @@ int main(int argc, char *argv[])
|
|
|
|
}
|
|
|
|
|
|
|
|
if (optind == argc - 1) {
|
|
|
|
- in = fopen(argv[optind], "r");
|
|
|
|
+ in = fopen(argv[optind], "re");
|
|
|
|
if (!in) {
|
|
|
|
fprintf(stderr, "Can't open %s: %s\n", argv[optind],
|
|
|
|
strerror(errno));
|
2010-08-04 14:50:25 +00:00
|
|
|
diff -up iptables-1.4.9/ip6tables-save.c.cloexec iptables-1.4.9/ip6tables-save.c
|
|
|
|
--- iptables-1.4.9/ip6tables-save.c.cloexec 2010-08-03 16:54:25.000000000 +0200
|
|
|
|
+++ iptables-1.4.9/ip6tables-save.c 2010-08-04 12:17:51.000000000 +0200
|
2009-09-17 09:13:09 +00:00
|
|
|
@@ -41,7 +41,7 @@ static int for_each_table(int (*func)(co
|
|
|
|
FILE *procfile = NULL;
|
|
|
|
char tablename[IP6T_TABLE_MAXNAMELEN+1];
|
|
|
|
|
|
|
|
- procfile = fopen("/proc/net/ip6_tables_names", "r");
|
|
|
|
+ procfile = fopen("/proc/net/ip6_tables_names", "re");
|
|
|
|
if (!procfile)
|
|
|
|
return ret;
|
|
|
|
|
2010-08-04 14:50:25 +00:00
|
|
|
diff -up iptables-1.4.9/iptables-restore.c.cloexec iptables-1.4.9/iptables-restore.c
|
|
|
|
--- iptables-1.4.9/iptables-restore.c.cloexec 2010-08-03 16:54:25.000000000 +0200
|
|
|
|
+++ iptables-1.4.9/iptables-restore.c 2010-08-04 12:17:51.000000000 +0200
|
2009-09-17 09:13:09 +00:00
|
|
|
@@ -175,7 +175,7 @@ main(int argc, char *argv[])
|
|
|
|
}
|
|
|
|
|
|
|
|
if (optind == argc - 1) {
|
|
|
|
- in = fopen(argv[optind], "r");
|
|
|
|
+ in = fopen(argv[optind], "re");
|
|
|
|
if (!in) {
|
|
|
|
fprintf(stderr, "Can't open %s: %s\n", argv[optind],
|
|
|
|
strerror(errno));
|
2010-08-04 14:50:25 +00:00
|
|
|
diff -up iptables-1.4.9/iptables-save.c.cloexec iptables-1.4.9/iptables-save.c
|
|
|
|
--- iptables-1.4.9/iptables-save.c.cloexec 2010-08-03 16:54:25.000000000 +0200
|
|
|
|
+++ iptables-1.4.9/iptables-save.c 2010-08-04 12:17:51.000000000 +0200
|
2009-09-17 09:13:09 +00:00
|
|
|
@@ -39,7 +39,7 @@ static int for_each_table(int (*func)(co
|
|
|
|
FILE *procfile = NULL;
|
|
|
|
char tablename[IPT_TABLE_MAXNAMELEN+1];
|
|
|
|
|
|
|
|
- procfile = fopen("/proc/net/ip_tables_names", "r");
|
|
|
|
+ procfile = fopen("/proc/net/ip_tables_names", "re");
|
|
|
|
if (!procfile)
|
|
|
|
return ret;
|
|
|
|
|
2010-08-04 14:50:25 +00:00
|
|
|
diff -up iptables-1.4.9/iptables-xml.c.cloexec iptables-1.4.9/iptables-xml.c
|
|
|
|
--- iptables-1.4.9/iptables-xml.c.cloexec 2010-08-03 16:54:25.000000000 +0200
|
|
|
|
+++ iptables-1.4.9/iptables-xml.c 2010-08-04 12:17:51.000000000 +0200
|
2009-09-17 09:13:09 +00:00
|
|
|
@@ -653,7 +653,7 @@ main(int argc, char *argv[])
|
|
|
|
}
|
|
|
|
|
|
|
|
if (optind == argc - 1) {
|
|
|
|
- in = fopen(argv[optind], "r");
|
|
|
|
+ in = fopen(argv[optind], "re");
|
|
|
|
if (!in) {
|
|
|
|
fprintf(stderr, "Can't open %s: %s", argv[optind],
|
|
|
|
strerror(errno));
|
2010-08-04 14:50:25 +00:00
|
|
|
diff -up iptables-1.4.9/libiptc/libiptc.c.cloexec iptables-1.4.9/libiptc/libiptc.c
|
|
|
|
--- iptables-1.4.9/libiptc/libiptc.c.cloexec 2010-08-03 16:54:25.000000000 +0200
|
|
|
|
+++ iptables-1.4.9/libiptc/libiptc.c 2010-08-04 12:17:51.000000000 +0200
|
2009-09-17 09:13:09 +00:00
|
|
|
@@ -29,6 +29,8 @@
|
|
|
|
* - performance work: speedup initial ruleset parsing.
|
|
|
|
* - sponsored by ComX Networks A/S (http://www.comx.dk/)
|
|
|
|
*/
|
|
|
|
+#include <unistd.h>
|
|
|
|
+#include <fcntl.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <xtables.h>
|
2010-08-04 14:50:25 +00:00
|
|
|
@@ -1328,6 +1330,12 @@ TC_INIT(const char *tablename)
|
2009-09-17 09:13:09 +00:00
|
|
|
if (sockfd < 0)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
+ if (fcntl(sockfd, F_SETFD, FD_CLOEXEC) == -1) {
|
|
|
|
+ fprintf(stderr, "Could not set close on exec: %s\n",
|
|
|
|
+ strerror(errno));
|
|
|
|
+ abort();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
retry:
|
|
|
|
s = sizeof(info);
|
|
|
|
|
2010-08-04 14:50:25 +00:00
|
|
|
diff -up iptables-1.4.9/xtables.c.cloexec iptables-1.4.9/xtables.c
|
|
|
|
--- iptables-1.4.9/xtables.c.cloexec 2010-08-03 16:54:25.000000000 +0200
|
|
|
|
+++ iptables-1.4.9/xtables.c 2010-08-04 12:17:51.000000000 +0200
|
|
|
|
@@ -284,6 +284,11 @@ static char *get_modprobe(void)
|
2009-09-17 09:13:09 +00:00
|
|
|
procfile = open(PROC_SYS_MODPROBE, O_RDONLY);
|
|
|
|
if (procfile < 0)
|
|
|
|
return NULL;
|
|
|
|
+ if (fcntl(procfile, F_SETFD, FD_CLOEXEC) == -1) {
|
|
|
|
+ fprintf(stderr, "Could not set close on exec: %s\n",
|
|
|
|
+ strerror(errno));
|
|
|
|
+ exit(1);
|
|
|
|
+ }
|
|
|
|
|
|
|
|
ret = (char *) malloc(PROCFILE_BUFSIZ);
|
|
|
|
if (ret) {
|
2010-08-04 14:50:25 +00:00
|
|
|
@@ -680,6 +685,12 @@ static int compatible_revision(const cha
|
2009-09-17 09:13:09 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
+ if (fcntl(sockfd, F_SETFD, FD_CLOEXEC) == -1) {
|
|
|
|
+ fprintf(stderr, "Could not set close on exec: %s\n",
|
|
|
|
+ strerror(errno));
|
|
|
|
+ exit(1);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
xtables_load_ko(xtables_modprobe_program, true);
|
|
|
|
|
|
|
|
strcpy(rev.name, name);
|