3 # Save a manually edited file
5 require './sendmail-lib.pl';
6 &error_setup($text{'file_err'});
7 $access{'manual'} || &error($text{'file_ecannot'});
9 $conf = &get_sendmailcf();
10 if ($in{'mode'} eq 'aliases') {
11 require './aliases-lib.pl';
12 $file = &aliases_file($conf)->[$in{'idx'}];
13 $return = "list_aliases.cgi";
15 $access{'amode'} == 1 && $access{'aedit_1'} && $access{'aedit_2'} &&
16 $access{'aedit_3'} && $access{'aedit_4'} && $access{'aedit_5'} &&
17 $access{'amax'} == 0 && $access{'apath'} eq '/' ||
18 &error($text{'file_ealiases'});
22 elsif ($in{'mode'} eq 'virtusers') {
23 require './virtusers-lib.pl';
24 $file = &virtusers_file($conf);
25 ($vdbm, $vdbmtype) = &virtusers_dbm($conf);
26 $return = "list_virtusers.cgi";
27 $post = "$config{'makemap_path'} $vdbmtype $vdbm <$file";
28 $access{'vmode'} == 1 && $access{'vedit_0'} && $access{'vedit_1'} &&
29 $access{'vedit_2'} && $access{'vmax'} == 0 ||
30 &error($text{'file_evirtusers'});
34 elsif ($in{'mode'} eq 'mailers') {
35 require './mailers-lib.pl';
36 $file = &mailers_file($conf);
37 ($mdbm, $mdbmtype) = &mailers_dbm($conf);
38 $return = "list_mailers.cgi";
39 $post = "$config{'makemap_path'} $mdbmtype $mdbm <$file";
40 $access{'mailers'} || &error($text{'file_emailers'});
44 elsif ($in{'mode'} eq 'generics') {
45 require './generics-lib.pl';
46 $file = &generics_file($conf);
47 ($gdbm, $gdbmtype) = &generics_dbm($conf);
48 $return = "list_generics.cgi";
49 $post = "$config{'makemap_path'} $gdbmtype $gdbm <$file";
50 $access{'omode'} == 1 || &error($text{'file_egenerics'});
54 elsif ($in{'mode'} eq 'domains') {
55 require './domain-lib.pl';
56 $file = &domains_file($conf);
57 ($ddbm, $ddbmtype) = &domains_dbm($conf);
58 $return = "list_domains.cgi";
59 $post = "$config{'makemap_path'} $ddbmtype $ddbm <$file";
60 $access{'domains'} || &error($text{'file_edomains'});
64 elsif ($in{'mode'} eq 'access') {
65 require './access-lib.pl';
66 $file = &access_file($conf);
67 ($adbm, $adbmtype) = &access_dbm($conf);
68 $return = "list_access.cgi";
69 $post = "$config{'makemap_path'} $adbmtype $adbm <$file";
70 $access{'access'} || &error($text{'file_eaccess'});
74 else { &error($text{'file_emode'}); }
77 $in{'text'} =~ s/\r//g;
78 @lines = split(/\n+/, $in{'text'});
79 foreach my $l (@lines) {
82 if ($fmt eq "alias") {
83 $l =~ /^\s*(\S+):\s*(\S.*)$/ ||
84 &error(&text('file_ealias',
85 "<tt>".&html_escape($l)."</tt>"));
87 elsif ($fmt eq "tab") {
88 $l =~ /^\s*(\S+)\s+(\S.*)$/ ||
89 &error(&text('file_etab',
90 "<tt>".&html_escape($l)."</tt>"));
95 &open_lock_tempfile(FILE, ">$file");
96 &print_tempfile(FILE, $in{'text'});
97 &close_tempfile(FILE);
98 &webmin_log("manual", $log, $file);
100 if (!&rebuild_map_cmd($file)) {
101 &system_logged("$post >/dev/null 2>&1") if ($post);