busybox: Install S41inetd and inetd.conf if inetd is enabled in busybox.
PATCH v2 1/1 busybox: Install S41inetd and inetd.conf if inetd is enabled in busybox.
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.
--- 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
package/busybox/S41inetd new file +28 -0
@@ -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 $? +
package/busybox/busybox.mk +32 -0
@@ -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
package/busybox/inetd.conf new file +3 -0
@@ -0,0 +1,3 @@ +# <service_name> <sock_type> <proto> <flags> <user> <server_path> <args> +# +
Signature · 1 line
1.7.1
PATCH v2 1/1 busybox: Install S41inetd and inetd.conf if inetd is enabled in busybox.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Kelvin" == Kelvin Cheung <[email protected]> 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 <[email protected]> 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.
Signature · 1 line
Bye, Peter Korsgaard
PATCH v2 1/1 busybox: Install S41inetd and inetd.conf if inetd is enabled in busybox.
2012/5/29 Peter Korsgaard <[email protected]>
Quoted 9 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Kelvin" == Kelvin Cheung <[email protected]> writes:
Hi,
Kelvin> Install S41inetd and inetd.conf if inetd is enabled in busybox. Kelvin> Add ftpd to
/etc/inetd.confif inetd and ftpd are enabled. Kelvin> Add telnetd to/etc/inetd.confif inetd and telnetd are enabled. Kelvin> Add tftpd to/etc/inetd.confif inetd and tftpd are enabled.
Quoted 7 lines
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.
Quoted 31 lines
Kelvin> Signed-off-by: Kelvin Cheung <[email protected]> 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.confKelvin> 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"
Quoted 4 lines
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.
Quoted 40 lines
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 --gita/package/busybox/busybox.mkb/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 @@ defineBUSYBOX_INSTALL_WATCHDOG_SCRIPTKelvin> endef
Kelvin> endifKelvin> +define
BUSYBOX_INSTALL_INETD_SCRIPT
Kelvin> + if grep -qCONFIG_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> +defineBUSYBOX_INSTALL_INETD_CONF
Kelvin> + if grep -qCONFIG_INETD=y$(@D)/.config; then \
Quoted 3 lines
It would imho be better to merge
INETD_SCRIPTandINETD_CONFhandling so we don't need to check if inetd is enabled twice.
Maybe it is better to keep them seperately like mdev did.
Quoted 39 lines
Kelvin> + [ -f $(TARGET_DIR)/etc/inetd.conf ] || \
Kelvin> + install -D -m 0644package/busybox/inetd.conf\
Kelvin> + $(TARGET_DIR)/etc/inetd.conf; \
Kelvin> + if grep -qCONFIG_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 -qCONFIG_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 -qCONFIG_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; \
Quoted 5 lines
Same here.
Maybe
/etc/inetd.confcontent 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.
Quoted 4 lines
--
Bye, Peter Korsgaard
Signature · 5 lines
Best Regards! Kelvin -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20120529/d295eb21/attachment.html>