Menu

[r1569]: / trunk / www / services_samba.php  Maximize  Restore  History

Download this file

436 lines (408 with data), 20.3 kB

  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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
#!/usr/local/bin/php
<?php
/*
services_samba.php
part of FreeNAS (http://www.freenas.org)
Copyright (C) 2005-2007 Olivier Cochard-Labbe <olivier@freenas.org>.
All rights reserved.
Based on m0n0wall (http://m0n0.ch/wall)
Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
require("guiconfig.inc");
$pgtitle = array(gettext("Services"),gettext("CIFS/SMB"));
if (!is_array($config['samba'])) {
$config['samba'] = array();
}
if(!is_array($config['samba']['auxparam']))
$config['samba']['auxparam'] = array();
sort($config['samba']['auxparam']);
if (!is_array($config['mounts']['mount']))
$config['mounts']['mount'] = array();
mount_sort();
$a_mount = &$config['mounts']['mount'];
$pconfig['netbiosname'] = $config['samba']['netbiosname'];
$pconfig['workgroup'] = $config['samba']['workgroup'];
$pconfig['serverdesc'] = $config['samba']['serverdesc'];
$pconfig['security'] = $config['samba']['security'];
$pconfig['localmaster'] = $config['samba']['localmaster'];
$pconfig['winssrv'] = $config['samba']['winssrv'];
$pconfig['timesrv'] = $config['samba']['timesrv'];
$pconfig['unixcharset'] = $config['samba']['unixcharset'];
$pconfig['doscharset'] = $config['samba']['doscharset'];
$pconfig['loglevel'] = $config['samba']['loglevel'];
$pconfig['sndbuf'] = $config['samba']['sndbuf'];
$pconfig['rcvbuf'] = $config['samba']['rcvbuf'];
$pconfig['enable'] = isset($config['samba']['enable']);
$pconfig['largereadwrite'] = isset($config['samba']['largereadwrite']);
$pconfig['easupport'] = isset($config['samba']['easupport']);
$pconfig['readahead'] = isset($config['samba']['readahead']);
$pconfig['createmask'] = $config['samba']['createmask'];
$pconfig['directorymask'] = $config['samba']['directorymask'];
if ($_POST) {
unset($input_errors);
$pconfig = $_POST;
$reqdfields = array();
$reqdfieldsn = array();
$reqdfieldst = array();
if ($_POST['enable']) {
$reqdfields = explode(" ", "security netbiosname workgroup localmaster");
$reqdfieldsn = array(gettext("Authentication"),gettext("NetBiosName"),gettext("Workgroup"),gettext("Local Master Browser"));
}
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
if ($_POST['enable']) {
$reqdfields = explode(" ", "netbiosname workgroup winssrv sndbuf rcvbuf createmask directorymask");
$reqdfieldsn = array(gettext("NetBiosName"),gettext("Workgroup"),gettext("WINS server"),gettext("Send Buffer Size"),gettext("Receive Buffer Size"),gettext("Create mask"),gettext("Directory mask"));
$reqdfieldst = explode(" ", "domain workgroup ipaddr numericint numericint filemode filemode");
}
do_input_validation_type($_POST, $reqdfields, $reqdfieldsn, $reqdfieldst, &$input_errors);
if (!$input_errors) {
$config['samba']['netbiosname'] = $_POST['netbiosname'];
$config['samba']['workgroup'] = $_POST['workgroup'];
$config['samba']['serverdesc'] = $_POST['serverdesc'];
$config['samba']['security'] = $_POST['security'];
$config['samba']['localmaster'] = $_POST['localmaster'];
$config['samba']['winssrv'] = $_POST['winssrv'];
$config['samba']['timesrv'] = $_POST['timesrv'];
$config['samba']['doscharset'] = $_POST['doscharset'];
$config['samba']['unixcharset'] = $_POST['unixcharset'];
$config['samba']['loglevel'] = $_POST['loglevel'];
$config['samba']['sndbuf'] = $_POST['sndbuf'];
$config['samba']['rcvbuf'] = $_POST['rcvbuf'];
$config['samba']['largereadwrite'] = $_POST['largereadwrite'] ? true : false;
$config['samba']['easupport'] = $_POST['easupport'] ? true : false;
$config['samba']['readahead'] = $_POST['readahead'] ? true : false;
if (!empty($_POST['createmask']))
$config['samba']['createmask'] = $_POST['createmask'];
else
unset($config['samba']['createmask']);
if (!empty($_POST['directorymask']))
$config['samba']['directorymask'] = $_POST['directorymask'];
else
unset($config['samba']['directorymask']);
$config['samba']['enable'] = $_POST['enable'] ? true : false;
write_config();
$retval = 0;
if (!file_exists($d_sysrebootreqd_path)) {
config_lock();
$retval |= rc_update_service("samba");
$retval |= rc_update_service("mdnsresponder");
config_unlock();
}
$savemsg = get_std_save_message($retval);
if(0 == $retval) {
if(file_exists($d_smbconfdirty_path))
unlink($d_smbconfdirty_path);
}
}
}
if($_GET['act'] === "del") {
/* Remove entry from auxparam list */
unset($config['samba']['auxparam'][$_GET['id']]);
write_config();
touch($d_smbconfdirty_path);
header("Location: services_samba.php");
exit;
}
?>
<?php include("fbegin.inc");?>
<script language="JavaScript">
<!--
function enable_change(enable_change) {
var endis = !(document.iform.enable.checked || enable_change);
document.iform.netbiosname.disabled = endis;
document.iform.workgroup.disabled = endis;
document.iform.localmaster.disabled = endis;
document.iform.winssrv.disabled = endis;
document.iform.timesrv.disabled = endis;
document.iform.serverdesc.disabled = endis;
document.iform.doscharset.disabled = endis;
document.iform.unixcharset.disabled = endis;
document.iform.loglevel.disabled = endis;
document.iform.sndbuf.disabled = endis;
document.iform.rcvbuf.disabled = endis;
document.iform.security.disabled = endis;
document.iform.largereadwrite.disabled = endis;
document.iform.easupport.disabled = endis;
document.iform.readahead.disabled = true;
document.iform.createmask.disabled = endis;
document.iform.directorymask.disabled = endis;
}
function authentication_change() {
switch(document.iform.security.value) {
case "share":
showElementById('createmask_tr','show');
showElementById('directorymask_tr','show');
break;
default:
showElementById('createmask_tr','hide');
showElementById('directorymask_tr','hide');
break;
}
}
//-->
</script>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="tabnavtbl">
<ul id="tabnav">
<li class="tabact"><a href="services_samba.php" style="color:black" title="<?=gettext("Reload page");?>"><?=gettext("Settings");?></a></li>
<li class="tabinact"><a href="services_samba_share.php"><?=gettext("Shares");?></a></li>
</ul>
</td>
</tr>
<tr>
<td class="tabcont">
<form action="services_samba.php" method="post" name="iform" id="iform">
<?php if ($input_errors) print_input_errors($input_errors);?>
<?php if ($savemsg) print_info_box($savemsg);?>
<?php if (file_exists($d_smbconfdirty_path)):?><p>
<?php print_info_box_np(gettext("The configuration has been changed.<br>You must apply the changes in order for them to take effect."));?><br>
<input name="apply" type="submit" class="formbtn" id="apply" value="<?=gettext("Apply changes");?>"></p>
<?php endif;?>
<table width="100%" border="0" cellpadding="6" cellspacing="0">
<tr>
<td colspan="2" valign="top" class="optsect_t">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>
<td class="optsect_s"><strong>Common Internet File System</strong></td>
<td align="right" class="optsect_s"><input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable']) echo "checked"; ?> onClick="enable_change(false)"> <strong><?=gettext("Enable") ;?></strong></td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="22%" valign="top" class="vncellreq"><?=gettext("Authentication"); ?></td>
<td width="78%" class="vtable">
<?=$mandfldhtml;?><select name="security" class="formfld" id="security" onchange="authentication_change()">
<?php $types = explode(",", "Anonymous,Local User,Domain"); $vals = explode(" ", "share user domain");?>
<?php $j = 0; for ($j = 0; $j < count($vals); $j++): ?>
<option value="<?=$vals[$j];?>" <?php if ($vals[$j] == $pconfig['security']) echo "selected";?>>
<?=htmlspecialchars($types[$j]);?>
</option>
<?php endfor; ?>
</select>
</td>
</tr>
<tr>
<td width="22%" valign="top" class="vncellreq"><?=gettext("NetBiosName") ;?></td>
<td width="78%" class="vtable">
<?=$mandfldhtml;?><input name="netbiosname" type="text" class="formfld" id="netbiosname" size="30" value="<?=htmlspecialchars($pconfig['netbiosname']);?>">
</td>
</tr>
<tr>
<td width="22%" valign="top" class="vncellreq"><?=gettext("Workgroup") ; ?></td>
<td width="78%" class="vtable">
<?=$mandfldhtml;?><input name="workgroup" type="text" class="formfld" id="workgroup" size="30" value="<?=htmlspecialchars($pconfig['workgroup']);?>">
<br><?=gettext("Workgroup to be member of.") ;?>
</td>
</tr>
<tr>
<tr>
<td width="22%" valign="top" class="vncell"><?=gettext("Description") ;?></td>
<td width="78%" class="vtable">
<input name="serverdesc" type="text" class="formfld" id="serverdesc" size="30" value="<?=htmlspecialchars($pconfig['serverdesc']);?>">
<br><?=gettext("Server description. This can usually be left blank.") ;?>
</td>
</tr>
<tr>
<td width="22%" valign="top" class="vncell"><?=gettext("Dos charset") ; ?></td>
<td width="78%" class="vtable">
<select name="doscharset" class="formfld" id="doscharset">
<?php $types = explode(",", "CP850,CP852,CP437,CP932,CP866,ASCII"); $vals = explode(" ", "CP850 CP852 CP437 CP932 CP866 ASCII");?>
<?php $j = 0; for ($j = 0; $j < count($vals); $j++): ?>
<option value="<?=$vals[$j];?>" <?php if ($vals[$j] == $pconfig['doscharset']) echo "selected";?>>
<?=htmlspecialchars($types[$j]);?>
</option>
<?php endfor; ?>
</select>
</td>
</tr>
<tr>
<td width="22%" valign="top" class="vncell"><?=gettext("Unix charset") ; ?></td>
<td width="78%" class="vtable">
<select name="unixcharset" class="formfld" id="unixcharset">
<?php $types = explode(",", "UTF-8,iso-8859-1,iso-8859-15,gb2312,EUC-JP,ASCII"); $vals = explode(" ", "UTF-8 iso-8859-1 iso-8859-15 gb2312 EUC-JP ASCII");?>
<?php $j = 0; for ($j = 0; $j < count($vals); $j++): ?>
<option value="<?=$vals[$j];?>" <?php if ($vals[$j] == $pconfig['unixcharset']) echo "selected";?>>
<?=htmlspecialchars($types[$j]);?>
</option>
<?php endfor; ?>
</select>
</td>
</tr>
<tr>
<td width="22%" valign="top" class="vncell"><?=gettext("Log Level") ; ?></td>
<td width="78%" class="vtable">
<select name="loglevel" class="formfld" id="loglevel">
<?php $types = explode(",", "Minimum,Normal,Full,Debug"); $vals = explode(" ", "1 2 3 10");?>
<?php $j = 0; for ($j = 0; $j < count($vals); $j++): ?>
<option value="<?=$vals[$j];?>" <?php if ($vals[$j] == $pconfig['loglevel']) echo "selected";?>>
<?=htmlspecialchars($types[$j]);?>
</option>
<?php endfor; ?>
</select>
</td>
</tr>
<tr>
<td width="22%" valign="top" class="vncell"><?=gettext("Local Master Browser"); ?></td>
<td width="78%" class="vtable">
<select name="localmaster" class="formfld" id="localmaster">
<?php $types = array(gettext("Yes"),gettext("No")); $vals = explode(" ", "yes no");?>
<?php $j = 0; for ($j = 0; $j < count($vals); $j++): ?>
<option value="<?=$vals[$j];?>" <?php if ($vals[$j] == $pconfig['localmaster']) echo "selected";?>>
<?=htmlspecialchars($types[$j]);?>
</option>
<?php endfor; ?>
</select>
<br><?php echo sprintf(gettext("Allows %s to try and become a local master browser."), get_product_name());?>
</td>
</tr>
<tr>
<td width="22%" valign="top" class="vncell"><?=gettext("Time server"); ?></td>
<td width="78%" class="vtable">
<select name="timesrv" class="formfld" id="timesrv">
<?php $types = array(gettext("Yes"),gettext("No")); $vals = explode(" ", "yes no");?>
<?php $j = 0; for ($j = 0; $j < count($vals); $j++): ?>
<option value="<?=$vals[$j];?>" <?php if ($vals[$j] == $pconfig['timesrv']) echo "selected";?>>
<?=htmlspecialchars($types[$j]);?>
</option>
<?php endfor; ?>
</select>
<br><?php echo sprintf(gettext("%s advertises itself as a time server to Windows clients."), get_product_name());?>
</td>
</tr>
<tr>
<td width="22%" valign="top" class="vncell"><?=gettext("WINS server"); ?></td>
<td width="78%" class="vtable">
<input name="winssrv" type="text" class="formfld" id="winssrv" size="30" value="<?=htmlspecialchars($pconfig['winssrv']);?>">
<br><?=gettext("WINS Server IP address."); ?>
</td>
</tr>
<tr>
<td colspan="2" class="list" height="12"></td>
</tr>
<tr>
<td colspan="2" valign="top" class="listtopic"><?=gettext("Advanced settings");?></td>
</tr>
<tr id="createmask_tr">
<td width="22%" valign="top" class="vncell"><?=gettext("Create mask"); ?></td>
<td width="78%" class="vtable">
<input name="createmask" type="text" class="formfld" id="createmask" size="30" value="<?=htmlspecialchars($pconfig['createmask']);?>">
<br><?=gettext("Use this option to override the file creation mask (0666 by default).");?>
</td>
</tr>
<tr id="directorymask_tr">
<td width="22%" valign="top" class="vncell"><?=gettext("Directory mask"); ?></td>
<td width="78%" class="vtable">
<input name="directorymask" type="text" class="formfld" id="directorymask" size="30" value="<?=htmlspecialchars($pconfig['directorymask']);?>">
<br><?=gettext("Use this option to override the directory creation mask (0777 by default).");?>
</td>
</tr>
<tr>
<td width="22%" valign="top" class="vncell"><?=gettext("Send Buffer Size"); ?></td>
<td width="78%" class="vtable">
<input name="sndbuf" type="text" class="formfld" id="sndbuf" size="30" value="<?=htmlspecialchars($pconfig['sndbuf']);?>">
<br><?=gettext("Size of send buffer (16384 by default)."); ?>
</td>
</tr>
<tr>
<td width="22%" valign="top" class="vncell"><?=gettext("Receive Buffer Size") ; ?></td>
<td width="78%" class="vtable">
<input name="rcvbuf" type="text" class="formfld" id="rcvbuf" size="30" value="<?=htmlspecialchars($pconfig['rcvbuf']);?>">
<br><?=gettext("Size of receive buffer (16384 by default).") ; ?>
</td>
</tr>
<tr>
<td width="22%" valign="top" class="vncell"><?=gettext("Large read/write");?></td>
<td width="78%" class="vtable">
<input name="largereadwrite" type="checkbox" id="largereadwrite" value="yes" <?php if ($pconfig['largereadwrite']) echo "checked"; ?>>
<?=gettext("Enable large read/write");?><span class="vexpl"><br>
<?=gettext("Use the new 64k streaming read and write varient SMB requests introduced with Windows 2000.");?></span>
</td>
</tr>
<tr>
<td width="22%" valign="top" class="vncell"><?=gettext("ReadAhead");?></td>
<td width="78%" class="vtable">
<input name="readahead" type="checkbox" id="readahead" value="yes" <?php if ($pconfig['readahead']) echo "checked"; ?>>
<?=gettext("Enable pipe-lined read support");?><span class="vexpl"><br>
<?=gettext("Improved performance when transferring files via Vista client");?></span>
</td>
</tr>
<tr>
<td width="22%" valign="top" class="vncell"><?=gettext("EA support");?></td>
<td width="78%" class="vtable">
<input name="easupport" type="checkbox" id="easupport" value="yes" <?php if ($pconfig['easupport']) echo "checked"; ?>>
<?=gettext("Enable extended attribute support");?><span class="vexpl"><br>
<?=gettext("Allow clients to attempt to store OS/2 style extended attributes on a share.");?></span>
</td>
</tr>
<tr>
<td width="22%" valign="top" class="vncell"><?=gettext("Auxiliary parameters");?></td>
<td width="78%" class="vtable">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="90%" class="listhdrr"><?=gettext("Parameter");?></td>
<td width="10%" class="list"></td>
</tr>
<?php if (is_array($config['samba']['auxparam'])):?>
<?php $i = 0; foreach($config['samba']['auxparam'] as $auxparamv):?>
<tr>
<td class="listlr"><?=htmlspecialchars($auxparamv);?> &nbsp;</td>
<td valign="middle" nowrap class="list">
<?php if(isset($config['samba']['enable'])):?>
<a href="services_samba_auxparam.php?id=<?=$i;?>"><img src="e.gif" title="<?=gettext("Edit parameter");?>" width="17" height="17" border="0"></a>&nbsp;
<a href="services_samba.php?act=del&id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this parameter?");?>')"><img src="x.gif" title="<?=gettext("Delete parameter"); ?>" width="17" height="17" border="0"></a>
<?php endif;?>
</td>
</tr>
<?php $i++; endforeach;?>
<?php endif;?>
<tr>
<td class="list" colspan="1"></td>
<td class="list">
<a href="services_samba_auxparam.php"><img src="plus.gif" title="<?=gettext("Add parameter");?>" width="17" height="17" border="0"></a>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="22%" valign="top">&nbsp;</td>
<td width="78%">
<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save and Restart");?>" onClick="enable_change(true)">
</td>
</tr>
<tr>
<td width="22%" valign="top">&nbsp;</td>
<td width="78%"><span class="red"><strong><?=gettext("Note");?>:</strong></span><br><?php echo sprintf( gettext("To increase CIFS performance try the following:<br>- Enable 'Large read/write' switch<br>- Enable '<a href='%s'>Tuning</a>' switch<br>- Increase <a href='%s'>MTU</a>"), "system_advanced.php", "interfaces_lan.php");?></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
<script language="JavaScript">
<!--
enable_change(false);
authentication_change();
//-->
</script>
<?php include("fend.inc");?>
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.