]>
Commit | Line | Data |
---|---|---|
5e773594 | 1 | #!/usr/bin/perl |
70df8302 MT |
2 | ############################################################################### |
3 | # # | |
4 | # IPFire.org - A linux based firewall # | |
725254ef | 5 | # Copyright (C) 2005-2013 IPFire Team <info@ipfire.org> # |
70df8302 MT |
6 | # # |
7 | # This program is free software: you can redistribute it and/or modify # | |
8 | # it under the terms of the GNU General Public License as published by # | |
9 | # the Free Software Foundation, either version 3 of the License, or # | |
10 | # (at your option) any later version. # | |
11 | # # | |
12 | # This program is distributed in the hope that it will be useful, # | |
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of # | |
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # | |
15 | # GNU General Public License for more details. # | |
16 | # # | |
17 | # You should have received a copy of the GNU General Public License # | |
18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. # | |
19 | # # | |
20 | ############################################################################### | |
5e773594 MT |
21 | |
22 | use strict; | |
23 | # enable only the following on debugging purpose | |
cb5e9c6c CS |
24 | #use warnings; |
25 | #use CGI::Carp 'fatalsToBrowser'; | |
5e773594 MT |
26 | |
27 | require '/var/ipfire/general-functions.pl'; | |
28 | require "${General::swroot}/lang.pl"; | |
29 | require "${General::swroot}/header.pl"; | |
30 | ||
31 | my %sambasettings = (); | |
44254afd | 32 | my %cgisettings = (); |
5e773594 MT |
33 | my %checked = (); |
34 | my %netsettings = (); | |
f2fdd0c1 CS |
35 | my %color = (); |
36 | my %mainsettings = (); | |
5e773594 MT |
37 | my $message = ""; |
38 | my $errormessage = ""; | |
c41c2eb4 | 39 | |
c41c2eb4 | 40 | my $Status = qx(/usr/local/bin/sambactrl smbstatus); |
160fc7b1 | 41 | $Status = &Header::cleanhtml($Status); |
c41c2eb4 | 42 | |
1ee8bf5d MT |
43 | my $userentry = ""; |
44 | my @user = (); | |
45 | my @userline = (); | |
c41c2eb4 | 46 | my $userfile = "${General::swroot}/samba/private/smbpasswd"; |
5e773594 | 47 | my %selected= () ; |
c41c2eb4 CS |
48 | |
49 | my $defaultoption= "[Share]\npath = /var/ipfire/samba/share1\ncomment = Share - Public Access\nbrowseable = yes\nwriteable = yes\ncreate mask = 0777\ndirectory mask = 0777\npublic = yes\nforce user = samba"; | |
c41c2eb4 CS |
50 | my %shares = (); |
51 | ||
5e773594 | 52 | &General::readhash("${General::swroot}/ethernet/settings", \%netsettings); |
f2fdd0c1 CS |
53 | &General::readhash("${General::swroot}/main/settings", \%mainsettings); |
54 | &General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color); | |
5e773594 | 55 | |
14cc7eac | 56 | ############################################################################################################################ |
32f77a0b | 57 | ############################################# Samba Dienste fr Statusberprfung ########################################## |
14cc7eac | 58 | |
5e773594 MT |
59 | &Header::showhttpheaders(); |
60 | ||
14cc7eac | 61 | ############################################################################################################################ |
32f77a0b | 62 | #################################### Initialisierung von Samba Variablen fr global Settings ############################### |
14cc7eac | 63 | |
5e773594 | 64 | $sambasettings{'WORKGRP'} = 'homeip.net'; |
1ee8bf5d | 65 | $sambasettings{'INTERFACES'} = ''; |
c771fe7c | 66 | $sambasettings{'SECURITY'} = 'user'; |
fa7be659 | 67 | $sambasettings{'REMOTEANNOUNCE'} = ''; |
2a1f6aa7 | 68 | $sambasettings{'REMOTESYNC'} = ''; |
1ee8bf5d | 69 | $sambasettings{'GUESTACCOUNT'} = 'samba'; |
725254ef | 70 | $sambasettings{'MAPTOGUEST'} = 'Bad User'; |
c9f3d846 AF |
71 | $sambasettings{'WIDELINKS'} = 'on'; |
72 | $sambasettings{'UNIXEXTENSION'} = 'off'; | |
01c4d3ba | 73 | $sambasettings{'ENCRYPTION'} = 'optional'; |
5e773594 | 74 | ### Values that have to be initialized |
fa7be659 | 75 | $sambasettings{'ACTION'} = ''; |
c9e1c143 | 76 | my $LOGLINES = '50'; |
5e773594 | 77 | |
32f77a0b CS |
78 | ############################################################################################################################ |
79 | ||
5e773594 MT |
80 | &General::readhash("${General::swroot}/samba/settings", \%sambasettings); |
81 | &Header::getcgihash(\%sambasettings); | |
82 | ||
c9f3d846 | 83 | if (($sambasettings{'WIDELINKS'} eq 'on') & ($sambasettings{'UNIXEXTENSION'} eq 'on')) |
82f53e0a | 84 | {$errormessage = "$errormessage<br />Don't enable 'Wide links' and 'Unix extension' at the same time"; } |
c9f3d846 | 85 | |
5e773594 MT |
86 | &Header::openpage('Samba', 1, ''); |
87 | &Header::openbigbox('100%', 'left', '', $errormessage); | |
88 | ||
89 | ############################################################################################################################ | |
fa7be659 | 90 | ############################################# Samba Rootskript aufrufe fr SU-Actions ####################################### |
14cc7eac | 91 | |
83ae629a MT |
92 | if ($sambasettings{'ACTION'} eq 'smbuserdisable'){system("/usr/local/bin/sambactrl smbuserdisable $sambasettings{'NAME'}");} |
93 | if ($sambasettings{'ACTION'} eq 'smbuserenable'){system("/usr/local/bin/sambactrl smbuserenable $sambasettings{'NAME'}");} | |
94 | if ($sambasettings{'ACTION'} eq 'smbuseradd'){system("/usr/local/bin/sambactrl smbuseradd $sambasettings{'USERNAME'} $sambasettings{'PASSWORD'} $sambasettings{'GROUP'} $sambasettings{'SHELL'}");} | |
95 | if ($sambasettings{'ACTION'} eq 'smbpcadd'){system("/usr/local/bin/sambactrl smbpcadd $sambasettings{'PCNAME'} $sambasettings{'GROUP'} $sambasettings{'SHELL'}");} | |
96 | if ($sambasettings{'ACTION'} eq 'smbchangepw'){system("/usr/local/bin/sambactrl smbchangepw $sambasettings{'USERNAME'} $sambasettings{'PASSWORD'}");} | |
97 | if ($sambasettings{'ACTION'} eq 'smbrestart'){system("/usr/local/bin/sambactrl smbrestart");} | |
98 | if ($sambasettings{'ACTION'} eq 'smbstart'){system("/usr/local/bin/sambactrl smbstart");} | |
99 | if ($sambasettings{'ACTION'} eq 'smbstop'){system("/usr/local/bin/sambactrl smbstop");} | |
100 | if ($sambasettings{'ACTION'} eq 'smbreload'){system("/usr/local/bin/sambactrl smbreload");} | |
0ffbb688 MT |
101 | if ($sambasettings{'ACTION'} eq 'join') { |
102 | $message .= &joindomain($sambasettings{'USERNAME'}, $sambasettings{'PASSWORD'}); | |
103 | } | |
104 | ||
fa7be659 CS |
105 | ############################################################################################################################ |
106 | ########################################### Samba Benutzer oder PC l�chen ################################################# | |
107 | ||
83ae629a | 108 | if ($sambasettings{'ACTION'} eq 'userdelete'){system("/usr/local/bin/sambactrl smbuserdelete $sambasettings{'NAME'}");} |
fa7be659 | 109 | |
14cc7eac MT |
110 | ############################################################################################################################ |
111 | ##################################### Umsetzen der Werte von Checkboxen und Dropdowns ###################################### | |
1ee8bf5d MT |
112 | |
113 | if ($sambasettings{'ACTION'} eq $Lang::tr{'save'}) | |
114 | { | |
1ee8bf5d | 115 | ############################################################################################################################ |
32f77a0b | 116 | ##################################### Schreiben settings und bersetzen fr smb.conf ####################################### |
1ee8bf5d | 117 | |
63d4db83 | 118 | delete $sambasettings{'__CGI__'};delete $sambasettings{'x'};delete $sambasettings{'y'}; |
c41c2eb4 CS |
119 | &General::writehash("${General::swroot}/samba/settings", \%sambasettings); |
120 | ||
c9f3d846 AF |
121 | if ($sambasettings{'WIDELINKS'} eq 'on'){ $sambasettings{'WIDELINKS'} = "yes";} else { $sambasettings{'WIDELINKS'} = "no";} |
122 | if ($sambasettings{'UNIXEXTENSION'} eq 'on'){ $sambasettings{'UNIXEXTENSION'} = "yes";} else { $sambasettings{'UNIXEXTENSION'} = "no";} | |
32f77a0b CS |
123 | |
124 | ############################################################################################################################ | |
125 | ############################################# Schreiben der Samba globals ################################################## | |
1ee8bf5d MT |
126 | |
127 | open (FILE, ">${General::swroot}/samba/global") or die "Can't save the global settings: $!"; | |
128 | flock (FILE, 2); | |
129 | ||
130 | print FILE <<END | |
32f77a0b CS |
131 | # global.settings by IPFire Project |
132 | ||
133 | [global] | |
18b7d734 MT |
134 | server string = Samba on IPFire |
135 | ||
32f77a0b | 136 | workgroup = $sambasettings{'WORKGRP'} |
0ffbb688 | 137 | realm = $mainsettings{'DOMAINNAME'} |
00a5af61 | 138 | passdb backend = smbpasswd |
32f77a0b | 139 | |
c9f3d846 AF |
140 | wide links = $sambasettings{'WIDELINKS'} |
141 | unix extensions = $sambasettings{'UNIXEXTENSION'} | |
32f77a0b | 142 | |
32f77a0b | 143 | map to guest = $sambasettings{'MAPTOGUEST'} |
32f77a0b CS |
144 | |
145 | security = $sambasettings{'SECURITY'} | |
32f77a0b | 146 | guest account = $sambasettings{'GUESTACCOUNT'} |
8dc8788b | 147 | unix password sync = no |
32f77a0b CS |
148 | |
149 | bind interfaces only = true | |
d7129fb1 | 150 | interfaces = green0 blue0 127.0.0.0/8 |
fa7be659 | 151 | remote announce = $sambasettings{'REMOTEANNOUNCE'} |
2a1f6aa7 | 152 | remote browse sync = $sambasettings{'REMOTESYNC'} |
32f77a0b | 153 | |
0ffbb688 MT |
154 | winbind separator = + |
155 | winbind uid = 10000-20000 | |
156 | winbind gid = 10000-20000 | |
157 | winbind use default domain = yes | |
158 | ||
13e455ae MT |
159 | # Log to syslog |
160 | logging = syslog | |
97e7cfaf | 161 | |
01c4d3ba MT |
162 | END |
163 | ; | |
164 | ||
165 | if ($sambasettings{'ENCRYPTION'} =~ m/(desired|required)/) { | |
166 | print FILE "smb encrypt = $1\n"; | |
167 | } | |
be155433 | 168 | |
01c4d3ba | 169 | print FILE <<END; |
be155433 MT |
170 | # Export all printers |
171 | [printers] | |
172 | path = /var/spool/samba/ | |
173 | printable = yes | |
174 | ||
32f77a0b | 175 | END |
32f77a0b | 176 | close FILE; |
1ee8bf5d | 177 | |
70000894 MT |
178 | system("/usr/local/bin/sambactrl smbsafeconf"); |
179 | system("/usr/local/bin/sambactrl smbreload"); | |
1ee8bf5d MT |
180 | } |
181 | &General::readhash("${General::swroot}/samba/settings", \%sambasettings); | |
fa7be659 | 182 | |
5e773594 | 183 | |
c41c2eb4 CS |
184 | if ($errormessage) |
185 | { | |
186 | &Header::openbox('100%', 'left', $Lang::tr{'error messages'}); | |
187 | print "<class name='base'>$errormessage\n"; | |
188 | print " </class>\n"; | |
189 | &Header::closebox(); | |
190 | } | |
1ee8bf5d | 191 | |
0ffbb688 MT |
192 | if ($message) { |
193 | $message = &Header::cleanhtml($message); | |
194 | $message =~ s/\n/<br>/g; | |
195 | ||
196 | &Header::openbox('100%', 'left', $Lang::tr{'messages'}); | |
197 | print "$message\n"; | |
198 | &Header::closebox(); | |
199 | } | |
200 | ||
14cc7eac MT |
201 | ############################################################################################################################ |
202 | ########################################## Aktivieren von Checkboxen und Dropdowns ######################################### | |
203 | ||
c9f3d846 AF |
204 | $checked{'WIDELINKS'}{'off'} = ''; |
205 | $checked{'WIDELINKS'}{'on'} = ''; | |
206 | $checked{'WIDELINKS'}{$sambasettings{'WIDELINKS'}} = "checked='checked'"; | |
207 | $checked{'UNIXEXTENSION'}{'off'} = ''; | |
208 | $checked{'UNIXEXTENSION'}{'on'} = ''; | |
209 | $checked{'UNIXEXTENSION'}{$sambasettings{'UNIXEXTENSION'}} = "checked='checked'"; | |
01c4d3ba MT |
210 | $selected{'ENCRYPTION'}{'optional'} = ''; |
211 | $selected{'ENCRYPTION'}{'desired'} = ''; | |
212 | $selected{'ENCRYPTION'}{'required'} = ''; | |
213 | $selected{'ENCRYPTION'}{$sambasettings{'ENCRYPTION'}} = "selected='selected'"; | |
5e773594 | 214 | |
725254ef AF |
215 | if ( $sambasettings{'MAPTOGUEST'} eq "Never" ) { |
216 | $sambasettings{'MAPTOGUEST'}="Bad User"; | |
217 | } | |
97de2cae | 218 | $selected{'MAPTOGUEST'}{$sambasettings{'MAPTOGUEST'}} = "selected='selected'"; |
97de2cae | 219 | $selected{'SECURITY'}{$sambasettings{'SECURITY'}} = "selected='selected'"; |
5e773594 MT |
220 | |
221 | ############################################################################################################################ | |
32f77a0b | 222 | ################################### Aufbau der HTML Seite fr globale Sambaeinstellungen ################################### |
5e773594 | 223 | |
c9e1c143 | 224 | &Header::openbox('100%', 'center', $Lang::tr{'samba'}); |
9e329f75 MT |
225 | |
226 | my %servicenames = ( | |
227 | "nmbd" => $Lang::tr{'netbios nameserver daemon'}, | |
228 | "smbd" => $Lang::tr{'smb daemon'}, | |
229 | "winbindd" => $Lang::tr{'winbind daemon'}, | |
230 | ); | |
231 | ||
232 | print <<END; | |
d83d30d6 | 233 | <table class="tbl" width='95%' cellspacing='0'> |
9e329f75 MT |
234 | <tr bgcolor='$color{'color20'}'> |
235 | <td colspan='2' align='left'><b>$Lang::tr{'all services'}</b></td> | |
236 | </tr> | |
32f77a0b | 237 | END |
32f77a0b | 238 | |
9e329f75 MT |
239 | foreach my $service (sort keys %servicenames) { |
240 | my $status = &isrunning($service); | |
241 | ||
242 | print <<END; | |
243 | <tr> | |
244 | <td align='left' width='40%'>$servicenames{$service}</td> | |
245 | $status | |
246 | </tr> | |
247 | END | |
248 | } | |
32f77a0b CS |
249 | |
250 | print <<END | |
9e329f75 | 251 | </table> |
e1e399fb MT |
252 | |
253 | <br> | |
254 | ||
255 | <table width="95%"> | |
256 | <td width="33%" align="center"> | |
257 | <form method="POST" action="$ENV{'SCRIPT_NAME'}"> | |
258 | <input type="hidden" name="ACTION" value="smbstart"> | |
259 | <input type="submit" value="$Lang::tr{'enable'}"> | |
260 | </form> | |
261 | </td> | |
262 | ||
263 | <td width="33%" align="center"> | |
264 | <form method="POST" action="$ENV{'SCRIPT_NAME'}"> | |
265 | <input type="hidden" name="ACTION" value="smbstop"> | |
266 | <input type="submit" value="$Lang::tr{'disable'}"> | |
267 | </form> | |
268 | </td> | |
269 | ||
270 | <td width="33%" align="center"> | |
271 | <form method="POST" action="$ENV{'SCRIPT_NAME'}"> | |
272 | <input type="hidden" name="ACTION" value="smbrestart"> | |
273 | <input type="submit" value="$Lang::tr{'restart'}"> | |
274 | </form> | |
275 | </td> | |
276 | </table> | |
277 | ||
278 | <br> | |
279 | ||
32f77a0b | 280 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> |
d83d30d6 | 281 | <table class="tbl" width='95%' cellspacing='0'> |
f2fdd0c1 | 282 | <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'basic options'}</b></td></tr> |
c9e1c143 | 283 | <tr><td align='left' width='40%'>$Lang::tr{'workgroup'}</td><td align='left'><input type='text' name='WORKGRP' value='$sambasettings{'WORKGRP'}' size="30" /></td></tr> |
32f77a0b | 284 | <tr><td align='left'><br /></td><td></td></tr> |
c9f3d846 AF |
285 | <tr><td align='left' width='40%'>Wide links</td><td align='left'>on <input type='radio' name='WIDELINKS' value='on' $checked{'WIDELINKS'}{'on'} />/ |
286 | <input type='radio' name='WIDELINKS' value='off' $checked{'WIDELINKS'}{'off'} /> off</td></tr> | |
287 | <tr><td align='left' width='40%'>Unix extension</td><td align='left'>on <input type='radio' name='UNIXEXTENSION' value='on' $checked{'UNIXEXTENSION'}{'on'} />/ | |
288 | <input type='radio' name='UNIXEXTENSION' value='off' $checked{'UNIXEXTENSION'}{'off'} /> off</td></tr> | |
289 | <tr><td align='left'><br /></td><td></td></tr> | |
f2fdd0c1 | 290 | <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'security options'}</b></td></tr> |
c9e1c143 | 291 | <tr><td align='left' width='40%'>$Lang::tr{'security'}</td><td align='left'><select name='SECURITY' style="width: 165px"> |
32f77a0b | 292 | <option value='user' $selected{'SECURITY'}{'user'}>User</option> |
32f77a0b CS |
293 | <option value='ADS' $selected{'SECURITY'}{'ADS'}>ADS</option> |
294 | <option value='server' $selected{'SECURITY'}{'server'}>Server</option> | |
295 | </select></td></tr> | |
01c4d3ba MT |
296 | <tr><td align='left' width='40%'>$Lang::tr{'encryption'}</td><td align='left'><select name='ENCRYPTION' style="width: 165px"> |
297 | <option value='optional' $selected{'ENCRYPTION'}{'optional'}>$Lang::tr{'optional'}</option> | |
298 | <option value='desired' $selected{'ENCRYPTION'}{'desired'}>$Lang::tr{'desired'}</option> | |
299 | <option value='required' $selected{'ENCRYPTION'}{'required'}>$Lang::tr{'required'}</option> | |
300 | </select></td></tr> | |
c9e1c143 | 301 | <tr><td align='left' width='40%'>$Lang::tr{'map to guest'}</td><td align='left'><select name='MAPTOGUEST' style="width: 165px"> |
32f77a0b CS |
302 | <option value='Bad User' $selected{'MAPTOGUEST'}{'Bad User'}>Bad User</option> |
303 | <option value='Bad Password' $selected{'MAPTOGUEST'}{'Bad Password'}>Bad Password</option> | |
304 | </select></td></tr> | |
fa7be659 | 305 | <tr><td align='left'><br /></td><td /></tr> |
f2fdd0c1 | 306 | <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'network options'}</b></td></tr> |
c9e1c143 | 307 | <tr><td align='left' width='40%'>$Lang::tr{'remote announce'}</td><td align='left'><input type='text' name='REMOTEANNOUNCE' value='$sambasettings{'REMOTEANNOUNCE'}' size="30" /></td></tr> |
fcd5cb6f | 308 | <tr><td align='left' width='40%'>$Lang::tr{'remote browse sync'}</td><td align='left'><input type='text' name='REMOTESYNC' value='$sambasettings{'REMOTESYNC'}' size="30" /></td></tr> |
32f77a0b | 309 | </table> |
92004c61 | 310 | <br /> |
32f77a0b | 311 | <table width='10%' cellspacing='0'> |
32f77a0b CS |
312 | <tr><td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'> |
313 | <input type='hidden' name='ACTION' value=$Lang::tr{'save'} /> | |
a08a5f33 | 314 | <input type='image' alt='$Lang::tr{'save'}' title='$Lang::tr{'save'}' src='/images/media-floppy.png' /></form></td> |
32f77a0b CS |
315 | <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'> |
316 | <input type='hidden' name='ACTION' value='globalcaption' /> | |
a08a5f33 | 317 | <input type='image' alt='$Lang::tr{'caption'}' title='$Lang::tr{'caption'}' src='/images/help-browser.png' /></form></td></tr> |
32f77a0b | 318 | </table> |
44254afd MT |
319 | END |
320 | ; | |
32f77a0b | 321 | |
44254afd | 322 | if ($sambasettings{'ACTION'} eq 'globalcaption') |
32f77a0b CS |
323 | { |
324 | print <<END | |
92004c61 | 325 | <br /> |
32f77a0b | 326 | <table width='95%' cellspacing='0'> |
c9e1c143 | 327 | <tr><td align='center' colspan='2'><b>$Lang::tr{'caption'}</b></td></tr> |
60124059 | 328 | <tr><td align='right' width='33%'><img src='/images/media-floppy.png' /></td><td align='left'>$Lang::tr{'save settings'}</td></tr> |
c9e1c143 | 329 | <tr><td align='right' width='33%'><img src='/images/reload.gif' /></td><td align='left'>$Lang::tr{'restore settings'}</td></tr> |
32f77a0b | 330 | </table> |
5e773594 MT |
331 | END |
332 | ; | |
32f77a0b CS |
333 | } |
334 | ||
5e773594 MT |
335 | &Header::closebox(); |
336 | ||
14cc7eac | 337 | ############################################################################################################################ |
32f77a0b | 338 | ########################################## Benutzerverwaltung fr Usersecurity ############################################# |
14cc7eac | 339 | |
1ee8bf5d | 340 | if ($sambasettings{'SECURITY'} eq 'user') |
32f77a0b | 341 | { |
70000894 | 342 | &Header::openbox('100%', 'center', $Lang::tr{'user management'}); |
32f77a0b | 343 | print <<END |
d3bea043 | 344 | <a name="$Lang::tr{'accounting'}"></a> |
92004c61 | 345 | <br /> |
d83d30d6 | 346 | <table class="tbl" width='95%' cellspacing='0'> |
32f77a0b | 347 | <tr><td colspan='6' align='left'></td></tr> |
f2fdd0c1 | 348 | <tr><td bgcolor='$color{'color20'}' colspan='7' align='left'><b>$Lang::tr{'accounting'}</b></td></tr> |
c9e1c143 | 349 | <tr><td align='left'><u>$Lang::tr{'username'}</u></td><td align='left'><u>$Lang::tr{'password'}</u></td> |
32f77a0b CS |
350 | END |
351 | ; | |
5e773594 | 352 | |
70000894 | 353 | print "<td></td>"; |
92004c61 | 354 | print "<td align='left'><u>$Lang::tr{'status'}</u></td><td colspan='3' width='5%' align='center'><u>$Lang::tr{'options'}</u></td></tr>"; |
32f77a0b | 355 | system('/usr/local/bin/sambactrl readsmbpasswd'); |
c41c2eb4 | 356 | open(FILE, "<${General::swroot}/samba/private/smbpasswd") or die "Can't read user file: $!"; |
32f77a0b CS |
357 | @user = <FILE>; |
358 | close(FILE); | |
359 | system('/usr/local/bin/sambactrl locksmbpasswd'); | |
a28fdc01 CS |
360 | |
361 | my $lines = 0; | |
362 | ||
32f77a0b CS |
363 | foreach $userentry (sort @user) |
364 | { | |
365 | @userline = split( /\:/, $userentry ); | |
a28fdc01 CS |
366 | if ($lines % 2) {print "<tr bgcolor='$color{'color20'}'>";} else {print "<tr bgcolor='$color{'color22'}'>";} |
367 | print "<td align='left'>$userline[0]</td><td align='left'>"; | |
32f77a0b CS |
368 | if ($userline[4] =~ /N/) |
369 | { | |
c9e1c143 | 370 | print "$Lang::tr{'not set'}</td><td align='left'>"; |
32f77a0b CS |
371 | } |
372 | else | |
373 | { | |
c9e1c143 | 374 | print "$Lang::tr{'set'}</td><td align='left'>"; |
32f77a0b CS |
375 | } |
376 | ||
70000894 | 377 | print "</td><td align='left'>"; |
32f77a0b CS |
378 | |
379 | if ($userline[4] =~ /D/) | |
380 | { | |
381 | print <<END | |
92004c61 | 382 | $Lang::tr{'inactive'}</td> |
19f5a6cc | 383 | <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'> |
32f77a0b CS |
384 | <input type='hidden' name='NAME' value='$userline[0]' /> |
385 | <input type='hidden' name='ACTION' value='smbuserenable' /> | |
25943d3b | 386 | <input type='image' alt='$Lang::tr{'activate'}' title='$Lang::tr{'activate'}' src='/images/off.gif' /> |
32f77a0b CS |
387 | </form></td> |
388 | END | |
389 | ; | |
390 | } | |
391 | else | |
392 | { | |
393 | print <<END | |
92004c61 | 394 | $Lang::tr{'active'}</td> |
19f5a6cc | 395 | <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'> |
32f77a0b CS |
396 | <input type='hidden' name='NAME' value='$userline[0]' /> |
397 | <input type='hidden' name='ACTION' value='smbuserdisable' /> | |
25943d3b | 398 | <input type='image' alt='$Lang::tr{'deactivate'}' title='$Lang::tr{'deactivate'}' src='/images/on.gif' /> |
32f77a0b CS |
399 | </form></td> |
400 | END | |
401 | ; | |
402 | } | |
403 | ||
404 | if ($userline[0] =~ /\$/) | |
405 | { | |
406 | print "<td></td>"; | |
407 | } | |
408 | else | |
409 | { | |
410 | print <<END | |
19f5a6cc | 411 | <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'> |
32f77a0b CS |
412 | <input type='hidden' name='NAME' value='$userline[0]' /> |
413 | <input type='hidden' name='ACTION' value='userchangepw' /> | |
a08a5f33 | 414 | <input type='image' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' src='/images/edit.gif' /> |
32f77a0b CS |
415 | </form></td> |
416 | END | |
417 | ; | |
418 | } | |
419 | ||
70000894 MT |
420 | print <<END |
421 | <td><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'> | |
422 | <input type='hidden' name='NAME' value='$userline[0]' /> | |
423 | <input type='hidden' name='ACTION' value='userdelete' /> | |
424 | <input type='image' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' src='/images/user-option-remove.png' /> | |
425 | </form></td></tr> | |
32f77a0b CS |
426 | END |
427 | ; | |
a28fdc01 | 428 | $lines++; |
32f77a0b CS |
429 | } |
430 | print <<END | |
431 | </table> | |
92004c61 | 432 | <br /> |
32f77a0b | 433 | <table width='10%' cellspacing='0'> |
19f5a6cc | 434 | <tr><td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'> |
32f77a0b | 435 | <input type='hidden' name='ACTION' value='useradd' /> |
a08a5f33 | 436 | <input type='image' alt='$Lang::tr{'add user'}' title='$Lang::tr{'add user'}' src='/images/user-option-add.png' /></form></td> |
5e773594 MT |
437 | END |
438 | ; | |
1ee8bf5d | 439 | |
32f77a0b | 440 | print <<END |
19f5a6cc | 441 | <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'> |
32f77a0b | 442 | <input type='hidden' name='ACTION' value='usercaption' /> |
a08a5f33 | 443 | <input type='image' alt='$Lang::tr{'caption'}' title='$Lang::tr{'caption'}' src='/images/help-browser.png' /></form> |
94819213 | 444 | </td></tr> |
32f77a0b CS |
445 | </table> |
446 | END | |
447 | ; | |
44254afd | 448 | |
32f77a0b CS |
449 | if ($sambasettings{'ACTION'} eq 'usercaption') |
450 | { | |
451 | print <<END | |
92004c61 | 452 | <br /> |
32f77a0b | 453 | <table width='95%' cellspacing='0'> |
c9e1c143 CS |
454 | <tr><td align='center' colspan='2'><b>$Lang::tr{'caption'}</b></td></tr> |
455 | <tr><td align='right' width='33%'><img src='/images/user-option-add.png' /></td><td align='left'>$Lang::tr{'add user'}</td></tr> | |
115340d2 | 456 | <tr><td align='right' width='33%'><img src='/images/network.png' /></td><td align='left'>$Lang::tr{'pc add'}</td></tr> |
c9e1c143 CS |
457 | <tr><td align='right' width='33%'><img src='/images/user-option-remove.png' /></td><td align='left'>$Lang::tr{'delete user'}</td></tr> |
458 | <tr><td align='right' width='33%'><img src='/images/network-error.png' /></td><td align='left'>$Lang::tr{'delete pc'}</td></tr> | |
25943d3b CS |
459 | <tr><td align='right' width='33%'><img src='/images/off.gif' /></td><td align='left'>$Lang::tr{'activate user'}</td></tr> |
460 | <tr><td align='right' width='33%'><img src='/images/on.gif' /></td><td align='left'>$Lang::tr{'deactivate user'}</td></tr> | |
c9e1c143 | 461 | <tr><td align='right' width='33%'><img src='/images/edit.gif' /></td><td align='left'>$Lang::tr{'change passwords'}</td></tr> |
60124059 | 462 | <tr><td align='right' width='33%'><img src='/images/media-floppy.png' /></td><td align='left'>$Lang::tr{'save config'}</td></tr> |
32f77a0b | 463 | </table> |
1ee8bf5d MT |
464 | END |
465 | ; | |
32f77a0b CS |
466 | } |
467 | ||
468 | if ($sambasettings{'ACTION'} eq 'userchangepw') | |
469 | { | |
470 | my $username = "$sambasettings{'NAME'}"; | |
471 | my $password = 'samba'; | |
472 | print <<END | |
92004c61 | 473 | <br /> |
19f5a6cc | 474 | <form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'> |
32f77a0b | 475 | <table width='95%' cellspacing='0'> |
f2fdd0c1 | 476 | <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'change passwords'}</b></td></tr> |
153cf640 | 477 | <tr><td align='left'>$Lang::tr{'username'}</td><td><input type='text' name='USERNAME' value='$username' size='30' readonly='readonly' /></td></tr> |
c9e1c143 | 478 | <tr><td align='left'>$Lang::tr{'password'}</td><td><input type='password' name='PASSWORD' value='$password' size='30' /></td></tr> |
32f77a0b | 479 | <tr><td colspan='2' align='center'><input type='hidden' name='ACTION' value='smbchangepw' /> |
f8aa0679 | 480 | <input type='image' alt='$Lang::tr{'save'}' title='$Lang::tr{'save'}' src='/images/media-floppy.png' /></td></tr> |
32f77a0b | 481 | </table> |
94819213 | 482 | </form> |
1ee8bf5d MT |
483 | END |
484 | ; | |
32f77a0b CS |
485 | } |
486 | ||
487 | if ($sambasettings{'ACTION'} eq 'useradd') | |
488 | { | |
489 | my $username = "user"; | |
490 | my $password = "samba"; | |
491 | chomp $username; | |
492 | $username=~s/\s//g; | |
493 | chomp $password; | |
494 | $password=~s/\s//g; | |
495 | print <<END | |
92004c61 | 496 | <br /> |
19f5a6cc | 497 | <form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'> |
32f77a0b | 498 | <table width='95%' cellspacing='0'> |
f2fdd0c1 | 499 | <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'add user'}</b></td></tr> |
c9e1c143 CS |
500 | <tr><td align='left'>$Lang::tr{'username'}</td><td><input type='text' name='USERNAME' value='$username' size='30' /></td></tr> |
501 | <tr><td align='left'>$Lang::tr{'password'}</td><td><input type='password' name='PASSWORD' value='$password' size='30' /></td></tr> | |
502 | <tr><td align='left'>$Lang::tr{'unix group'}</td><td><input type='text' name='GROUP' value='sambauser' size='30' /></td></tr> | |
503 | <tr><td align='left'>$Lang::tr{'unix shell'}</td><td><input type='text' name='SHELL' value='/bin/false' size='30' /></td></tr> | |
32f77a0b | 504 | <tr><td colspan='2' align='center'><input type='hidden' name='ACTION' value='smbuseradd' /> |
f8aa0679 | 505 | <input type='image' alt='$Lang::tr{'save'}' title='$Lang::tr{'save'}' src='/images/media-floppy.png' /></td></tr> |
32f77a0b | 506 | </table> |
94819213 | 507 | </form> |
32f77a0b CS |
508 | END |
509 | ; | |
510 | } | |
511 | ||
512 | if ($sambasettings{'ACTION'} eq 'pcadd') | |
513 | { | |
514 | my $pcname = "client\$"; | |
515 | chomp $pcname; | |
516 | $pcname=~s/\s//g; | |
517 | print <<END | |
92004c61 | 518 | <br /> |
19f5a6cc | 519 | <form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'> |
32f77a0b | 520 | <table width='95%' cellspacing='0'> |
f2fdd0c1 | 521 | <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'pc add'}</b></td></tr> |
c9e1c143 CS |
522 | <tr><td align='left'>$Lang::tr{'client'}</td><td><input type='text' name='PCNAME' value='$pcname' size='30' /></td></tr> |
523 | <tr><td align='left'>$Lang::tr{'unix group'}</td><td><input type='text' name='GROUP' value='sambawks' size='30' /></td></tr> | |
524 | <tr><td align='left'>$Lang::tr{'unix shell'}</td><td><input type='text' name='SHELL' value='/bin/false' size='30' /></td></tr> | |
32f77a0b | 525 | <tr><td colspan='2' align='center'><input type='hidden' name='ACTION' value='smbpcadd' /> |
f8aa0679 | 526 | <input type='image' alt='$Lang::tr{'save'}' title='$Lang::tr{'save'}' src='/images/media-floppy.png' /></td></tr> |
32f77a0b | 527 | </table> |
94819213 | 528 | </form> |
32f77a0b CS |
529 | END |
530 | ; | |
531 | } | |
97de2cae MT |
532 | |
533 | &Header::closebox(); | |
1ee8bf5d | 534 | } |
14cc7eac | 535 | |
0ffbb688 MT |
536 | if ($sambasettings{'SECURITY'} eq "ADS") { |
537 | &Header::openbox('100%', 'center', $Lang::tr{'samba join a domain'}); | |
538 | ||
539 | my $AD_DOMAINNAME = uc($mainsettings{'DOMAINNAME'}); | |
540 | ||
541 | print <<END; | |
542 | <form method="POST" action="$ENV{'SCRIPT_NAME'}"> | |
543 | <input type="hidden" name="ACTION" value="join"> | |
544 | ||
d83d30d6 | 545 | <table class="tbl" width="95%"> |
0ffbb688 MT |
546 | <tbody> |
547 | <tr> | |
548 | <td width="40%"> | |
549 | $Lang::tr{'domain'} | |
550 | </td> | |
551 | <td> | |
552 | $AD_DOMAINNAME | |
553 | </td> | |
554 | </tr> | |
555 | <tr> | |
556 | <td width="40%"> | |
557 | $Lang::tr{'administrator username'} | |
558 | </td> | |
559 | <td> | |
560 | <input type="text" name="USERNAME" size="30"> | |
561 | </td> | |
562 | </tr> | |
563 | <tr> | |
564 | <td width="40%"> | |
565 | $Lang::tr{'administrator password'} | |
566 | </td> | |
567 | <td> | |
568 | <input type="password" name="PASSWORD" size="30"> | |
569 | </td> | |
570 | </tr> | |
571 | <tr> | |
572 | <td></td> | |
573 | <td> | |
574 | <input type="submit" value="$Lang::tr{'samba join domain'}"> | |
575 | </td> | |
576 | </tr> | |
577 | </tbody> | |
578 | </table> | |
579 | </form> | |
580 | END | |
581 | ||
582 | &Header::closebox(); | |
583 | } | |
584 | ||
14cc7eac MT |
585 | ############################################################################################################################ |
586 | ############################################### Verwalten von Freigaben #################################################### | |
fa7be659 | 587 | |
c9e1c143 | 588 | &Header::openbox('100%', 'center', $Lang::tr{'shares'}); |
97de2cae | 589 | |
c41c2eb4 CS |
590 | my %shares = config("${General::swroot}/samba/shares"); |
591 | ||
592 | ||
1ee8bf5d | 593 | print <<END |
d3bea043 | 594 | <a name="$Lang::tr{'manage shares'}"></a> |
92004c61 | 595 | <br /> |
d83d30d6 | 596 | <table class="tbl" width='95%' cellspacing='0' class='tbl'> |
961f3dbc AM |
597 | <tr><th bgcolor='$color{'color20'}' colspan='3' align='left'><b>$Lang::tr{'manage shares'}</b></th></tr> |
598 | <tr><th align='left'><u>$Lang::tr{'sharename'}</u></th><th colspan='2' width="5%" align='center'><u>$Lang::tr{'options'}</u></th></tr> | |
1ee8bf5d MT |
599 | END |
600 | ; | |
14cc7eac | 601 | |
c41c2eb4 | 602 | my @Shares = keys(%shares); |
a28fdc01 | 603 | my $lines = 0; |
961f3dbc | 604 | my $col=""; |
c41c2eb4 | 605 | foreach my $shareentry (sort @Shares) |
32f77a0b | 606 | { |
c41c2eb4 | 607 | chomp $shareentry; |
961f3dbc AM |
608 | if ($lines % 2) { |
609 | print "<tr>"; | |
610 | $col="bgcolor='$color{'color20'}'"; | |
611 | } else { | |
612 | print "<tr>"; | |
613 | $col="bgcolor='$color{'color22'}'"; | |
614 | } | |
32f77a0b | 615 | print <<END |
961f3dbc AM |
616 | <td align='left' $col>$shareentry</td> |
617 | <td $col><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage shares'}'> | |
32f77a0b CS |
618 | <input type='hidden' name='NAME' value='$shareentry' /> |
619 | <input type='hidden' name='ACTION' value='sharechange' /> | |
a08a5f33 | 620 | <input type='image' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' src='/images/edit.gif' /> |
32f77a0b | 621 | </form></td> |
961f3dbc | 622 | <td $col><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage shares'}'> |
32f77a0b CS |
623 | <input type='hidden' name='NAME' value='$shareentry' /> |
624 | <input type='hidden' name='ACTION' value='smbsharedel' /> | |
a08a5f33 | 625 | <input type='image' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' src='/images/user-trash.png' /> |
94819213 | 626 | </form></td></tr> |
32f77a0b CS |
627 | END |
628 | ; | |
a28fdc01 | 629 | $lines++; |
32f77a0b CS |
630 | } |
631 | ||
632 | print <<END | |
633 | </table> | |
92004c61 | 634 | <br /> |
32f77a0b | 635 | <table width='10%' cellspacing='0'> |
19f5a6cc | 636 | <tr><td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage shares'}'> |
94819213 | 637 | <input type='hidden' name='ACTION' value='shareadd' /> |
a08a5f33 | 638 | <input type='image' alt='$Lang::tr{'add share'}' title='$Lang::tr{'add share'}' src='/images/list-add.png' /> |
32f77a0b | 639 | </form></td> |
19f5a6cc | 640 | <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage shares'}'> |
88932936 | 641 | <input type='hidden' name='ACTION' value='sharecaption' /> |
a08a5f33 | 642 | <input type='image' alt='$Lang::tr{'caption'}' title='$Lang::tr{'caption'}' src='/images/help-browser.png' /> |
88932936 CS |
643 | </form></td> |
644 | </tr> | |
32f77a0b | 645 | </table> |
1ee8bf5d MT |
646 | END |
647 | ; | |
32f77a0b | 648 | |
1ee8bf5d | 649 | if ($sambasettings{'ACTION'} eq 'sharecaption') |
32f77a0b CS |
650 | { |
651 | print <<END | |
92004c61 | 652 | <br /> |
32f77a0b | 653 | <table width='95%' cellspacing='0'> |
92004c61 | 654 | <tr><td align='center' colspan='2'><b>$Lang::tr{'caption'}</b></td></tr> |
60124059 | 655 | <tr><td align='right' width='33%'><img src='/images/list-add.png' /></td><td align='left'>$Lang::tr{'add share'}</td></tr> |
c9e1c143 | 656 | <tr><td align='right' width='33%'><img src='/images/edit.gif' /></td><td align='left'>$Lang::tr{'edit share'}</td></tr> |
60124059 | 657 | <tr><td align='right' width='33%'><img src='/images/media-floppy.png' /></td><td align='left'>$Lang::tr{'save config'}</td></tr> |
60124059 | 658 | <tr><td align='right' width='33%'><img src='/images/user-trash.png' /></td><td align='left'>$Lang::tr{'delete share'}</td></tr> |
32f77a0b | 659 | </table> |
1ee8bf5d MT |
660 | END |
661 | ; | |
32f77a0b | 662 | } |
97de2cae | 663 | |
1ee8bf5d | 664 | if ($sambasettings{'ACTION'} eq 'shareadd' || $sambasettings{'ACTION'} eq 'optioncaption' ) |
32f77a0b CS |
665 | { |
666 | print <<END | |
92004c61 | 667 | <br /> |
32f77a0b | 668 | <table width='95%' cellspacing='0'> |
f2fdd0c1 | 669 | <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'add share'}</b></td></tr> |
32f77a0b | 670 | <tr><td colspan='2' align='center'></td></tr> |
19f5a6cc | 671 | <form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage shares'}'><tr><td colspan='2' align='center'><textarea name="SHAREOPTION" cols="50" rows="15" Wrap="off">$defaultoption</textarea></td></tr> |
32f77a0b | 672 | </table> |
92004c61 | 673 | <br /> |
32f77a0b | 674 | <table width='10%' cellspacing='0'> |
94819213 | 675 | <tr><td align='center'><input type='hidden' name='ACTION' value='smbshareadd' /> |
a08a5f33 | 676 | <input type='image' alt='$Lang::tr{'add share'}' title='$Lang::tr{'add share'}' src='/images/media-floppy.png' /></td></tr></form> |
32f77a0b | 677 | </table> |
5e773594 MT |
678 | END |
679 | ; | |
32f77a0b | 680 | } |
5e773594 | 681 | |
1ee8bf5d | 682 | if ($sambasettings{'ACTION'} eq 'sharechange' || $sambasettings{'ACTION'} eq 'optioncaption2' ) |
32f77a0b | 683 | { |
c41c2eb4 | 684 | my $shareoption = $shares{$sambasettings{'NAME'}}; |
32f77a0b | 685 | print <<END |
92004c61 | 686 | <br /> |
32f77a0b | 687 | <table width='95%' cellspacing='0'> |
f2fdd0c1 | 688 | <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'edit share'}</b></td></tr> |
32f77a0b | 689 | <tr><td colspan='2' align='center'></td></tr> |
19f5a6cc | 690 | <tr><td colspan='2' align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage shares'}'><textarea name="SHAREOPTION" cols="50" rows="15" Wrap="off">$shareoption</textarea></td></tr> |
32f77a0b | 691 | </table> |
92004c61 | 692 | <br /> |
32f77a0b | 693 | <table width='10%' cellspacing='0'> |
94819213 | 694 | <tr><td align='center'><input type='hidden' name='NAME' value='$sambasettings{'NAME'}' /> |
a08a5f33 | 695 | <input type='image' alt='$Lang::tr{'change share'}' title='$Lang::tr{'change share'}' src='/images/media-floppy.png' /> |
fa7be659 | 696 | <input type='hidden' name='ACTION' value='smbsharechange' /></form></td></tr> |
32f77a0b | 697 | </table> |
1ee8bf5d MT |
698 | END |
699 | ; | |
32f77a0b | 700 | } |
5e773594 | 701 | |
c41c2eb4 CS |
702 | if ($sambasettings{'ACTION'} eq 'smbshareadd') |
703 | { | |
704 | $shares{'xvx'}= "$sambasettings{'SHAREOPTION'}"; | |
705 | save("shares"); | |
706 | my $shares = config("${General::swroot}/samba/shares"); | |
707 | } | |
708 | if ($sambasettings{'ACTION'} eq 'smbsharedel') | |
709 | { | |
710 | delete $shares{$sambasettings{'NAME'}}; | |
711 | save("shares"); | |
712 | my %shares = config("${General::swroot}/samba/shares"); | |
713 | } | |
714 | if ($sambasettings{'ACTION'} eq 'smbsharechange') | |
715 | { | |
716 | $shares{$sambasettings{'NAME'}} = $sambasettings{'SHAREOPTION'}; | |
717 | save("shares"); | |
718 | my %shares = config("${General::swroot}/samba/shares"); | |
719 | } | |
720 | ||
721 | &Header::closebox(); | |
722 | ||
32f77a0b CS |
723 | ############################################################################################################################ |
724 | ############################################### Anzeige des Sambastatus #################################################### | |
725 | ||
726 | &Header::openbox('100%', 'center', 'Status'); | |
727 | ||
728 | print <<END | |
92004c61 | 729 | <br /> |
d83d30d6 | 730 | <table class="tbl" width='95%' cellspacing='0'> |
f2fdd0c1 | 731 | <tr><td bgcolor='$color{'color20'}' colspan='3' align='left'><b>$Lang::tr{'samba status'}</b></td></tr> |
fb8e2c14 | 732 | <tr><td align='left'><small><pre>$Status</pre></small></td></tr> |
fa7be659 CS |
733 | </table> |
734 | END | |
735 | ; | |
736 | &Header::closebox(); | |
737 | ||
5e773594 MT |
738 | &Header::closebigbox(); |
739 | &Header::closepage(); | |
740 | ||
741 | ############################################################################################################################ | |
fa7be659 | 742 | ############################################ Subfunktion fr Sambadienste ################################################### |
5e773594 | 743 | |
c41c2eb4 CS |
744 | sub config |
745 | { | |
746 | my $file = shift; | |
747 | my @allarray = `grep -n '^\\[' $file`; | |
748 | my @linesarray = (); | |
749 | my @namearray = (); | |
750 | my %hash = (); | |
751 | my $options = (); | |
752 | my $EOF = qx(cat $file | wc -l); | |
753 | foreach my $allarrayentry (@allarray) | |
754 | { | |
755 | my @allarrayline = split( /\:/, $allarrayentry ); | |
756 | push(@linesarray,$allarrayline[0]);$allarrayline[1]=~s/\[//g;$allarrayline[1]=~s/\]//g;push(@namearray,$allarrayline[1]); | |
757 | } | |
758 | for(my $i = 0; $i <= $#namearray; $i++) | |
759 | { | |
760 | chomp $namearray[$i]; | |
761 | $namearray[$i]=~s/\[//g;$namearray[$i]=~s/\]//g; | |
762 | if ( $i eq $#namearray ) | |
763 | { | |
764 | my $lineend = $EOF-$linesarray[$i]+1; | |
765 | $options=qx(tail -$lineend $file); | |
766 | } | |
767 | else | |
768 | { | |
769 | my $linestart = $EOF-$linesarray[$i]+1; | |
770 | my $lineend = $linesarray[$i+1]-$linesarray[$i]; | |
771 | $options=qx(tail -$linestart $file | head -$lineend); | |
772 | } | |
773 | $hash{$namearray[$i]} = "$options"; | |
1e482cb6 | 774 | #print"<pre>$namearray[$i]\n$options\n</pre>"; # enable only for debuging |
c41c2eb4 CS |
775 | } |
776 | return(%hash); | |
777 | } | |
778 | ||
779 | sub save | |
780 | { | |
781 | my $smb = shift; | |
782 | open (FILE, ">${General::swroot}/samba/$smb") or die "Can't $smb settings $!"; | |
783 | flock (FILE, 2); | |
784 | ||
c41c2eb4 CS |
785 | if ( $smb eq 'shares') |
786 | {while (my ($name, $option) = each %shares){chomp $option;$option =~ s/\r\n/\n/gi;$option =~ s/^\n//gi;$option =~ s/^\r//gi;$option =~ s/^.\n//gi;$option =~ s/^.\r//gi;print FILE "$option\n";} } | |
787 | ||
788 | close FILE; | |
789 | ||
70000894 | 790 | system("/usr/local/bin/sambactrl smbsafeconf"); |
c41c2eb4 | 791 | system("/usr/local/bin/sambactrl smbreload"); |
a4a3e35c | 792 | } |
c41c2eb4 | 793 | |
5e773594 | 794 | sub isrunning |
32f77a0b CS |
795 | { |
796 | my $cmd = $_[0]; | |
797 | my $status = "<td align='center' bgcolor='${Header::colourred}'><font color='white'><b>$Lang::tr{'stopped'}</b></font></td>"; | |
798 | my $pid = ''; | |
799 | my $testcmd = ''; | |
800 | my $exename; | |
801 | ||
802 | $cmd =~ /(^[a-z]+)/; | |
803 | $exename = $1; | |
804 | ||
805 | if (open(FILE, "/var/run/${cmd}.pid")) | |
806 | { | |
807 | $pid = <FILE>; chomp $pid; | |
808 | close FILE; | |
809 | if (open(FILE, "/proc/${pid}/status")) | |
810 | { | |
811 | while (<FILE>) | |
812 | { | |
813 | if (/^Name:\W+(.*)/) | |
814 | { | |
815 | $testcmd = $1; | |
816 | } | |
817 | } | |
818 | close FILE; | |
819 | if ($testcmd =~ /$exename/) | |
820 | { | |
821 | $status = "<td align='center' bgcolor='${Header::colourgreen}'><font color='white'><b>$Lang::tr{'running'}</b></font></td>"; | |
822 | } | |
823 | } | |
824 | } | |
825 | return $status; | |
c41c2eb4 | 826 | } |
0ffbb688 MT |
827 | |
828 | sub joindomain { | |
829 | my $username = shift; | |
830 | my $password = shift; | |
831 | ||
832 | my @options = ("/usr/local/bin/sambactrl", "join", $username, $password); | |
833 | my $output = qx(@options); | |
834 | ||
835 | return $output; | |
836 | } |