Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions backup.pl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
# Do a scheduled virtual server backup

package virtual_server;

unless ($ENV{VIRTUALMIN_NO_MAIN}) {

$main::no_acl_check++;
require './virtual-server-lib.pl';
$host = &get_system_hostname();
Expand Down Expand Up @@ -338,6 +341,8 @@ package virtual_server;
'failed' => !$ok,
'sched' => $id, });

} # end of unless ($ENV{VIRTUALMIN_NO_MAIN})

# Override print functions to capture output
sub first_save_print
{
Expand Down
4 changes: 4 additions & 0 deletions bwgraph.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# bwgraph.cgi
# Show current bandwidth usage graphs

unless (caller) {

require './virtual-server-lib.pl';
&ReadParse();

Expand Down Expand Up @@ -404,6 +406,8 @@ if (&can_edit_templates() && $in{'dom'}) {
push(@rets, "", $text{'index_return'});
&ui_print_footer(@rets);

} # end of unless (caller)

# usage_colours(&domain, &usage)
sub usage_colours
{
Expand Down
5 changes: 5 additions & 0 deletions check-scripts.pl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ =head1 check-scripts.pl
=cut

package virtual_server;

unless ($ENV{VIRTUALMIN_NO_MAIN}) {

if (!$module_name) {
$main::no_acl_check++;
$ENV{'WEBMIN_CONFIG'} ||= "/etc/webmin";
Expand Down Expand Up @@ -246,6 +249,8 @@ package virtual_server;
}
}

} # end of unless ($ENV{VIRTUALMIN_NO_MAIN})

sub patch_file
{
my ($script_file, $script_name, $ver_curr, $ver_new) = @_;
Expand Down
5 changes: 5 additions & 0 deletions downgrade-licence.pl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ =head1 downgrade-licence.pl
=cut

package virtual_server;

unless ($ENV{VIRTUALMIN_NO_MAIN}) {

if (!$module_name) {
$main::no_acl_check++;
$ENV{'WEBMIN_CONFIG'} ||= "/etc/webmin";
Expand Down Expand Up @@ -167,6 +170,8 @@ package virtual_server;
&$first_print($text{'downgrade_gpl_all_done'});
}

} # end of unless ($ENV{VIRTUALMIN_NO_MAIN})

# lock_all_resellers()
# Lock all reseller accounts
sub lock_all_resellers
Expand Down
5 changes: 5 additions & 0 deletions functional-test.pl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
# Runs all Virtualmin tests

package virtual_server;

unless ($ENV{VIRTUALMIN_NO_MAIN}) {

if (!$module_name) {
$main::no_acl_check++;
$ENV{'WEBMIN_CONFIG'} ||= "/etc/webmin";
Expand Down Expand Up @@ -13320,6 +13323,8 @@ package virtual_server;
}
exit($total_failed);

} # end of unless ($ENV{VIRTUALMIN_NO_MAIN})

sub run_test
{
local ($t) = @_;
Expand Down
5 changes: 5 additions & 0 deletions info.pl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ =head1 info.pl
=cut

package virtual_server;

unless ($ENV{VIRTUALMIN_NO_MAIN}) {

if (!$module_name) {
$main::no_acl_check++;
$ENV{'WEBMIN_CONFIG'} ||= "/etc/webmin";
Expand Down Expand Up @@ -90,6 +93,8 @@ package virtual_server;
}
&recursive_info_dump($info, "");

} # end of unless ($ENV{VIRTUALMIN_NO_MAIN})

sub recursive_info_dump
{
local ($info, $indent) = @_;
Expand Down
4 changes: 4 additions & 0 deletions link.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,8 @@ if (!$$injected_ref) {
return $chunk;
}

unless (caller) {

&init_config();
delete($ENV{'HTTP_REFERER'});
$| = 1;
Expand Down Expand Up @@ -369,3 +371,5 @@ else {
}
&close_http_connection($con);

} # end of unless (caller)

15 changes: 12 additions & 3 deletions list-config-revisions.pl
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ =head2 Options

package virtual_server;

# File-scope lexicals shared between the main body and the subs below.
# Kept outside the VIRTUALMIN_NO_MAIN guard so subs see them when the
# script is `require`d for testing without the main body running.
my ($etcdir, $depth, $git_repo);

unless ($ENV{VIRTUALMIN_NO_MAIN}) {
Comment thread
swelljoe marked this conversation as resolved.

# If not loaded by Webmin, do standard Virtualmin environment prep
if (!$module_name) {
$main::no_acl_check++;
Expand All @@ -88,7 +95,7 @@ package virtual_server;
}

# Get /etc from environment
my $etcdir = $ENV{'WEBMIN_CONFIG'};
$etcdir = $ENV{'WEBMIN_CONFIG'};
$etcdir =~ s/\/[^\/]+$//;

# Disable HTML output
Expand All @@ -97,10 +104,10 @@ package virtual_server;
# Parse command-line args
&parse_common_cli_flags(\@ARGV);

my $depth = 1;
$depth = 1;
my @module_files;
my $module;
my $git_repo = "$etcdir/.git";
$git_repo = "$etcdir/.git";

while(@ARGV > 0) {
my $a = shift(@ARGV);
Expand Down Expand Up @@ -162,6 +169,8 @@ package virtual_server;
&do_list(\@source_paths, $depth, $git_repo);
exit(0);

} # end of unless ($ENV{VIRTUALMIN_NO_MAIN})

# usage(msg)
# Print usage message and exit
sub usage
Expand Down
9 changes: 7 additions & 2 deletions lookup-domain-daemon.pl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ =head1 lookup-domain-daemon.pl
=cut

package virtual_server;
use POSIX;
use Socket;

unless ($ENV{VIRTUALMIN_NO_MAIN}) {

$main::no_acl_check++;
$ENV{'WEBMIN_CONFIG'} ||= "/etc/webmin";
$ENV{'WEBMIN_VAR'} ||= "/var/webmin";
Expand All @@ -33,8 +38,6 @@ package virtual_server;
$no_virtualmin_plugins = 1;
require './virtual-server-lib.pl';
$< == 0 || die "lookup-domain-daemon.pl must be run as root";
use POSIX;
use Socket;

# Parse command line
$port = $config{'lookup_domain_port'} || $lookup_domain_port;
Expand Down Expand Up @@ -136,6 +139,8 @@ package virtual_server;
}
}

} # end of unless ($ENV{VIRTUALMIN_NO_MAIN})

sub handle_one_request
{
# Read the username
Expand Down
5 changes: 5 additions & 0 deletions quotas.pl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
# the admin for those that are over.

package virtual_server;

unless ($ENV{VIRTUALMIN_NO_MAIN}) {

$main::no_acl_check++;
$no_virtualmin_plugins = 1;
require './virtual-server-lib.pl';
Expand Down Expand Up @@ -111,6 +114,8 @@ package virtual_server;
}
}

} # end of unless ($ENV{VIRTUALMIN_NO_MAIN})

# send_domain_quota_email(&message, address)
# Converts a list of domain over-quota notifications into a message, and send it
sub send_domain_quota_email
Expand Down
17 changes: 12 additions & 5 deletions restore-config-revision.pl
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ =head2 Options

package virtual_server;

# File-scope lexical shared between the main body and the subs below.
# Kept outside the VIRTUALMIN_NO_MAIN guard so subs see it when the
# script is `require`d for testing without the main body running.
my ($etcdir);

unless ($ENV{VIRTUALMIN_NO_MAIN}) {

# If not loaded by Webmin, do standard Virtualmin environment prep
if (!$module_name) {
$main::no_acl_check++;
Expand All @@ -110,7 +117,7 @@ package virtual_server;
}

# Get /etc from environment
my $etcdir = $ENV{'WEBMIN_CONFIG'};
$etcdir = $ENV{'WEBMIN_CONFIG'};
$etcdir =~ s/\/[^\/]+$//;

# Disable HTML output
Expand All @@ -119,12 +126,10 @@ package virtual_server;
# Parse command-line args
&parse_common_cli_flags(\@ARGV);

my $target_dir;
my $dry_run;
my $depth = 1;
$depth = 1;
my @module_files;
my $module;
my $git_repo = "$etcdir/.git";
$git_repo = "$etcdir/.git";

while(@ARGV > 0) {
my $a = shift(@ARGV);
Expand Down Expand Up @@ -199,6 +204,8 @@ package virtual_server;
&do_restore(\@source_paths, $depth, $git_repo, $target_dir, $dry_run);
exit(0);

} # end of unless ($ENV{VIRTUALMIN_NO_MAIN})

# usage(msg)
# Print usage message and exit
sub usage
Expand Down
5 changes: 5 additions & 0 deletions spamtrap.pl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
# domains with spam emailed.

package virtual_server;

unless ($ENV{VIRTUALMIN_NO_MAIN}) {

$main::no_acl_check++;
$no_virtualmin_plugins = 1;
require './virtual-server-lib.pl';
Expand Down Expand Up @@ -246,6 +249,8 @@ package virtual_server;
&clear_index_file($hamf->{'file'});
}

} # end of unless ($ENV{VIRTUALMIN_NO_MAIN})

# find_user_by_email(email, &users, &aliases)
sub find_user_by_email
{
Expand Down
Loading