From edefe63680cf4542760a977ddc30108938fa6998 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Tue, 27 Jan 2009 19:28:31 +0100 Subject: [PATCH] shadow: add a prepost-action script to enable shadow passwords and create a default /etc/passwd and /etc/group file. --HG-- extra : convert_revision : 5967a67bce2b0d504b3cff502466e4ac72d3178c --- templates/shadow.prepost-action | 67 +++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 templates/shadow.prepost-action diff --git a/templates/shadow.prepost-action b/templates/shadow.prepost-action new file mode 100644 index 00000000000..b39ed5d1898 --- /dev/null +++ b/templates/shadow.prepost-action @@ -0,0 +1,67 @@ +#!/bin/sh -e + +export PATH="/bin:/sbin:/usr/bin:/usr/sbin" + +# $1 = chrootdir +# $2 = action +# $3 = pkgname +# $4 = version + +create_passwd() +{ + cat > ./etc/passwd <<_EOF +root:x:0:0:root:/root:/bin/bash +nobody:x:99:99:Unprivileged User:/dev/null:/bin/false +_EOF + echo "Created default /etc/passwd file." +} + +create_group() +{ + # Default group list as specified by LFS. + cat > ./etc/group <<_EOF +root:x:0: +bin:x:1: +sys:x:2: +kmem:x:3: +tty:x:4: +tape:x:5: +daemon:x:6: +floppy:x:7: +disk:x:8: +lp:x:9: +uucp:x:10: +audio:x:11: +video:x:12: +utmp:x:13: +usb:x:14: +cdrom:x:15: +mail:x:34: +nogroup:x:99: +users:x:1000: +_EOF + echo "Created default /etc/group file." +} + +case "$2" in +preinst) + ;; +postinst) + if [ "$1" = "NOTSET" ]; then + run_cmd="pwconv" + else + run_cmd="chroot $1 pwconv" + fi + + [ ! -f ./etc/passwd ] && create_passwd + [ ! -f ./etc/group ] && create_group + + if [ ! -f ./etc/shadow ]; then + echo "Enabling shadow passwords..." + ${run_cmd} + fi + ;; +esac + +exit 0 +