[ Avaa Bypassed ]




Upload:

Command:

www-data@18.224.3.26: ~ $
#!/usr/bin/env perl
# server - control Webmin web-server

use strict;
use warnings;
use 5.010;

use File::Basename;
use Getopt::Long;
use Pod::Usage;
use Term::ANSIColor qw(:constants);
use lib (dirname(dirname($0)));
use WebminCore;

sub main
{
    my %opt;
    GetOptions('help|h'      => \$opt{'help'},
               'command|x=s' => \$opt{'command'},
               'config|c=s'  => \$opt{'config'});

    # If username passed as regular param
    my $cmd = scalar(@ARGV) == 1 && $ARGV[0];
    $cmd = $opt{'command'} if ($opt{'command'});
    if ($cmd !~ /^(status|start|stop|restart|reload|force-restart|kill)$/) {
        $cmd = undef;
    }

    # Show usage
    pod2usage(0) if ($opt{'help'} || !$cmd);

    # Assign defaults
    $opt{'config'} ||= "/etc/webmin";
    $opt{'cmd'} = $cmd;

    # Catch kill signal
    my $sigkill = sub {
        system("stty echo");
        print "\n^C";
        print "\n";
        exit 1;
    };
    $SIG{INT} = \&$sigkill;

    # Run change password command
    run(\%opt);

    return 0;
}
exit main(\@ARGV) if !caller(0);

sub run
{
    my ($o) = @_;
    my $conf_check = sub {
        my ($configs) = @_;
        foreach my $config (@{$configs}) {
            if (!-r $config) {
                say BRIGHT_RED, "Error: ", RESET, "Failed to read Webmin essential config file: ", BRIGHT_YELLOW, $config,
                  RESET, " doesn't exist";
                exit 1;
            }
        }
    };
    root($o->{'config'}, \&$conf_check);
    my $service = ($o->{'config'} =~ /usermin/ ? 'usermin' : 'webmin');
    my $systemctlcmd = `which systemctl`;
    $systemctlcmd =~ s/\s+$//;
    if ($o->{'cmd'} =~ /^(start|stop|restart|reload)$/) {
        my $rs = system("$o->{'config'}/$o->{'cmd'} $service");
        exit $rs;
    }
    if ($o->{'cmd'} =~ /^(kill)$/) {
        my $rs;
        if (-x $systemctlcmd) {
            $rs = system("$systemctlcmd stop $service");
            $rs = system("$systemctlcmd kill -s SIGTERM $service");
        }
        $rs = system("$o->{'config'}/.stop-init --kill >/dev/null 2>&1 $service");
        exit $rs;
    }
    if ($o->{'cmd'} =~ /^(force-restart)$/) {
        my $rs = system("$o->{'config'}/restart-by-force-kill $service");
        exit $rs;
    }
    if ($o->{'cmd'} =~ /^(status)$/) {
        my $rs;
        if (-x $systemctlcmd) {
            $rs = system("$systemctlcmd status $service");
        } else {
            $rs = system("service $service status");
        }
        exit $rs;
    }
    exit 0;
}

sub root
{
    my ($config, $conf_check) = @_;
    my $mconf = "$config/miniserv.conf";
    $conf_check->([$mconf]);
    open(my $CONF, "<", $mconf);
    my $root;
    while (<$CONF>) {
        if (/^root=(.*)/) {
            $root = $1;
        }
    }
    close($CONF);

    # Does the Webmin root exist?
    if ($root) {
        die BRIGHT_RED, "Error: ", BRIGHT_YELLOW, $root, RESET, " is not a directory\n" unless (-d $root);
    } else {

        # Try to guess where Webmin lives, since config file didn't know.
        die BRIGHT_RED, "Error: ", RESET, "Unable to determine Webmin installation directory\n";
    }

    return $root;
}

1;

=pod

=head1 NAME

 server

=head1 DESCRIPTION

 This program allows you to control Webmin web-server

=head1 SYNOPSIS

 webmin server [command]
 webmin [command]

=head1 OPTIONS

=over

=item --help, -h

 Print this usage summary and exit.

 Examples of usage:
   - webmin server status
   - webmin server restart
   - webmin server --config /usr/local/etc/webmin --command start
   - webmin status
   - webmin restart

=item --config, -c

 Specify the full path to the Webmin configuration directory. Defaults to C</etc/webmin>

=item --command, -x

 Available commands:
   - status
   - start
   - stop
   - restart
   - force-restart
   - reload
   - kill

=back

=head1 LICENSE AND COPYRIGHT

 Copyright 2018 Jamie Cameron <jcameron@webmin.com>
                Joe Cooper <joe@virtualmin.com>
                Ilia Rostovtsev <ilia@virtualmin.com>


Filemanager

Name Type Size Permission Actions
disable-proxy File 3.54 KB 0755
disable-twofactor File 2.6 KB 0755
enable-proxy File 4.12 KB 0755
language-manager File 79.29 KB 0755
list-config File 5.14 KB 0755
passwd File 7.43 KB 0755
server File 3.92 KB 0755
set-config File 4.35 KB 0755
update-devel File 1.64 KB 0755
webmin File 14.57 KB 0755