/var/log/install.log
Apr 1 13:12:44 AMCHOUKI-M-C091 installd[669]: ./postinstall: <dscl_cmd> DS Error: -14009 (eDSUnknownNodeName)
Apr 1 13:12:44 AMCHOUKI-M-C091 installd[669]: ./postinstall: list: Invalid Path
Apr 1 13:12:44 AMCHOUKI-M-C091 installd[669]: ./postinstall: No jenkins user found, creating jenkins user and group
Apr 1 13:12:44 AMCHOUKI-M-C091 installd[669]: ./postinstall: ERROR: All system uids are in use!
Looking at the postinstall script the current code does the following to get a uid bellow 500 for jenkins:
uid=$(dscl . -list /Users uid | sort -nrk 2 | awk '$2 < 500 {print $2 + 1; exit 0;}')
On my OS X system I have the following uids at the beginning of the list:
499
498
252
uid will be 500 after running this command and the postinstall script will fail because of this condition:
if [ $uid -eq 500 ]; then
echo 'ERROR: All system uids are in use!'
exit 1
fi
From the above uids it is clear that jenkins could use any uids between 252 and 498. A second concern is that the command does not check if $2 + 1 is already in use.
I would like to propose the following change to find a uid for jenkins bellow 500:
uids=$(dscl . -list /Users uid | sort -nrk 2 | awk '$2 < 500 {print $2;}')
uid=0
prev_uid=500
found_uid=false
for i in $uids;
do
uid=$(($i + 1))
if [ "$uid" != "$prev" ]
then
echo "Found an available uid"
found_uid=true
break
fi
prev_uid=$i
done
if [ "$found_uid" = false ]; then
echo 'ERROR: All system uids are in use!'
exit 1
fi
Let me know if that makes sense. I tried to look for the postinstall in the git repo of jenkins but could not find it. I also created the following issue to track the resolution:
https://issues.jenkins-ci.org/browse/JENKINS-43284
Cheers
Amine