a6508b3cd52a041a6b47c7ecc2e94568df53abc0
[tprouty/samba.git] / testsuite / nsswitch / getgrgid.exp
1 #
2 # @(#) Test reverse lookup of group ids from getent match getgrgid() output
3 #
4
5 load_lib util-defs.exp
6 load_lib "$srcdir/config/env.exp"
7 load_lib "$srcdir/config/default-nt-names.exp"
8
9 # Compile getpwuid.c
10
11 set output [target_compile "$srcdir/$subdir/getgrgid.c" \
12         "$srcdir/$subdir/getgrgid" executable {additional_flags="-g"}]
13
14 if {$output != ""} {
15     perror "compile getgrgid"
16     puts $output
17     return
18 }
19
20 # Get list of uids using getent
21
22 set output [util_start "getent" "group" ""]
23 set got_entries 0
24
25 foreach {line} [split $output "\n"] {
26
27     # Process user
28
29     set grp_entry [split $line ":"]
30     set group [lindex $grp_entry 0]
31
32     if {[regexp "^($domain)/" $group]} {
33
34         set got_entries 1
35
36         # Only lookup winbindd users
37
38         set gid [lindex $grp_entry 2]
39
40         # Test lookup of gid succeeds
41
42         set output [util_start "$srcdir/$subdir/getgrgid" "$gid" ""]
43         if {[regexp "PASS:" $output]} {
44             pass "getgrgid $gid ($group)"
45         } else {
46             fail "getgrgid $gid ($group)"
47         }            
48     }
49
50 }
51
52 if {!$got_entries} {
53     perror "No domain groups returned from getent"
54 }