This commit was manufactured by cvs2svn to create branch 'SAMBA_3_0'.
[kai/samba.git] / testsuite / smbd / sighup.exp
1 #
2 # @(#) Check services file reloaded after SIGHUP
3 #
4
5 load_lib "util-defs.exp"
6
7 # Create a smb.conf file from a list of sections.  Each section consists of
8 # a name and a list of lines which are the contents of that section.
9 # Returns a temporary filename which must be deleted after use.
10
11 proc write_smb_conf { args } {
12
13     # Set up temporary file
14
15     set name "/tmp/smb.conf-test-[pid]"
16     set f [open $name "w"]
17
18     # Parse sections
19
20     foreach section [lindex $args 0] {
21         set secname [lindex $section 0]
22         set contents [lindex $section 1]
23         
24         puts $f "\[$secname]"
25
26         foreach { line } $contents {
27             puts $f "\t$line"
28         }
29
30         puts $f ""
31     }
32
33     close $f
34
35     # Return filename of smb.conf file
36
37     return $name
38 }
39
40 proc append_smb_conf { args } {
41     
42     set name [lindex $args 0]
43     set f [open $name "a"]
44     
45     foreach section [lindex $args 1] {
46         set secname [lindex $section 0]
47         set contents [lindex $section 1]
48         
49         puts $f "\[$secname]"
50
51         foreach { line } $contents {
52             puts $f "\t$line"
53         }
54
55         puts $f ""
56     }
57
58     close $f
59 }
60
61 # Create a smb.conf file
62
63 set smb_conf [list \
64         [list "global" \
65             [list "netbios name = testing" \
66                   "guest ok = true"]]]
67
68 set name [write_smb_conf $smb_conf]
69
70 # Run smbd and smbclient output
71
72 set smbd_output [util_start "bin/smbd" "-s $name"]
73 set nmbd_output [util_start "bin/nmbd" "-s $name"]
74
75 sleep 5
76
77 set smbclient_output [util_start "bin/smbclient -L //testing -N"]
78 verbose $smbclient_output
79
80 if { ![regexp "Anonymous login successful" $smbclient_output] } {
81     untested "smbd could not be started"
82     util_start "killall" "smbd nmbd"
83     file delete $name
84     return
85 }
86
87 # Append another share and sighup
88
89 append_smb_conf $name [list [list "tmp" [list "browseable = true"]]]
90 set output [util_start "killall" "-HUP smbd"]
91 verbose $output
92
93 sleep 2
94
95 set smbclient_output2 [util_start "bin/smbclient -L //testing -N"]
96 verbose $smbclient_output2
97
98 if { [regexp "tmp.*Disk" $smbclient_output2] } {
99     pass "sighup reload"
100 } else {
101     fail "sighup reload"
102 }
103
104 # Clean up
105
106 util_start "killall" "smbd nmbd"
107 file delete $name