Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ifplugd and refpolicy fixes #1445

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 110 additions & 0 deletions recipes-core/busybox/busybox-ifplugd/ifplugd
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
#!/bin/sh
# $Id: ifplugd.init.in 86 2004-01-26 15:34:24Z lennart $

# This file is part of ifplugd.
#
# ifplugd is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# ifplugd is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with ifplugd; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.

# ifplugd Brings up/down network automatically
#
# chkconfig: 2345 11 89
# description: Brings networks interfaces up and down automatically when \
# the cable is removed / inserted
#
# processname: /usr/sbin/ifplugd
# config: /etc/ifplugd/ifplugd.conf

### BEGIN INIT INFO
# Provides: ifplugd
# Required-Start: $network
# X-UnitedLinux-Should-Start:
# Required-Stop: $network
# X-UnitedLinux-Should-Stop: $
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Short-Description: ifplugd daemon
# Description: Start ifplugd
### END INIT INFO

CFG=/etc/ifplugd/ifplugd.conf

IFPLUGD=/usr/sbin/ifplugd
test -x $IFPLUGD || exit 0

if [ `id -u` != "0" ] && [ "$1" = "start" -o "$1" = "stop" ] ; then
echo "You must be root to start, stop or restart ifplugd."
exit 1
fi

[ -f $CFG ] && . $CFG

VERB="$1"
shift

[ "x$*" != "x" ] && INTERFACES="$*"

[ "x$INTERFACES" = "xauto" ] && INTERFACES="`cat /proc/net/dev | awk '{ print $1 }' | egrep '^(eth|wlan)' | cut -d: -f1`"

case "$VERB" in
start)
echo -n "Starting Network Interface Plugging Daemon:"
for IF in $INTERFACES ; do
A="`eval echo \$\{ARGS_${IF}\}`"
[ -z "$A" ] && A="$ARGS"
$IFPLUGD -i $IF $A
echo -n " $IF"
done
echo "."
;;
stop)
echo -n "Stopping Network Interface Plugging Daemon:"
for IF in $INTERFACES ; do
$IFPLUGD -k -i $IF
echo -n " $IF"
done
echo "."
;;
status)
for IF in $INTERFACES ; do
$IFPLUGD -c -i $IF
done
;;
suspend)
echo -n "Suspending Network Interface Plugging Daemon:"
for IF in $INTERFACES ; do
$IFPLUGD -S -i $IF
echo -n " $IF"
done
echo "."
;;
resume)
echo -n "Resuming Network Interface Plugging Daemon:"
for IF in $INTERFACES ; do
$IFPLUGD -R -i $IF
echo -n " $IF"
done
echo "."
;;
force-reload|restart)
$0 stop $INTERFACES
sleep 3
$0 start $INTERFACES
;;
*)
echo "Usage: $0 {start|stop|restart|force-reload|status|suspend|resume}"
exit 1
esac

exit 0
30 changes: 30 additions & 0 deletions recipes-core/busybox/busybox-ifplugd/ifplugd.action
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/sh
# $Id: ifplugd.action 99 2004-02-08 20:17:59Z lennart $

# This file is part of ifplugd.
#
# ifplugd is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# ifplugd is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with ifplugd; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.

set -e

if [ -z "$1" ] || [ -z "$2" ] ; then
echo "Wrong arguments" > /dev/stderr
exit 1
fi

[ "$2" = "up" ] && exec /sbin/ifup $1
[ "$2" = "down" ] && exec /sbin/ifdown $1

exit 1
42 changes: 42 additions & 0 deletions recipes-core/busybox/busybox-ifplugd/ifplugd.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# -*-sh-*-
# $Id: ifplugd.conf 43 2003-09-13 11:25:11Z lennart $

# This file is part of ifplugd.
#
# ifplugd is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# ifplugd is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with ifplugd; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.

# ifplugd configuration file

# Please note that this is a bourne shell fragment sourced by the
# init script of ifplugd.

# Specify the interfaces to control here, separated by spaces.
# Ifplugd processes will be started for each of these interfaces when
# the ifplugd init script is called with the "start" argument. You may
# use the magic string "auto" to make the init script start or stop
# ifplugd processes for ALL eth and wlan interfaces that are available
# according to /proc/net/dev. Note that the list of interfaces
# appearing in /proc/net/dev may depend on which kernel modules you
# have loaded.
INTERFACES="eth0"

# Additional parameters for ifplugd.
# (Run "ifplugd -h" for further information.)
ARGS="-fIM -u0 -d0"

# Additional parameters for ifplugd for the specified interface. Note
# that $ARGS is ignored, when a variable like this is set for an
# interface
#ARGS_wlan0="-MwI -u5 -d5"
29 changes: 29 additions & 0 deletions recipes-core/busybox/busybox-ifplugd_1.0.bb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
DESCRIPTION = "ifplugd initscript and conf for busybox"
LICENSE = "GPLv2"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6"

SRC_URI = " \
file://ifplugd \
file://ifplugd.action \
file://ifplugd.conf \
"

inherit update-rc.d allarch

INITSCRIPT_NAME = "ifplugd"
INITSCRIPT_PARAMS = "defaults 30"

CONFFILES_${PN} = "${sysconfdir}/ifplugd/ifplugd.conf"

do_install_append() {
install -d ${D}${sysconfdir}/ifplugd
install -m 0644 ${WORKDIR}/ifplugd.conf ${D}${sysconfdir}/ifplugd/
install -m 0755 ${WORKDIR}/ifplugd.action ${D}${sysconfdir}/ifplugd/

install -d ${D}${sysconfdir}/init.d
install -m 0755 ${WORKDIR}/ifplugd ${D}${sysconfdir}/init.d/
}

RDEPENDS_${PN} += " \
busybox \
"
1 change: 1 addition & 0 deletions recipes-core/busybox/busybox_%.bbappend
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ SRC_URI += " \
file://syslog.cfg \
file://sysutils.cfg \
file://tftp.cfg \
file://ifplugd-dont-leak-fds.patch \
"

# We should use sh wrappers instead of links so the commands could get correct
Expand Down
19 changes: 19 additions & 0 deletions recipes-core/busybox/files/ifplugd-dont-leak-fds.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
ifplugd: Don't leak FDs.

These don't need to end up in any spawned children. Set cloexec so
they don't leak.

--- a/networking/ifplugd.c
+++ b/networking/ifplugd.c
@@ -603,9 +603,11 @@ int ifplugd_main(int argc UNUSED_PARAM,
bb_daemonize_or_rexec(DAEMON_CHDIR_ROOT, argv);

xmove_fd(xsocket(AF_INET, SOCK_DGRAM, 0), ioctl_fd);
+ close_on_exec_on(ioctl_fd);
if (opts & FLAG_MONITOR) {
int fd = create_and_bind_to_netlink(NETLINK_ROUTE, RTMGRP_LINK, 0);
xmove_fd(fd, netlink_fd);
+ close_on_exec_on(netlink_fd);
}

write_pidfile(pidfile_name);
2 changes: 2 additions & 0 deletions recipes-core/busybox/files/netutils.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ CONFIG_FEATURE_IFCONFIG_BROADCAST_PLUS=y
CONFIG_IFUPDOWN=y
CONFIG_FEATURE_IFUPDOWN_IP=y

CONFIG_IFPLUGD=y

CONFIG_NETSTAT=y
CONFIG_FEATURE_NETSTAT_WIDE=y
CONFIG_FEATURE_NETSTAT_PRG=y
1 change: 1 addition & 0 deletions recipes-core/images/xenclient-syncvm-image.bb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ IMAGE_INSTALL = "\
openssh \
wget \
sync-client \
busybox-ifplugd \
xenclient-syncvm-tweaks \
${@bb.utils.contains('DISTRO_FEATURES', 'blktap2', 'xen-tools-blktap', 'xen-tools-blktap3', d)} \
"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,4 @@ auto lo
iface lo inet loopback

auto eth0
iface eth0 inet manual

auto uivm
iface uivm inet manual

auto brinternal
iface brinternal inet manual

auto brshared
iface brshared inet manual

auto brwireless
iface brwireless inet manual

auto brbridged
iface brbridged inet dhcp

iface eth0 inet dhcp
Loading