summaryrefslogtreecommitdiff
path: root/sys-apps/netplug
diff options
context:
space:
mode:
Diffstat (limited to 'sys-apps/netplug')
-rw-r--r--sys-apps/netplug/Manifest10
-rw-r--r--sys-apps/netplug/files/netplug-1.2.9-ignore-wireless.patch37
-rw-r--r--sys-apps/netplug/files/netplug-1.2.9-remove-nest.patch187
-rw-r--r--sys-apps/netplug/files/netplug-1.2.9.2-downandout.patch13
-rw-r--r--sys-apps/netplug/files/netplug-243
-rw-r--r--sys-apps/netplug/metadata.xml11
-rw-r--r--sys-apps/netplug/netplug-1.2.9.2-r1.ebuild63
-rw-r--r--sys-apps/netplug/netplug-1.2.9.2-r2.ebuild70
8 files changed, 434 insertions, 0 deletions
diff --git a/sys-apps/netplug/Manifest b/sys-apps/netplug/Manifest
new file mode 100644
index 000000000000..d3d34b4eab8a
--- /dev/null
+++ b/sys-apps/netplug/Manifest
@@ -0,0 +1,10 @@
+AUX netplug-1.2.9-ignore-wireless.patch 938 SHA256 75cf296b40316a387c76db51ab2534426a3784ac8ea1ce94b9f32dddd8a3419a SHA512 a045d1a1dfc6d29334aff6ec035244d68e80887bb05f79d0512c87d7ac0dbb3cdf866569762e575b13a6306604e85e0ba951f10d54f88a39ef558ce2a65ddbed WHIRLPOOL 0468db7bb892e78b1313bd2c6dd115b05f84c6b5bd0499919e0d48f49d9a18dd5f9b95089a205bcdd2c8b767d560b596f14053d694f2c264f3bc4420df778156
+AUX netplug-1.2.9-remove-nest.patch 5516 SHA256 282b390c459c1190b55049cc42828916189097faa75695b738a9a6391079a5a4 SHA512 dfcb72f1977cefbdb231c0e7a1ab758e9c753c434d9e5ccc5336a7f606e787fcec943cd1055481d1ba9f2ce9da0e33bf93852a106eeda4b2539d0c66c433945b WHIRLPOOL fcab8a938dacbf8b34ffc91c8efbab459814eac38a2e655589bea2f65d3132bfdd8298197d341a011130160d7877b4fbb26a8610f4796f3305a2db6a2da08c9c
+AUX netplug-1.2.9.2-downandout.patch 340 SHA256 20378613d53c716040c8c47b7f241d24f21a155d577463211fa3d4c3868e8621 SHA512 b1b7e99afda7988245f574c7ecffcf50f78493be71290d0484f0df2c94580f25ee3037db01d5fc2e577a2cd1ec721f93663bce3e1b59dcb38dd009a133d034f8 WHIRLPOOL e38f2ce592ccd820ab227edd8119836356f678eda4659515767148b71cd2a8cfcb51226c74edad3769fb1b94610f2502fdeaca96252df8f788c0ebc7f75032f9
+AUX netplug-2 715 SHA256 aaa5549bedfa767d594e76c4fde3b29c2e20c8430a24df13c656b1a2a2a16b5c SHA512 11efb8b8916d40615840c5721aba089dc9f81bf30f2af6f47d6df2fd8f2b6f22e0cd59ebd37fd9875c4af31e064128e93acbef5cf859b3cabb553fbdd2f3c9ee WHIRLPOOL 956f75b28b23ecb862454d05d41148e3f4acf43f249e97325b40433ba58da3852cd300bc40a0a3f27d3474f82d391ee102e4768e6ab869acab612394feec61f6
+DIST netplug-1.2.9.2.tar.bz2 22332 SHA256 5180dfd9a7d3d0633a027b0a04f01b45a6a64623813cd48bd54423b90814864e SHA512 b68a00eb8874ec7dd6aa9f7b7f529a6e1d9ecece4b798c8cee996b7f3534c556656f642de0ac4b2a6d06fbaf18e3bfaab00934a9292b95939a4935e673e9ca8c WHIRLPOOL 51d54d4c7784b82b71b3a8964c9df3f17e8df1b21b11a95250f911c6f0917aabab1bf0fe5117884623b3222b1df0c443ce4416ad74f63c0d761f762e5f39216f
+EBUILD netplug-1.2.9.2-r1.ebuild 1289 SHA256 e66e3946280ea0618b84d2910c45e0d0cd8c171e4604f5df4589afe280e8cbc2 SHA512 fadc601d1e406c77af3a139a91c2ae3040039c17b6e948f07f892ed0235631e1bc4180cce9ebf80e2f09df7b8d71bd160953cdc8d174dbd93d8aeea1c882788a WHIRLPOOL c2efd205e17fc96a478041f539071d58b35557bcb402b741160c94f5d8011dbd053113f6bf282e4586d2f8e178b8a1a0c4df027075bc54760b85d671dfa0e482
+EBUILD netplug-1.2.9.2-r2.ebuild 1375 SHA256 7bedcc2dd17406ae894f07e89245840ec2ca88721f0cf11fd0412b9ace20fb73 SHA512 71a7c1615e2c848b54962bcae7dbc587a19f67ee96b163d5c6d86c86996526e1352a3e880ef4fd55003c665af36ca7f67dc118a12ffad49b96809c55443d902f WHIRLPOOL bccd71c5b932174c60130d1d653ee14ffa3eb19233836ae6f319e02881ee6864fdf5e5abdcfe3206015ffd6a526d82f45342f0567978f98056319b3bc2c9b9aa
+MISC ChangeLog 2645 SHA256 f965bc7846a1e136d3e32181dd2e55df74c21374b0987b20a4484ebe0935ea2a SHA512 33f85eebb972956dc24bc14ac27c0e22591e8978997df6e56602ad845e5a24ae49bd420a459097405be0825f02502417eddbf6df4e8139c8b2e5b8c308d8971f WHIRLPOOL dc5853e1bd56bf404a39f0c9d0d5958b76024726bcb5d570d9607a80e1c15cd70497ccaf3da22e1c3e0865064cd40861a5c3a9d2e46327021d1fcc29a6c8e44a
+MISC ChangeLog-2015 5415 SHA256 600478475c32b243904b680311920239fb093cf68694045fe4fc3ee86191c6b0 SHA512 268f20f234016ef0a94d81dec7705756601db257d4da183ad7bd54d3eea22b79b4714f46c516577b14a5e9ddcf073c580d583d815360c71311435ca405e01e5a WHIRLPOOL 5b5c5dc97eefcf7e83348901b92bef9c853d169936c63428bfc81727faaaa97dc83b83dec14d7e936d6ba1158af79a5e696cd3a26b5737465e0cb0280640dfa4
+MISC metadata.xml 367 SHA256 ee2ec084f92ba03f4fd0495ff04aec426ddd4daa25ef63734a7e111992b77646 SHA512 d2cdfcaac3690abf52d3ee9ebd7086815b84802d4918778911b63d4ecb36ac8928178ac7d02ebbf3823ee50ef2917069a20a4cdce319097298d7f66ad15e272c WHIRLPOOL 5a1ca40ca7144d447a7ece7af2a08fb6cb3caac84cb9ed3b97dae9c5fe9bc57745c1fdb72c19db058430e772fb3f938f3d9d4eeb259d4bfbe635be68437feb01
diff --git a/sys-apps/netplug/files/netplug-1.2.9-ignore-wireless.patch b/sys-apps/netplug/files/netplug-1.2.9-ignore-wireless.patch
new file mode 100644
index 000000000000..de5cba2cb08d
--- /dev/null
+++ b/sys-apps/netplug/files/netplug-1.2.9-ignore-wireless.patch
@@ -0,0 +1,37 @@
+--- netplug-1.2.9/main.c
++++ netplug-1.2.9/main.c
+@@ -36,6 +36,10 @@
+
+ #include "netplug.h"
+
++/* Support old kernels without wireless */
++#ifndef IFLA_WIRELESS
++#define IFLA_WIRELESS (IFLA_MASTER + 1)
++#endif /* IFLA_WIRELESS */
+
+ int use_syslog;
+ static char *pid_file;
+@@ -63,6 +67,14 @@
+
+ parse_rtattrs(attrs, IFLA_MAX, IFLA_RTA(info), len);
+
++ /* Ignore wireless messages */
++ if (attrs[IFLA_WIRELESS] != NULL
++ && hdr->nlmsg_type == RTM_NEWLINK
++ && info->ifi_change == 0) {
++ do_log(LOG_DEBUG, "Ignoring wireless netlink message");
++ return 0;
++ }
++
+ if (attrs[IFLA_IFNAME] == NULL) {
+ do_log(LOG_ERR, "No interface name");
+ return -1;
+@@ -71,7 +83,7 @@
+ char *name = RTA_DATA(attrs[IFLA_IFNAME]);
+
+ if (!if_match(name)) {
+- do_log(LOG_INFO, "%s: ignoring event", name);
++ do_log(LOG_DEBUG, "%s: ignoring event", name);
+ return 0;
+ }
+
diff --git a/sys-apps/netplug/files/netplug-1.2.9-remove-nest.patch b/sys-apps/netplug/files/netplug-1.2.9-remove-nest.patch
new file mode 100644
index 000000000000..0a3b991a82bf
--- /dev/null
+++ b/sys-apps/netplug/files/netplug-1.2.9-remove-nest.patch
@@ -0,0 +1,187 @@
+This patch replaces the for_each_iface nested funtion with a macro so that we
+don't have an executable stack and work correctly on NX capable hardware.
+See http://www.gentoo.org/proj/en/hardened/gnu-stack.xml for more information.
+
+Patch by Diego Pettenò (flameeyes@gentoo.org)
+
+Index: netplug-1.2.9/if_info.c
+===================================================================
+--- netplug-1.2.9.orig/if_info.c
++++ netplug-1.2.9/if_info.c
+@@ -29,8 +29,7 @@
+
+ #include "netplug.h"
+
+-#define INFOHASHSZ 16 /* must be a power of 2 */
+-static struct if_info *if_info[INFOHASHSZ];
++struct if_info *if_info[INFOHASHSZ];
+
+ static const char *
+ statename(enum ifstate s)
+@@ -95,17 +94,6 @@ flags_str(char *buf, unsigned int fl)
+ return buf;
+ }
+
+-void
+-for_each_iface(int (*func)(struct if_info *))
+-{
+- for(int i = 0; i < INFOHASHSZ; i++) {
+- for(struct if_info *info = if_info[i]; info != NULL; info = info->next) {
+- if ((*func)(info))
+- return;
+- }
+- }
+-}
+-
+ /* Reevaluate the state machine based on the current state and flag settings */
+ void
+ ifsm_flagpoll(struct if_info *info)
+@@ -284,6 +272,14 @@ ifsm_flagchange(struct if_info *info, un
+ info->lastchange = time(0);
+ }
+
++int find_pid(struct if_info *i, pid_t pid, struct if_info **info) {
++ if (i->worker == pid) {
++ *info = i;
++ return 1;
++ }
++ return 0;
++}
++
+ /* handle a script termination and update the state accordingly */
+ void ifsm_scriptdone(pid_t pid, int exitstatus)
+ {
+@@ -291,16 +287,8 @@ void ifsm_scriptdone(pid_t pid, int exit
+ 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);
++ for_each_iface(find_pid, pid, &info);
+
+ if (info == NULL) {
+ do_log(LOG_INFO, "Unexpected child %d exited with status %d",
+Index: netplug-1.2.9/main.c
+===================================================================
+--- netplug-1.2.9.orig/main.c
++++ netplug-1.2.9/main.c
+@@ -164,6 +164,23 @@ child_handler(int sig, siginfo_t *info,
+ write(child_handler_pipe[1], &ce, sizeof(ce));
+ }
+
++int pollflags_state(struct if_info *info, int sockfd) {
++ 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;
++}
++
+ /* Poll the existing interface state, so we can catch any state
+ changes for which we may not have neen a netlink message. */
+ static void
+@@ -180,28 +197,20 @@ 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);
++ for_each_iface(pollflags_state, sockfd);
+ }
+
+ int debug = 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_check(struct if_info *i) {
++ if (if_match(i->name))
++ ifsm_flagpoll(i);
++ return 0;
++}
++
+ int
+ main(int argc, char *argv[])
+ {
+@@ -331,17 +340,7 @@ 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);
+- }
++ for_each_iface(poll_flags_check);
+
+ for(;;) {
+ int ret;
+Index: netplug-1.2.9/netplug.h
+===================================================================
+--- netplug-1.2.9.orig/netplug.h
++++ netplug-1.2.9/netplug.h
+@@ -28,6 +28,9 @@
+
+ #define NP_SCRIPT NP_SCRIPT_DIR "/netplug"
+
++#define INFOHASHSZ 16 /* must be a power of 2 */
++extern struct if_info *if_info[INFOHASHSZ];
++
+ /* configuration */
+
+ void read_config(char *filename);
+@@ -83,7 +86,14 @@ 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 *));
++
++#define for_each_iface(func, ...) \
++ for(int i = 0; i < INFOHASHSZ; i++) { \
++ for(struct if_info *each_iface = if_info[i]; each_iface != NULL; each_iface = each_iface->next) { \
++ if (func (each_iface, ##__VA_ARGS__)) \
++ break; \
++ } \
++ }
+
+ void ifsm_flagpoll(struct if_info *info);
+ void ifsm_flagchange(struct if_info *info, unsigned int newflags);
diff --git a/sys-apps/netplug/files/netplug-1.2.9.2-downandout.patch b/sys-apps/netplug/files/netplug-1.2.9.2-downandout.patch
new file mode 100644
index 000000000000..be164e58a440
--- /dev/null
+++ b/sys-apps/netplug/files/netplug-1.2.9.2-downandout.patch
@@ -0,0 +1,13 @@
+https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=652418
+https://bugs.gentoo.org/599400
+
+--- a/if_info.c
++++ b/if_info.c
+@@ -186,6 +186,7 @@
+ if (newflags & IFF_UP) {
+ switch(info->state) {
+ case ST_DOWN:
++ case ST_DOWNANDOUT:
+ info->state = ST_INACTIVE;
+ break;
+
diff --git a/sys-apps/netplug/files/netplug-2 b/sys-apps/netplug/files/netplug-2
new file mode 100644
index 000000000000..539f1465516a
--- /dev/null
+++ b/sys-apps/netplug/files/netplug-2
@@ -0,0 +1,43 @@
+#!/bin/sh
+# Copyright 1999-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+#
+# Gentoo-specific netplug script
+#
+# This file gets called by netplug when it wants to bring an interface
+# up or down.
+#
+
+IFACE="$1"
+ACTION="$2"
+
+EXEC="/etc/init.d/net.${IFACE}"
+
+case "${ACTION}" in
+ in)
+ ARGS="--quiet start"
+ ;;
+ out)
+ ARGS="--quiet stop"
+ ;;
+ probe)
+ # Do nothing as we should already be up
+ exit 0
+ ;;
+ *)
+ echo "$0: wrong arguments" >&2
+ echo "Call with <interface> <in|out|probe>" >&2
+ exit 1
+ ;;
+esac
+
+export IN_BACKGROUND=true
+
+if [ -x "${EXEC}" ]
+then
+ ${EXEC} ${ARGS}
+ exit 0
+else
+ logger -t netplug "Error: Couldn't configure ${IFACE}, no ${EXEC} !"
+ exit 1
+fi
diff --git a/sys-apps/netplug/metadata.xml b/sys-apps/netplug/metadata.xml
new file mode 100644
index 000000000000..04c54cf1d796
--- /dev/null
+++ b/sys-apps/netplug/metadata.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+ <maintainer type="person">
+ <email>polynomial-c@gentoo.org</email>
+ <name>Lars Wendler</name>
+ </maintainer>
+ <longdescription lang="en">
+ Brings up/down ethernet ports automatically with cable detection
+ </longdescription>
+</pkgmetadata>
diff --git a/sys-apps/netplug/netplug-1.2.9.2-r1.ebuild b/sys-apps/netplug/netplug-1.2.9.2-r1.ebuild
new file mode 100644
index 000000000000..8456a5d68924
--- /dev/null
+++ b/sys-apps/netplug/netplug-1.2.9.2-r1.ebuild
@@ -0,0 +1,63 @@
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit eutils toolchain-funcs
+
+DESCRIPTION="Brings up/down ethernet ports automatically with cable detection"
+HOMEPAGE="http://www.red-bean.com/~bos/"
+SRC_URI="http://www.red-bean.com/~bos/netplug/${P}.tar.bz2"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="amd64 arm ~mips ppc sparc x86"
+IUSE="debug doc"
+
+DEPEND="doc? ( app-text/ghostscript-gpl
+ media-gfx/graphviz )"
+RDEPEND=""
+
+src_prepare() {
+ # Remove debug flags from CFLAGS
+ if ! use debug; then
+ sed -i -e "s/ -ggdb3//" Makefile || die
+ fi
+
+ # Remove -O3 and -Werror from CFLAGS
+ sed -i -e "s/ -O3//" -e "s/ -Werror//" Makefile || die
+
+ # Remove nested functions, #116140
+ epatch "${FILESDIR}/${PN}-1.2.9-remove-nest.patch"
+
+ # Ignore wireless events
+ epatch "${FILESDIR}/${PN}-1.2.9-ignore-wireless.patch"
+}
+
+src_compile() {
+ tc-export CC
+ emake CC="${CC}"
+
+ if use doc; then
+ emake -C docs/
+ fi
+}
+
+src_install() {
+ into /
+ dosbin netplugd
+ doman man/man8/netplugd.8
+
+ dodir /etc/netplug.d
+ exeinto /etc/netplug.d
+ newexe "${FILESDIR}/netplug-2" netplug
+
+ dodir /etc/netplug
+ echo "eth*" > "${D}"/etc/netplug/netplugd.conf || die
+
+ dodoc ChangeLog NEWS README TODO
+
+ if use doc; then
+ dodoc docs/state-machine.ps
+ fi
+}
diff --git a/sys-apps/netplug/netplug-1.2.9.2-r2.ebuild b/sys-apps/netplug/netplug-1.2.9.2-r2.ebuild
new file mode 100644
index 000000000000..fefdce0fd90e
--- /dev/null
+++ b/sys-apps/netplug/netplug-1.2.9.2-r2.ebuild
@@ -0,0 +1,70 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=6
+
+inherit eutils toolchain-funcs
+
+DESCRIPTION="Brings up/down ethernet ports automatically with cable detection"
+HOMEPAGE="http://www.red-bean.com/~bos/"
+SRC_URI="http://www.red-bean.com/~bos/netplug/${P}.tar.bz2"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="amd64 arm ~mips ppc ppc64 sparc x86"
+IUSE="debug doc"
+
+DEPEND="doc? ( app-text/ghostscript-gpl
+ media-gfx/graphviz )"
+RDEPEND=""
+
+PATCHES=(
+ # Remove nested functions, #116140
+ "${FILESDIR}/${PN}-1.2.9-remove-nest.patch"
+
+ # Ignore wireless events
+ "${FILESDIR}/${PN}-1.2.9-ignore-wireless.patch"
+
+ # Fix DOWNANDOUT problem #599400
+ "${FILESDIR}/${P}-downandout.patch"
+)
+
+src_prepare() {
+ # Remove debug flags from CFLAGS
+ if ! use debug; then
+ sed -i -e "s/ -ggdb3//" Makefile || die
+ fi
+
+ # Remove -O3 and -Werror from CFLAGS
+ sed -i -e "s/ -O3//" -e "s/ -Werror//" Makefile || die
+
+ default
+}
+
+src_compile() {
+ tc-export CC
+ emake CC="${CC}"
+
+ if use doc; then
+ emake -C docs/
+ fi
+}
+
+src_install() {
+ into /
+ dosbin netplugd
+ doman man/man8/netplugd.8
+
+ dodir /etc/netplug.d
+ exeinto /etc/netplug.d
+ newexe "${FILESDIR}/netplug-2" netplug
+
+ dodir /etc/netplug
+ echo "eth*" > "${D}"/etc/netplug/netplugd.conf || die
+
+ dodoc ChangeLog NEWS README TODO
+
+ if use doc; then
+ dodoc docs/state-machine.ps
+ fi
+}