#!/usr/bin/perl # Handles remote_* function calls by a faster method. When first called # as a CGI, forks and starts listening on a port which is returned to the # client. From then on, direct TCP connections can be made to this port # to send requests and get replies. BEGIN { push(@INC, "."); }; use WebminCore; use POSIX; use Socket; $force_lang = $default_lang; &init_config(); print "Content-type: text/plain\n\n"; # Can this user make remote calls? if (!&webmin_user_can_rpc()) { print "0 Invalid user for RPC\n"; exit; } # Will IPv6 work? &get_miniserv_config(\%miniserv); $use_ipv6 = 0; if ($miniserv{'ipv6'}) { eval "use Socket6"; $use_ipv6 = 1 if (!$@); } # Find a free port $port = $miniserv{'port'} || 10000; $aerr = &allocate_socket(MAIN, $use_ipv6 ? MAIN6 : undef, \$port); if ($aerr) { print "0 $aerr\n"; exit; } if (open(RANDOM, "/dev/urandom")) { local $tmpsid; read(RANDOM, $tmpsid, 16); $sid = lc(unpack('h*', $tmpsid)); close RANDOM; } else { $sid = time()*$$; } $version = &get_webmin_version(); print "1 $port $sid $version\n"; # Fork and listen for calls .. $pid = fork(); if ($pid < 0) { die "fork() failed : $!"; } elsif ($pid) { exit; } untie(*STDIN); untie(*STDOUT); # Accept the TCP connection local $rmask; vec($rmask, fileno(MAIN), 1) = 1; if ($use_ipv6) { vec($rmask, fileno(MAIN6), 1) = 1; } $sel = select($rmask, undef, undef, 60); if ($sel <= 0) { print STDERR "fastrpc: accept timed out\n" if ($gconfig{'rpcdebug'}); exit; } if (vec($rmask, fileno(MAIN), 1)) { $acptaddr = accept(SOCK, MAIN); } elsif ($use_ipv6 && vec($rmask, fileno(MAIN6), 1)) { $acptaddr = accept(SOCK, MAIN6); } else { die "No connection on any socket!"; } die "accept failed : $!" if (!$acptaddr); $oldsel = select(SOCK); $| = 1; select($oldsel); $rcount = 0; while(1) { # Wait for the request. Wait longer if this isn't the first one local $rmask; vec($rmask, fileno(SOCK), 1) = 1; local $sel = select($rmask, undef, undef, $rcount ? 360 : 60); if ($sel <= 0) { print STDERR "fastrpc: session timed out\n" if ($gconfig{'rpcdebug'}); last; } local $line = <SOCK>; last if (!$line); local ($len, $auth) = split(/\s+/, $line); die "Invalid session ID" if ($auth ne $sid); local $rawarg; while(length($rawarg) < $len) { local $got; local $rv = read(SOCK, $got, $len - length($rawarg)); exit if ($rv <= 0); $rawarg .= $got; } print STDERR "fastrpc: raw $rawarg\n" if ($gconfig{'rpcdebug'}); local $dumper = substr($rawarg, 0, 5) eq '$VAR1' ? 1 : 0; local $arg = &unserialise_variable($rawarg); # Process it local $rv; if ($arg->{'action'} eq 'ping') { # Just respond with an OK print STDERR "fastrpc: ping\n" if ($gconfig{'rpcdebug'}); $rv = { 'status' => 1 }; } elsif ($arg->{'action'} eq 'check') { # Check if some module is supported print STDERR "fastrpc: check $arg->{'module'}\n" if ($gconfig{'rpcdebug'}); $rv = { 'status' => 1, 'rv' => &foreign_check($arg->{'module'}, undef, undef, $arg->{'api'}) }; } elsif ($arg->{'action'} eq 'config') { # Get the config for some module print STDERR "fastrpc: config $arg->{'module'}\n" if ($gconfig{'rpcdebug'}); local %config = &foreign_config($arg->{'module'}); $rv = { 'status' => 1, 'rv' => \%config }; } elsif ($arg->{'action'} eq 'write') { # Transfer data to a local temp file local $file = $arg->{'file'} ? $arg->{'file'} : $arg->{'name'} ? &tempname($arg->{'name'}) : &tempname(); print STDERR "fastrpc: write $file\n" if ($gconfig{'rpcdebug'}); open(FILE, ">$file"); binmode(FILE); print FILE $arg->{'data'}; close(FILE); $rv = { 'status' => 1, 'rv' => $file }; } elsif ($arg->{'action'} eq 'tcpwrite') { # Transfer data to a local temp file over TCP connection local $file = $arg->{'file'} ? $arg->{'file'} : $arg->{'name'} ? &tempname($arg->{'name'}) : &tempname(); print STDERR "fastrpc: tcpwrite $file\n" if ($gconfig{'rpcdebug'}); local $tsock = time().$$; local $tsock6 = $use_ipv6 ? time().$$."v6" : undef; local $tport = $port + 1; &allocate_socket($tsock, $tsock6, \$tport); if (!fork()) { # Accept connection in separate process print STDERR "fastrpc: tcpwrite $file port $tport\n" if ($gconfig{'rpcdebug'}); local $rmask; vec($rmask, fileno($tsock), 1) = 1; if ($use_ipv6) { vec($rmask, fileno($tsock6), 1) = 1; } local $sel = select($rmask, undef, undef, 30); exit if ($sel <= 0); if (vec($rmask, fileno($tsock), 1)) { accept(TRANS, $tsock) || exit; } elsif ($use_ipv6 && vec($rmask, fileno($tsock6), 1)) { accept(TRANS, $tsock6) || exit; } print STDERR "fastrpc: tcpwrite $file accepted\n" if ($gconfig{'rpcdebug'}); local $buf; local $err; if (open(FILE, ">$file")) { binmode(FILE); print STDERR "fastrpc: tcpwrite $file writing\n" if ($gconfig{'rpcdebug'}); my $bs = &get_buffer_size(); while(read(TRANS, $buf, $bs) > 0) { local $ok = (print FILE $buf); if (!$ok) { $err = "Write to $file failed : $!"; last; } } close(FILE); print STDERR "fastrpc: tcpwrite $file written\n" if ($gconfig{'rpcdebug'}); } else { print STDERR "fastrpc: tcpwrite $file open failed $!\n" if ($gconfig{'rpcdebug'}); $err = "Failed to open $file : $!"; } print TRANS $err ? "$err\n" : "OK\n"; close(TRANS); exit; } close($tsock); close($tsock6); print STDERR "fastrpc: tcpwrite $file done\n" if ($gconfig{'rpcdebug'}); $rv = { 'status' => 1, 'rv' => [ $file, $tport ] }; } elsif ($arg->{'action'} eq 'read') { # Transfer data from a file print STDERR "fastrpc: read $arg->{'file'}\n" if ($gconfig{'rpcdebug'}); local ($data, $got); open(FILE, "<$arg->{'file'}"); binmode(FILE); my $bs = &get_buffer_size(); while(read(FILE, $got, $bs) > 0) { $data .= $got; } close(FILE); $rv = { 'status' => 1, 'rv' => $data }; } elsif ($arg->{'action'} eq 'tcpread') { # Transfer data from a file over TCP connection print STDERR "fastrpc: tcpread $arg->{'file'}\n" if ($gconfig{'rpcdebug'}); if (-d $arg->{'file'}) { $rv = { 'status' => 1, 'rv' => [ undef, "$arg->{'file'} is a directory" ] }; } elsif (!open(FILE, "<$arg->{'file'}")) { $rv = { 'status' => 1, 'rv' => [ undef, "Failed to open $arg->{'file'} : $!" ] }; } else { binmode(FILE); local $tsock = time().$$; local $tsock6 = $use_ipv6 ? time().$$."v6" : undef; local $tport = $port + 1; &allocate_socket($tsock, $tsock6, \$tport); if (!fork()) { # Accept connection in separate process local $rmask; vec($rmask, fileno($tsock), 1) = 1; if ($use_ipv6) { vec($rmask, fileno($tsock6), 1) = 1; } local $sel = select($rmask, undef, undef, 30); exit if ($sel <= 0); if (vec($rmask, fileno($tsock), 1)) { accept(TRANS, $tsock) || exit; } elsif (vec($rmask, fileno($tsock6), 1)) { accept(TRANS, $tsock6) || exit; } local $buf; while(read(FILE, $buf, 1024) > 0) { print TRANS $buf; } close(FILE); close(TRANS); exit; } close(FILE); close($tsock); close($tsock6); print STDERR "fastrpc: tcpread $arg->{'file'} done\n" if ($gconfig{'rpcdebug'}); $rv = { 'status' => 1, 'rv' => [ $arg->{'file'}, $tport ] }; } } elsif ($arg->{'action'} eq 'require') { # require a library print STDERR "fastrpc: require $arg->{'module'}/$arg->{'file'}\n" if ($gconfig{'rpcdebug'}); eval { &foreign_require($arg->{'module'}, $arg->{'file'}); }; if ($@) { print STDERR "fastrpc: require error $@\n" if ($gconfig{'rpcdebug'}); $rv = { 'status' => 0, 'rv' => $@ }; } else { print STDERR "fastrpc: require done\n" if ($gconfig{'rpcdebug'}); $rv = { 'status' => 1 }; } } elsif ($arg->{'action'} eq 'call') { # execute a function print STDERR "fastrpc: call $arg->{'module'}::$arg->{'func'}(",join(",", @{$arg->{'args'}}),")\n" if ($gconfig{'rpcdebug'}); local @rv; eval { local $main::error_must_die = 1; @rv = &foreign_call($arg->{'module'}, $arg->{'func'}, @{$arg->{'args'}}); }; if ($@) { print STDERR "fastrpc: call error $@\n" if ($gconfig{'rpcdebug'}); $rv = { 'status' => 0, 'rv' => $@ }; } elsif (@rv == 1) { $rv = { 'status' => 1, 'rv' => $rv[0] }; } else { $rv = { 'status' => 1, 'arv' => \@rv }; } print STDERR "fastrpc: call $arg->{'module'}::$arg->{'func'} done = ",join(",", @rv),"\n" if ($gconfig{'rpcdebug'}); } elsif ($arg->{'action'} eq 'eval') { # eval some perl code print STDERR "fastrpc: eval $arg->{'module'} $arg->{'code'}\n" if ($gconfig{'rpcdebug'}); local $erv; if ($arg->{'module'}) { local $pkg = $arg->{'module'}; $pkg =~ s/[^A-Za-z0-9]/_/g; $erv = eval "package $pkg;\n". $arg->{'code'}."\n"; } else { $erv = eval $arg->{'code'}; } print STDERR "fastrpc: eval $arg->{'module'} $arg->{'code'} done = $rv error = $@\n" if ($gconfig{'rpcdebug'}); if ($@) { $rv = { 'status' => 0, 'rv' => $@ }; } else { $rv = { 'status' => 1, 'rv' => $erv }; } } elsif ($arg->{'action'} eq 'quit') { print STDERR "fastrpc: quit\n" if ($gconfig{'rpcdebug'}); $rv = { 'status' => 1 }; } else { print STDERR "fastrpc: unknown $arg->{'action'}\n" if ($gconfig{'rpcdebug'}); $rv = { 'status' => 0 }; } $rawrv = &serialise_variable($rv, $dumper); # Send back to the client print SOCK length($rawrv),"\n"; print SOCK $rawrv; last if ($arg->{'action'} eq 'quit'); $rcount++; } # allocate_socket(handle, ipv6-handle, &port) sub allocate_socket { local ($fh, $fh6, $port) = @_; local $proto = getprotobyname('tcp'); if (!socket($fh, PF_INET, SOCK_STREAM, $proto)) { return "socket failed : $!"; } setsockopt($fh, SOL_SOCKET, SO_REUSEADDR, pack("l", 1)); if ($fh6) { if (!socket($fh6, PF_INET6(), SOCK_STREAM, $proto)) { return "socket6 failed : $!"; } setsockopt($fh6, SOL_SOCKET, SO_REUSEADDR, pack("l", 1)); setsockopt($fh6, 41, 26, pack("l", 1)); # IPv6 only } while(1) { $$port++; $pack = pack_sockaddr_in($$port, INADDR_ANY); next if (!bind($fh, $pack)); if ($fh6) { $pack6 = pack_sockaddr_in6($$port, in6addr_any()); next if (!bind($fh6, $pack6)); } last; } listen($fh, SOMAXCONN) || return "listen failed : $!"; if ($fh6) { listen($fh6, SOMAXCONN) || return "listen6 failed : $!"; } return undef; }
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
acl | Folder | 0755 |
|
|
adsl-client | Folder | 0755 |
|
|
apache | Folder | 0755 |
|
|
at | Folder | 0755 |
|
|
authentic-theme | Folder | 0755 |
|
|
backup-config | Folder | 0755 |
|
|
bacula-backup | Folder | 0755 |
|
|
bandwidth | Folder | 0755 |
|
|
bin | Folder | 0755 |
|
|
bind8 | Folder | 0755 |
|
|
blue-theme | Folder | 0755 |
|
|
change-user | Folder | 0755 |
|
|
cluster-copy | Folder | 0755 |
|
|
cluster-cron | Folder | 0755 |
|
|
cluster-passwd | Folder | 0755 |
|
|
cluster-shell | Folder | 0755 |
|
|
cluster-software | Folder | 0755 |
|
|
cluster-useradmin | Folder | 0755 |
|
|
cluster-usermin | Folder | 0755 |
|
|
cluster-webmin | Folder | 0755 |
|
|
cpan | Folder | 0755 |
|
|
cron | Folder | 0755 |
|
|
custom | Folder | 0755 |
|
|
dfsadmin | Folder | 0755 |
|
|
dhcpd | Folder | 0755 |
|
|
dovecot | Folder | 0755 |
|
|
exim | Folder | 0755 |
|
|
exports | Folder | 0755 |
|
|
fail2ban | Folder | 0755 |
|
|
fdisk | Folder | 0755 |
|
|
fetchmail | Folder | 0755 |
|
|
filemin | Folder | 0755 |
|
|
filter | Folder | 0755 |
|
|
firewall | Folder | 0755 |
|
|
firewall6 | Folder | 0755 |
|
|
firewalld | Folder | 0755 |
|
|
fsdump | Folder | 0755 |
|
|
gray-theme | Folder | 0755 |
|
|
grub | Folder | 0755 |
|
|
heartbeat | Folder | 0755 |
|
|
htaccess-htpasswd | Folder | 0755 |
|
|
idmapd | Folder | 0755 |
|
|
images | Folder | 0755 |
|
|
inetd | Folder | 0755 |
|
|
init | Folder | 0755 |
|
|
inittab | Folder | 0755 |
|
|
ipfilter | Folder | 0755 |
|
|
ipfw | Folder | 0755 |
|
|
ipsec | Folder | 0755 |
|
|
iscsi-client | Folder | 0755 |
|
|
iscsi-server | Folder | 0755 |
|
|
iscsi-target | Folder | 0755 |
|
|
iscsi-tgtd | Folder | 0755 |
|
|
jabber | Folder | 0755 |
|
|
krb5 | Folder | 0755 |
|
|
lang | Folder | 0755 |
|
|
ldap-client | Folder | 0755 |
|
|
ldap-server | Folder | 0755 |
|
|
ldap-useradmin | Folder | 0755 |
|
|
logrotate | Folder | 0755 |
|
|
logviewer | Folder | 0755 |
|
|
lpadmin | Folder | 0755 |
|
|
lvm | Folder | 0755 |
|
|
mailboxes | Folder | 0755 |
|
|
mailcap | Folder | 0755 |
|
|
man | Folder | 0755 |
|
|
mon | Folder | 0755 |
|
|
mount | Folder | 0755 |
|
|
mysql | Folder | 0755 |
|
|
net | Folder | 0755 |
|
|
nis | Folder | 0755 |
|
|
openslp | Folder | 0755 |
|
|
package-updates | Folder | 0755 |
|
|
pam | Folder | 0755 |
|
|
pap | Folder | 0755 |
|
|
passwd | Folder | 0755 |
|
|
phpini | Folder | 0755 |
|
|
postfix | Folder | 0755 |
|
|
postgresql | Folder | 0755 |
|
|
ppp-client | Folder | 0755 |
|
|
pptp-client | Folder | 0755 |
|
|
pptp-server | Folder | 0755 |
|
|
proc | Folder | 0755 |
|
|
procmail | Folder | 0755 |
|
|
proftpd | Folder | 0755 |
|
|
qmailadmin | Folder | 0755 |
|
|
quota | Folder | 0755 |
|
|
raid | Folder | 0755 |
|
|
samba | Folder | 0755 |
|
|
sarg | Folder | 0755 |
|
|
sendmail | Folder | 0755 |
|
|
servers | Folder | 0755 |
|
|
shell | Folder | 0755 |
|
|
shorewall | Folder | 0755 |
|
|
shorewall6 | Folder | 0755 |
|
|
smart-status | Folder | 0755 |
|
|
smf | Folder | 0755 |
|
|
software | Folder | 0755 |
|
|
spam | Folder | 0755 |
|
|
squid | Folder | 0755 |
|
|
sshd | Folder | 0755 |
|
|
status | Folder | 0755 |
|
|
stunnel | Folder | 0755 |
|
|
syslog | Folder | 0755 |
|
|
syslog-ng | Folder | 0755 |
|
|
system-status | Folder | 0755 |
|
|
tcpwrappers | Folder | 0755 |
|
|
time | Folder | 0755 |
|
|
tunnel | Folder | 0755 |
|
|
unauthenticated | Folder | 0755 |
|
|
updown | Folder | 0755 |
|
|
useradmin | Folder | 0755 |
|
|
usermin | Folder | 0755 |
|
|
vendor_perl | Folder | 0755 |
|
|
vgetty | Folder | 0755 |
|
|
webalizer | Folder | 0755 |
|
|
webmin | Folder | 0755 |
|
|
webmincron | Folder | 0755 |
|
|
webminlog | Folder | 0755 |
|
|
wuftpd | Folder | 0755 |
|
|
xinetd | Folder | 0755 |
|
|
xterm | Folder | 0755 |
|
|
LICENCE | File | 1.48 KB | 0644 |
|
LICENCE.ja | File | 1.62 KB | 0644 |
|
README.md | File | 4.25 KB | 0644 |
|
WebminCore.pm | File | 7.85 KB | 0644 |
|
acl_security.pl | File | 4.51 KB | 0755 |
|
changepass.pl | File | 868 B | 0755 |
|
chooser.cgi | File | 7.21 KB | 0755 |
|
config-aix | File | 227 B | 0644 |
|
config-cobalt-linux | File | 264 B | 0644 |
|
config-coherent-linux | File | 264 B | 0644 |
|
config-corel-linux | File | 264 B | 0644 |
|
config-debian-linux | File | 264 B | 0644 |
|
config-freebsd | File | 256 B | 0644 |
|
config-generic-linux | File | 264 B | 0644 |
|
config-gentoo-linux | File | 264 B | 0644 |
|
config-hpux | File | 243 B | 0644 |
|
config-irix | File | 284 B | 0644 |
|
config-lib.pl | File | 10.82 KB | 0755 |
|
config-macos | File | 260 B | 0644 |
|
config-mandrake-linux | File | 278 B | 0644 |
|
config-msc-linux | File | 264 B | 0644 |
|
config-netbsd | File | 283 B | 0644 |
|
config-open-linux | File | 264 B | 0644 |
|
config-openbsd | File | 241 B | 0644 |
|
config-openmamba-linux | File | 264 B | 0644 |
|
config-openserver | File | 236 B | 0644 |
|
config-osf1 | File | 266 B | 0644 |
|
config-pardus-linux | File | 264 B | 0644 |
|
config-redhat-linux | File | 264 B | 0644 |
|
config-slackware-linux | File | 280 B | 0644 |
|
config-sol-linux | File | 264 B | 0644 |
|
config-solaris | File | 417 B | 0644 |
|
config-suse-linux | File | 264 B | 0644 |
|
config-syno-linux | File | 364 B | 0644 |
|
config-trustix-linux | File | 264 B | 0644 |
|
config-turbo-linux | File | 264 B | 0644 |
|
config-united-linux | File | 264 B | 0644 |
|
config-unixware | File | 286 B | 0644 |
|
config-windows | File | 88 B | 0644 |
|
config.cgi | File | 1.55 KB | 0755 |
|
config_save.cgi | File | 1.64 KB | 0755 |
|
copyconfig.pl | File | 4.33 KB | 0755 |
|
create-module.pl | File | 3.82 KB | 0755 |
|
date_chooser.cgi | File | 2.19 KB | 0755 |
|
deb-name | File | 7 B | 0644 |
|
defaultacl | File | 98 B | 0644 |
|
defaulttheme | File | 16 B | 0644 |
|
entities_map.txt | File | 1.47 KB | 0644 |
|
fastrpc.cgi | File | 10.18 KB | 0755 |
|
favicon.ico | File | 14.73 KB | 0644 |
|
feedback.cgi | File | 6.37 KB | 0755 |
|
feedback_form.cgi | File | 3.45 KB | 0755 |
|
group_chooser.cgi | File | 7.36 KB | 0755 |
|
help.cgi | File | 2.94 KB | 0755 |
|
index.cgi | File | 5.61 KB | 0755 |
|
install-module.pl | File | 1.54 KB | 0755 |
|
install-type | File | 4 B | 0644 |
|
javascript-lib.pl | File | 14.69 KB | 0755 |
|
lang_list.txt | File | 3.41 KB | 0644 |
|
maketemp.pl | File | 424 B | 0755 |
|
mime.types | File | 12.42 KB | 0644 |
|
miniserv.pem | File | 2.9 KB | 0644 |
|
miniserv.pl | File | 179.71 KB | 0755 |
|
module_chooser.cgi | File | 4.14 KB | 0755 |
|
newmods.pl | File | 1.25 KB | 0755 |
|
os_list.txt | File | 34.18 KB | 0644 |
|
oschooser.pl | File | 4.55 KB | 0755 |
|
pam_login.cgi | File | 2.83 KB | 0755 |
|
password_change.cgi | File | 7 KB | 0755 |
|
password_form.cgi | File | 1.3 KB | 0755 |
|
perlpath.pl | File | 571 B | 0755 |
|
record-failed.pl | File | 503 B | 0755 |
|
record-login.pl | File | 513 B | 0755 |
|
record-logout.pl | File | 516 B | 0755 |
|
robots.txt | File | 26 B | 0644 |
|
rpc.cgi | File | 4 KB | 0755 |
|
run-postinstalls.pl | File | 1 KB | 0755 |
|
run-uninstalls.pl | File | 1004 B | 0755 |
|
safeacl | File | 44 B | 0644 |
|
session_login.cgi | File | 3.55 KB | 0755 |
|
setup-repos.sh | File | 4.66 KB | 0755 |
|
setup.bat | File | 3.09 KB | 0644 |
|
setup.pl | File | 30.33 KB | 0755 |
|
setup.sh | File | 32.06 KB | 0755 |
|
switch_skill.cgi | File | 293 B | 0755 |
|
switch_user.cgi | File | 404 B | 0755 |
|
thirdparty.pl | File | 1.73 KB | 0755 |
|
ui-lib.pl | File | 82.8 KB | 0755 |
|
update-from-repo.sh | File | 14.8 KB | 0755 |
|
uptracker.cgi | File | 2.88 KB | 0755 |
|
user_chooser.cgi | File | 7.29 KB | 0755 |
|
version | File | 6 B | 0644 |
|
web-lib-funcs.pl | File | 356.13 KB | 0755 |
|
web-lib.pl | File | 907 B | 0755 |
|
webmin-daemon | File | 80 B | 0644 |
|
webmin-init | File | 1.93 KB | 0755 |
|
webmin-pam | File | 101 B | 0644 |
|
webmin-search-lib.pl | File | 9.42 KB | 0755 |
|
webmin-systemd | File | 371 B | 0644 |
|
webmin_search.cgi | File | 2.63 KB | 0755 |
|
xmlrpc.cgi | File | 7.53 KB | 0755 |
|