2011年10月12日 星期三

更改Tomato的SAMBA設定讓Wan連接

1.更改檔案"release/src-rt/router/www/nas-media.asp"
增加選項3&4

function verifyFields(focused, quiet)
{
var a, b;

a = E('_smbd_enable').value;

elem.display(PR('_smbd_user'), PR('_smbd_passwd'), ((a == 2) || (a == 4)));

E('_smbd_wgroup').disabled = (a == 0);
E('_smbd_cpage').disabled = (a == 0);
E('_smbd_custom').disabled = (a == 0);
E('_smbd_autoshare').disabled = (a == 0);
E('_f_smbd_master').disabled = (a == 0);
...........

return 1;
}
<div class='section-title'>Samba 伺服器設定(Samba File Sharing)</div>
<div class='section'>
<script type='text/javascript'>
createFieldTable('', [
{ title: '檔案分享', name: 'smbd_enable', type: 'select',
options: [['0', 'No'],['1', 'Yes, no Authentication, LAN only'],['2', 'Yes, Authentication required, LAN only'],['3', 'Yes, no Authentication, WAN and LAN'],['4', 'Yes, Authentication required, WAN and LAN']],
value: nvram.smbd_enable },
{ title: '使用者名稱', indent: 2, name: 'smbd_user', type: 'text', maxlen: 50, size: 32,
value: nvram.smbd_user },
............
</script>
</div>

2.更改檔案"release/src-rt/router/httpd/tomato.c"
更改smbd_enable範圍為4

#ifdef TCONFIG_SAMBASRV
// nas-samba - !!TB
{ "smbd_enable", V_RANGE(0, 4) },
{ "smbd_wgroup", V_LENGTH(0, 20) },
{ "smbd_master", V_01 },
{ "smbd_wins", V_01 },
{ "smbd_cpage", V_LENGTH(0, 4) },
{ "smbd_cset", V_LENGTH(0, 20) },
{ "smbd_custom", V_TEXT(0, 2048) },
{ "smbd_autoshare", V_RANGE(0, 3) },
{ "smbd_shares", V_LENGTH(0, 4096) },
{ "smbd_user", V_LENGTH(0, 50) },
{ "smbd_passwd", V_LENGTH(0, 50) },
#endif

2.更改檔案"release/src-rt/router/rc/services.c"
更改產生"/etc/smb.conf"的地方

static void start_samba(void)
{
FILE *fp;
DIR *dir = NULL;
struct dirent *dp;
char nlsmod[15];
int mode;
char *nv;

if (getpid() != 1) {
start_service("smbd");
return;
}

mode = nvram_get_int("smbd_enable");
if (!mode || !nvram_invmatch("lan_hostname", ""))
return;

if ((fp = fopen("/etc/smb.conf", "w")) == NULL)
return;

fprintf(fp, "[global]\n"
" interfaces = %s %s\n"
" bind interfaces only = yes\n"
" workgroup = %s\n"
" netbios name = %s\n"
" server string = %s\n"
" guest account = nobody\n"
" security = user\n"
" %s\n"
" guest ok = %s\n"
" guest only = no\n"
" browseable = yes\n"
" syslog only = yes\n"
" timestamp logs = no\n"
" syslog = 1\n"
" encrypt passwords = yes\n"
" preserve case = yes\n"
" short preserve case = yes\n",
nvram_safe_get("lan_ifname"),
((mode == 1) || (mode == 2)) ?  "": nvram_safe_get("wan_ifname"),
nvram_get("smbd_wgroup") ? : "WORKGROUP",
nvram_safe_get("lan_hostname"),
nvram_get("router_name") ? : "Tomato",
((mode == 2) || (mode == 4)) ? "" : "map to guest = Bad User",
((mode == 2) || (mode == 4)) ? "no" : "yes" // guest ok
);

4.完成後可在WEBUI看見新增設定


沒有留言:

張貼留言