1
0
Fork 0
mirror of https://github.com/LnL7/nix-darwin.git synced 2024-12-14 11:57:34 +00:00

users: use lib.escapeShellArg for sysadminctl -deleteUser

This commit is contained in:
Michael Hoang 2024-10-22 07:05:10 +11:00
parent 9a6b12b9ef
commit cb2e5fa6c5
2 changed files with 6 additions and 6 deletions

View file

@ -150,7 +150,7 @@ in
u=$(id -u ${lib.escapeShellArg v.name} 2> /dev/null) || true
if [[ "$u" -eq ${toString v.uid} ]]; then
echo "deleting user ${v.name}..." >&2
sysadminctl -deleteUser '${v.name}' 2> /dev/null
sysadminctl -deleteUser ${lib.escapeShellArg v.name} 2> /dev/null
else
echo "warning: existing user '${v.name}' has unexpected uid $u, skipping..." >&2
fi
@ -181,7 +181,7 @@ in
if [ -n "$u" ]; then
if [ "$u" -gt 501 ]; then
echo "deleting user ${name}..." >&2
sysadminctl -deleteUser '${name}' 2> /dev/null
sysadminctl -deleteUser ${lib.escapeShellArg name} 2> /dev/null
else
echo "warning: existing user '${name}' has unexpected uid $u, skipping..." >&2
fi

View file

@ -46,19 +46,19 @@
grep -zoP "sysadminctl -addUser 'foo' (.|\n)* -UID 42000 (.|\n)* -GID 42000 (.|\n)* -fullName 'Foo user' (.|\n)* -home '/Users/foo' (.|\n)* -shell ${lib.escapeShellArg "/run/current-system/sw/bin/bash"}" ${config.out}/activate
grep "createhomedir -cu 'foo'" ${config.out}/activate
grep -zoP "sysadminctl -addUser 'created.user' (.|\n)* -UID 42001 (.|\n)* -shell ${lib.escapeShellArg "/sbin/nologin"}" ${config.out}/activate
grep -qv "sysadminctl -deleteUser 'created.user'" ${config.out}/activate
grep -qv "sysadminctl -deleteUser 'created.user'" ${config.out}/activate
grep -qv "sysadminctl -deleteUser ${lib.escapeShellArg "created.user"}" ${config.out}/activate
grep -qv "sysadminctl -deleteUser ${lib.escapeShellArg "created.user"}" ${config.out}/activate
# checking user properties always get updated in /activate
grep "dscl . -create '/Users/foo' UserShell ${lib.escapeShellArg "/run/current-system/sw/bin/bash"}" ${config.out}/activate
# checking user deletion in /activate
grep "sysadminctl -deleteUser 'deleted.user'" ${config.out}/activate
grep "sysadminctl -deleteUser ${lib.escapeShellArg "deleted.user"}" ${config.out}/activate
grep -qv "sysadminctl -addUser 'deleted.user'" ${config.out}/activate
# checking unknown user in /activate
grep -qv "sysadminctl -addUser 'unknown.user'" ${config.out}/activate
grep -qv "sysadminctl -deleteUser 'unknown.user'" ${config.out}/activate
grep -qv "sysadminctl -deleteUser ${lib.escapeShellArg "unknown.user"}" ${config.out}/activate
set +v
'';