Handle hostnames with upper-case letters
[webmin.git] / file / list_shares.cgi
1 #!/usr/local/bin/perl
2 # list_shares.cgi
3 # Output info about samba shares
4
5 require './file-lib.pl';
6 print "Content-type: text/plain\n\n";
7 if ($access{'uid'}) {
8         # User has no access to samba
9         print "0\n";
10         exit;
11         }
12
13 %minfo = &get_module_info("samba");
14 &read_acl(\%acl, undef);
15 if (!%minfo || !&check_os_support(\%minfo) ||
16     !$acl{$base_remote_user,'samba'}) {
17         # Samba module not installed or supported
18         print "0\n";
19         exit;
20         }
21
22 &foreign_require("samba", "samba-lib.pl");
23 %sconfig = &foreign_config("samba");
24 if (!-r $sconfig{'smb_conf'} || !&has_command($sconfig{'samba_server'})) {
25         # Samba not installed
26         print "0\n";
27         exit;
28         }
29
30 print "1\n";
31 foreach $s (&foreign_call("samba", "list_shares")) {
32         &foreign_call("samba", "get_share", $s);
33         if ($s ne 'global' && $s ne 'homes' && $s ne 'printers' &&
34             $samba::share{'path'} =~ /^\/[^\%\s\:]*$/ &&
35             $samba::share{'printable'} !~ /true|yes/i) {
36                 printf "%s:%s:%s:%s:%s\n",
37                         $samba::share{'path'},
38                         $samba::share{'available'} =~ /no|false/i ? 0 : 1,
39                         $samba::share{'writable'} =~ /yes|true/i ||
40                          $samba::share{'writeable'} =~ /yes|true/i ? 1 : 0,
41                         $samba::share{'guest only'} =~ /yes|true/i ? 2 :
42                         $samba::share{'public'} =~ /yes|true/i ? 1 : 0,
43                         $samba::share{'comment'};
44                 }
45         }
46