2 # @
(#
) Test operation of WINBINDD_DOMAIN environment
variable
5 load_lib
"util-defs.exp"
6 load_lib
"$srcdir/lib/nsswitch-config.exp"
9 # @
(#
) Test that there is at least one domain user and domain group
10 # @
(#
) in the output of getent passwd and getent group.
13 #
Get list of users and groups
15 set user_list
[util_start
"getent passwd"]
16 set group_list
[util_start
"getent group"]
18 verbose
"user list is:\n$user_list"
19 verbose
"group list is:\n$group_list"
21 # Check
for domain users
25 if { ![regexp
"$domain/" $user_list] } {
26 fail
"no domain users in getent"
30 # Check
for domain groups
32 if { ![regexp
"$domain/" $group_list] } {
33 fail
"no domain groups in getent group"
42 # @
(#
) Check
for "leakage" between different domains using the
43 # @
(#
) WINBINDD_DOMAIN environment
variable.
46 verbose
"Domain is $domain"
48 set output
[util_start
"bin/wbinfo" "-m"]
49 verbose
"Trusted domains are $output"
50 set trusted_domain_list
[split $output
"\n"]
52 # Test simple inclusion by setting $WINBINDD_DOMAIN to each trusted domain
53 # in turn and checking there are no users
/groups from other domains in the
56 set domain_list $trusted_domain_list
57 lappend domain_list $domain
59 foreach
{ the_domain
} $domain_list
{
61 set env
(WINBINDD_DOMAIN
) $the_domain
63 set user_out
[util_start
"getent passwd"]
64 set group_out
[util_start
"getent group"]
66 verbose
"users in $the_domain:\n$user_out\n"
67 verbose
"groups in $the_domain:\n$group_out\n"
71 set test_desc
"users in WINBINDD_DOMAIN $the_domain"
74 foreach
{ user
} [split $user_out
"\n"] {
75 set user_name
[lindex
[split $user
":"] 0]
76 if { [regexp
"/" $user_name] && ![regexp $the_domain $user_name]} {
89 set test_desc
"groups in WINBINDD_DOMAIN $the_domain"
92 foreach
{ group
} [split $group_out
"\n"] {
93 set group_name
[lindex
[split $group
":"] 0]
94 if { [regexp
"/" $group_name] && ![regexp $the_domain $group_name]} {
107 # @
(#
) Test inclusion of a dummy domain doesn
't generate users/groups
108 # @(#) from that domain.
111 set env(WINBINDD_DOMAIN) "asmithee"
112 set user_out [util_start "getent passwd"]
113 set group_out [util_start "getent group"]
117 set test_desc "users in different WINBINDD_DOMAIN"
118 if { [regexp $domain $user_out] } {
126 set test_desc "groups in different WINBINDD_DOMAIN"
127 if { [regexp $domain $group_out] } {
134 # @(#) Test comma separated inclusion of dummy domain doesn't generate
135 # @
(#
) users
/groups in the dummy domain.
138 foreach
{ the_domain
} $domain_list
{
139 set env
(WINBINDD_DOMAIN
) "$the_domain,asmithee"
140 set user_out
[util_start
"getent passwd"]
141 set group_out
[util_start
"getent group"]
143 verbose
"users in $the_domain:\n$user_out\n"
144 verbose
"groups in $the_domain:\n$group_out\n"
148 set test_desc
"users in comma separated WINBINDD_DOMAIN $the_domain"
151 foreach
{ user
} [split $user_out
"\n"] {
152 set user_name
[lindex
[split $user
":"] 0]
153 if { [regexp
"/" $user_name] && ![regexp $the_domain $user_name]} {
166 set test_desc
"groups in comma separated WINBINDD_DOMAIN $the_domain"
169 foreach
{ group
} [split $group_out
"\n"] {
170 set group_name
[lindex
[split $group
":"] 0]
171 if { [regexp
"/" $group_name] && ![regexp $the_domain $group_name]} {
184 # @
(#
) Test two comma separated dummy domains
do not generate
any domain
185 # @
(#
) users or groups.
188 foreach
{ the_domain
} $domain_list
{
190 set env
(WINBINDD_DOMAIN
) "moose,asmithee"
191 set user_out
[util_start
"getent passwd"]
192 set group_out
[util_start
"getent group"]
194 verbose
"users in $the_domain:\n$user_out\n"
195 verbose
"groups in $the_domain:\n$group_out\n"
199 set test_desc
"users in comma separated invalid WINBINDD_DOMAIN"
200 if { [regexp $the_domain $user_out
] } {
208 set test_desc
"groups in comma separated invalid WINBINDD_DOMAIN"
209 if { [regexp $the_domain $group_out
] } {
216 set env
(WINBINDD_DOMAIN
) ""
219 # @
(#
) Test _NO_WINBINDD doesn
't return any domain users or groups
222 set env(_NO_WINBINDD) "1"
223 set user_out [util_start "getent passwd"]
224 set group_out [util_start "getent group"]
226 verbose "users with _NO_WINBINDD:\n$user_out\n"
227 verbose "groups with _NO_WINBINDD:\n$group_out\n"
229 foreach { the_domain } $domain_list {
233 set test_desc "users found with _NO_WINBINDD environment variable set"
234 if { [regexp $the_domain $user_out] } {
242 set test_desc "groups found with _NO_WINBINDD environment variable set"
243 if { [regexp $the_domain $group_out] } {
250 # Unset _NO_WINBINDD and make sure everything still works
252 unset env(_NO_WINBINDD)
254 set user_out [util_start "getent passwd"]
255 set group_out [util_start "getent group"]
257 verbose "users with _NO_WINBINDD unset:\n$user_out\n"
258 verbose "groups with _NO_WINBINDD unset:\n$group_out\n"
262 set test_desc "no users found with _NO_WINBINDD environment variable set"
263 if { $user_out != $user_list } {
271 set test_desc "no groups found with _NO_WINBINDD environment variable set"
272 if { $group_out != $group_list } {
278 # Make sure we unset the environment vars so we don't cause subsequent tests
281 catch
{ unset env
(WINBINDD_DOMAIN
) } tmp
282 catch
{ unset env
(_NO_WINBINDD
) } tmp