3 # Save anonymous section options
5 require './proftpd-lib.pl';
9 $virt = $conf->[$in{'virt'}];
10 $vconf = $virt->{'members'};
15 &error_setup($text{'aserv_err'});
18 -d $in{'root'} || $in{'root'} =~ /^~/ || &error($text{'aserv_eroot'});
19 $in{'User_def'} || scalar(getpwnam($in{'User'})) ||
20 &error($text{'aserv_euser'});
21 $in{'Group_def'} || scalar(getgrnam($in{'Group'})) ||
22 &error($text{'aserv_egroup'});
25 # Create a new <Anonymous> directive
26 $l = $vconf->[@$vconf - 1];
27 &lock_file($l->{'file'});
29 $lref = &read_file_lines($l->{'file'});
30 local @l = ( "<Anonymous $in{'root'}>" );
31 push(@l, "User $in{'User'}") if (!$in{'User_def'});
32 push(@l, "UserAlias anonymous $in{'User'}") if (!$in{'User_def'});
33 push(@l, "Group $in{'Group'}") if (!$in{'Group_def'});
34 push(@l, "</Anonymous>");
35 splice(@$lref, $l->{'eline'}+1, 0, @l);
38 &unlock_file($l->{'file'});
39 &webmin_log("anon", "create", $in{'root'}, \%in);
42 # Update existing directive
43 $anon = &find_directive_struct("Anonymous", $vconf);
44 &lock_file($anon->{'file'});
46 $lref = &read_file_lines($anon->{'file'});
47 $lref->[$anon->{'line'}] = "<Anonymous $in{'root'}>";
48 &save_directive("User", $in{'User_def'} ? [ ] : [ $in{'User'} ],
49 $anon->{'members'}, $vconf);
50 &save_directive("Group", $in{'Group_def'} ? [ ] : [ $in{'Group'} ],
51 $anon->{'members'}, $vconf);
54 &unlock_file($anon->{'file'});
55 &webmin_log("anon", "save", $anon->{'value'}, \%in);
57 &redirect("anon_index.cgi?virt=$in{'virt'}");