Server IP : 195.201.23.43 / Your IP : 3.18.213.37 Web Server : Apache System : Linux webserver2.vercom.be 5.4.0-192-generic #212-Ubuntu SMP Fri Jul 5 09:47:39 UTC 2024 x86_64 User : kdecoratie ( 1041) PHP Version : 7.1.33-63+ubuntu20.04.1+deb.sury.org+1 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /usr/share/webmin/bin/ |
Upload File : |
#!/usr/bin/env perl # disable-proxy - Reverse/remove the configuration options set by enable-proxy. use strict; use warnings; BEGIN { $Pod::Usage::Formatter = 'Pod::Text::Color'; } use 5.010; # Version in CentOS 6 use Getopt::Long qw(:config permute pass_through); use Pod::Usage; use Term::ANSIColor qw(:constants); use Fcntl qw( :flock ); use Sys::Hostname; sub main { my %opt; GetOptions( 'help|h' => \$opt{'help'}, 'config|c=s' => \$opt{'config'}, ); pod2usage(0) if ( $opt{'help'} ); $opt{'config'} ||= "/etc/webmin"; enable_proxy( \%opt ); return 0; } exit main( \@ARGV ) if !caller(0); sub enable_proxy { my ($optref) = @_; my @config_lines; my $file = "$optref->{'config'}/config"; my $referer; if ($optref->{'referer'}) { $referer = $optref->{'referer'}; } else { $referer = hostname; } # Setup Webmin if ($optref->{'prefix'}) { # Set'em up for proxying on https://domain.tld/prefix set_config('webprefix', '', $file); set_config('webprefix_noredir', '', $file); set_config('ssl_redirect', '1', "$optref->{'config'}/miniserv.conf"); set_config('ssl', '1', "$optref->{'config'}/miniserv.conf"); } else { # No prefix, just proxying at the root level: https://domain.tld/ set_config('ssl_redirect', '1', "$optref->{'config'}/miniserv.conf"); set_config('ssl', '1', "$optref->{'config'}/miniserv.conf"); } # Setup the local web server? # Restart Webmin say "Restarting Webmin to apply changes..."; system("$optref->{'config'}/restart"); exit 0; } sub set_config { my ($key, $value, $file, $module, $force) = @_; $key or die RED, "An --option must be specified", RESET; my @config_lines; open my $fh, '+<', $file or die RED, "Unable to open $file", RESET; flock($fh, LOCK_EX) or die RED, "Unable to lock $file", RESET; chomp(@config_lines = <$fh>); # Change'em my $found = 0; my $exit_code = 0; # Validate it against the config.info if this is a module and if ($module && !$force) { validate_config_option($key, $value, $module); } for (@config_lines) { if (/^${key}=(.*)/) { s/^${key}=(.*)/${key}=${value}/; $found++; } } unless ($found > 0) { push(@config_lines, "$key=$value"); $exit_code++; } # Write'em seek($fh, 0, 0); print $fh qq|$_\n| for @config_lines; close $fh; } sub root { my ($config) = @_; open(my $CONF, "<", "$config/miniserv.conf") || die RED, "Failed to open $config/miniserv.conf", RESET; my $root; while (<$CONF>) { if (/^root=(.*)/) { $root = $1; } } close($CONF); # Does the Webmin root exist? if ( $root ) { die "$root is not a directory. Is --config correct?" unless (-d $root); } else { # Try to guess where Webmin lives, since config file didn't know. die "Unable to determine Webmin installation directory from $ENV{'WEBMIN_CONFIG'}"; } return $root; } 1; =pod =head1 NAME disable-proxy =head1 DESCRIPTION Disable proxy-related features in Webmin. =head1 SYNOPSIS webmin disable-proxy [options] =head1 OPTIONS =over =item --help, -h Print this usage summary and exit. =item --config, -c Specify the full path to the Webmin configuration directory. Defaults to C</etc/webmin> =back =head1 LICENSE AND COPYRIGHT Copyright 2018 Jamie Cameron <jcameron@webmin.com> Joe Cooper <joe@virtualmin.com>Private