From: Nicolas Thill Date: Wed, 9 Nov 2011 23:11:43 +0000 (+0000) Subject: packages/openssh: use new service functions, move user/group creation from postinst... X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=c9ab33a8e0259d467ca614974a2f4d6c5a1447ba;p=openwrt%2Fsvn-archive%2Fpackages.git packages/openssh: use new service functions, move user/group creation from postinst to initscript SVN-Revision: 28899 --- diff --git a/net/openssh/Makefile b/net/openssh/Makefile index 05a44b9b8..19b89427e 100644 --- a/net/openssh/Makefile +++ b/net/openssh/Makefile @@ -1,5 +1,5 @@ # -# Copyright (C) 2006,2008-2011 OpenWrt.org +# Copyright (C) 2006-2011 OpenWrt.org # # This is free software, licensed under the GNU General Public License v2. # See /LICENSE for more information. @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=openssh PKG_VERSION:=5.9p1 -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=ftp://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/ \ @@ -179,23 +179,6 @@ define Package/openssh-server/install $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/sshd $(1)/usr/sbin/ endef -define Package/openssh-server/postinst -#!/bin/sh - -name=sshd -id=22 - -if [ -z "$$(grep ^\\$${name}: $${IPKG_INSTROOT}/etc/group)" ]; then - echo "adding group $$name to /etc/group" - echo "$${name}:x:$${id}:" >> $${IPKG_INSTROOT}/etc/group -fi - -if [ -z "$$(grep ^\\$${name}: $${IPKG_INSTROOT}/etc/passwd)" ]; then - echo "adding user $$name to /etc/passwd" - echo "$${name}:x:$${id}:$${id}:$${name}:/var/empty/.$${name}:/bin/false" >> $${IPKG_INSTROOT}/etc/passwd -fi -endef - define Package/openssh-sftp-client/install $(INSTALL_DIR) $(1)/usr/bin $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/sftp $(1)/usr/bin/ diff --git a/net/openssh/files/sshd.init b/net/openssh/files/sshd.init index 58b5ce720..ff66338a7 100644 --- a/net/openssh/files/sshd.init +++ b/net/openssh/files/sshd.init @@ -1,8 +1,11 @@ #!/bin/sh /etc/rc.common -# Copyright (C) 2006 OpenWrt.org +# Copyright (C) 2006-2011 OpenWrt.org + START=50 STOP=50 +SERVICE_USE_PID=1 + start() { for type in rsa dsa; do { # check for keys @@ -15,15 +18,29 @@ start() { exit 0 } }; done - mkdir -p /var/empty - chmod 0700 /var/empty - /usr/sbin/sshd + user_exists sshd 22 || user_add sshd 22 + group_exists sshd 22 || group_add ssh 22 + mkdir -m 0700 -p /var/empty + mkdir -m 0755 -p /var/run/sshd + service_start /usr/sbin/sshd } stop() { - kill $(cat /var/run/sshd.pid) + service_stop /usr/sbin/sshd } shutdown() { - killall sshd + local pid + local pids + local pid_mine + + stop + + # kill active clients + pid_mine="$$" + pids="$(pidof sshd)" + for pid in $pids; do + [ "$pid" = "$pid_mine" ] && continue + [ -e "/proc/$pid/stat" ] && kill $pid + done }