#!/usr/bin/perl # setup.pl # This script should be run after the webmin archive is unpacked, in order # to setup the various config files use POSIX; use Socket; # Find install directory $ENV{'LANG'} = ''; $0 =~ s/\\/\//g; $bootscript = $ENV{'bootscript'} || "webmin"; if ($0 =~ /^(.*)\//) { chdir($1); } $wadir = getcwd(); $wadir =~ s/\\/\//g; # always use / separator on windows $srcdir = $wadir; open(VERSION, "$wadir/version") || &errorexit("Cannot find the Webmin install directory"); chop($ver = <VERSION>); close(VERSION); my $spaces_count_def = 10; my $verleneach = int(length($ver) / 2); my $space_count = int($spaces_count_def - $verleneach); my $space_count_cond = " " x $space_count; print "***********************************************************************\n"; print "* $space_count_cond Welcome to the Webmin setup script, version $ver $space_count_cond *\n"; print "***********************************************************************\n"; print "Webmin is a web-based interface that allows Unix-like operating\n"; print "systems and common Unix services to be easily administered.\n"; print "\n"; # Only root can run this if ($< != 0) { &errorexit("The Webmin install script must be run as root"); } # Use the supplied destination directory, if any if ($ARGV[0]) { $wadir = $ARGV[0]; $wadir =~ s/\\/\//g; # always use / separator on windows print "Installing Webmin from $srcdir to $wadir\n"; if (!-d $wadir) { mkdir($wadir, 0755) || &errorexit("Failed to create $wadir"); } else { # Make sure dest dir is not in use @files = grep { !/rpmsave/ } &files_in_dir($wadir); if (@files && !-r "$wadir/setup.pl") { &errorexit("Installation directory $wadir contains other files"); } } } else { print "Installing Webmin in $wadir\n" } # Work out perl library path $ENV{'PERLLIB'} = $wadir; $ENV{'WEBMIN_LIBDIR'} = $wadir; if ($ENV{'perllib'}) { $ENV{'PERLLIB'} .= ":".$ENV{'perllib'}; } # Validate source directory @allmods = map { s/\/module.info$//; $_ } glob("*/module.info"); if (!@allmods) { &errorexit("ERROR: Failed to get module list"); } $allmods = join(" ", @allmods); print "\n"; chdir($wadir); # Load package-defined variable overrides if (-r "$srcdir/setup-pre.pl") { require "$srcdir/setup-pre.pl"; } # Ask for webmin config directory print "***********************************************************************\n"; print "Webmin uses separate directories for configuration files and log files.\n"; print "Unless you want to run multiple versions of Webmin at the same time\n"; print "you can just accept the defaults.\n"; print "\n"; my $envetcdir = $ENV{'config_directory'} || "/etc/webmin"; print "Config file directory [$envetcdir]: "; if ($ENV{'config_directory'}) { $config_directory = $ENV{'config_directory'}; print "$envetcdir\n"; print ".. predefined\n"; $envetcdirexists = 1; } else { chop($config_directory = <STDIN>); } $config_directory ||= "/etc/webmin"; $config_directory =~ s/\\/\//g; if ($config_directory !~ /^([a-z]:)?\//i) { &errorexit("Config directory must be an absolute path"); } if (!-d $config_directory) { make_dir_recursive_local($config_directory, 0755) || &errorexit("Failed to create directory $config_directory"); } if (-r "$config_directory/config") { print ".. found\n" if (!$envetcdirexists); $upgrading = 1; } # We can now load the main Webmin library $ENV{'WEBMIN_CONFIG'} = $config_directory; $ENV{'WEBMIN_VAR'} = "/var/webmin"; # Only used for initial load of web-lib require "$srcdir/web-lib-funcs.pl"; # Do we need to reload instead # Can be deleted with Webmin 2.0 $killmodenonepl = 0; # Check if upgrading from an old version if ($upgrading) { print "\n"; # Get current var path open(VAR, "$config_directory/var-path"); chop($var_dir = <VAR>); $var_directory = $var_dir; $ENV{'WEBMIN_VAR'} = $var_directory; close(VAR); # Get current bootscript name if (-r "$config_directory/bootscript-name") { open(BOOTVAR, "$config_directory/bootscript-name"); chop($newbootscript = <BOOTVAR>); close(BOOTVAR); $bootscript = $newbootscript if ($newbootscript); } # Force creation if non-existant mkdir($var_dir, 0755); # Get current perl path $perl = &get_perl_path(); # Get old os name and version &read_file("$config_directory/config", \%gconfig); $os_type = $gconfig{'os_type'}; $os_version = $gconfig{'os_version'}; $real_os_type = $gconfig{'real_os_type'}; $real_os_version = $gconfig{'real_os_version'}; &get_miniserv_config(\%miniserv); $oldwadir = $miniserv{'root'}; $path_separator = $gconfig{'os_type'} eq 'windows' ? ';' : ':'; $null_file = $gconfig{'os_type'} eq 'windows' ? "NUL" : "/dev/null"; if (!$miniserv{'inetd'}) { # Stop old version if ($os_type eq "windows") { system("$config_directory/stop.bat >/dev/null 2>&1"); } else { if (-r "$config_directory/.pre-install") { system("$config_directory/.pre-install >/dev/null 2>&1"); } else { $killmodenonepl = 1; } } } # Copy files to target directory ©_to_wadir(); # Update ACLs system("$perl "."e_path("$wadir/newmods.pl")." $config_directory $allmods"); # Update miniserv.conf with new root directory and mime types file $miniserv{'root'} = $wadir; $miniserv{'mimetypes'} = "$wadir/mime.types"; &put_miniserv_config(\%miniserv); # Check for third-party modules in old version if ($wadir ne $oldwadir) { print "Checking for third-party modules ..\n"; if ($ENV{'webmin_upgrade"'}) { $autothird = 1; } system("$perl "."e_path("$wadir/thirdparty.pl")." "."e_path($wadir)." "."e_path($oldwadir)." $autothird"); print ".. done\n"; print "\n"; } # Remove old cache of module infos unlink("$config_directory/module.infos.cache"); } else { # Config directory exists .. make sure it is not in use @files = grep { !/rpmsave/ } &files_in_dir($config_directory); if (@files && $config_directory ne "/etc/webmin") { &errorexit("Config directory $config_directory is not empty"); } # Ask for log directory my $envvardir = $ENV{'var_dir'} || "/var/webmin"; print "Log file directory [$envvardir]: "; if ($ENV{'var_dir'}) { $var_dir = $ENV{'var_dir'}; } else { chop($var_dir = <STDIN>); } $var_dir ||= "/var/webmin"; $var_dir =~ s/\\/\//g; $var_directory = $var_dir; if ($var_dir !~ /^([a-z]:)?\//i) { &errorexit("Log file directory must be an absolute path"); } if ($var_dir eq "/" || $var_dir =~ /^[a-z]:\/$/) { &errorexit("Log directory cannot be /"); } if (!-d $var_dir) { make_dir_recursive_local($var_dir, 0755) || &errorexit("Failed to create directory $var_dir"); } $ENV{'WEBMIN_VAR'} = $var_dir; print "\n"; # No need to ask where Perl is, because we already have it! $perl = &has_command($^X) || $^X; if (!-x $perl) { &errorexit("Failed to find Perl at $perl"); } if ($] < 5.002) { &errorexit("Detected old perl version. Webmin requires perl 5.002 or better to run"); } print "Perl seems to be installed ok\n"; print "\n"; # Ask for operating system type print "***********************************************************************\n"; $autoos = $ENV{'autoos'} || 2; $temp = &tempname(); $ex = system("$perl "."e_path("$srcdir/oschooser.pl")." "."e_path("$srcdir/os_list.txt")." "."e_path($temp)." $autoos"); exit($ex) if ($ex); &read_env_file($temp, \%osinfo); $os_type = $osinfo{'os_type'}; $os_version = $osinfo{'os_version'}; $real_os_type = $osinfo{'real_os_type'}; $real_os_version = $osinfo{'real_os_version'}; $gconfig{'os_type'} = $os_type; $gconfig{'os_version'} = $os_version; $gconfig{'real_os_type'} = $real_os_type; $gconfig{'real_os_version'} = $real_os_version; $path_separator = $gconfig{'os_type'} eq 'windows' ? ';' : ':'; $null_file = $gconfig{'os_type'} eq 'windows' ? "NUL" : "/dev/null"; unlink($temp); print "Operating system name: $real_os_type\n"; print "Operating system version: $real_os_version\n"; print "\n"; if ($os_type eq "windows") { # Check Windows dependencies if (!&has_command("process.exe")) { &errorexit("The command process.exe must be installed to run Webmin on Windows"); } if (!eval "use Win32::Daemon; 1") { &errorexit("The Perl module Win32::Daemon must be installed to run Webmin on Windows"); } } # Ask for web server port, name and password print "***********************************************************************\n"; print "Webmin uses its own password protected web server to provide access\n"; print "to the administration programs. The setup script needs to know :\n"; print " - What port to run the web server on. There must not be another\n"; print " web server already using this port.\n"; print " - The login name required to access the web server.\n"; print " - The password required to access the web server.\n"; print " - If the webserver should use SSL (if your system supports it).\n"; print " - Whether to start webmin at boot time.\n"; print "\n"; print "Web server port (default 10000): "; if ($ENV{'port'}) { $port = $ENV{'port'}; } else { chop($port = <STDIN>); } $port ||= 10000; if ($port < 1 || $port > 65535) { &errorexit("$port is not a valid port number"); } socket(FOO, PF_INET, SOCK_STREAM, getprotobyname("tcp")); setsockopt(FOO, SOL_SOCKET, SO_REUSEADDR, pack("l", 1)); bind(FOO, pack_sockaddr_in($port, INADDR_ANY)) || &errorexit("TCP port $port is already in use by another program"); close(FOO); print "Login name (default admin): "; if ($ENV{'login'}) { $login = $ENV{'login'}; } else { chop($login = <STDIN>); } $login ||= "admin"; if ($login =~ /:/) { &errorexit("Username contains a : character"); } if ($login =~ /\s/) { &errorexit("Username contains a space"); } if ($login eq "webmin") { &errorexit("Username 'webmin' is reserved for internal use"); } print "Login password: "; if ($ENV{'password'}) { $password = $ENV{'password'}; } elsif ($ENV{'crypt'}) { $crypt = $ENV{'crypt'}; } else { system("stty -echo"); chop($password = <STDIN>); system("stty echo"); print "\nPassword again: "; system("stty -echo"); chop($password2 = <STDIN>); system("stty echo"); print "\n"; if ($password ne $password2) { &errorexit("Passwords don't match"); } if ($password =~ /:/) { &errorexit("Password contains a : character"); } } # Ask the user if SSL should be used if ($ENV{'ssl'} ne '') { $ssl = $ENV{'ssl'}; } else { $ssl = 0; eval "use Net::SSLeay"; if (!$@) { print "Use SSL (y/n): "; chop($sslyn = <STDIN>); if ($sslyn =~ /^y/i) { $ssl = 1; } } else { print "The Perl SSLeay library is not installed. SSL not available.\n" } } # Don't use SSL if missing Net::SSLeay if ($ssl) { eval "use Net::SSLeay"; if ($@) { $ssl = 0; } } # Ask whether to run at boot time if ($ENV{'atboot'}) { $atboot = $ENV{'atboot'}; } else { $atboot = 0; print "Start Webmin at boot time (y/n): "; chop($atbootyn = <STDIN>); if ($atbootyn =~ /^y/i) { $atboot = 1; } } $makeboot = $atboot; # Copy files to target directory print "***********************************************************************\n"; ©_to_wadir(); # Create webserver config file open(PERL, ">$config_directory/perl-path"); print PERL $perl,"\n"; close(PERL); open(VAR, ">$config_directory/var-path"); print VAR $var_dir,"\n"; close(VAR); open(BOOTS, ">$config_directory/bootscript-name"); print BOOTS $bootscript,"\n"; close(BOOTS); print "Creating web server config files ..\n"; $ufile = "$config_directory/miniserv.users"; $kfile = "$config_directory/miniserv.pem"; %miniserv = ( 'port' => $port, 'root' => $wadir, 'mimetypes' => "$wadir/mime.types", 'addtype_cgi' => 'internal/cgi', 'realm' => 'Webmin Server', 'logfile' => "$var_dir/miniserv.log", 'errorlog' => "$var_dir/miniserv.error", 'pidfile' => "$var_dir/miniserv.pid", 'logtime' => 168, 'ppath' => $ppath, 'ssl' => $ssl, 'no_ssl2' => 1, 'no_ssl3' => 1, 'no_tls1' => 1, 'no_tls1_1' => 1, 'env_WEBMIN_CONFIG' => $config_directory, 'env_WEBMIN_VAR' => $var_dir, 'atboot' => $atboot, 'logout' => "$config_directory/logout-flag", 'listen' => 10000, 'denyfile' => "\\.pl\$", 'log' => 1, 'blockhost_failures' => 5, 'blockhost_time' => 60, 'syslog' => $os_type eq 'windows' ? 0 : 1, 'userfile' => $ufile, 'keyfile' => $kfile, 'preload' => 'main=web-lib-funcs.pl', ); if ($ENV{'allow'}) { $miniserv{'allow'} = $ENV{'allow'}; } if ($ENV{'session'} eq '') { $miniserv{'session'} = $os_type eq 'windows' ? 0 : 1; } else { $miniserv{'session'} = $ENV{'session'}; } if ($os_type eq 'windows') { $miniserv{'no_pam'} = 1; } elsif ($ENV{'pam'}) { $miniserv{'pam'} = $ENV{'pam'}; } if ($os_type eq 'windows') { $miniserv{'nofork'} = 1; $miniserv{'restartflag'} = "$var_dir/restart.flag"; $miniserv{'reloadflag'} = "$var_dir/reload.flag"; $miniserv{'forkcgis'} = 1; # Avoid memory leaks } &put_miniserv_config(\%miniserv); # Test available hashing formats if (&unix_crypt('test', '$y$j9T$waHytoaqP/CEnKFroGn0S/$fxd5mVc2mBPUc3vv.cpqDckpwrWTyIm2iD4JfnVBi26') eq '$y$j9T$waHytoaqP/CEnKFroGn0S/$fxd5mVc2mBPUc3vv.cpqDckpwrWTyIm2iD4JfnVBi26') { $yescryptpass = 1; } if (&unix_crypt('test', '$6$Tk5o/GEE$zjvXhYf/dr5M7/jan3pgunkNrAsKmQO9r5O8sr/Cr1hFOLkWmsH4iE9hhqdmHwXd5Pzm4ubBWTEjtMeC.h5qv1') eq '$6$Tk5o/GEE$zjvXhYf/dr5M7/jan3pgunkNrAsKmQO9r5O8sr/Cr1hFOLkWmsH4iE9hhqdmHwXd5Pzm4ubBWTEjtMeC.h5qv1') { $sha512pass = 1; } if (&unix_crypt('test', '$1$A9wB3O18$zaZgqrEmb9VNltWTL454R/') eq '$1$A9wB3O18$zaZgqrEmb9VNltWTL454R/') { $md5pass = 1; } # Generate random @saltbase = ('a'..'z', 'A'..'Z', '0'..'9'); $salt8 = join('', map ($saltbase[rand(@saltbase)], 1..8)); $salt2 = join('', map ($saltbase[rand(@saltbase)], 1..2)); # Create users file open(UFILE, ">$ufile"); if ($crypt) { print UFILE "$login:$crypt:0\n"; } elsif ($yescryptpass) { print UFILE $login,":",&unix_crypt($password, "\$y\$j9T\$$salt8"),"\n"; } elsif ($sha512pass) { print UFILE $login,":",&unix_crypt($password, "\$6\$$salt8"),"\n"; } elsif ($md5pass) { print UFILE $login,":",&unix_crypt($password, "\$1\$$salt8"),"\n"; } else { print UFILE $login,":",&unix_crypt($password, $salt2),"\n"; } close(UFILE); chmod(0600, $ufile); # Generate cert if (system("openssl version >/dev/null 2>&1") == 0) { # We can generate a new SSL key for this host $host = &get_system_hostname(); $cert = &tempname(); $key = &tempname(); $addtextsup = &get_openssl_version() >= 1.1 ? "-addext subjectAltName=DNS:$host,DNS:localhost -addext extendedKeyUsage=serverAuth" : ""; open(SSL, "| openssl req -newkey rsa:2048 -x509 -nodes -out $cert -keyout $key -days 1825 -sha256 -subj '/CN=$host/C=US/L=Santa Clara' $addtextsup >/dev/null 2>&1"); print SSL ".\n"; print SSL ".\n"; print SSL ".\n"; print SSL "Webmin Webserver on $host\n"; print SSL ".\n"; print SSL "*\n"; print SSL "root\@$host\n"; $ok = close(SSL); if (!$?) { open(CERTIN, $cert); open(KEYIN, $key); open(OUT, ">$kfile"); while(<CERTIN>) { print OUT $_; } while(<KEYIN>) { print OUT $_; } close(CERTIN); close(KEYIN); close(OUT); } unlink($cert, $key); } if (!-r $kfile) { # Fall back to the built-in key ©_source_dest("$wadir/miniserv.pem", $kfile); } chmod(0600, $kfile); print ".. done\n"; print "\n"; print "Creating access control file ..\n"; $afile = "$config_directory/webmin.acl"; open(AFILE, ">$afile"); if ($ENV{'defaultmods'}) { print AFILE "$login: $ENV{'defaultmods'}\n"; } else { print AFILE "$login: $allmods\n"; } close(AFILE); chmod(0600, $afile); print ".. done\n"; print "\n"; if ($login ne "root" && $login ne "admin") { # Allow use of RPC by this user open(ACL, ">$config_directory/$login.acl"); print ACL "rpc=1\n"; close(ACL); } } if (!$ENV{'noperlpath"'} && $os_type ne 'windows') { print "Inserting path to perl into scripts ..\n"; system("(find "."e_path($wadir)." -name '*.cgi' -print ; find "."e_path($wadir)." -name '*.pl' -print) | $perl "."e_path("$wadir/perlpath.pl")." $perl -"); print ".. done\n"; print "\n"; } my $systemctlcmd = &has_command('systemctl'); print "Creating start and stop scripts ..\n"; if ($os_type eq "windows") { open(START, ">>$config_directory/start.bat"); print START "$perl \"$wadir/miniserv.pl\" $config_directory/miniserv.conf\n"; close(START); $start_cmd = "sc start $bootscript"; open(STOP, ">>$config_directory/stop.bat"); print STOP "echo Not implemented\n"; close(STOP); } else { # Re-generating main scripts # Start main open(START, ">$config_directory/.start-init"); print START "#!/bin/sh\n"; print START "echo Starting Webmin server in $wadir\n"; print START "trap '' 1\n"; print START "LANG=\n"; print START "export LANG\n"; print START "unset PERLIO\n"; print START "export PERLIO\n"; print START "PERLLIB=$perllib\n"; print START "export PERLLIB\n"; if ($os_type eq "hpux") { print START "exec '$wadir/miniserv.pl' $config_directory/miniserv.conf &\n"; } else { print START "exec '$wadir/miniserv.pl' $config_directory/miniserv.conf\n"; } close(START); # Define final start command if ($upgrading) { if ($killmodenonepl == 1) { $start_cmd = "$config_directory/.reload-init"; } else { $start_cmd = "$config_directory/.post-install"; } } else { $start_cmd = "$config_directory/start"; } # Stop main open(STOP, ">$config_directory/.stop-init"); print STOP "#!/bin/sh\n"; print STOP "if [ \"\$1\" = \"--kill\" ]; then\n"; print STOP " echo Force stopping Webmin server in $wadir\n"; print STOP "else\n"; print STOP " echo Stopping Webmin server in $wadir\n"; print STOP "fi\n"; print STOP "pidfile=\`grep \"^pidfile=\" $config_directory/miniserv.conf | sed -e 's/pidfile=//g'\`\n"; print STOP "pid=\`cat \$pidfile 2>/dev/null\`\n"; print STOP "if [ \"\$pid\" != \"\" ]; then\n"; print STOP " kill \$pid || exit 1\n"; print STOP " touch $var_dir/stop-flag\n"; print STOP " if [ \"\$1\" = \"--kill\" ]; then\n"; print STOP " sleep 1\n"; print STOP " (ps axf | grep \"$wadir\\\/miniserv\\.pl\" | awk '{print \"kill -9 -- -\" \$1}' | bash ; kill -9 -- -\$pid ; kill -9 \$pid) 2>/dev/null\n"; print STOP " fi\n"; print STOP " exit 0\n"; print STOP "else\n"; print STOP " if [ \"\$1\" = \"--kill\" ]; then\n"; print STOP " (ps axf | grep \"$wadir\\\/miniserv\\.pl\" | awk '{print \"kill -9 -- -\" \$1}' | bash ; kill -9 -- -\$pid ; kill -9 \$pid) 2>/dev/null\n"; print STOP " fi\n"; print STOP "fi\n"; close(STOP); # Restart main open(RESTART, ">$config_directory/.restart-init"); print RESTART "#!/bin/sh\n"; print RESTART "$config_directory/.stop-init\n"; print RESTART "$config_directory/.start-init\n"; close(RESTART); # Force reload main open(FRELOAD, ">$config_directory/.restart-by-force-kill-init"); print FRELOAD "#!/bin/sh\n"; print FRELOAD "$config_directory/.stop-init --kill\n"; print FRELOAD "$config_directory/.start-init\n"; close(FRELOAD); # Reload main open(RELOAD, ">$config_directory/.reload-init"); print RELOAD "#!/bin/sh\n"; print RELOAD "echo Reloading Webmin server in $wadir\n"; print RELOAD "pidfile=\`grep \"^pidfile=\" $config_directory/miniserv.conf | sed -e 's/pidfile=//g'\`\n"; print RELOAD "kill -USR1 \`cat \$pidfile\`\n"; close(RELOAD); # Switch to systemd from init (intermediate) if ($killmodenonepl == 1 && -x $systemctlcmd) { if ($ver < 1.994) { open(SDRELOAD, ">$config_directory/.reload-init-systemd"); print SDRELOAD "#!/bin/sh\n"; print SDRELOAD "$config_directory/.stop-init\n"; print SDRELOAD "$config_directory/start\n"; close(SDRELOAD); chmod(0755, "$config_directory/.reload-init-systemd"); } } # Pre install open(PREINST, ">$config_directory/.pre-install"); print PREINST "#!/bin/sh\n"; print PREINST "$config_directory/.stop-init\n"; close(PREINST); # # Post install open(POSTINST, ">$config_directory/.post-install"); print POSTINST "#!/bin/sh\n"; print POSTINST "$config_directory/.start-init\n"; close(POSTINST); chmod(0755, "$config_directory/.start-init"); chmod(0755, "$config_directory/.stop-init"); chmod(0755, "$config_directory/.restart-init"); chmod(0755, "$config_directory/.restart-by-force-kill-init"); chmod(0755, "$config_directory/.reload-init"); chmod(0755, "$config_directory/.pre-install"); chmod(0755, "$config_directory/.post-install"); # Re-generating supplementary # Clear existing unlink("$config_directory/start"); unlink("$config_directory/stop"); unlink("$config_directory/restart"); unlink("$config_directory/restart-by-force-kill"); unlink("$config_directory/reload"); # Create symlinks # Start init.d symlink("$config_directory/.start-init", "$config_directory/start"); # Stop init.d symlink("$config_directory/.stop-init", "$config_directory/stop"); # Restart init.d symlink("$config_directory/.restart-init", "$config_directory/restart"); # Force reload init.d symlink("$config_directory/.restart-by-force-kill-init", "$config_directory/restart-by-force-kill"); # Reload init.d symlink("$config_directory/.reload-init", "$config_directory/reload"); # For systemd if (-x $systemctlcmd) { # Clear existing unlink("$config_directory/start"); unlink("$config_directory/stop"); unlink("$config_directory/restart"); unlink("$config_directory/restart-by-force-kill"); unlink("$config_directory/reload"); # Start systemd open(STARTD, ">$config_directory/start"); print STARTD "$systemctlcmd start $bootscript\n"; close(STARTD); # Stop systemd open(STOPD, ">$config_directory/stop"); print STOPD "$systemctlcmd stop $bootscript\n"; close(STOPD); # Restart systemd open(RESTARTD, ">$config_directory/restart"); print RESTARTD "$systemctlcmd restart $bootscript\n"; close(RESTARTD); # Force reload systemd open(FRELOADD, ">$config_directory/restart-by-force-kill"); print FRELOADD "$systemctlcmd stop $bootscript\n"; print FRELOADD "$config_directory/.stop-init --kill >/dev/null 2>&1\n"; print FRELOADD "$systemctlcmd start $bootscript\n"; close(FRELOADD); # Reload systemd open(RELOADD, ">$config_directory/reload"); print RELOADD "$systemctlcmd reload $bootscript\n"; close(RELOADD); # Pre install open(PREINSTT, ">$config_directory/.pre-install"); print PREINSTT "#!/bin/sh\n"; #print PREINSTT "$systemctlcmd kill --signal=SIGSTOP --kill-who=main $bootscript\n"; close(PREINSTT); # Post install open(POSTINSTT, ">$config_directory/.post-install"); print POSTINSTT "#!/bin/sh\n"; #print POSTINSTT "$systemctlcmd kill --signal=SIGCONT --kill-who=main $bootscript\n"; print POSTINSTT "$systemctlcmd kill --signal=SIGHUP --kill-who=main $bootscript\n"; close(POSTINSTT); chmod(0755, "$config_directory/start"); chmod(0755, "$config_directory/stop"); chmod(0755, "$config_directory/restart"); chmod(0755, "$config_directory/restart-by-force-kill"); chmod(0755, "$config_directory/reload"); chmod(0755, "$config_directory/.pre-install"); chmod(0755, "$config_directory/.post-install"); # Fix existing systemd webmin.service file to update start and stop commands my $perl = &get_perl_path(); chdir("$wadir/init"); system("$perl "."e_path("$wadir/init/updateboot.pl")." $bootscript"); } } print ".. done\n"; print "\n"; if ($upgrading) { print "Updating config files ..\n"; } else { print "Copying config files ..\n"; } system("$perl "."e_path("$wadir/copyconfig.pl")." "."e_path("$os_type/$real_os_type")." "."e_path("$os_version/$real_os_version")." "."e_path($wadir)." ".$config_directory." \"\" ".$allmods . " >/dev/null 2>&1"); if (!$upgrading) { # Store the OS and version &read_file("$config_directory/config", \%gconfig); $gconfig{'os_type'} = $os_type; $gconfig{'os_version'} = $os_version; $gconfig{'real_os_type'} = $real_os_type; $gconfig{'real_os_version'} = $real_os_version; $gconfig{'log'} = 1; &write_file("$config_directory/config", \%gconfig); } open(VER, ">$config_directory/version"); print VER $ver,"\n"; close(VER); print ".. done\n"; print "\n"; # Set passwd_ fields in miniserv.conf from global config &get_miniserv_config(\%miniserv); foreach $field ("passwd_file", "passwd_uindex", "passwd_pindex", "passwd_cindex", "passwd_mindex") { if ($gconfig{$field}) { $miniserv{$field} = $gconfig{$field}; } } if (!defined($miniserv{'passwd_mode'})) { $miniserv{'passwd_mode'} = 0; } # Use system default for password hashing $gconfig{'md5pass'} = 0; # Set a special theme if none was set before if ($ENV{'theme'}) { $theme = $ENV{'theme'}; } elsif (open(THEME, "$wadir/defaulttheme")) { chop($theme = <THEME>); close(THEME); } if ($theme && -d "$wadir/$theme") { $gconfig{'theme'} = $theme; $miniserv{'preroot'} = $theme; } # Set the product field in the global config $gconfig{'product'} ||= "webmin"; if ($makeboot) { print "Configuring Webmin to start at boot time ..\n"; chdir("$wadir/init"); system("$perl "."e_path("$wadir/init/atboot.pl")." $bootscript"); print ".. done\n"; print "\n"; } # If password delays are not specifically disabled, enable them if (!defined($miniserv{'passdelay'}) && $os_type ne 'windows') { $miniserv{'passdelay'} = 1; } # Turn on referer checks if (!defined($gconfig{'referers_none'})) { $gconfig{'referers_none'} = 1; } # Save configs &put_miniserv_config(\%miniserv); &write_file("$config_directory/config", \%gconfig); if (!$ENV{'nouninstall'} && $os_type ne "windows") { print "Creating uninstall script $config_directory/uninstall.sh ..\n"; open(UN, ">$config_directory/uninstall.sh"); print UN <<EOF; #!/bin/sh printf "Are you sure you want to uninstall Webmin? (y/n) : " read answer printf "\n" if [ "\$answer" = "y" ]; then $config_directory/stop echo "Running uninstall scripts .." (cd "$wadir" ; WEBMIN_CONFIG=$config_directory WEBMIN_VAR=$var_dir LANG= "$wadir/run-uninstalls.pl") >/dev/null 2>&1 </dev/null echo "Deleting $wadir .." rm -rf "$wadir" echo "Deleting $config_directory .." rm -rf "$config_directory" echo "Done!" fi EOF chmod(0755, "$config_directory/uninstall.sh"); print ".. done\n"; print "\n"; } if ($os_type ne "windows") { print "Changing ownership and permissions ..\n"; system("chown -R root $config_directory"); system("chgrp -R bin $config_directory"); system("chmod -R og-rw $config_directory"); system("chmod 755 $config_directory/{sendmail,qmailadmin,postfix}*/config >/dev/null 2>&1"); system("chmod 755 $config_directory/{sendmail,qmailadmin,postfix}*/autoreply.pl >/dev/null 2>&1"); system("chmod 755 $config_directory/{sendmail,qmailadmin,postfix}*/filter.pl >/dev/null 2>&1"); system("chmod 755 $config_directory/squid*/squid-auth.pl >/dev/null 2>&1"); system("chmod 755 $config_directory/squid*/users >/dev/null 2>&1"); system("chmod 755 $config_directory/cron*/range.pl >/dev/null 2>&1"); system("chmod +r $config_directory/version"); if (!$ENV{'nochown'}) { system("chown -R root \"$wadir\""); system("chgrp -R bin \"$wadir\""); system("chmod -R og-w \"$wadir\""); system("chmod -R a+rx \"$wadir\""); } if ($var_dir ne "/var") { system("chown -R root $var_dir"); system("chgrp -R bin $var_dir"); system("chmod -R og-rwx $var_dir"); } print ".. done\n"; print "\n"; } # Save target directory if one was specified if ($wadir ne $srcdir) { open(INSTALL, ">$config_directory/install-dir"); print INSTALL $wadir,"\n"; close(INSTALL); } else { unlink("$config_directory/install-dir"); } if (!$ENV{'nopostinstall'}) { print "Running postinstall scripts ..\n"; chdir($wadir); $ENV{'WEBMIN_UPGRADING'} = $upgrading; system("$perl "."e_path("$wadir/run-postinstalls.pl")); print ".. done\n"; print "\n"; } # Run package-defined post-install script if (-r "$srcdir/setup-post.pl") { require "$srcdir/setup-post.pl"; } if (!$ENV{'nostart'}) { if (!$miniserv{'inetd'}) { $action = 'start'; if ($upgrading) { $action = 'restart'; } my $start_cmd_extra; if ($upgrading && $killmodenonepl == 1) { $start_cmd_extra = "$config_directory/.reload-init-systemd"; if (-r $start_cmd_extra) { $start_cmd .= " ; $start_cmd_extra"; } } print "Attempting to $action Webmin web server ..\n"; $ex = system($start_cmd); unlink($start_cmd_extra) if (-r $start_cmd_extra); if ($ex) { &errorexit("Failed to $action web server!"); } print ".. done\n"; print "\n"; } print "***********************************************************************\n"; print "Webmin has been installed and started successfully. Use your web\n"; print "browser to go to\n"; print "\n"; $host = &get_system_hostname(); if ($ssl) { print " https://$host:$miniserv{'port'}/\n"; } else { print " http://$host:$miniserv{'port'}/\n"; } print "\n"; print "and login with the name and password you entered previously.\n"; print "\n"; if ($ssl) { print "Because Webmin uses SSL for encryption only, the certificate\n"; print "it uses is not signed by one of the recognized CAs such as\n"; print "Verisign. When you first connect to the Webmin server, your\n"; print "browser will ask you if you want to accept the certificate\n"; print "presented, as it does not recognize the CA. Say yes.\n"; print "\n"; } } else { print "***********************************************************************\n"; print "Webmin has been installed but not started!\n\n"; } if ($oldwadir ne $wadir && $upgrading && !$ENV{'deletedold'}) { print "The directory from the previous version of Webmin\n"; print " $oldwadir\n"; print "Can now be safely deleted to free up disk space, assuming\n"; print "that all third-party modules have been copied to the new\n"; print "version.\n"; print "\n"; } sub errorexit { print "ERROR: ",@_,"\n"; print "\n"; exit(1); } sub copy_to_wadir { if ($wadir ne $srcdir) { print "Copying files to $wadir ..\n"; if ("$^O" !~ /MSWin32/) { # Unix tar exists system("cd "."e_path($srcdir)." && tar cf - . | (cd "."e_path($wadir)." ; tar xf -)"); } else { # Looks like Windows .. use xcopy command system("xcopy \"$srcdir\" \"$wadir\" /Y /E /I /Q"); } print ".. done\n"; print "\n"; } } sub files_in_dir { opendir(DIR, $_[0]); local @rv = grep { $_ ne "." && $_ ne ".." } readdir(DIR); closedir(DIR); return @rv; } sub make_dir_recursive_local { my ($dir, $mod) = @_; my @folders = split(/\//, $dir); my $folder_created; foreach my $folder (@folders) { next if (!$folder); $folder_created .= "/$folder"; if (mkdir($folder_created)) { chmod($mod, $folder_created) if ($mod && -d $folder_created); } } return -d $dir; } sub get_openssl_version { my $out = &backquote_command("openssl version 2>/dev/null"); if ($out =~ /OpenSSL\s+(\d\.\d)/) { return $1; } return 0; }
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 |
|