rpms/netplug/devel import.log, NONE, 1.1 netplug-1.2.9.1-execshield.patch, NONE, 1.1 netplug-1.2.9.1-init.patch, NONE, 1.1 netplug.spec, NONE, 1.1 .cvsignore, 1.1, 1.2 sources, 1.1, 1.2

Jiří Popelka jpopelka at fedoraproject.org
Tue Sep 29 09:20:59 UTC 2009


Author: jpopelka

Update of /cvs/pkgs/rpms/netplug/devel
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv3308/devel

Modified Files:
	.cvsignore sources 
Added Files:
	import.log netplug-1.2.9.1-execshield.patch 
	netplug-1.2.9.1-init.patch netplug.spec 
Log Message:
Initial import.



--- NEW FILE import.log ---
netplug-1_2_9_1-1_fc11:HEAD:netplug-1.2.9.1-1.src.rpm:1254215937

netplug-1.2.9.1-execshield.patch:
 Makefile            |   12 ++++++----
 if_info.c           |   27 +++++++++++-------------
 main.c              |   58 ++++++++++++++++++++++++++--------------------------
 man/man8/netplugd.8 |    2 -
 netplug.h           |    2 -
 5 files changed, 51 insertions(+), 50 deletions(-)

--- NEW FILE netplug-1.2.9.1-execshield.patch ---
diff -up netplug-1.2.9.1/if_info.c.execshield netplug-1.2.9.1/if_info.c
--- netplug-1.2.9.1/if_info.c.execshield	2008-12-23 00:36:23.000000000 +0100
+++ netplug-1.2.9.1/if_info.c	2009-09-09 10:02:12.000000000 +0200
@@ -95,15 +95,16 @@ flags_str(char *buf, unsigned int fl)
     return buf;
 }
 
-void
-for_each_iface(int (*func)(struct if_info *))
+struct if_info *
+for_each_iface(int (*func)(struct if_info *, long), long param)
 {
     for(int i = 0; i < INFOHASHSZ; i++) {
         for(struct if_info *info = if_info[i]; info != NULL; info = info->next) {
-            if ((*func)(info))
-                return;
+            if ((*func)(info, param))
+                return info;
         }
     }
+    return NULL;
 }
 
 /* Reevaluate the state machine based on the current state and flag settings */
@@ -285,22 +286,20 @@ ifsm_flagchange(struct if_info *info, un
 }
 
 /* handle a script termination and update the state accordingly */
+int find_pid(struct if_info *i, long param) {
+    if (i->worker == param) {
+        return 1;
+    }
+    return 0;
+}
+
 void ifsm_scriptdone(pid_t pid, int exitstatus)
 {
     int exitok = WIFEXITED(exitstatus) && WEXITSTATUS(exitstatus) == 0;
     struct if_info *info;
     assert(WIFEXITED(exitstatus) || WIFSIGNALED(exitstatus));
 
-    int find_pid(struct if_info *i) {
-        if (i->worker == pid) {
-            info = i;
-            return 1;
-        }
-        return 0;
-    }
-
-    info = NULL;
-    for_each_iface(find_pid);
+    info = for_each_iface(find_pid, pid);
 
     if (info == NULL) {
         do_log(LOG_INFO, "Unexpected child %d exited with status %d",
diff -up netplug-1.2.9.1/main.c.execshield netplug-1.2.9.1/main.c
--- netplug-1.2.9.1/main.c.execshield	2008-12-23 00:36:23.000000000 +0100
+++ netplug-1.2.9.1/main.c	2009-09-09 10:02:12.000000000 +0200
@@ -161,11 +161,28 @@ child_handler(int sig, siginfo_t *info, 
     ce.pid = info->si_pid;
     ret = waitpid(info->si_pid, &ce.status, 0);
     if (ret == info->si_pid)
-        write(child_handler_pipe[1], &ce, sizeof(ce));
+        (void)write(child_handler_pipe[1], &ce, sizeof(ce));
 }
 
 /* Poll the existing interface state, so we can catch any state
    changes for which we may not have neen a netlink message. */
+static int pollflags(struct if_info *info, long param) {
+    struct ifreq ifr;
+
+    if (!if_match(info->name))
+        return 0;
+
+    memcpy(ifr.ifr_name, info->name, sizeof(ifr.ifr_name));
+    if (ioctl(param, SIOCGIFFLAGS, &ifr) < 0)
+        do_log(LOG_ERR, "%s: can't get flags: %m", info->name);
+    else {
+        ifsm_flagchange(info, ifr.ifr_flags);
+        ifsm_flagpoll(info);
+    }
+
+    return 0;
+}
+
 static void
 poll_interfaces(void)
 {
@@ -180,24 +197,13 @@ poll_interfaces(void)
         close_on_exec(sockfd);
     }
 
-    int pollflags(struct if_info *info) {
-        struct ifreq ifr;
-
-        if (!if_match(info->name))
-            return 0;
-
-        memcpy(ifr.ifr_name, info->name, sizeof(ifr.ifr_name));
-        if (ioctl(sockfd, SIOCGIFFLAGS, &ifr) < 0)
-            do_log(LOG_ERR, "%s: can't get flags: %m", info->name);
-        else {
-            ifsm_flagchange(info, ifr.ifr_flags);
-            ifsm_flagpoll(info);
-        }
-
-        return 0;
-    }
+    for_each_iface(pollflags, sockfd);
+}
 
-    for_each_iface(pollflags);
+static int poll_flags(struct if_info *i, long param) {
+    if (if_match(i->name))
+        ifsm_flagpoll(i);
+    return 0;
 }
 
 int debug = 0;
@@ -331,17 +337,11 @@ main(int argc, char *argv[])
         { child_handler_pipe[0], POLLIN, 0 },
     };
 
-    {
-        /* Run over each of the interfaces we know and care about, and
-           make sure the state machine has done the appropriate thing
-           for their current state. */
-        int poll_flags(struct if_info *i) {
-            if (if_match(i->name))
-                ifsm_flagpoll(i);
-            return 0;
-        }
-        for_each_iface(poll_flags);
-    }
+    /* Run over each of the interfaces we know and care about, and
+       make sure the state machine has done the appropriate thing
+       for their current state. */
+    for_each_iface(poll_flags, 0);
+
 
     for(;;) {
         int ret;
diff -up netplug-1.2.9.1/Makefile.execshield netplug-1.2.9.1/Makefile
--- netplug-1.2.9.1/Makefile.execshield	2008-12-23 00:41:38.000000000 +0100
+++ netplug-1.2.9.1/Makefile	2009-09-09 10:02:12.000000000 +0200
@@ -4,15 +4,15 @@ DESTDIR ?=
 
 prefix ?=
 bindir ?= $(prefix)/sbin
-etcdir ?= $(prefix)/etc/netplug
+etcdir ?= $(prefix)/etc/netplug.d
 initdir ?= $(prefix)/etc/rc.d/init.d
 scriptdir ?= $(prefix)/etc/netplug.d
 mandir ?= $(prefix)/usr/share/man
 
 install_opts :=
 
-CFLAGS += -Wall -Werror -std=gnu99 -DNP_ETC_DIR='"$(etcdir)"' \
-	-DNP_SCRIPT_DIR='"$(scriptdir)"' -ggdb3 -O3 -DNP_VERSION='"$(version)"'
+CFLAGS += -std=gnu99 -DNP_ETC_DIR='"$(etcdir)"' \
+	-DNP_SCRIPT_DIR='"$(scriptdir)"' -DNP_VERSION='"$(version)"'
 
 netplugd: config.o netlink.o lib.o if_info.o main.o
 	$(CC) $(LDFLAGS) -o $@ $^
@@ -30,10 +30,12 @@ install:
 	install $(install_opts) -m 755 scripts/rc.netplugd $(DESTDIR)/$(initdir)/netplugd
 	install $(install_opts) -m 444 man/man8/netplugd.8 $(DESTDIR)/$(mandir)/man8
 
-hg_root := $(shell hg root)
+#hg_root := $(shell hg root)
+hg_root := $(shell)
 tar_root := netplug-$(version)
 tar_file := $(hg_root)/$(tar_root).tar.bz2
-files := $(shell hg manifest)
+#files := $(shell hg manifest)
+files := $(shell)
 
 tarball: $(tar_file)
 
diff -up netplug-1.2.9.1/man/man8/netplugd.8.execshield netplug-1.2.9.1/man/man8/netplugd.8
--- netplug-1.2.9.1/man/man8/netplugd.8.execshield	2008-12-23 00:36:23.000000000 +0100
+++ netplug-1.2.9.1/man/man8/netplugd.8	2009-09-09 10:07:33.000000000 +0200
@@ -134,7 +134,7 @@ to run in the foreground, this option is
 .\"
 .Sh FILES
 .Bl -tag -width Ds
-.It Pa /etc/netplug/netplugd.conf
+.It Pa /etc/netplug.d/netplugd.conf
 Default config file to read, if none is specified on the command line.
 The config file format is one pattern per line, with white space,
 empty lines, and comments starting with a
diff -up netplug-1.2.9.1/netplug.h.execshield netplug-1.2.9.1/netplug.h
--- netplug-1.2.9.1/netplug.h.execshield	2008-12-23 00:36:23.000000000 +0100
+++ netplug-1.2.9.1/netplug.h	2009-09-09 10:02:12.000000000 +0200
@@ -83,7 +83,7 @@ struct if_info *if_info_update_interface
                                          struct rtattr *attrs[]);
 int if_info_save_interface(struct nlmsghdr *hdr, void *arg);
 void parse_rtattrs(struct rtattr *tb[], int max, struct rtattr *rta, int len);
-void for_each_iface(int (*func)(struct if_info *));
+struct if_info *for_each_iface(int (*func)(struct if_info *, long), long param);
 
 void ifsm_flagpoll(struct if_info *info);
 void ifsm_flagchange(struct if_info *info, unsigned int newflags);

netplug-1.2.9.1-init.patch:
 rc.netplugd |    9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

--- NEW FILE netplug-1.2.9.1-init.patch ---
diff -up netplug-1.2.9.1/scripts/rc.netplugd.init netplug-1.2.9.1/scripts/rc.netplugd
--- netplug-1.2.9.1/scripts/rc.netplugd.init	2008-12-23 00:36:23.000000000 +0100
+++ netplug-1.2.9.1/scripts/rc.netplugd	2009-09-08 11:55:03.000000000 +0200
@@ -17,11 +17,6 @@
 # Source networking configuration.
 . /etc/sysconfig/network
 
-# Check that networking is up.
-[ ${NETWORKING} = "no" ] && exit 0
-
-[ -x /sbin/netplugd ] || exit 0
-
 if [ -f /etc/sysconfig/netplugd ]; then
     . /etc/sysconfig/netplugd
 fi
@@ -30,6 +25,8 @@ fi
 case "$1" in
   start)
 	# Start daemon.
+	[ ${NETWORKING} = "no" ] && exit 1
+	[ -x /sbin/netplugd ] || exit 1
 	echo -n $"Starting network plug daemon: "
 	daemon /sbin/netplugd ${NETPLUGDARGS} -p /var/run/netplugd.pid
 	RETVAL=$?
@@ -57,7 +54,7 @@ case "$1" in
 	;;
   *)
 	echo $"Usage: $0 {start|stop|status|restart}"
-	RETVAL=1
+	RETVAL=3
 	;;
 esac
 


--- NEW FILE netplug.spec ---
Summary: Daemon that responds to network cables being plugged in and out
Name: netplug
Version: 1.2.9.1
Release: 1%{?dist}
License: GPLv2
Group: System Environment/Base
URL: http://www.red-bean.com/~bos/
Source0: http://www.red-bean.com/~bos/netplug/netplug-%{version}.tar.bz2

#execshield patch for netplug <t8m at redhat.com>
Patch1: netplug-1.2.9.1-execshield.patch

#fix netplugd init script (#242919)
Patch2: netplug-1.2.9.1-init.patch

Requires: iproute >= 2.4.7
Conflicts: net-tools < 1.60-96
Requires(post): /sbin/chkconfig
Requires(preun): /sbin/chkconfig
Requires(preun): /sbin/service
Requires(postun): /sbin/service
BuildRequires: gettext

%description
Netplug is a daemon that manages network interfaces in response to
link-level events such as cables being plugged in and out.  When a
cable is plugged into an interface, the netplug daemon brings that
interface up.  When the cable is unplugged, the daemon brings that
interface back down.

This is extremely useful for systems such as laptops, which are
constantly being unplugged from one network and plugged into another,
and for moving systems in a machine room from one switch to another
without a need for manual intervention.

%prep
%setup -q
%patch1 -p1 -b .execshield
%patch2 -p1 -b .init

%build
export CFLAGS="$RPM_OPT_FLAGS $CFLAGS"
make

%install
make install prefix=%{buildroot} \
             initdir=%{buildroot}/%{_initrddir} \
             mandir=%{buildroot}/%{_mandir}

mkdir -p %{buildroot}/%{_mandir}/man5
ln -fs %{_mandir}/man8/netplugd.8.gz %{buildroot}/%{_mandir}/man5/netplug.5.gz
ln -fs %{_mandir}/man8/netplugd.8.gz %{buildroot}/%{_mandir}/man5/netplug.d.5.gz
ln -fs %{_mandir}/man8/netplugd.8.gz %{buildroot}/%{_mandir}/man5/netplugd.conf.5.gz

%clean
rm -rf %{buildroot}

%post
  /sbin/chkconfig --add netplugd
  exit 0

%preun
if [ "$1" = "0" ]; then
  /sbin/chkconfig --del netplugd || :
  /sbin/service netplugd stop &> /dev/null || :
fi
exit 0

%postun
  /sbin/service netplugd condrestart >/dev/null 2>&1 || :
  exit 0

%files
%defattr(-,root,root)
%doc COPYING README TODO
/sbin/netplugd
%{_mandir}/man[58]/*
%{_sysconfdir}/netplug.d
%config(noreplace) %{_sysconfdir}/netplug.d/netplugd.conf
%{_initrddir}/netplugd

%changelog

* Tue Sep 8 2009  Jiri Popelka <jpopelka at redhat.com> - 1.2.9.1-1
- Initial standalone package. Up to now netplug has been part of net-tools.

Index: .cvsignore
===================================================================
RCS file: /cvs/pkgs/rpms/netplug/devel/.cvsignore,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -p -r1.1 -r1.2
--- .cvsignore	25 Sep 2009 16:14:40 -0000	1.1
+++ .cvsignore	29 Sep 2009 09:20:57 -0000	1.2
@@ -0,0 +1 @@
+netplug-1.2.9.1.tar.bz2


Index: sources
===================================================================
RCS file: /cvs/pkgs/rpms/netplug/devel/sources,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -p -r1.1 -r1.2
--- sources	25 Sep 2009 16:14:40 -0000	1.1
+++ sources	29 Sep 2009 09:20:58 -0000	1.2
@@ -0,0 +1 @@
+1e439dc3fc5a52de0b85467efbd25a57  netplug-1.2.9.1.tar.bz2




More information about the scm-commits mailing list