source: trunk/server/testsuite/smbd/sighup.exp@ 1036

Last change on this file since 1036 was 414, checked in by Herwig Bauernfeind, 16 years ago

Samba 3.5.0: Initial import

File size: 2.0 KB
Line 
1#
2# @(#) Check services file reloaded after SIGHUP
3#
4
5load_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
11proc 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
40proc 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
63set smb_conf [list \
64 [list "global" \
65 [list "netbios name = testing" \
66 "guest ok = true"]]]
67
68set name [write_smb_conf $smb_conf]
69
70# Run smbd and smbclient output
71
72set smbd_output [util_start "bin/smbd" "-s $name"]
73set nmbd_output [util_start "bin/nmbd" "-s $name"]
74
75sleep 5
76
77set smbclient_output [util_start "bin/smbclient -L //testing -N"]
78verbose $smbclient_output
79
80if { ![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
89append_smb_conf $name [list [list "tmp" [list "browseable = true"]]]
90set output [util_start "killall" "-HUP smbd"]
91verbose $output
92
93sleep 2
94
95set smbclient_output2 [util_start "bin/smbclient -L //testing -N"]
96verbose $smbclient_output2
97
98if { [regexp "tmp.*Disk" $smbclient_output2] } {
99 pass "sighup reload"
100} else {
101 fail "sighup reload"
102}
103
104# Clean up
105
106util_start "killall" "smbd nmbd"
107file delete $name
Note: See TracBrowser for help on using the repository browser.