Esempio n. 1
0
void
stop_samba(int force_stop)
{
	char* svcs[] = { "smbd", "nmbd", NULL };

	if (!force_stop && nvram_match("wins_enable", "1"))
		svcs[1] = NULL;

	kill_services(svcs, 5, 1);

	clean_smbd_trash();
}
Esempio n. 2
0
void run_samba(void)
{
	int sh_num, has_nmbd, i;
	char tmpuser[40], tmp2[40];
	char cmd[256];

	if (nvram_match("enable_samba", "0") || nvram_match("st_samba_mode", "0"))
		return;

	mkdir_if_none("/etc/samba", "777");

	has_nmbd = pids("nmbd");
	if (!has_nmbd) {
		doSystem("rm -f %s", "/etc/samba/*");
		clean_smbd_trash();
	}

	recreate_passwd_unix(0);

	write_smb_conf();

	sh_num = nvram_safe_get_int("acc_num", 0, 0, MAX_ACCOUNT_NUM);
	for (i = 0; i < sh_num; i++) {
		snprintf(tmpuser, sizeof(tmpuser), "acc_username%d", i);
		snprintf(tmp2, sizeof(tmp2), "acc_password%d", i);
		snprintf(cmd, sizeof(cmd), "smbpasswd %s %s", nvram_safe_get(tmpuser), nvram_safe_get(tmp2));
		system(cmd);
	}

	if (has_nmbd)
		doSystem("killall %s %s", "-SIGHUP", "nmbd");
	else
		eval("/sbin/nmbd", "-D", "-s", "/etc/smb.conf");

	eval("/sbin/smbd", "-D", "-s", "/etc/smb.conf");

	if (pids("smbd") && pids("nmbd"))
		logmessage("Samba Server", "daemon is started");
}