Handle hostnames with upper-case letters
[webmin.git] / proftpd / find_ftpaccess.cgi
1 #!/usr/local/bin/perl
2 # find_ftpaccess.cgi
3 # Finds all per-directory options files under the all the document roots
4
5 require './proftpd-lib.pl';
6 &ReadParse();
7 @rv = grep { -r $_ } @ftpaccess_files;
8 &error_setup($text{'find_err'});
9
10 if ($in{'from'}) {
11         # Look under the given directory
12         @dirs = ( $in{'dir'} );
13         }
14 else {
15         # Look in Anonymous sections
16         $conf = &get_config();
17         $anon = &find_directive("Anonymous", $conf);
18         push(@dirs, $anon) if ($anon);
19         foreach $v (&find_directive_struct("VirtualHost", $conf)) {
20                 $anon = &find_directive("Anonymous", $v->{'members'});
21                 push(@dirs, $anon) if ($anon);
22                 }
23         &error($text{'find_eanon'}) if (!@dirs);
24         }
25
26 foreach $d (@dirs) {
27         if ($d =~ /^~(\S+)$/) {
28                 local @u = getpwnam($1);
29                 $d = $u[7];
30                 next if (!$u[7]);
31                 }
32         open(FIND, "find '$d' -name .ftpaccess -print |");
33         while(<FIND>) {
34                 s/\r|\n//g;
35                 push(@rv, $_);
36                 }
37         close(FIND);
38         }
39
40 # save results
41 $site{'ftpaccess'} = join(' ', &unique(@rv));
42 &write_file("$module_config_directory/site", \%site);
43 &redirect("ftpaccess.cgi");
44