summaryrefslogtreecommitdiff
path: root/test/integration/targets/group/files/get_free_gid.py
blob: 4c07b5e3bc4ee701c4fcb478e07abe8c44ceab9d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

from __future__ import (absolute_import, division, print_function)
__metaclass__ = type

import grp


def main():
    gids = [g.gr_gid for g in grp.getgrall()]

    # Start the gid numbering with 1
    # FreeBSD doesn't support the usage of gid 0, it doesn't fail (rc=0) but instead a number in the normal
    # range is picked.
    i = 1
    while True:
        if i not in gids:
            print(i)
            break
        i += 1


if __name__ == '__main__':
    main()