3286dd6
--- net-tools-1.60/netplug-1.2.9/if_info.c.execshield	2005-01-08 06:57:08.000000000 +0100
9945db7
+++ net-tools-1.60/netplug-1.2.9/if_info.c	2005-02-28 14:43:05.596799288 +0100
3286dd6
@@ -95,15 +95,16 @@
3286dd6
     return buf;
3286dd6
 }
3286dd6
 
3286dd6
-void
3286dd6
-for_each_iface(int (*func)(struct if_info *))
3286dd6
+struct if_info *
3286dd6
+for_each_iface(int (*func)(struct if_info *, long), long param)
3286dd6
 {
3286dd6
     for(int i = 0; i < INFOHASHSZ; i++) {
3286dd6
         for(struct if_info *info = if_info[i]; info != NULL; info = info->next) {
3286dd6
-            if ((*func)(info))
3286dd6
-                return;
3286dd6
+            if ((*func)(info, param))
3286dd6
+                return info;
3286dd6
         }
3286dd6
     }
3286dd6
+    return NULL;
3286dd6
 }
3286dd6
 
3286dd6
 /* Reevaluate the state machine based on the current state and flag settings */
3286dd6
@@ -285,22 +286,20 @@
3286dd6
 }
3286dd6
 
3286dd6
 /* handle a script termination and update the state accordingly */
3286dd6
+int find_pid(struct if_info *i, long param) {
3286dd6
+    if (i->worker == param) {
3286dd6
+        return 1;
3286dd6
+    }
3286dd6
+    return 0;
3286dd6
+}
3286dd6
+
3286dd6
 void ifsm_scriptdone(pid_t pid, int exitstatus)
3286dd6
 {
3286dd6
     int exitok = WIFEXITED(exitstatus) && WEXITSTATUS(exitstatus) == 0;
3286dd6
     struct if_info *info;
3286dd6
     assert(WIFEXITED(exitstatus) || WIFSIGNALED(exitstatus));
3286dd6
 
3286dd6
-    int find_pid(struct if_info *i) {
3286dd6
-        if (i->worker == pid) {
3286dd6
-            info = i;
3286dd6
-            return 1;
3286dd6
-        }
3286dd6
-        return 0;
3286dd6
-    }
3286dd6
-
3286dd6
-    info = NULL;
3286dd6
-    for_each_iface(find_pid);
3286dd6
+    info = for_each_iface(find_pid, pid);
3286dd6
 
3286dd6
     if (info == NULL) {
3286dd6
         do_log(LOG_INFO, "Unexpected child %d exited with status %d",
3286dd6
--- net-tools-1.60/netplug-1.2.9/netplug.h.execshield	2005-01-08 06:57:09.000000000 +0100
9945db7
+++ net-tools-1.60/netplug-1.2.9/netplug.h	2005-02-28 14:43:05.597799136 +0100
3286dd6
@@ -83,7 +83,7 @@
3286dd6
                                          struct rtattr *attrs[]);
3286dd6
 int if_info_save_interface(struct nlmsghdr *hdr, void *arg);
3286dd6
 void parse_rtattrs(struct rtattr *tb[], int max, struct rtattr *rta, int len);
3286dd6
-void for_each_iface(int (*func)(struct if_info *));
3286dd6
+struct if_info *for_each_iface(int (*func)(struct if_info *, long), long param);
3286dd6
 
3286dd6
 void ifsm_flagpoll(struct if_info *info);
3286dd6
 void ifsm_flagchange(struct if_info *info, unsigned int newflags);
9945db7
--- net-tools-1.60/netplug-1.2.9/Makefile.execshield	2005-02-28 14:43:05.000000000 +0100
9945db7
+++ net-tools-1.60/netplug-1.2.9/Makefile	2005-02-28 14:47:42.123760800 +0100
9945db7
@@ -9,8 +9,8 @@
9945db7
 
9945db7
 install_opts :=
9945db7
 
9945db7
-CFLAGS += -Wall -Werror -std=gnu99 -DNP_ETC_DIR='"$(etcdir)"' \
9945db7
-	-DNP_SCRIPT_DIR='"$(scriptdir)"' -ggdb3 -O3 -DNP_VERSION='"$(version)"'
9945db7
+CFLAGS += -std=gnu99 -DNP_ETC_DIR='"$(etcdir)"' \
9945db7
+	-DNP_SCRIPT_DIR='"$(scriptdir)"' -DNP_VERSION='"$(version)"'
9945db7
 
9945db7
 netplugd: config.o netlink.o lib.o if_info.o main.o
9945db7
 	$(CC) $(LDFLAGS) -o $@ $^
3286dd6
--- net-tools-1.60/netplug-1.2.9/main.c.execshield	2005-01-08 06:57:09.000000000 +0100
9945db7
+++ net-tools-1.60/netplug-1.2.9/main.c	2005-02-28 14:43:05.599798832 +0100
3286dd6
@@ -161,11 +161,28 @@
3286dd6
     ce.pid = info->si_pid;
3286dd6
     ret = waitpid(info->si_pid, &ce.status, 0);
3286dd6
     if (ret == info->si_pid)
3286dd6
-        write(child_handler_pipe[1], &ce, sizeof(ce));
3286dd6
+        (void)write(child_handler_pipe[1], &ce, sizeof(ce));
3286dd6
 }
c77899c
 
c77899c
 /* Poll the existing interface state, so we can catch any state
c77899c
    changes for which we may not have neen a netlink message. */
c77899c
+static int pollflags(struct if_info *info, long param) {
c77899c
+    struct ifreq ifr;
c77899c
+
c77899c
+    if (!if_match(info->name))
c77899c
+        return 0;
c77899c
+
c77899c
+    memcpy(ifr.ifr_name, info->name, sizeof(ifr.ifr_name));
c77899c
+    if (ioctl(param, SIOCGIFFLAGS, &ifr) < 0)
c77899c
+        do_log(LOG_ERR, "%s: can't get flags: %m", info->name);
c77899c
+    else {
c77899c
+        ifsm_flagchange(info, ifr.ifr_flags);
c77899c
+        ifsm_flagpoll(info);
c77899c
+    }
c77899c
+
c77899c
+    return 0;
c77899c
+}
c77899c
+
c77899c
 static void
c77899c
 poll_interfaces(void)
c77899c
 {
c77899c
@@ -180,24 +197,13 @@
c77899c
         close_on_exec(sockfd);
c77899c
     }
c77899c
 
c77899c
-    int pollflags(struct if_info *info) {
c77899c
-        struct ifreq ifr;
c77899c
-
c77899c
-        if (!if_match(info->name))
c77899c
-            return 0;
c77899c
-
c77899c
-        memcpy(ifr.ifr_name, info->name, sizeof(ifr.ifr_name));
c77899c
-        if (ioctl(sockfd, SIOCGIFFLAGS, &ifr) < 0)
c77899c
-            do_log(LOG_ERR, "%s: can't get flags: %m", info->name);
c77899c
-        else {
c77899c
-            ifsm_flagchange(info, ifr.ifr_flags);
c77899c
-            ifsm_flagpoll(info);
c77899c
-        }
c77899c
-
c77899c
-        return 0;
c77899c
-    }
c77899c
+    for_each_iface(pollflags, sockfd);
c77899c
+}
c77899c
 
c77899c
-    for_each_iface(pollflags);
c77899c
+static int poll_flags(struct if_info *i, long param) {
c77899c
+    if (if_match(i->name))
c77899c
+        ifsm_flagpoll(i);
c77899c
+    return 0;
c77899c
 }
c77899c
 
c77899c
 int debug = 0;
3286dd6
@@ -331,17 +337,11 @@
c77899c
         { child_handler_pipe[0], POLLIN, 0 },
c77899c
     };
c77899c
 
c77899c
-    {
c77899c
-        /* Run over each of the interfaces we know and care about, and
c77899c
-           make sure the state machine has done the appropriate thing
c77899c
-           for their current state. */
c77899c
-        int poll_flags(struct if_info *i) {
c77899c
-            if (if_match(i->name))
c77899c
-                ifsm_flagpoll(i);
c77899c
-            return 0;
c77899c
-        }
c77899c
-        for_each_iface(poll_flags);
c77899c
-    }
c77899c
+    /* Run over each of the interfaces we know and care about, and
c77899c
+       make sure the state machine has done the appropriate thing
c77899c
+       for their current state. */
c77899c
+    for_each_iface(poll_flags, 0);
c77899c
+
c77899c
 
c77899c
     for(;;) {
c77899c
         int ret;