Message ID | 1338190882-4548-1-git-send-email-keguang.zhang@gmail.com |
---|---|
State | Superseded |
Headers | show |
>>>>> "Kelvin" == Kelvin Cheung <keguang.zhang@gmail.com> writes:
Hi,
Kelvin> Install S41inetd and inetd.conf if inetd is enabled in busybox.
Kelvin> Add ftpd to /etc/inetd.conf if inetd and ftpd are enabled.
Kelvin> Add telnetd to /etc/inetd.conf if inetd and telnetd are enabled.
Kelvin> Add tftpd to /etc/inetd.conf if inetd and tftpd are enabled.
Kelvin> Changes for v2:
Kelvin> Update ftpd and tftpd configuration in inetd.conf.
These changes should go after the '---' line, otherwise they get
included in the commit message.
Kelvin> Signed-off-by: Kelvin Cheung <keguang.zhang@gmail.com>
Kelvin> ---
Kelvin> package/busybox/S41inetd | 28 ++++++++++++++++++++++++++++
Kelvin> package/busybox/busybox.mk | 32 ++++++++++++++++++++++++++++++++
Kelvin> package/busybox/inetd.conf | 3 +++
Kelvin> 3 files changed, 63 insertions(+), 0 deletions(-)
Kelvin> create mode 100644 package/busybox/S41inetd
Kelvin> create mode 100644 package/busybox/inetd.conf
Kelvin> diff --git a/package/busybox/S41inetd b/package/busybox/S41inetd
Kelvin> new file mode 100644
Kelvin> index 0000000..9d7d3cd
Kelvin> --- /dev/null
Kelvin> +++ b/package/busybox/S41inetd
Kelvin> @@ -0,0 +1,28 @@
Kelvin> +#!/bin/sh
Kelvin> +#
Kelvin> +# Starts the inetd daemon.
Kelvin> +#
Kelvin> +
Kelvin> +NAME=inetd
Kelvin> +DAEMON=/usr/sbin/$NAME
Kelvin> +
Kelvin> +case "$1" in
Kelvin> + start)
Kelvin> + echo -n "Starting $NAME: "
Kelvin> + start-stop-daemon -S -q -x $DAEMON && echo "OK" || echo "Failed"
Minor nit - We typically use the '-m -p /var/run/$NAME.pid' options to
get ssd to create/use a pidfile. If you do that, then you need to stop
inetd from forking into the background with -f.
Kelvin> + ;;
Kelvin> + stop)
Kelvin> + echo -n "Stopping $NAME: "
Kelvin> + start-stop-daemon -K -q -n $NAME && echo "OK" || echo "Failed"
Kelvin> + ;;
Kelvin> + restart|reload)
Kelvin> + $0 stop
Kelvin> + $0 start
Kelvin> + ;;
Kelvin> + *)
Kelvin> + echo $"Usage: $0 {start|stop|restart}"
Kelvin> + exit 1
Kelvin> +esac
Kelvin> +
Kelvin> +exit $?
Kelvin> +
Kelvin> diff --git a/package/busybox/busybox.mk b/package/busybox/busybox.mk
Kelvin> index 1d988f8..4ddd552 100644
Kelvin> --- a/package/busybox/busybox.mk
Kelvin> +++ b/package/busybox/busybox.mk
Kelvin> @@ -155,6 +155,36 @@ define BUSYBOX_INSTALL_WATCHDOG_SCRIPT
Kelvin> endef
Kelvin> endif
Kelvin> +define BUSYBOX_INSTALL_INETD_SCRIPT
Kelvin> + if grep -q CONFIG_INETD=y $(@D)/.config; then \
Kelvin> + [ -f $(TARGET_DIR)/etc/init.d/S41inetd ] || \
Kelvin> + $(INSTALL) -m 0755 -D package/busybox/S41inetd \
Kelvin> + $(TARGET_DIR)/etc/init.d/S41inetd; \
Kelvin> + else rm -f $(TARGET_DIR)/etc/init.d/S41inetd; fi
Kelvin> +endef
Kelvin> +define BUSYBOX_INSTALL_INETD_CONF
Kelvin> + if grep -q CONFIG_INETD=y $(@D)/.config; then \
It would imho be better to merge INETD_SCRIPT and INETD_CONF handling so
we don't need to check if inetd is enabled twice.
Kelvin> + [ -f $(TARGET_DIR)/etc/inetd.conf ] || \
Kelvin> + install -D -m 0644 package/busybox/inetd.conf \
Kelvin> + $(TARGET_DIR)/etc/inetd.conf; \
Kelvin> + if grep -q CONFIG_FTPD=y $(@D)/.config; then \
Kelvin> + if ! grep -q '^ftp' $(TARGET_DIR)/etc/inetd.conf; then \
Kelvin> + echo -e "ftp\tstream\ttcp\tnowait\troot\tftpd\tftpd -w /root" >> $(TARGET_DIR)/etc/inetd.conf; \
Giving writable root permissions by default doesn't really sound right
to me.
Kelvin> + fi; \
Kelvin> + else $(SED) '/^ftp/d' $(TARGET_DIR)/etc/inetd.conf; fi; \
Kelvin> + if grep -q CONFIG_TELNETD=y $(@D)/.config; then \
Kelvin> + if ! grep -q '^telnet' $(TARGET_DIR)/etc/inetd.conf; then \
Kelvin> + echo -e "telnet\tstream\ttcp\tnowait\troot\ttelnetd\ttelnetd -i" >> $(TARGET_DIR)/etc/inetd.conf; \
Kelvin> + fi; \
Kelvin> + else $(SED) '/^telnet/d' $(TARGET_DIR)/etc/inetd.conf; fi; \
Kelvin> + if grep -q CONFIG_TFTPD=y $(@D)/.config; then \
Kelvin> + if ! grep -q '^tftp' $(TARGET_DIR)/etc/inetd.conf; then \
Kelvin> + echo -e "tftp\tdgram\tudp\tnowait\troot\ttftpd\ttftpd -l -c /root" >> $(TARGET_DIR)/etc/inetd.conf; \
Same here.
Maybe /etc/inetd.conf content is too hard to provide a good default for,
and we should just stick to the init script + an empty inetd.conf.
2012/5/29 Peter Korsgaard <jacmet@uclibc.org> > >>>>> "Kelvin" == Kelvin Cheung <keguang.zhang@gmail.com> writes: > > Hi, > > Kelvin> Install S41inetd and inetd.conf if inetd is enabled in busybox. > Kelvin> Add ftpd to /etc/inetd.conf if inetd and ftpd are enabled. > Kelvin> Add telnetd to /etc/inetd.conf if inetd and telnetd are enabled. > Kelvin> Add tftpd to /etc/inetd.conf if inetd and tftpd are enabled. > > Kelvin> Changes for v2: > Kelvin> Update ftpd and tftpd configuration in inetd.conf. > > These changes should go after the '---' line, otherwise they get > included in the commit message. > > This will be fixed in next version. > > Kelvin> Signed-off-by: Kelvin Cheung <keguang.zhang@gmail.com> > Kelvin> --- > Kelvin> package/busybox/S41inetd | 28 ++++++++++++++++++++++++++++ > Kelvin> package/busybox/busybox.mk | 32 > ++++++++++++++++++++++++++++++++ > Kelvin> package/busybox/inetd.conf | 3 +++ > Kelvin> 3 files changed, 63 insertions(+), 0 deletions(-) > Kelvin> create mode 100644 package/busybox/S41inetd > Kelvin> create mode 100644 package/busybox/inetd.conf > > Kelvin> diff --git a/package/busybox/S41inetd b/package/busybox/S41inetd > Kelvin> new file mode 100644 > Kelvin> index 0000000..9d7d3cd > Kelvin> --- /dev/null > Kelvin> +++ b/package/busybox/S41inetd > Kelvin> @@ -0,0 +1,28 @@ > Kelvin> +#!/bin/sh > Kelvin> +# > Kelvin> +# Starts the inetd daemon. > Kelvin> +# > Kelvin> + > Kelvin> +NAME=inetd > Kelvin> +DAEMON=/usr/sbin/$NAME > Kelvin> + > Kelvin> +case "$1" in > Kelvin> + start) > Kelvin> + echo -n "Starting $NAME: " > Kelvin> + start-stop-daemon -S -q -x $DAEMON && echo "OK" || echo > "Failed" > > Minor nit - We typically use the '-m -p /var/run/$NAME.pid' options to > get ssd to create/use a pidfile. If you do that, then you need to stop > inetd from forking into the background with -f. > This will be fixed in next version. > > Kelvin> + ;; > Kelvin> + stop) > Kelvin> + echo -n "Stopping $NAME: " > Kelvin> + start-stop-daemon -K -q -n $NAME && echo "OK" || echo > "Failed" > Kelvin> + ;; > Kelvin> + restart|reload) > Kelvin> + $0 stop > Kelvin> + $0 start > Kelvin> + ;; > Kelvin> + *) > Kelvin> + echo $"Usage: $0 {start|stop|restart}" > Kelvin> + exit 1 > Kelvin> +esac > Kelvin> + > Kelvin> +exit $? > Kelvin> + > Kelvin> diff --git a/package/busybox/busybox.mk b/package/busybox/ > busybox.mk > Kelvin> index 1d988f8..4ddd552 100644 > Kelvin> --- a/package/busybox/busybox.mk > Kelvin> +++ b/package/busybox/busybox.mk > Kelvin> @@ -155,6 +155,36 @@ define BUSYBOX_INSTALL_WATCHDOG_SCRIPT > Kelvin> endef > Kelvin> endif > > Kelvin> +define BUSYBOX_INSTALL_INETD_SCRIPT > Kelvin> + if grep -q CONFIG_INETD=y $(@D)/.config; then \ > Kelvin> + [ -f $(TARGET_DIR)/etc/init.d/S41inetd ] || \ > Kelvin> + $(INSTALL) -m 0755 -D > package/busybox/S41inetd \ > Kelvin> + $(TARGET_DIR)/etc/init.d/S41inetd; > \ > Kelvin> + else rm -f $(TARGET_DIR)/etc/init.d/S41inetd; fi > Kelvin> +endef > Kelvin> +define BUSYBOX_INSTALL_INETD_CONF > Kelvin> + if grep -q CONFIG_INETD=y $(@D)/.config; then \ > > > It would imho be better to merge INETD_SCRIPT and INETD_CONF handling so > we don't need to check if inetd is enabled twice. > Maybe it is better to keep them seperately like mdev did. > > Kelvin> + [ -f $(TARGET_DIR)/etc/inetd.conf ] || \ > Kelvin> + install -D -m 0644 > package/busybox/inetd.conf \ > Kelvin> + $(TARGET_DIR)/etc/inetd.conf; \ > Kelvin> + if grep -q CONFIG_FTPD=y $(@D)/.config; then \ > Kelvin> + if ! grep -q '^ftp' > $(TARGET_DIR)/etc/inetd.conf; then \ > Kelvin> + echo -e > "ftp\tstream\ttcp\tnowait\troot\tftpd\tftpd -w /root" >> > $(TARGET_DIR)/etc/inetd.conf; \ > > > Giving writable root permissions by default doesn't really sound right > to me. > > > Kelvin> + fi; \ > Kelvin> + else $(SED) '/^ftp/d' > $(TARGET_DIR)/etc/inetd.conf; fi; \ > Kelvin> + if grep -q CONFIG_TELNETD=y $(@D)/.config; then \ > Kelvin> + if ! grep -q '^telnet' > $(TARGET_DIR)/etc/inetd.conf; then \ > Kelvin> + echo -e > "telnet\tstream\ttcp\tnowait\troot\ttelnetd\ttelnetd -i" >> > $(TARGET_DIR)/etc/inetd.conf; \ > Kelvin> + fi; \ > Kelvin> + else $(SED) '/^telnet/d' > $(TARGET_DIR)/etc/inetd.conf; fi; \ > Kelvin> + if grep -q CONFIG_TFTPD=y $(@D)/.config; then \ > Kelvin> + if ! grep -q '^tftp' > $(TARGET_DIR)/etc/inetd.conf; then \ > Kelvin> + echo -e > "tftp\tdgram\tudp\tnowait\troot\ttftpd\ttftpd -l -c /root" >> > $(TARGET_DIR)/etc/inetd.conf; \ > > > Same here. > > Maybe /etc/inetd.conf content is too hard to provide a good default for, > and we should just stick to the init script + an empty inetd.conf. > Yes, exactly. Maybe we could provide examples instead of configurations. And let the users decide how to configure the ftp and tftp service. > > -- > Bye, Peter Korsgaard >
diff --git a/package/busybox/S41inetd b/package/busybox/S41inetd new file mode 100644 index 0000000..9d7d3cd --- /dev/null +++ b/package/busybox/S41inetd @@ -0,0 +1,28 @@ +#!/bin/sh +# +# Starts the inetd daemon. +# + +NAME=inetd +DAEMON=/usr/sbin/$NAME + +case "$1" in + start) + echo -n "Starting $NAME: " + start-stop-daemon -S -q -x $DAEMON && echo "OK" || echo "Failed" + ;; + stop) + echo -n "Stopping $NAME: " + start-stop-daemon -K -q -n $NAME && echo "OK" || echo "Failed" + ;; + restart|reload) + $0 stop + $0 start + ;; + *) + echo $"Usage: $0 {start|stop|restart}" + exit 1 +esac + +exit $? + diff --git a/package/busybox/busybox.mk b/package/busybox/busybox.mk index 1d988f8..4ddd552 100644 --- a/package/busybox/busybox.mk +++ b/package/busybox/busybox.mk @@ -155,6 +155,36 @@ define BUSYBOX_INSTALL_WATCHDOG_SCRIPT endef endif +define BUSYBOX_INSTALL_INETD_SCRIPT + if grep -q CONFIG_INETD=y $(@D)/.config; then \ + [ -f $(TARGET_DIR)/etc/init.d/S41inetd ] || \ + $(INSTALL) -m 0755 -D package/busybox/S41inetd \ + $(TARGET_DIR)/etc/init.d/S41inetd; \ + else rm -f $(TARGET_DIR)/etc/init.d/S41inetd; fi +endef +define BUSYBOX_INSTALL_INETD_CONF + if grep -q CONFIG_INETD=y $(@D)/.config; then \ + [ -f $(TARGET_DIR)/etc/inetd.conf ] || \ + install -D -m 0644 package/busybox/inetd.conf \ + $(TARGET_DIR)/etc/inetd.conf; \ + if grep -q CONFIG_FTPD=y $(@D)/.config; then \ + if ! grep -q '^ftp' $(TARGET_DIR)/etc/inetd.conf; then \ + echo -e "ftp\tstream\ttcp\tnowait\troot\tftpd\tftpd -w /root" >> $(TARGET_DIR)/etc/inetd.conf; \ + fi; \ + else $(SED) '/^ftp/d' $(TARGET_DIR)/etc/inetd.conf; fi; \ + if grep -q CONFIG_TELNETD=y $(@D)/.config; then \ + if ! grep -q '^telnet' $(TARGET_DIR)/etc/inetd.conf; then \ + echo -e "telnet\tstream\ttcp\tnowait\troot\ttelnetd\ttelnetd -i" >> $(TARGET_DIR)/etc/inetd.conf; \ + fi; \ + else $(SED) '/^telnet/d' $(TARGET_DIR)/etc/inetd.conf; fi; \ + if grep -q CONFIG_TFTPD=y $(@D)/.config; then \ + if ! grep -q '^tftp' $(TARGET_DIR)/etc/inetd.conf; then \ + echo -e "tftp\tdgram\tudp\tnowait\troot\ttftpd\ttftpd -l -c /root" >> $(TARGET_DIR)/etc/inetd.conf; \ + fi; \ + else $(SED) '/^tftp/d' $(TARGET_DIR)/etc/inetd.conf; fi \ + else rm -f $(TARGET_DIR)/etc/inetd.conf; fi +endef + # We do this here to avoid busting a modified .config in configure BUSYBOX_POST_EXTRACT_HOOKS += BUSYBOX_COPY_CONFIG @@ -187,6 +217,8 @@ define BUSYBOX_INSTALL_TARGET_CMDS $(BUSYBOX_INSTALL_MDEV_CONF) $(BUSYBOX_INSTALL_LOGGING_SCRIPT) $(BUSYBOX_INSTALL_WATCHDOG_SCRIPT) + $(BUSYBOX_INSTALL_INETD_SCRIPT) + $(BUSYBOX_INSTALL_INETD_CONF) endef define BUSYBOX_UNINSTALL_TARGET_CMDS diff --git a/package/busybox/inetd.conf b/package/busybox/inetd.conf new file mode 100644 index 0000000..82cfa15 --- /dev/null +++ b/package/busybox/inetd.conf @@ -0,0 +1,3 @@ +# <service_name> <sock_type> <proto> <flags> <user> <server_path> <args> +# +
Install S41inetd and inetd.conf if inetd is enabled in busybox. Add ftpd to /etc/inetd.conf if inetd and ftpd are enabled. Add telnetd to /etc/inetd.conf if inetd and telnetd are enabled. Add tftpd to /etc/inetd.conf if inetd and tftpd are enabled. Changes for v2: Update ftpd and tftpd configuration in inetd.conf. Signed-off-by: Kelvin Cheung <keguang.zhang@gmail.com> --- package/busybox/S41inetd | 28 ++++++++++++++++++++++++++++ package/busybox/busybox.mk | 32 ++++++++++++++++++++++++++++++++ package/busybox/inetd.conf | 3 +++ 3 files changed, 63 insertions(+), 0 deletions(-) create mode 100644 package/busybox/S41inetd create mode 100644 package/busybox/inetd.conf