$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
enable-proxy
=head1 DESCRIPTION
Configure the Webmin web server to be proxied through another web server, like Apache or nginx. This is not usually recommended, and disables some security features, but can help traverse a firewall.