]>
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 | ||
42ebeaa8 MT |
280 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> |
281 | <table class="tbl" width='95%' cellspacing='0'> | |
282 | <tr bgcolor='$color{'color20'}'> | |
283 | <td colspan='2' align='left'><b>$Lang::tr{'basic options'}</b></td> | |
284 | </tr> | |
285 | <tr> | |
286 | <td align='left' width='40%'>$Lang::tr{'workgroup'}</td> | |
287 | <td align='left'> | |
288 | <input type='text' name='WORKGRP' value='$sambasettings{'WORKGRP'}' size="30" /> | |
289 | </td> | |
290 | </tr> | |
291 | <tr> | |
292 | <td align='left'><br /></td> | |
293 | <td></td> | |
294 | </tr> | |
295 | <tr> | |
296 | <td align='left' width='40%'>Wide links</td> | |
297 | <td align='left'> | |
298 | on <input type='radio' name='WIDELINKS' value='on' $checked{'WIDELINKS'}{'on'} /> / | |
299 | <input type='radio' name='WIDELINKS' value='off' $checked{'WIDELINKS'}{'off'} /> off | |
300 | </td> | |
301 | </tr> | |
302 | <tr> | |
303 | <td align='left' width='40%'>Unix extension</td> | |
304 | <td align='left'> | |
305 | on <input type='radio' name='UNIXEXTENSION' value='on' $checked{'UNIXEXTENSION'}{'on'} /> / | |
306 | <input type='radio' name='UNIXEXTENSION' value='off' $checked{'UNIXEXTENSION'}{'off'} /> off | |
307 | </td> | |
308 | </tr> | |
309 | <tr> | |
310 | <td align='left'><br /></td> | |
311 | <td></td> | |
312 | </tr> | |
313 | <tr bgcolor='$color{'color20'}'> | |
314 | <td colspan='2' align='left'><b>$Lang::tr{'security options'}</b></td> | |
315 | </tr> | |
316 | <tr> | |
317 | <td align='left' width='40%'>$Lang::tr{'security'}</td> | |
318 | <td align='left'> | |
319 | <select name='SECURITY' style="width: 165px"> | |
320 | <option value='user' $selected{'SECURITY'}{'user'}>User</option> | |
321 | <option value='ADS' $selected{'SECURITY'}{'ADS'}>ADS</option> | |
322 | <option value='server' $selected{'SECURITY'}{'server'}>Server</option> | |
323 | </select> | |
324 | </td> | |
325 | </tr> | |
326 | <tr> | |
327 | <td align='left' width='40%'>$Lang::tr{'encryption'}</td> | |
328 | <td align='left'> | |
329 | <select name='ENCRYPTION' style="width: 165px"> | |
330 | <option value='optional' $selected{'ENCRYPTION'}{'optional'}>$Lang::tr{'optional'}</option> | |
331 | <option value='desired' $selected{'ENCRYPTION'}{'desired'}>$Lang::tr{'desired'}</option> | |
332 | <option value='required' $selected{'ENCRYPTION'}{'required'}>$Lang::tr{'required'}</option> | |
333 | </select> | |
334 | </td> | |
335 | </tr> | |
336 | <tr> | |
337 | <td align='left' width='40%'>$Lang::tr{'map to guest'}</td> | |
338 | <td align='left'> | |
339 | <select name='MAPTOGUEST' style="width: 165px"> | |
340 | <option value='Bad User' $selected{'MAPTOGUEST'}{'Bad User'}>Bad User</option> | |
341 | <option value='Bad Password' $selected{'MAPTOGUEST'}{'Bad Password'}>Bad Password</option> | |
342 | </select> | |
343 | </td> | |
344 | </tr> | |
345 | <tr> | |
346 | <td align='left'><br /></td> | |
347 | <td></td> | |
348 | </tr> | |
349 | <tr bgcolor='$color{'color20'}'> | |
350 | <td colspan='2' align='left'><b>$Lang::tr{'network options'}</b></td> | |
351 | </tr> | |
352 | <tr> | |
353 | <td align='left' width='40%'>$Lang::tr{'remote announce'}</td> | |
354 | <td align='left'> | |
355 | <input type='text' name='REMOTEANNOUNCE' value='$sambasettings{'REMOTEANNOUNCE'}' size="30" /> | |
356 | </td> | |
357 | </tr> | |
358 | <tr> | |
359 | <td align='left' width='40%'>$Lang::tr{'remote browse sync'}</td> | |
360 | <td align='left'> | |
361 | <input type='text' name='REMOTESYNC' value='$sambasettings{'REMOTESYNC'}' size="30" /> | |
362 | </td> | |
363 | </tr> | |
364 | </table> | |
365 | ||
366 | <br> | |
367 | ||
368 | <table width='10%' cellspacing='0'> | |
369 | <tr> | |
370 | <td align='center'> | |
371 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
372 | <input type='hidden' name='ACTION' value=$Lang::tr{'save'} /> | |
373 | <input type='image' alt='$Lang::tr{'save'}' title='$Lang::tr{'save'}' src='/images/media-floppy.png' /> | |
374 | </form> | |
375 | </td> | |
376 | <td align='center'> | |
377 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
378 | <input type='hidden' name='ACTION' value='globalcaption' /> | |
379 | <input type='image' alt='$Lang::tr{'caption'}' title='$Lang::tr{'caption'}' src='/images/help-browser.png' /> | |
380 | </form> | |
381 | </td> | |
382 | </tr> | |
383 | </table> | |
44254afd MT |
384 | END |
385 | ; | |
32f77a0b | 386 | |
44254afd | 387 | if ($sambasettings{'ACTION'} eq 'globalcaption') |
32f77a0b CS |
388 | { |
389 | print <<END | |
92004c61 | 390 | <br /> |
32f77a0b | 391 | <table width='95%' cellspacing='0'> |
c9e1c143 | 392 | <tr><td align='center' colspan='2'><b>$Lang::tr{'caption'}</b></td></tr> |
60124059 | 393 | <tr><td align='right' width='33%'><img src='/images/media-floppy.png' /></td><td align='left'>$Lang::tr{'save settings'}</td></tr> |
c9e1c143 | 394 | <tr><td align='right' width='33%'><img src='/images/reload.gif' /></td><td align='left'>$Lang::tr{'restore settings'}</td></tr> |
32f77a0b | 395 | </table> |
5e773594 MT |
396 | END |
397 | ; | |
32f77a0b CS |
398 | } |
399 | ||
5e773594 MT |
400 | &Header::closebox(); |
401 | ||
14cc7eac | 402 | ############################################################################################################################ |
32f77a0b | 403 | ########################################## Benutzerverwaltung fr Usersecurity ############################################# |
14cc7eac | 404 | |
1ee8bf5d | 405 | if ($sambasettings{'SECURITY'} eq 'user') |
32f77a0b | 406 | { |
70000894 | 407 | &Header::openbox('100%', 'center', $Lang::tr{'user management'}); |
32f77a0b | 408 | print <<END |
d3bea043 | 409 | <a name="$Lang::tr{'accounting'}"></a> |
92004c61 | 410 | <br /> |
d83d30d6 | 411 | <table class="tbl" width='95%' cellspacing='0'> |
32f77a0b | 412 | <tr><td colspan='6' align='left'></td></tr> |
f2fdd0c1 | 413 | <tr><td bgcolor='$color{'color20'}' colspan='7' align='left'><b>$Lang::tr{'accounting'}</b></td></tr> |
c9e1c143 | 414 | <tr><td align='left'><u>$Lang::tr{'username'}</u></td><td align='left'><u>$Lang::tr{'password'}</u></td> |
32f77a0b CS |
415 | END |
416 | ; | |
5e773594 | 417 | |
70000894 | 418 | print "<td></td>"; |
92004c61 | 419 | 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 | 420 | system('/usr/local/bin/sambactrl readsmbpasswd'); |
c41c2eb4 | 421 | open(FILE, "<${General::swroot}/samba/private/smbpasswd") or die "Can't read user file: $!"; |
32f77a0b CS |
422 | @user = <FILE>; |
423 | close(FILE); | |
424 | system('/usr/local/bin/sambactrl locksmbpasswd'); | |
a28fdc01 CS |
425 | |
426 | my $lines = 0; | |
427 | ||
32f77a0b CS |
428 | foreach $userentry (sort @user) |
429 | { | |
430 | @userline = split( /\:/, $userentry ); | |
a28fdc01 CS |
431 | if ($lines % 2) {print "<tr bgcolor='$color{'color20'}'>";} else {print "<tr bgcolor='$color{'color22'}'>";} |
432 | print "<td align='left'>$userline[0]</td><td align='left'>"; | |
32f77a0b CS |
433 | if ($userline[4] =~ /N/) |
434 | { | |
c9e1c143 | 435 | print "$Lang::tr{'not set'}</td><td align='left'>"; |
32f77a0b CS |
436 | } |
437 | else | |
438 | { | |
c9e1c143 | 439 | print "$Lang::tr{'set'}</td><td align='left'>"; |
32f77a0b CS |
440 | } |
441 | ||
70000894 | 442 | print "</td><td align='left'>"; |
32f77a0b CS |
443 | |
444 | if ($userline[4] =~ /D/) | |
445 | { | |
446 | print <<END | |
92004c61 | 447 | $Lang::tr{'inactive'}</td> |
19f5a6cc | 448 | <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'> |
32f77a0b CS |
449 | <input type='hidden' name='NAME' value='$userline[0]' /> |
450 | <input type='hidden' name='ACTION' value='smbuserenable' /> | |
25943d3b | 451 | <input type='image' alt='$Lang::tr{'activate'}' title='$Lang::tr{'activate'}' src='/images/off.gif' /> |
32f77a0b CS |
452 | </form></td> |
453 | END | |
454 | ; | |
455 | } | |
456 | else | |
457 | { | |
458 | print <<END | |
92004c61 | 459 | $Lang::tr{'active'}</td> |
19f5a6cc | 460 | <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'> |
32f77a0b CS |
461 | <input type='hidden' name='NAME' value='$userline[0]' /> |
462 | <input type='hidden' name='ACTION' value='smbuserdisable' /> | |
25943d3b | 463 | <input type='image' alt='$Lang::tr{'deactivate'}' title='$Lang::tr{'deactivate'}' src='/images/on.gif' /> |
32f77a0b CS |
464 | </form></td> |
465 | END | |
466 | ; | |
467 | } | |
468 | ||
469 | if ($userline[0] =~ /\$/) | |
470 | { | |
471 | print "<td></td>"; | |
472 | } | |
473 | else | |
474 | { | |
475 | print <<END | |
19f5a6cc | 476 | <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'> |
32f77a0b CS |
477 | <input type='hidden' name='NAME' value='$userline[0]' /> |
478 | <input type='hidden' name='ACTION' value='userchangepw' /> | |
a08a5f33 | 479 | <input type='image' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' src='/images/edit.gif' /> |
32f77a0b CS |
480 | </form></td> |
481 | END | |
482 | ; | |
483 | } | |
484 | ||
70000894 MT |
485 | print <<END |
486 | <td><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'> | |
487 | <input type='hidden' name='NAME' value='$userline[0]' /> | |
488 | <input type='hidden' name='ACTION' value='userdelete' /> | |
489 | <input type='image' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' src='/images/user-option-remove.png' /> | |
490 | </form></td></tr> | |
32f77a0b CS |
491 | END |
492 | ; | |
a28fdc01 | 493 | $lines++; |
32f77a0b CS |
494 | } |
495 | print <<END | |
496 | </table> | |
92004c61 | 497 | <br /> |
32f77a0b | 498 | <table width='10%' cellspacing='0'> |
19f5a6cc | 499 | <tr><td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'> |
32f77a0b | 500 | <input type='hidden' name='ACTION' value='useradd' /> |
a08a5f33 | 501 | <input type='image' alt='$Lang::tr{'add user'}' title='$Lang::tr{'add user'}' src='/images/user-option-add.png' /></form></td> |
5e773594 MT |
502 | END |
503 | ; | |
1ee8bf5d | 504 | |
32f77a0b | 505 | print <<END |
19f5a6cc | 506 | <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'> |
32f77a0b | 507 | <input type='hidden' name='ACTION' value='usercaption' /> |
a08a5f33 | 508 | <input type='image' alt='$Lang::tr{'caption'}' title='$Lang::tr{'caption'}' src='/images/help-browser.png' /></form> |
94819213 | 509 | </td></tr> |
32f77a0b CS |
510 | </table> |
511 | END | |
512 | ; | |
44254afd | 513 | |
32f77a0b CS |
514 | if ($sambasettings{'ACTION'} eq 'usercaption') |
515 | { | |
516 | print <<END | |
92004c61 | 517 | <br /> |
32f77a0b | 518 | <table width='95%' cellspacing='0'> |
c9e1c143 CS |
519 | <tr><td align='center' colspan='2'><b>$Lang::tr{'caption'}</b></td></tr> |
520 | <tr><td align='right' width='33%'><img src='/images/user-option-add.png' /></td><td align='left'>$Lang::tr{'add user'}</td></tr> | |
115340d2 | 521 | <tr><td align='right' width='33%'><img src='/images/network.png' /></td><td align='left'>$Lang::tr{'pc add'}</td></tr> |
c9e1c143 CS |
522 | <tr><td align='right' width='33%'><img src='/images/user-option-remove.png' /></td><td align='left'>$Lang::tr{'delete user'}</td></tr> |
523 | <tr><td align='right' width='33%'><img src='/images/network-error.png' /></td><td align='left'>$Lang::tr{'delete pc'}</td></tr> | |
25943d3b CS |
524 | <tr><td align='right' width='33%'><img src='/images/off.gif' /></td><td align='left'>$Lang::tr{'activate user'}</td></tr> |
525 | <tr><td align='right' width='33%'><img src='/images/on.gif' /></td><td align='left'>$Lang::tr{'deactivate user'}</td></tr> | |
c9e1c143 | 526 | <tr><td align='right' width='33%'><img src='/images/edit.gif' /></td><td align='left'>$Lang::tr{'change passwords'}</td></tr> |
60124059 | 527 | <tr><td align='right' width='33%'><img src='/images/media-floppy.png' /></td><td align='left'>$Lang::tr{'save config'}</td></tr> |
32f77a0b | 528 | </table> |
1ee8bf5d MT |
529 | END |
530 | ; | |
32f77a0b CS |
531 | } |
532 | ||
533 | if ($sambasettings{'ACTION'} eq 'userchangepw') | |
534 | { | |
535 | my $username = "$sambasettings{'NAME'}"; | |
536 | my $password = 'samba'; | |
537 | print <<END | |
92004c61 | 538 | <br /> |
19f5a6cc | 539 | <form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'> |
32f77a0b | 540 | <table width='95%' cellspacing='0'> |
f2fdd0c1 | 541 | <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'change passwords'}</b></td></tr> |
153cf640 | 542 | <tr><td align='left'>$Lang::tr{'username'}</td><td><input type='text' name='USERNAME' value='$username' size='30' readonly='readonly' /></td></tr> |
c9e1c143 | 543 | <tr><td align='left'>$Lang::tr{'password'}</td><td><input type='password' name='PASSWORD' value='$password' size='30' /></td></tr> |
32f77a0b | 544 | <tr><td colspan='2' align='center'><input type='hidden' name='ACTION' value='smbchangepw' /> |
f8aa0679 | 545 | <input type='image' alt='$Lang::tr{'save'}' title='$Lang::tr{'save'}' src='/images/media-floppy.png' /></td></tr> |
32f77a0b | 546 | </table> |
94819213 | 547 | </form> |
1ee8bf5d MT |
548 | END |
549 | ; | |
32f77a0b CS |
550 | } |
551 | ||
552 | if ($sambasettings{'ACTION'} eq 'useradd') | |
553 | { | |
554 | my $username = "user"; | |
555 | my $password = "samba"; | |
556 | chomp $username; | |
557 | $username=~s/\s//g; | |
558 | chomp $password; | |
559 | $password=~s/\s//g; | |
560 | print <<END | |
92004c61 | 561 | <br /> |
19f5a6cc | 562 | <form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'> |
32f77a0b | 563 | <table width='95%' cellspacing='0'> |
f2fdd0c1 | 564 | <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'add user'}</b></td></tr> |
c9e1c143 CS |
565 | <tr><td align='left'>$Lang::tr{'username'}</td><td><input type='text' name='USERNAME' value='$username' size='30' /></td></tr> |
566 | <tr><td align='left'>$Lang::tr{'password'}</td><td><input type='password' name='PASSWORD' value='$password' size='30' /></td></tr> | |
567 | <tr><td align='left'>$Lang::tr{'unix group'}</td><td><input type='text' name='GROUP' value='sambauser' size='30' /></td></tr> | |
568 | <tr><td align='left'>$Lang::tr{'unix shell'}</td><td><input type='text' name='SHELL' value='/bin/false' size='30' /></td></tr> | |
32f77a0b | 569 | <tr><td colspan='2' align='center'><input type='hidden' name='ACTION' value='smbuseradd' /> |
f8aa0679 | 570 | <input type='image' alt='$Lang::tr{'save'}' title='$Lang::tr{'save'}' src='/images/media-floppy.png' /></td></tr> |
32f77a0b | 571 | </table> |
94819213 | 572 | </form> |
32f77a0b CS |
573 | END |
574 | ; | |
575 | } | |
576 | ||
577 | if ($sambasettings{'ACTION'} eq 'pcadd') | |
578 | { | |
579 | my $pcname = "client\$"; | |
580 | chomp $pcname; | |
581 | $pcname=~s/\s//g; | |
582 | print <<END | |
92004c61 | 583 | <br /> |
19f5a6cc | 584 | <form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'accounting'}'> |
32f77a0b | 585 | <table width='95%' cellspacing='0'> |
f2fdd0c1 | 586 | <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'pc add'}</b></td></tr> |
c9e1c143 CS |
587 | <tr><td align='left'>$Lang::tr{'client'}</td><td><input type='text' name='PCNAME' value='$pcname' size='30' /></td></tr> |
588 | <tr><td align='left'>$Lang::tr{'unix group'}</td><td><input type='text' name='GROUP' value='sambawks' size='30' /></td></tr> | |
589 | <tr><td align='left'>$Lang::tr{'unix shell'}</td><td><input type='text' name='SHELL' value='/bin/false' size='30' /></td></tr> | |
32f77a0b | 590 | <tr><td colspan='2' align='center'><input type='hidden' name='ACTION' value='smbpcadd' /> |
f8aa0679 | 591 | <input type='image' alt='$Lang::tr{'save'}' title='$Lang::tr{'save'}' src='/images/media-floppy.png' /></td></tr> |
32f77a0b | 592 | </table> |
94819213 | 593 | </form> |
32f77a0b CS |
594 | END |
595 | ; | |
596 | } | |
97de2cae MT |
597 | |
598 | &Header::closebox(); | |
1ee8bf5d | 599 | } |
14cc7eac | 600 | |
0ffbb688 MT |
601 | if ($sambasettings{'SECURITY'} eq "ADS") { |
602 | &Header::openbox('100%', 'center', $Lang::tr{'samba join a domain'}); | |
603 | ||
604 | my $AD_DOMAINNAME = uc($mainsettings{'DOMAINNAME'}); | |
605 | ||
606 | print <<END; | |
607 | <form method="POST" action="$ENV{'SCRIPT_NAME'}"> | |
608 | <input type="hidden" name="ACTION" value="join"> | |
609 | ||
d83d30d6 | 610 | <table class="tbl" width="95%"> |
0ffbb688 MT |
611 | <tbody> |
612 | <tr> | |
613 | <td width="40%"> | |
614 | $Lang::tr{'domain'} | |
615 | </td> | |
616 | <td> | |
617 | $AD_DOMAINNAME | |
618 | </td> | |
619 | </tr> | |
620 | <tr> | |
621 | <td width="40%"> | |
622 | $Lang::tr{'administrator username'} | |
623 | </td> | |
624 | <td> | |
625 | <input type="text" name="USERNAME" size="30"> | |
626 | </td> | |
627 | </tr> | |
628 | <tr> | |
629 | <td width="40%"> | |
630 | $Lang::tr{'administrator password'} | |
631 | </td> | |
632 | <td> | |
633 | <input type="password" name="PASSWORD" size="30"> | |
634 | </td> | |
635 | </tr> | |
636 | <tr> | |
637 | <td></td> | |
638 | <td> | |
639 | <input type="submit" value="$Lang::tr{'samba join domain'}"> | |
640 | </td> | |
641 | </tr> | |
642 | </tbody> | |
643 | </table> | |
644 | </form> | |
645 | END | |
646 | ||
647 | &Header::closebox(); | |
648 | } | |
649 | ||
14cc7eac MT |
650 | ############################################################################################################################ |
651 | ############################################### Verwalten von Freigaben #################################################### | |
fa7be659 | 652 | |
c9e1c143 | 653 | &Header::openbox('100%', 'center', $Lang::tr{'shares'}); |
97de2cae | 654 | |
c41c2eb4 CS |
655 | my %shares = config("${General::swroot}/samba/shares"); |
656 | ||
657 | ||
1ee8bf5d | 658 | print <<END |
d3bea043 | 659 | <a name="$Lang::tr{'manage shares'}"></a> |
92004c61 | 660 | <br /> |
d83d30d6 | 661 | <table class="tbl" width='95%' cellspacing='0' class='tbl'> |
961f3dbc AM |
662 | <tr><th bgcolor='$color{'color20'}' colspan='3' align='left'><b>$Lang::tr{'manage shares'}</b></th></tr> |
663 | <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 |
664 | END |
665 | ; | |
14cc7eac | 666 | |
c41c2eb4 | 667 | my @Shares = keys(%shares); |
a28fdc01 | 668 | my $lines = 0; |
961f3dbc | 669 | my $col=""; |
c41c2eb4 | 670 | foreach my $shareentry (sort @Shares) |
32f77a0b | 671 | { |
c41c2eb4 | 672 | chomp $shareentry; |
961f3dbc AM |
673 | if ($lines % 2) { |
674 | print "<tr>"; | |
675 | $col="bgcolor='$color{'color20'}'"; | |
676 | } else { | |
677 | print "<tr>"; | |
678 | $col="bgcolor='$color{'color22'}'"; | |
679 | } | |
32f77a0b | 680 | print <<END |
961f3dbc AM |
681 | <td align='left' $col>$shareentry</td> |
682 | <td $col><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage shares'}'> | |
32f77a0b CS |
683 | <input type='hidden' name='NAME' value='$shareentry' /> |
684 | <input type='hidden' name='ACTION' value='sharechange' /> | |
a08a5f33 | 685 | <input type='image' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' src='/images/edit.gif' /> |
32f77a0b | 686 | </form></td> |
961f3dbc | 687 | <td $col><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage shares'}'> |
32f77a0b CS |
688 | <input type='hidden' name='NAME' value='$shareentry' /> |
689 | <input type='hidden' name='ACTION' value='smbsharedel' /> | |
a08a5f33 | 690 | <input type='image' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' src='/images/user-trash.png' /> |
94819213 | 691 | </form></td></tr> |
32f77a0b CS |
692 | END |
693 | ; | |
a28fdc01 | 694 | $lines++; |
32f77a0b CS |
695 | } |
696 | ||
697 | print <<END | |
698 | </table> | |
92004c61 | 699 | <br /> |
32f77a0b | 700 | <table width='10%' cellspacing='0'> |
19f5a6cc | 701 | <tr><td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage shares'}'> |
94819213 | 702 | <input type='hidden' name='ACTION' value='shareadd' /> |
a08a5f33 | 703 | <input type='image' alt='$Lang::tr{'add share'}' title='$Lang::tr{'add share'}' src='/images/list-add.png' /> |
32f77a0b | 704 | </form></td> |
19f5a6cc | 705 | <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'manage shares'}'> |
88932936 | 706 | <input type='hidden' name='ACTION' value='sharecaption' /> |
a08a5f33 | 707 | <input type='image' alt='$Lang::tr{'caption'}' title='$Lang::tr{'caption'}' src='/images/help-browser.png' /> |
88932936 CS |
708 | </form></td> |
709 | </tr> | |
32f77a0b | 710 | </table> |
1ee8bf5d MT |
711 | END |
712 | ; | |
32f77a0b | 713 | |
1ee8bf5d | 714 | if ($sambasettings{'ACTION'} eq 'sharecaption') |
32f77a0b CS |
715 | { |
716 | print <<END | |
92004c61 | 717 | <br /> |
32f77a0b | 718 | <table width='95%' cellspacing='0'> |
92004c61 | 719 | <tr><td align='center' colspan='2'><b>$Lang::tr{'caption'}</b></td></tr> |
60124059 | 720 | <tr><td align='right' width='33%'><img src='/images/list-add.png' /></td><td align='left'>$Lang::tr{'add share'}</td></tr> |
c9e1c143 | 721 | <tr><td align='right' width='33%'><img src='/images/edit.gif' /></td><td align='left'>$Lang::tr{'edit share'}</td></tr> |
60124059 | 722 | <tr><td align='right' width='33%'><img src='/images/media-floppy.png' /></td><td align='left'>$Lang::tr{'save config'}</td></tr> |
60124059 | 723 | <tr><td align='right' width='33%'><img src='/images/user-trash.png' /></td><td align='left'>$Lang::tr{'delete share'}</td></tr> |
32f77a0b | 724 | </table> |
1ee8bf5d MT |
725 | END |
726 | ; | |
32f77a0b | 727 | } |
97de2cae | 728 | |
1ee8bf5d | 729 | if ($sambasettings{'ACTION'} eq 'shareadd' || $sambasettings{'ACTION'} eq 'optioncaption' ) |
32f77a0b CS |
730 | { |
731 | print <<END | |
92004c61 | 732 | <br /> |
32f77a0b | 733 | <table width='95%' cellspacing='0'> |
f2fdd0c1 | 734 | <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'add share'}</b></td></tr> |
32f77a0b | 735 | <tr><td colspan='2' align='center'></td></tr> |
19f5a6cc | 736 | <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 | 737 | </table> |
92004c61 | 738 | <br /> |
32f77a0b | 739 | <table width='10%' cellspacing='0'> |
94819213 | 740 | <tr><td align='center'><input type='hidden' name='ACTION' value='smbshareadd' /> |
a08a5f33 | 741 | <input type='image' alt='$Lang::tr{'add share'}' title='$Lang::tr{'add share'}' src='/images/media-floppy.png' /></td></tr></form> |
32f77a0b | 742 | </table> |
5e773594 MT |
743 | END |
744 | ; | |
32f77a0b | 745 | } |
5e773594 | 746 | |
1ee8bf5d | 747 | if ($sambasettings{'ACTION'} eq 'sharechange' || $sambasettings{'ACTION'} eq 'optioncaption2' ) |
32f77a0b | 748 | { |
c41c2eb4 | 749 | my $shareoption = $shares{$sambasettings{'NAME'}}; |
32f77a0b | 750 | print <<END |
92004c61 | 751 | <br /> |
32f77a0b | 752 | <table width='95%' cellspacing='0'> |
f2fdd0c1 | 753 | <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'edit share'}</b></td></tr> |
32f77a0b | 754 | <tr><td colspan='2' align='center'></td></tr> |
19f5a6cc | 755 | <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 | 756 | </table> |
92004c61 | 757 | <br /> |
32f77a0b | 758 | <table width='10%' cellspacing='0'> |
94819213 | 759 | <tr><td align='center'><input type='hidden' name='NAME' value='$sambasettings{'NAME'}' /> |
a08a5f33 | 760 | <input type='image' alt='$Lang::tr{'change share'}' title='$Lang::tr{'change share'}' src='/images/media-floppy.png' /> |
fa7be659 | 761 | <input type='hidden' name='ACTION' value='smbsharechange' /></form></td></tr> |
32f77a0b | 762 | </table> |
1ee8bf5d MT |
763 | END |
764 | ; | |
32f77a0b | 765 | } |
5e773594 | 766 | |
c41c2eb4 CS |
767 | if ($sambasettings{'ACTION'} eq 'smbshareadd') |
768 | { | |
769 | $shares{'xvx'}= "$sambasettings{'SHAREOPTION'}"; | |
770 | save("shares"); | |
771 | my $shares = config("${General::swroot}/samba/shares"); | |
772 | } | |
773 | if ($sambasettings{'ACTION'} eq 'smbsharedel') | |
774 | { | |
775 | delete $shares{$sambasettings{'NAME'}}; | |
776 | save("shares"); | |
777 | my %shares = config("${General::swroot}/samba/shares"); | |
778 | } | |
779 | if ($sambasettings{'ACTION'} eq 'smbsharechange') | |
780 | { | |
781 | $shares{$sambasettings{'NAME'}} = $sambasettings{'SHAREOPTION'}; | |
782 | save("shares"); | |
783 | my %shares = config("${General::swroot}/samba/shares"); | |
784 | } | |
785 | ||
786 | &Header::closebox(); | |
787 | ||
32f77a0b CS |
788 | ############################################################################################################################ |
789 | ############################################### Anzeige des Sambastatus #################################################### | |
790 | ||
791 | &Header::openbox('100%', 'center', 'Status'); | |
792 | ||
793 | print <<END | |
92004c61 | 794 | <br /> |
d83d30d6 | 795 | <table class="tbl" width='95%' cellspacing='0'> |
f2fdd0c1 | 796 | <tr><td bgcolor='$color{'color20'}' colspan='3' align='left'><b>$Lang::tr{'samba status'}</b></td></tr> |
fb8e2c14 | 797 | <tr><td align='left'><small><pre>$Status</pre></small></td></tr> |
fa7be659 CS |
798 | </table> |
799 | END | |
800 | ; | |
801 | &Header::closebox(); | |
802 | ||
5e773594 MT |
803 | &Header::closebigbox(); |
804 | &Header::closepage(); | |
805 | ||
806 | ############################################################################################################################ | |
fa7be659 | 807 | ############################################ Subfunktion fr Sambadienste ################################################### |
5e773594 | 808 | |
c41c2eb4 CS |
809 | sub config |
810 | { | |
811 | my $file = shift; | |
812 | my @allarray = `grep -n '^\\[' $file`; | |
813 | my @linesarray = (); | |
814 | my @namearray = (); | |
815 | my %hash = (); | |
816 | my $options = (); | |
817 | my $EOF = qx(cat $file | wc -l); | |
818 | foreach my $allarrayentry (@allarray) | |
819 | { | |
820 | my @allarrayline = split( /\:/, $allarrayentry ); | |
821 | push(@linesarray,$allarrayline[0]);$allarrayline[1]=~s/\[//g;$allarrayline[1]=~s/\]//g;push(@namearray,$allarrayline[1]); | |
822 | } | |
823 | for(my $i = 0; $i <= $#namearray; $i++) | |
824 | { | |
825 | chomp $namearray[$i]; | |
826 | $namearray[$i]=~s/\[//g;$namearray[$i]=~s/\]//g; | |
827 | if ( $i eq $#namearray ) | |
828 | { | |
829 | my $lineend = $EOF-$linesarray[$i]+1; | |
830 | $options=qx(tail -$lineend $file); | |
831 | } | |
832 | else | |
833 | { | |
834 | my $linestart = $EOF-$linesarray[$i]+1; | |
835 | my $lineend = $linesarray[$i+1]-$linesarray[$i]; | |
836 | $options=qx(tail -$linestart $file | head -$lineend); | |
837 | } | |
838 | $hash{$namearray[$i]} = "$options"; | |
1e482cb6 | 839 | #print"<pre>$namearray[$i]\n$options\n</pre>"; # enable only for debuging |
c41c2eb4 CS |
840 | } |
841 | return(%hash); | |
842 | } | |
843 | ||
844 | sub save | |
845 | { | |
846 | my $smb = shift; | |
847 | open (FILE, ">${General::swroot}/samba/$smb") or die "Can't $smb settings $!"; | |
848 | flock (FILE, 2); | |
849 | ||
c41c2eb4 CS |
850 | if ( $smb eq 'shares') |
851 | {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";} } | |
852 | ||
853 | close FILE; | |
854 | ||
70000894 | 855 | system("/usr/local/bin/sambactrl smbsafeconf"); |
c41c2eb4 | 856 | system("/usr/local/bin/sambactrl smbreload"); |
a4a3e35c | 857 | } |
c41c2eb4 | 858 | |
5e773594 | 859 | sub isrunning |
32f77a0b CS |
860 | { |
861 | my $cmd = $_[0]; | |
862 | my $status = "<td align='center' bgcolor='${Header::colourred}'><font color='white'><b>$Lang::tr{'stopped'}</b></font></td>"; | |
863 | my $pid = ''; | |
864 | my $testcmd = ''; | |
865 | my $exename; | |
866 | ||
867 | $cmd =~ /(^[a-z]+)/; | |
868 | $exename = $1; | |
869 | ||
870 | if (open(FILE, "/var/run/${cmd}.pid")) | |
871 | { | |
872 | $pid = <FILE>; chomp $pid; | |
873 | close FILE; | |
874 | if (open(FILE, "/proc/${pid}/status")) | |
875 | { | |
876 | while (<FILE>) | |
877 | { | |
878 | if (/^Name:\W+(.*)/) | |
879 | { | |
880 | $testcmd = $1; | |
881 | } | |
882 | } | |
883 | close FILE; | |
884 | if ($testcmd =~ /$exename/) | |
885 | { | |
886 | $status = "<td align='center' bgcolor='${Header::colourgreen}'><font color='white'><b>$Lang::tr{'running'}</b></font></td>"; | |
887 | } | |
888 | } | |
889 | } | |
890 | return $status; | |
c41c2eb4 | 891 | } |
0ffbb688 MT |
892 | |
893 | sub joindomain { | |
894 | my $username = shift; | |
895 | my $password = shift; | |
896 | ||
897 | my @options = ("/usr/local/bin/sambactrl", "join", $username, $password); | |
898 | my $output = qx(@options); | |
899 | ||
900 | return $output; | |
901 | } |