Fix for OS X postinstall script uid

15 views
Skip to first unread message

amine choukir

unread,
Apr 2, 2017, 5:04:24 AM4/2/17
to Jenkins Developers
Hello,

While installing jenkins-2.46.1 I encountered the following error:

/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

Daniel Beck

unread,
Apr 2, 2017, 4:49:17 PM4/2/17
to jenkin...@googlegroups.com

> On 02.04.2017, at 11:04, amine choukir <amch...@gmail.com> wrote:
>
> e. I tried to look for the postinstall in the git repo of jenkins but could not find it.

It's in https://github.com/jenkinsci/packaging (also the name of the Jira component to use)

amine choukir

unread,
Apr 3, 2017, 3:51:28 AM4/3/17
to Jenkins Developers, m...@beckweb.net
Thanks Daniel!!

I submitted the pull request:

Reply all
Reply to author
Forward
0 new messages