3 # Save inputs from conf_pass.cgi
5 require './samba-lib.pl';
7 &lock_file($config{'smb_conf'});
8 $global = &get_share("global");
12 &error_setup("<blink><font color=red>$text{'eacl_aviol'}</font></blink>");
13 &error("$text{'eacl_np'} $text{'eacl_pcp'}") unless $access{'conf_pass'};
15 &error_setup($text{'savepass_fail'});
16 $nopass = (`$config{samba_password_program} 2>&1 </dev/null` =~ /encryption not selected/);
17 if ($in{encrypt_passwords} eq "yes" && $nopass) {
18 &error($text{'savepass_nopass'});
20 &setval("encrypt passwords", $in{encrypt_passwords}, "no");
22 &setval("null passwords", $in{null_passwords}, "no");
24 if (!$in{passwd_program_def} && !$in{passwd_program}) {
25 &error($text{'savepass_passwd'});
27 &setval("passwd program", $in{passwd_program_def}?"":$in{passwd_program}, "");
29 &setval("unix password sync", $in{'unix_password_sync'}, "no");
31 if ($in{passwd_chat_def}) { &delval("passwd chat"); }
33 for($i=0; defined($in{"chat_recv_$i"}); $i++) {
34 push(@chat, $in{"chat_recv_$i"});
35 push(@chat, $in{"chat_send_$i"});
38 for($i=0; $i<@chat; $i++) {
39 if ($chat[$i] =~ /\S/) { $clast = $i; }
42 &error($text{'savepass_chat'});
44 @chat = @chat[0 .. $clast];
45 @chat = map { /^$/ ? "." : /^\S+$/ ? $_ : "\"$_\""; } @chat;
46 &setval("passwd chat", join(' ', @chat));
49 $mapfile = &getval("username map");
50 if ($in{username_map_def}) { &delval("username map"); }
53 $config{smb_conf} =~ /^(.*)\/[^\/]+$/;
54 $mapfile = "$1/user.map";
56 &setval("username map", $mapfile);
57 for($i=0; defined($in{"umap_unix_$i"}); $i++) {
58 if ($in{"umap_unix_$i"} =~ /\S/ && $in{"umap_win_$i"} =~ /\S/) {
59 if ($in{"umap_win_$i"} =~ /\s/) {
60 push(@umap, $in{"umap_unix_$i"}."=\"".
61 $in{"umap_win_$i"}."\"");
64 push(@umap, $in{"umap_unix_$i"}."=".
69 &open_lock_tempfile(UMAP, "> $mapfile");
70 foreach $line (@umap) {
71 &print_tempfile(UMAP, "$line\n");
73 &close_tempfile(UMAP);
76 if ($global) { &modify_share("global", "global"); }
77 else { &create_share("global"); }
78 &unlock_file($config{'smb_conf'});
79 &webmin_log("pass", undef, undef, \%in);