summaryrefslogtreecommitdiffstats
path: root/testsuite/smbd/sighup.exp
blob: a9e1bffe11d4929576d923c790b45744ac9c51b9 (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#
# @(#) Check services file reloaded after SIGHUP
#

load_lib "util-defs.exp"

# Create a smb.conf file from a list of sections.  Each section consists of
# a name and a list of lines which are the contents of that section.
# Returns a temporary filename which must be deleted after use.

proc write_smb_conf { args } {

    # Set up temporary file

    set name "/tmp/smb.conf-test-[pid]"
    set f [open $name "w"]

    # Parse sections

    foreach section [lindex $args 0] {
	set secname [lindex $section 0]
	set contents [lindex $section 1]
	
	puts $f "\[$secname]"

	foreach { line } $contents {
	    puts $f "\t$line"
	}

	puts $f ""
    }

    close $f

    # Return filename of smb.conf file

    return $name
}

proc append_smb_conf { args } {
    
    set name [lindex $args 0]
    set f [open $name "a"]
    
    foreach section [lindex $args 1] {
	set secname [lindex $section 0]
	set contents [lindex $section 1]
	
	puts $f "\[$secname]"

	foreach { line } $contents {
	    puts $f "\t$line"
	}

	puts $f ""
    }

    close $f
}

# Create a smb.conf file

set smb_conf [list \
	[list "global" \
	    [list "netbios name = testing" \
	          "guest ok = true"]]]

set name [write_smb_conf $smb_conf]

# Run smbd and smbclient output

set smbd_output [util_start "bin/smbd" "-s $name"]
set nmbd_output [util_start "bin/nmbd" "-s $name"]

sleep 5

set smbclient_output [util_start "bin/smbclient -L //testing -N"]
verbose $smbclient_output

if { ![regexp "Anonymous login successful" $smbclient_output] } {
    untested "smbd could not be started"
    util_start "killall" "smbd nmbd"
    file delete $name
    return
}

# Append another share and sighup

append_smb_conf $name [list [list "tmp" [list "browseable = true"]]]
set output [util_start "killall" "-HUP smbd"]
verbose $output

sleep 2

set smbclient_output2 [util_start "bin/smbclient -L //testing -N"]
verbose $smbclient_output2

if { [regexp "tmp.*Disk" $smbclient_output2] } {
    pass "sighup reload"
} else {
    fail "sighup reload"
}

# Clean up

util_start "killall" "smbd nmbd"
file delete $name