From bf499256df48dad291ec8b66fbadb303bb4646f9 Mon Sep 17 00:00:00 2001 From: "T. R. Bernstein" <137705289+trbernstein@users.noreply.github.com> Date: Mon, 6 Jan 2025 06:18:07 +0100 Subject: [PATCH] Use sysadminctl new boundaries for User ID --- modules/04-install-brew.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/04-install-brew.sh b/modules/04-install-brew.sh index 8fbea64..674d5fe 100755 --- a/modules/04-install-brew.sh +++ b/modules/04-install-brew.sh @@ -36,12 +36,15 @@ function ensureUserCanRunPasswordlessSudo() { } function getFirstFreeRoleAccountID() { - dscl . -list '/Users' UniqueID | grep '_.*' | sort -n -k2 | awk -v i=401 '$2>200 && $2<401 {if(i < $2) { print i; nextfile} else i=$2+1;}' + local minUserID=450 + local maxUserID=499 + dscl . -list '/Users' UniqueID | grep '_.*' | sort -n -k2 | awk -v i=${minUserID} '$2>='${minUserID}' && $2<'${maxUserID}' {if(i < $2) { print i; nextfile} else i=$2+1;} END {if(i <= '${maxUserID}' && ($2 < '${minUserID}' || $2 > '${maxUserID}')) print i;}' } function createHomebrewUser() { local username=$1 local userID=`getFirstFreeRoleAccountID` + [[ -n $userID ]] || return 10 sysadminctl -addUser "${username}" -fullName "Homebrew User" -shell /usr/bin/false -home '/var/empty' -roleAccount -UID "${userID}" > /dev/null 2>&1 }