summaryrefslogtreecommitdiff
path: root/package
diff options
context:
space:
mode:
authorwbx <wbx@3c298f89-4303-0410-b956-a3cf2f4a3e73>2005-03-23 20:19:42 +0000
committerwbx <wbx@3c298f89-4303-0410-b956-a3cf2f4a3e73>2005-03-23 20:19:42 +0000
commitf0876cc261a8aab859ae9d304748e5ef19ccb95d (patch)
treea04ca2f800e790691980023d5ae310e503c502cc /package
parent4b7ec6e3964247c7b836ad27acd84bd0c04120a2 (diff)
fixup openntpd package. ntpd now starts as user ntp and
CONTROL/postinst can be executed on host and target system. idea from nbd to use IPKG_ROOTDIR git-svn-id: svn://svn.openwrt.org/openwrt/trunk/openwrt@435 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package')
-rw-r--r--package/openntpd/Makefile6
-rwxr-xr-xpackage/openntpd/ipkg/CONTROL/postinst25
-rwxr-xr-xpackage/openntpd/ipkg/etc/init.d/S49ntpd3
-rw-r--r--package/openntpd/ipkg/etc/ntpd.conf (renamed from package/openntpd/files/ntpd.conf)0
4 files changed, 31 insertions, 3 deletions
diff --git a/package/openntpd/Makefile b/package/openntpd/Makefile
index 8094e5ef7a..3f6f950377 100644
--- a/package/openntpd/Makefile
+++ b/package/openntpd/Makefile
@@ -42,6 +42,7 @@ $(PKG_BUILD_DIR)/.configured: $(PKG_BUILD_DIR)/.unpacked
--mandir=/usr/man \
--infodir=/usr/info \
--with-builtin-arc4random \
+ --with-privsep-user=ntp \
);
touch $(PKG_BUILD_DIR)/.configured
@@ -49,11 +50,10 @@ $(PKG_BUILD_DIR)/ntpd: $(PKG_BUILD_DIR)/.configured
$(MAKE) -C $(PKG_BUILD_DIR)
$(PKG_IPK): $(PKG_BUILD_DIR)/ntpd
+ mkdir -p $(PKG_IPK_DIR)/usr/sbin
+ cp -a ./ipkg/* $(PKG_IPK_DIR)/
$(SCRIPT_DIR)/make-ipkg-dir.sh $(PKG_IPK_DIR) $(PKG_NAME).control $(PKG_VERSION)-$(PKG_RELEASE) $(ARCH)
- mkdir -p $(PKG_IPK_DIR){/usr/sbin,/etc/init.d}
cp $(PKG_BUILD_DIR)/ntpd $(PKG_IPK_DIR)/usr/sbin/
- cp ./files/ntpd.conf $(PKG_IPK_DIR)/etc/
- cp ./files/S49ntpd $(PKG_IPK_DIR)/etc/init.d/
$(STRIP) $(PKG_IPK_DIR)/usr/sbin/*
mkdir -p $(PACKAGE_DIR)
$(IPKG_BUILD) $(PKG_IPK_DIR) $(PACKAGE_DIR)
diff --git a/package/openntpd/ipkg/CONTROL/postinst b/package/openntpd/ipkg/CONTROL/postinst
new file mode 100755
index 0000000000..8881116c0d
--- /dev/null
+++ b/package/openntpd/ipkg/CONTROL/postinst
@@ -0,0 +1,25 @@
+#!/bin/sh
+grep -q '^ntp[[:space:]]*123/udp' ${IPKG_INSTROOT}/etc/services 2>/dev/null
+[ $? -ne 0 ] && echo "ntp 123/udp" >>${IPKG_INSTROOT}/etc/services
+
+NU=ntp
+U=`grep "^$NU:" ${IPKG_INSTROOT}/etc/passwd 2>/dev/null | cut -d: -f3`
+if [ .$U = . ]; then
+ U=`cut -d: -f3 ${IPKG_INSTROOT}/etc/passwd 2>/dev/null | sort -n | tail -1`
+ [ .$U = . ] && U=49
+ U=`expr $U + 1`
+ [ $U -lt 50 ] && U=50
+ G=`grep "^$NU:" ${IPKG_INSTROOT}/etc/group 2>/dev/null | cut -d: -f3`
+ if [ .$G = . ]; then
+ G=`cut -d: -f3 ${IPKG_INSTROOT}/etc/group 2>/dev/null | sort -n | tail -1`
+ [ .$G = . ] && G=49
+ G=`expr $G + 1`
+ [ $G -lt 50 ] && G=50
+ fi
+ LINE="$NU:x:$U:$G::/tmp/.ntp:/bin/false"
+ echo "$LINE" >>${IPKG_INSTROOT}/etc/passwd
+else
+ awk -F: '{ if($1=="ntp") printf("%s:%s:%s:%s:%s:/tmp/.ntp:/bin/false\n",$1,$2,$3,$4,$5); else print $0 }' ${IPKG_INSTROOT}/etc/passwd >/tmp/$$
+ mv /tmp/$$ ${IPKG_INSTROOT}/etc/passwd
+ chmod 644 ${IPKG_INSTROOT}/etc/passwd
+fi
diff --git a/package/openntpd/ipkg/etc/init.d/S49ntpd b/package/openntpd/ipkg/etc/init.d/S49ntpd
new file mode 100755
index 0000000000..e528748780
--- /dev/null
+++ b/package/openntpd/ipkg/etc/init.d/S49ntpd
@@ -0,0 +1,3 @@
+#!/bin/sh
+mkdir -p `grep "^ntp:" /etc/passwd | cut -d: -f6`
+/usr/sbin/ntpd -s
diff --git a/package/openntpd/files/ntpd.conf b/package/openntpd/ipkg/etc/ntpd.conf
index 6993b8eba2..6993b8eba2 100644
--- a/package/openntpd/files/ntpd.conf
+++ b/package/openntpd/ipkg/etc/ntpd.conf