mirror of
https://github.com/LnL7/nix-darwin.git
synced 2024-08-17 00:20:44 +03:00
fix: set shell for new users, and only known ones
This commit is contained in:
parent
888533c35f
commit
f1d47fc2dd
@ -159,6 +159,9 @@ in
|
||||
|
||||
u=$(dscl . -read '/Users/${v.name}' UniqueID 2> /dev/null) || true
|
||||
u=''${u#UniqueID: }
|
||||
if [[ -n "$u" && "$u" -ne "${toString v.uid}" ]]; then
|
||||
echo "[1;31mwarning: existing user '${v.name}' has unexpected uid $u, skipping...[0m" >&2
|
||||
else
|
||||
if [ -z "$u" ]; then
|
||||
echo "creating user ${v.name}..." >&2
|
||||
dscl . -create '/Users/${v.name}' UniqueID ${toString v.uid}
|
||||
@ -167,11 +170,7 @@ in
|
||||
dscl . -create '/Users/${v.name}' RealName '${v.description}'
|
||||
dscl . -create '/Users/${v.name}' NFSHomeDirectory '${v.home}'
|
||||
${optionalString v.createHome "createhomedir -cu '${v.name}'"}
|
||||
else
|
||||
if [ "$u" -ne ${toString v.uid} ]; then
|
||||
echo "[1;31mwarning: existing user '${v.name}' has unexpected uid $u, skipping...[0m" >&2
|
||||
fi
|
||||
|
||||
# Always set the shell path, in case it was updated
|
||||
dscl . -create '/Users/${v.name}' UserShell ${lib.escapeShellArg (shellPath v.shell)}
|
||||
fi
|
||||
|
@ -16,7 +16,7 @@
|
||||
users.users.foo.isHidden = false;
|
||||
users.users.foo.home = "/Users/foo";
|
||||
users.users.foo.createHome = true;
|
||||
users.users.foo.shell = "/run/current-system/sw/bin/bash";
|
||||
users.users.foo.shell = pkgs.bashInteractive;
|
||||
|
||||
users.users."created.user".uid = 42001;
|
||||
users.users."unknown.user".uid = 42002;
|
||||
@ -48,6 +48,7 @@
|
||||
grep "dscl . -create '/Users/foo' NFSHomeDirectory '/Users/foo'" ${config.out}/activate
|
||||
grep "dscl . -create '/Users/foo' UserShell '/run/current-system/sw/bin/bash'" ${config.out}/activate
|
||||
grep "dscl . -create '/Users/created.user' UniqueID 42001" ${config.out}/activate
|
||||
grep "dscl . -create '/Users/created.user' UserShell '/sbin/nologin'" ${config.out}/activate
|
||||
grep "createhomedir -cu 'foo'" ${config.out}/activate
|
||||
grep -qv "dscl . -delete '/Groups/created.user'" ${config.out}/activate
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user