summaryrefslogtreecommitdiff
path: root/testsuite/nsswitch/getgrgid.exp
blob: c53749f26291bb198000b97b39c19522f653bb0c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#
# @(#) Test reverse lookup of group ids from getent match getgrgid() output
#

load_lib util-defs.exp
load_lib compile.exp

# Compile getgruid.c

simple_compile "getgrgid"

# Get list of gids using getent

set output [util_start "getent" "group" ""]
set got_entries 0

verbose $output

foreach {line} [split $output "\n"] {

    # Process user

    set grp_entry [split $line ":"]
    set group [lindex $grp_entry 0]

    if {[regexp {^[^/]+/} $group]} {

        set got_entries 1

        # Only lookup winbindd users

        set gid [lindex $grp_entry 2]

        # Test lookup of gid succeeds

        set output [util_start "$srcdir/$subdir/getgrgid" "$gid" ""]
	verbose $output

        if {[regexp "PASS:" $output]} {
            pass "getgrgid $gid ($group)"
        } else {
            fail "getgrgid $gid ($group)"
        }            
    }

}

if {!$got_entries} {
    perror "No domain groups returned from getent"
}