diff options
| author | Palica <palica+gitlab@liguros.net> | 2020-06-23 22:35:08 +0200 |
|---|---|---|
| committer | Palica <palica+gitlab@liguros.net> | 2020-06-23 22:35:08 +0200 |
| commit | ecdac123787b96ce6649f0f91da12ea6458cc2b1 (patch) | |
| tree | b89c74d9e6fe6e8aebc4c77bcbeb4ab73214127d /sys-apps/netplug | |
| parent | 1be72aa41cf41dedadeecf59dca9f01de6381f5e (diff) | |
| download | baldeagleos-repo-ecdac123787b96ce6649f0f91da12ea6458cc2b1.tar.gz baldeagleos-repo-ecdac123787b96ce6649f0f91da12ea6458cc2b1.tar.xz baldeagleos-repo-ecdac123787b96ce6649f0f91da12ea6458cc2b1.zip | |
Updating liguros repo
Diffstat (limited to 'sys-apps/netplug')
| -rw-r--r-- | sys-apps/netplug/.audit | 1 | ||||
| -rw-r--r-- | sys-apps/netplug/Manifest | 1 | ||||
| -rw-r--r-- | sys-apps/netplug/files/netplug-1.2.9-ignore-wireless.patch | 37 | ||||
| -rw-r--r-- | sys-apps/netplug/files/netplug-1.2.9-remove-nest.patch | 187 | ||||
| -rw-r--r-- | sys-apps/netplug/files/netplug-1.2.9.2-downandout.patch | 13 | ||||
| -rw-r--r-- | sys-apps/netplug/files/netplug-1.2.9.2-multi-waitpid-sigchld.patch | 65 | ||||
| -rwxr-xr-x | sys-apps/netplug/files/netplug-2-r1 | 38 | ||||
| -rw-r--r-- | sys-apps/netplug/metadata.xml | 12 | ||||
| -rw-r--r-- | sys-apps/netplug/netplug-1.2.9.2-r2.ebuild | 69 | ||||
| -rw-r--r-- | sys-apps/netplug/netplug-1.2.9.2-r3.ebuild | 72 |
10 files changed, 495 insertions, 0 deletions
diff --git a/sys-apps/netplug/.audit b/sys-apps/netplug/.audit new file mode 100644 index 000000000000..f8ed10325c17 --- /dev/null +++ b/sys-apps/netplug/.audit @@ -0,0 +1 @@ +This was forked to make compatible with funtoo networking scripts. diff --git a/sys-apps/netplug/Manifest b/sys-apps/netplug/Manifest new file mode 100644 index 000000000000..ebf69a0f3b6f --- /dev/null +++ b/sys-apps/netplug/Manifest @@ -0,0 +1 @@ +DIST netplug-1.2.9.2.tar.bz2 22332 SHA256 5180dfd9a7d3d0633a027b0a04f01b45a6a64623813cd48bd54423b90814864e SHA512 b68a00eb8874ec7dd6aa9f7b7f529a6e1d9ecece4b798c8cee996b7f3534c556656f642de0ac4b2a6d06fbaf18e3bfaab00934a9292b95939a4935e673e9ca8c WHIRLPOOL 51d54d4c7784b82b71b3a8964c9df3f17e8df1b21b11a95250f911c6f0917aabab1bf0fe5117884623b3222b1df0c443ce4416ad74f63c0d761f762e5f39216f 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-1.2.9.2-multi-waitpid-sigchld.patch b/sys-apps/netplug/files/netplug-1.2.9.2-multi-waitpid-sigchld.patch new file mode 100644 index 000000000000..06e645c1dee9 --- /dev/null +++ b/sys-apps/netplug/files/netplug-1.2.9.2-multi-waitpid-sigchld.patch @@ -0,0 +1,65 @@ +# Rework SIGCHLD handler to anticipate multiple children dying while the +# handler is being executed. +# +# Without the patch if multiple SIGCHLD signals are received while the signal +# handler is being executed, the first will be left in pending state and the +# extra discarded. Due to the children processing logic in netplugd, the ones +# which were missed will never be waited, left as zombies. +# +# Implementation of the signal handler is following suggested handling in +# https://www.gnu.org/software/libc/manual/html_node/Merged-Signals.html +# +# The patch strives to change only the children wait logic in the signal +# handler, it doesn't try to enhance write call error handling or the unsafe +# call to exit/do_log. Also the formatting is left as it was in the original +# code. + +--- a/main.c ++++ b/main.c +@@ -153,17 +153,29 @@ static int child_handler_pipe[2]; + static void + child_handler(int sig, siginfo_t *info, void *v) + { +- struct child_exit ce; +- int ret; +- ssize_t s = 0; ++ int old_errno = errno; + + assert(sig == SIGCHLD); + +- ce.pid = info->si_pid; +- ret = waitpid(info->si_pid, &ce.status, 0); +- if (ret == info->si_pid) ++ while (1) + { +- s = write(child_handler_pipe[1], &ce, sizeof(ce)); ++ pid_t pid; ++ int status; ++ ++ do ++ { ++ errno = 0; ++ pid = waitpid(WAIT_ANY, &status, WNOHANG); ++ } while (pid <= 0 && errno == EINTR); ++ ++ if (pid <= 0) ++ { ++ break; ++ } ++ ++ struct child_exit ce = { .pid = pid, .status = status }; ++ ++ ssize_t s = write(child_handler_pipe[1], &ce, sizeof(ce)); + + if (s == -1) + { +@@ -171,6 +183,9 @@ child_handler(int sig, siginfo_t *info, void *v) + exit(1); + } + } ++ ++ errno = old_errno; ++ return; + } + + /* Poll the existing interface state, so we can catch any state diff --git a/sys-apps/netplug/files/netplug-2-r1 b/sys-apps/netplug/files/netplug-2-r1 new file mode 100755 index 000000000000..0453770991b0 --- /dev/null +++ b/sys-apps/netplug/files/netplug-2-r1 @@ -0,0 +1,38 @@ +#!/bin/sh +# Distributed under the terms of the GNU General Public License v2 +# This file gets called by netplug when it wants to bring an interface +# up or down. + +IFACE="$1" +ACTION="$2" + +EXEC="/etc/init.d/netif.${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..10aea0e6be3b --- /dev/null +++ b/sys-apps/netplug/metadata.xml @@ -0,0 +1,12 @@ +<?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> + <origin>kit-fixups</origin> +</pkgmetadata> 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..519e6f7e6a75 --- /dev/null +++ b/sys-apps/netplug/netplug-1.2.9.2-r2.ebuild @@ -0,0 +1,69 @@ +# 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="https://www.red-bean.com/~bos/" +SRC_URI="https://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-r1" 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-r3.ebuild b/sys-apps/netplug/netplug-1.2.9.2-r3.ebuild new file mode 100644 index 000000000000..42b9683a1a26 --- /dev/null +++ b/sys-apps/netplug/netplug-1.2.9.2-r3.ebuild @@ -0,0 +1,72 @@ +# Distributed under the terms of the GNU General Public License v2 + +EAPI=7 + +inherit toolchain-funcs + +DESCRIPTION="Brings up/down ethernet ports automatically with cable detection" +HOMEPAGE="https://www.red-bean.com/~bos/" +SRC_URI="https://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" + + # Wait for multiple children in SIGCHLD handler #631316 + "${FILESDIR}/${P}-multi-waitpid-sigchld.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-r1" netplug + + dodir /etc/netplug + echo "eth*" > "${ED}"/etc/netplug/netplugd.conf || die + + dodoc ChangeLog NEWS README TODO + + if use doc; then + dodoc docs/state-machine.ps + fi +} |
