MOON
Server: Apache
System: Linux cl1170g 4.19.62-mod-std-ipv6-64-rescue #828825 SMP Tue Jul 30 13:54:49 UTC 2019 x86_64
User: wh0f20bb (1057)
PHP: 5.6.40
Disabled: NONE
Upload Files
File: //proc/thread-self/root/root/webmin-1.881/file/list_shares.cgi
#!/usr/bin/perl
# list_shares.cgi
# Output info about samba shares

require './file-lib.pl';
print "Content-type: text/plain\n\n";
if ($access{'uid'}) {
	# User has no access to samba
	print "0\n";
	exit;
	}

%minfo = &get_module_info("samba");
&read_acl(\%acl, undef);
if (!%minfo || !&check_os_support(\%minfo) ||
    !$acl{$base_remote_user,'samba'}) {
	# Samba module not installed or supported
	print "0\n";
	exit;
	}

&foreign_require("samba", "samba-lib.pl");
%sconfig = &foreign_config("samba");
if (!-r $sconfig{'smb_conf'} || !&has_command($sconfig{'samba_server'})) {
	# Samba not installed
	print "0\n";
	exit;
	}

print "1\n";
foreach $s (&foreign_call("samba", "list_shares")) {
	&foreign_call("samba", "get_share", $s);
	if ($s ne 'global' && $s ne 'homes' && $s ne 'printers' &&
	    $samba::share{'path'} =~ /^\/[^\%\s\:]*$/ &&
	    $samba::share{'printable'} !~ /true|yes/i) {
		printf "%s:%s:%s:%s:%s\n",
			$samba::share{'path'},
			$samba::share{'available'} =~ /no|false/i ? 0 : 1,
			$samba::share{'writable'} =~ /yes|true/i ||
			 $samba::share{'writeable'} =~ /yes|true/i ? 1 : 0,
			$samba::share{'guest only'} =~ /yes|true/i ? 2 :
			$samba::share{'public'} =~ /yes|true/i ? 1 : 0,
			$samba::share{'comment'};
		}
	}