next_free_uid

in ssh_users/libraries/user.rb [92:104]


    def next_free_uid(starting_from = 4000)
      candidate = starting_from
      existing_uids = @@allocated_uids
      (node[:passwd] || node[:etc][:passwd]).each do |username, entry|
        existing_uids << entry[:uid] unless existing_uids.include?(entry[:uid])
      end
      while existing_uids.include?(candidate) do
        candidate += 1
      end
      @@allocated_uids << candidate
      candidate
    end