* Use getenv/useradd.
svn path=/nixos/trunk/; revision=7382
This commit is contained in:
parent
4ae268739d
commit
87e2456814
@ -66,7 +66,7 @@ import ../upstart-jobs/gather.nix {
|
|||||||
# SSH daemon.
|
# SSH daemon.
|
||||||
++ optional ["services" "sshd" "enable"]
|
++ optional ["services" "sshd" "enable"]
|
||||||
(import ../upstart-jobs/sshd.nix {
|
(import ../upstart-jobs/sshd.nix {
|
||||||
inherit (pkgs) openssh;
|
inherit (pkgs) openssh glibc pwdutils;
|
||||||
})
|
})
|
||||||
|
|
||||||
# X server.
|
# X server.
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
@ -1,4 +1,4 @@
|
|||||||
{openssh}:
|
{openssh, glibc, pwdutils}:
|
||||||
|
|
||||||
{
|
{
|
||||||
name = "sshd";
|
name = "sshd";
|
||||||
@ -10,8 +10,6 @@ start on network-interfaces/started
|
|||||||
stop on network-interfaces/stop
|
stop on network-interfaces/stop
|
||||||
|
|
||||||
start script
|
start script
|
||||||
source ${../helpers/accounts.sh}
|
|
||||||
|
|
||||||
mkdir -m 0555 -p /var/empty
|
mkdir -m 0555 -p /var/empty
|
||||||
|
|
||||||
mkdir -m 0755 -p /etc/ssh
|
mkdir -m 0755 -p /etc/ssh
|
||||||
@ -20,10 +18,10 @@ start script
|
|||||||
${openssh}/bin/ssh-keygen -t dsa -b 1024 -f /etc/ssh/ssh_host_dsa_key -N ''
|
${openssh}/bin/ssh-keygen -t dsa -b 1024 -f /etc/ssh/ssh_host_dsa_key -N ''
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! userExists sshd; then
|
if ! {glibc}/bin/getent passwd sshd > /dev/null; then
|
||||||
createUser sshd x 74 74 'SSH privilege separation user' /var/empty /noshell
|
${pwdutils}/sbin/useradd -g nogroup -d /var/empty -s /noshell \\
|
||||||
|
-c 'SSH privilege separation user' sshd
|
||||||
fi
|
fi
|
||||||
|
|
||||||
end script
|
end script
|
||||||
|
|
||||||
respawn ${openssh}/sbin/sshd -D -h /etc/ssh/ssh_host_dsa_key -f ${./sshd_config}
|
respawn ${openssh}/sbin/sshd -D -h /etc/ssh/ssh_host_dsa_key -f ${./sshd_config}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user