mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-19 04:03:56 +00:00
* Helper script to check for and create accounts.
svn path=/nixos/trunk/; revision=7171
This commit is contained in:
parent
79464e0d9c
commit
ec764b7c08
@ -26,6 +26,7 @@ if test -n "$grubDevice"; then
|
||||
$grub/sbin/grub-install "$grubDevice" --no-floppy --recheck
|
||||
fi
|
||||
fi
|
||||
sync
|
||||
EOF
|
||||
|
||||
chmod +x $out/bin/switch-to-configuration
|
||||
|
20
helpers/accounts.sh
Normal file
20
helpers/accounts.sh
Normal file
@ -0,0 +1,20 @@
|
||||
userExists() {
|
||||
local name="$1"
|
||||
if id -u "$name" > /dev/null 2>&1; then
|
||||
return 0 # true
|
||||
else
|
||||
return 1 # false
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
createUser() {
|
||||
local name="$1"
|
||||
local password="$2"
|
||||
local uid="$3"
|
||||
local gid="$4"
|
||||
local gecos="$5"
|
||||
local homedir="$6"
|
||||
local shell="$7"
|
||||
echo "$name:$password:$uid:$gid:$gecos:$homedir:$shell" >> /etc/passwd
|
||||
}
|
@ -10,6 +10,8 @@ start on network-interfaces/started
|
||||
stop on network-interfaces/stop
|
||||
|
||||
start script
|
||||
source ${../helpers/accounts.sh}
|
||||
|
||||
mkdir -m 0555 -p /var/empty
|
||||
|
||||
mkdir -m 0755 -p /etc/ssh
|
||||
@ -20,8 +22,8 @@ start script
|
||||
${openssh}/bin/ssh-keygen -t dsa -b 1024 -f /etc/ssh/ssh_host_dsa_key -N ''
|
||||
fi
|
||||
|
||||
if ! grep -q '^sshd:' /etc/passwd; then
|
||||
echo 'sshd:x:74:74:SSH privilege separation user:/var/empty:/noshell' >> /etc/passwd
|
||||
if ! userExists sshd; then
|
||||
createUser sshd x 74 74 'SSH privilege separation user' /var/empty /noshell
|
||||
fi
|
||||
|
||||
end script
|
||||
|
Loading…
Reference in New Issue
Block a user