Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-43284

Fix for OS X postinstall script uid

XMLWordPrintable

      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;}')
          echo "uids: $uids"
          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.

            Unassigned Unassigned
            amchoukir Amine Choukir
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: