]> git.ipfire.org Git - people/arne_f/ipfire-3.x.git/blame - netplug/patches/netplug-1.2.9.1-execshield.patch
Move all packages to root.
[people/arne_f/ipfire-3.x.git] / netplug / patches / netplug-1.2.9.1-execshield.patch
CommitLineData
92409c7b
MT
1diff -up netplug-1.2.9.1/if_info.c.execshield netplug-1.2.9.1/if_info.c
2--- netplug-1.2.9.1/if_info.c.execshield 2008-12-23 00:36:23.000000000 +0100
3+++ netplug-1.2.9.1/if_info.c 2009-09-09 10:02:12.000000000 +0200
4@@ -95,15 +95,16 @@ flags_str(char *buf, unsigned int fl)
5 return buf;
6 }
7
8-void
9-for_each_iface(int (*func)(struct if_info *))
10+struct if_info *
11+for_each_iface(int (*func)(struct if_info *, long), long param)
12 {
13 for(int i = 0; i < INFOHASHSZ; i++) {
14 for(struct if_info *info = if_info[i]; info != NULL; info = info->next) {
15- if ((*func)(info))
16- return;
17+ if ((*func)(info, param))
18+ return info;
19 }
20 }
21+ return NULL;
22 }
23
24 /* Reevaluate the state machine based on the current state and flag settings */
25@@ -285,22 +286,20 @@ ifsm_flagchange(struct if_info *info, un
26 }
27
28 /* handle a script termination and update the state accordingly */
29+int find_pid(struct if_info *i, long param) {
30+ if (i->worker == param) {
31+ return 1;
32+ }
33+ return 0;
34+}
35+
36 void ifsm_scriptdone(pid_t pid, int exitstatus)
37 {
38 int exitok = WIFEXITED(exitstatus) && WEXITSTATUS(exitstatus) == 0;
39 struct if_info *info;
40 assert(WIFEXITED(exitstatus) || WIFSIGNALED(exitstatus));
41
42- int find_pid(struct if_info *i) {
43- if (i->worker == pid) {
44- info = i;
45- return 1;
46- }
47- return 0;
48- }
49-
50- info = NULL;
51- for_each_iface(find_pid);
52+ info = for_each_iface(find_pid, pid);
53
54 if (info == NULL) {
55 do_log(LOG_INFO, "Unexpected child %d exited with status %d",
56diff -up netplug-1.2.9.1/main.c.execshield netplug-1.2.9.1/main.c
57--- netplug-1.2.9.1/main.c.execshield 2008-12-23 00:36:23.000000000 +0100
58+++ netplug-1.2.9.1/main.c 2009-09-09 10:02:12.000000000 +0200
59@@ -161,11 +161,28 @@ child_handler(int sig, siginfo_t *info,
60 ce.pid = info->si_pid;
61 ret = waitpid(info->si_pid, &ce.status, 0);
62 if (ret == info->si_pid)
63- write(child_handler_pipe[1], &ce, sizeof(ce));
64+ (void)write(child_handler_pipe[1], &ce, sizeof(ce));
65 }
66
67 /* Poll the existing interface state, so we can catch any state
68 changes for which we may not have neen a netlink message. */
69+static int pollflags(struct if_info *info, long param) {
70+ struct ifreq ifr;
71+
72+ if (!if_match(info->name))
73+ return 0;
74+
75+ memcpy(ifr.ifr_name, info->name, sizeof(ifr.ifr_name));
76+ if (ioctl(param, SIOCGIFFLAGS, &ifr) < 0)
77+ do_log(LOG_ERR, "%s: can't get flags: %m", info->name);
78+ else {
79+ ifsm_flagchange(info, ifr.ifr_flags);
80+ ifsm_flagpoll(info);
81+ }
82+
83+ return 0;
84+}
85+
86 static void
87 poll_interfaces(void)
88 {
89@@ -180,24 +197,13 @@ poll_interfaces(void)
90 close_on_exec(sockfd);
91 }
92
93- int pollflags(struct if_info *info) {
94- struct ifreq ifr;
95-
96- if (!if_match(info->name))
97- return 0;
98-
99- memcpy(ifr.ifr_name, info->name, sizeof(ifr.ifr_name));
100- if (ioctl(sockfd, SIOCGIFFLAGS, &ifr) < 0)
101- do_log(LOG_ERR, "%s: can't get flags: %m", info->name);
102- else {
103- ifsm_flagchange(info, ifr.ifr_flags);
104- ifsm_flagpoll(info);
105- }
106-
107- return 0;
108- }
109+ for_each_iface(pollflags, sockfd);
110+}
111
112- for_each_iface(pollflags);
113+static int poll_flags(struct if_info *i, long param) {
114+ if (if_match(i->name))
115+ ifsm_flagpoll(i);
116+ return 0;
117 }
118
119 int debug = 0;
120@@ -331,17 +337,11 @@ main(int argc, char *argv[])
121 { child_handler_pipe[0], POLLIN, 0 },
122 };
123
124- {
125- /* Run over each of the interfaces we know and care about, and
126- make sure the state machine has done the appropriate thing
127- for their current state. */
128- int poll_flags(struct if_info *i) {
129- if (if_match(i->name))
130- ifsm_flagpoll(i);
131- return 0;
132- }
133- for_each_iface(poll_flags);
134- }
135+ /* Run over each of the interfaces we know and care about, and
136+ make sure the state machine has done the appropriate thing
137+ for their current state. */
138+ for_each_iface(poll_flags, 0);
139+
140
141 for(;;) {
142 int ret;
143diff -up netplug-1.2.9.1/Makefile.execshield netplug-1.2.9.1/Makefile
144--- netplug-1.2.9.1/Makefile.execshield 2008-12-23 00:41:38.000000000 +0100
145+++ netplug-1.2.9.1/Makefile 2009-09-09 10:02:12.000000000 +0200
146@@ -4,15 +4,15 @@ DESTDIR ?=
147
148 prefix ?=
149 bindir ?= $(prefix)/sbin
150-etcdir ?= $(prefix)/etc/netplug
151+etcdir ?= $(prefix)/etc/netplug.d
152 initdir ?= $(prefix)/etc/rc.d/init.d
153 scriptdir ?= $(prefix)/etc/netplug.d
154 mandir ?= $(prefix)/usr/share/man
155
156 install_opts :=
157
158-CFLAGS += -Wall -Werror -std=gnu99 -DNP_ETC_DIR='"$(etcdir)"' \
159- -DNP_SCRIPT_DIR='"$(scriptdir)"' -ggdb3 -O3 -DNP_VERSION='"$(version)"'
160+CFLAGS += -std=gnu99 -DNP_ETC_DIR='"$(etcdir)"' \
161+ -DNP_SCRIPT_DIR='"$(scriptdir)"' -DNP_VERSION='"$(version)"'
162
163 netplugd: config.o netlink.o lib.o if_info.o main.o
164 $(CC) $(LDFLAGS) -o $@ $^
165@@ -30,10 +30,12 @@ install:
166 install $(install_opts) -m 755 scripts/rc.netplugd $(DESTDIR)/$(initdir)/netplugd
167 install $(install_opts) -m 444 man/man8/netplugd.8 $(DESTDIR)/$(mandir)/man8
168
169-hg_root := $(shell hg root)
170+#hg_root := $(shell hg root)
171+hg_root := $(shell)
172 tar_root := netplug-$(version)
173 tar_file := $(hg_root)/$(tar_root).tar.bz2
174-files := $(shell hg manifest)
175+#files := $(shell hg manifest)
176+files := $(shell)
177
178 tarball: $(tar_file)
179
180diff -up netplug-1.2.9.1/man/man8/netplugd.8.execshield netplug-1.2.9.1/man/man8/netplugd.8
181--- netplug-1.2.9.1/man/man8/netplugd.8.execshield 2008-12-23 00:36:23.000000000 +0100
182+++ netplug-1.2.9.1/man/man8/netplugd.8 2009-09-09 10:07:33.000000000 +0200
183@@ -134,7 +134,7 @@ to run in the foreground, this option is
184 .\"
185 .Sh FILES
186 .Bl -tag -width Ds
187-.It Pa /etc/netplug/netplugd.conf
188+.It Pa /etc/netplug.d/netplugd.conf
189 Default config file to read, if none is specified on the command line.
190 The config file format is one pattern per line, with white space,
191 empty lines, and comments starting with a
192diff -up netplug-1.2.9.1/netplug.h.execshield netplug-1.2.9.1/netplug.h
193--- netplug-1.2.9.1/netplug.h.execshield 2008-12-23 00:36:23.000000000 +0100
194+++ netplug-1.2.9.1/netplug.h 2009-09-09 10:02:12.000000000 +0200
195@@ -83,7 +83,7 @@ struct if_info *if_info_update_interface
196 struct rtattr *attrs[]);
197 int if_info_save_interface(struct nlmsghdr *hdr, void *arg);
198 void parse_rtattrs(struct rtattr *tb[], int max, struct rtattr *rta, int len);
199-void for_each_iface(int (*func)(struct if_info *));
200+struct if_info *for_each_iface(int (*func)(struct if_info *, long), long param);
201
202 void ifsm_flagpoll(struct if_info *info);
203 void ifsm_flagchange(struct if_info *info, unsigned int newflags);