mirror of
https://github.com/webmin/webmin.git
synced 2026-02-03 14:13:29 +00:00
Show more error context, remove blink tags
This commit is contained in:
@@ -35,3 +35,4 @@ String custom options are now always quoted.
|
||||
Converted buttons on the module's main page to use the Webmin UI library.
|
||||
Expired leases are no longer counted towards usage on the DHCP Leases page.
|
||||
Added a mode to the DHCP Leases page to show usage by subnet, thanks to a suggestion by Coles.
|
||||
When applying the configuration fails with an error mentioning a line in the config file, 10 lines around that will also be displayed by Webmin in the error.
|
||||
|
||||
@@ -164,7 +164,6 @@ sub acl_security_save
|
||||
{
|
||||
if ($in{'r_sub'} < $in{'w_sub'} || $in{'r_sha'} < $in{'w_sha'} ||
|
||||
$in{'r_hst'} < $in{'w_hst'} || $in{'r_grp'} < $in{'w_grp'}) {
|
||||
$whatfailed = $text{'acl_err'};
|
||||
&error($text{'acl_ernow'});
|
||||
}
|
||||
$_[0]->{'apply'}=$in{'apply'};
|
||||
|
||||
@@ -14,7 +14,7 @@ foreach $i ($in{'sidx'}, $in{'uidx'}, $in{'idx'}) {
|
||||
|
||||
# check acls
|
||||
%access = &get_module_acl();
|
||||
&error_setup("<blink><font color=red>$text{'eacl_aviol'}</font></blink>");
|
||||
&error_setup($text{'eacl_aviol'});
|
||||
|
||||
@host = &find("host", $par->{'members'});
|
||||
@group = &find("group", $par->{'members'});
|
||||
|
||||
@@ -24,7 +24,7 @@ $to_del = $parconf->[$in{'idx'}];
|
||||
|
||||
# check acls
|
||||
%access = &get_module_acl();
|
||||
&error_setup("<blink><font color=red>$text{'eacl_aviol'}</font></blink>");
|
||||
&error_setup($text{'eacl_aviol'});
|
||||
if ($to_del->{'name'} eq "group") {
|
||||
&error("$text{'eacl_np'} $text{'eacl_pdg'}")
|
||||
if !&can('rw', \%access, $to_del, 1);
|
||||
|
||||
@@ -6,7 +6,7 @@ require './dhcpd-lib.pl';
|
||||
&ReadParse();
|
||||
|
||||
%access = &get_module_acl();
|
||||
&error_setup("<blink><font color=red>$text{'eacl_aviol'}</font></blink>");
|
||||
&error_setup($text{'eacl_aviol'});
|
||||
if( !($access{'w_leases'} && $access{'r_leases'}) ) {
|
||||
&error("$text{'eacl_np'} $text{'eacl_pdl'}");
|
||||
}
|
||||
|
||||
@@ -823,7 +823,6 @@ local $out;
|
||||
if ($config{'restart_cmd'}) {
|
||||
# Run the restart script
|
||||
$out = &backquote_logged("$config{'restart_cmd'} 2>&1");
|
||||
return "<pre>$out</pre>" if ($?);
|
||||
}
|
||||
else {
|
||||
# Kill and re-run the server
|
||||
@@ -836,11 +835,31 @@ else {
|
||||
else {
|
||||
$out = &backquote_logged("$config{'dhcpd_path'} -cf $config{'dhcpd_conf'} -lf $config{'lease_file'} $config{'interfaces'} 2>&1");
|
||||
}
|
||||
return "<pre>$out</pre>" if ($?);
|
||||
}
|
||||
if ($?) {
|
||||
return &parse_error_out($out);
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
# Find and add config file lines around those in an error message
|
||||
sub parse_error_out
|
||||
{
|
||||
local ($out) = @_;
|
||||
local $conftext;
|
||||
if ($out =~ /(\S+)\s+line\s+(\d+):/) {
|
||||
local ($file, $line) = ($1, $2);
|
||||
local $lref = &read_file_lines($file, 1);
|
||||
local $start = $line - 5;
|
||||
local $end = $line + 5;
|
||||
$start = 0 if ($start < 0);
|
||||
$end = @$lref-1 if ($end > @$lref-1);
|
||||
$conftext = &text('restart_conftext', $line, $file)."<br>".
|
||||
"<pre>".&html_escape(join("\n", @$lref[$start .. $end]))."</pre>";
|
||||
}
|
||||
return "<pre>".&html_escape($out)."</pre>".$conftext;
|
||||
}
|
||||
|
||||
# stop_dhcpd()
|
||||
# Stop the running DHCP server. Returns undef on success, or an error message
|
||||
# on failure.
|
||||
@@ -881,7 +900,7 @@ else {
|
||||
$out = &backquote_logged("$config{'dhcpd_path'} -cf $config{'dhcpd_conf'} -lf $config{'lease_file'} $config{'interfaces'} 2>&1");
|
||||
}
|
||||
if ($? || $out =~ /error|failed/i) {
|
||||
return "<pre>$out</pre>";
|
||||
return &parse_error_out($out);
|
||||
}
|
||||
else {
|
||||
return undef;
|
||||
|
||||
@@ -12,7 +12,7 @@ $mems = $par->{'members'};
|
||||
|
||||
# check acls
|
||||
%access = &get_module_acl();
|
||||
&error_setup("<blink><font color=red>$text{'eacl_aviol'}</font></blink>");
|
||||
&error_setup($text{'eacl_aviol'});
|
||||
if ($in{'new'}) {
|
||||
&error("$text{'eacl_np'} $text{'eacl_pig'}")
|
||||
unless &can('c', \%access, $group) && &can('rw', \%access, $par);
|
||||
|
||||
@@ -11,7 +11,7 @@ $hconf = $host->{'members'};
|
||||
|
||||
# check acls
|
||||
%access = &get_module_acl();
|
||||
&error_setup("<blink><font color=red>$text{'eacl_aviol'}</font></blink>");
|
||||
&error_setup($text{'eacl_aviol'});
|
||||
if ($in{'new'} ) {
|
||||
&error("$text{'eacl_np'} $text{'eacl_pih'}")
|
||||
unless &can('c', \%access, $host) && &can('rw', \%access, $par);
|
||||
|
||||
@@ -14,7 +14,7 @@ $conf = &get_config();
|
||||
|
||||
# check acls
|
||||
# %access = &get_module_acl();
|
||||
# &error_setup("<blink><font color=red>$text{'eacl_aviol'}</font></blink>");
|
||||
# &error_setup($text{'eacl_aviol'});
|
||||
# &error("$text{'eacl_np'} $text{'eacl_pss'}") if !&can('r',\%access,$sub);
|
||||
|
||||
if ($in{'new'}) {
|
||||
|
||||
@@ -8,7 +8,7 @@ require './params-lib.pl';
|
||||
$conf = &get_config();
|
||||
|
||||
%access = &get_module_acl();
|
||||
&error_setup("<blink><font color=red>$text{'eacl_aviol'}</font></blink>");
|
||||
&error_setup($text{'eacl_aviol'});
|
||||
|
||||
$client = &get_parent_config();
|
||||
push(@parents, $client);
|
||||
|
||||
@@ -14,7 +14,7 @@ else { $sub = $conf->[$in{'uidx'}]; }
|
||||
|
||||
# check acls
|
||||
%access = &get_module_acl();
|
||||
&error_setup("<blink><font color=red>$text{'eacl_aviol'}</font></blink>");
|
||||
&error_setup($text{'eacl_aviol'});
|
||||
&error("$text{'eacl_np'} $text{'eacl_pss'}") if !&can('r',\%access,$sub);
|
||||
|
||||
# display
|
||||
|
||||
@@ -11,7 +11,7 @@ $sconf = $sha->{'members'};
|
||||
|
||||
# check acls
|
||||
%access = &get_module_acl();
|
||||
&error_setup("<blink><font color=red>$text{'eacl_aviol'}</font></blink>");
|
||||
&error_setup($text{'eacl_aviol'});
|
||||
if ($in{'new'} ) {
|
||||
&error("$text{'eacl_np'} $text{'eacl_pin'}")
|
||||
unless &can('c', \%access, $sha) && &can('rw', \%access, $par);
|
||||
|
||||
@@ -12,7 +12,7 @@ $sconf = $sub->{'members'};
|
||||
|
||||
# check acls
|
||||
%access = &get_module_acl();
|
||||
&error_setup("<blink><font color=red>$text{'eacl_aviol'}</font></blink>");
|
||||
&error_setup($text{'eacl_aviol'});
|
||||
if ($in{'new'}) {
|
||||
&error("$text{'eacl_np'} $text{'eacl_pis'}")
|
||||
unless &can('c', \%access, $sub) && &can('rw', \%access, $par);
|
||||
|
||||
@@ -165,6 +165,7 @@ listl_pc=Percentage
|
||||
restart_errmsg1=Failed to restart dhcpd
|
||||
restart_errmsg2=Failed to signal process
|
||||
start_failstart=Failed to start dhcpd
|
||||
restart_conftext=Lines around $1 in $2 :
|
||||
|
||||
sgroup_faildel=Failed to delete group
|
||||
sgroup_failsave=Failed to save group
|
||||
|
||||
@@ -9,7 +9,7 @@ require 'timelocal.pl';
|
||||
$timenow = time();
|
||||
|
||||
%access = &get_module_acl();
|
||||
&error_setup("<blink><font color=red>$text{'eacl_aviol'}</font></blink>");
|
||||
&error_setup($text{'eacl_aviol'});
|
||||
&error("$text{'eacl_np'} $text{'eacl_psl'}") unless $access{'r_leases'};
|
||||
|
||||
if ($in{'network'}) {
|
||||
|
||||
@@ -11,7 +11,7 @@ $parconf = $par->{'members'};
|
||||
|
||||
# check acls
|
||||
%access = &get_module_acl();
|
||||
&error_setup("<blink><font color=red>$text{'eacl_aviol'}</font></blink>");
|
||||
&error_setup($text{'eacl_aviol'});
|
||||
if ($in{'delete'}) {
|
||||
&error("$text{'eacl_np'} $text{'eacl_pdg'}")
|
||||
if !&can('rw', \%access, $group, 1);
|
||||
@@ -38,8 +38,8 @@ if ($in{'options'}) {
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
$whatfailed = $in{'delete'} ? $text{'sgroup_faildel'} :
|
||||
$text{'sgroup_failsave'};
|
||||
&error_setup($in{'delete'} ? $text{'sgroup_faildel'} :
|
||||
$text{'sgroup_failsave'});
|
||||
|
||||
# Move hosts into or out of this group
|
||||
@wasin = &find("host", $group->{'members'});
|
||||
@@ -58,7 +58,7 @@ else {
|
||||
}
|
||||
}
|
||||
|
||||
$whatfailed = "<blink><font color=red>$text{'eacl_aviol'}</font></blink>";
|
||||
&error_setup($text{'eacl_aviol'});
|
||||
foreach $h (&unique(@wasin, @nowin)) {
|
||||
$was = &indexof($h, @wasin) != -1;
|
||||
$now = &indexof($h, @nowin) != -1;
|
||||
@@ -85,7 +85,7 @@ else {
|
||||
$group->{'comment'} = $in{'desc'};
|
||||
&parse_params($group, $indent+1);
|
||||
|
||||
$whatfailed = $text{'sgroup_failsave'};
|
||||
&error_setup($text{'sgroup_failsave'});
|
||||
@partypes = ( "", "shared-network", "subnet" );
|
||||
if (!$npar || $in{'assign'} > 0 && $npar->{'name'} ne $partypes[$in{'assign'}]) {
|
||||
if ($in{'jsquirk'}) {
|
||||
|
||||
@@ -10,7 +10,7 @@ require './params-lib.pl';
|
||||
|
||||
# check acls
|
||||
%access = &get_module_acl();
|
||||
&error_setup("<blink><font color=red>$text{'eacl_aviol'}</font></blink>");
|
||||
&error_setup($text{'eacl_aviol'});
|
||||
if ($in{'delete'}) {
|
||||
&error("$text{'eacl_np'} $text{'eacl_pdh'}")
|
||||
if !&can('rw', \%access, $host, 1);
|
||||
@@ -35,7 +35,7 @@ else {
|
||||
# save
|
||||
if ($in{'delete'}) {
|
||||
# Delete this host
|
||||
$whatfailed = $text{'shost_faildel'};
|
||||
&error_setup($text{'shost_faildel'});
|
||||
&save_directive($par, [ $host ], [ ], 0);
|
||||
&drop_dhcpd_acl('hst', \%access, $host->{'values'}->[0]);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ foreach $i ($in{'sidx'}, $in{'uidx'}, $in{'gidx'}, $in{'idx'}) {
|
||||
|
||||
# check acls
|
||||
%access = &get_module_acl();
|
||||
&error_setup("<blink><font color=red>$text{'eacl_aviol'}</font></blink>");
|
||||
&error_setup($text{'eacl_aviol'});
|
||||
if ($client->{'name'} eq 'subnet') {
|
||||
&error("$text{'eacl_np'} $text{'eacl_pus'}")
|
||||
if !&can('rw', \%access, $client);
|
||||
|
||||
@@ -27,7 +27,7 @@ else {
|
||||
|
||||
# check acls
|
||||
%access = &get_module_acl();
|
||||
&error_setup("<blink><font color=red>$text{'eacl_aviol'}</font></blink>");
|
||||
&error_setup($text{'eacl_aviol'});
|
||||
&error("$text{'eacl_np'} $text{'eacl_pus'}") if !&can('rw', \%access, $sub);
|
||||
|
||||
# save
|
||||
|
||||
@@ -11,7 +11,7 @@ $parconf = $par->{'members'};
|
||||
|
||||
# check acls
|
||||
%access = &get_module_acl();
|
||||
&error_setup("<blink><font color=red>$text{'eacl_aviol'}</font></blink>");
|
||||
&error_setup($text{'eacl_aviol'});
|
||||
if ($in{'delete'}) {
|
||||
&error("$text{'eacl_np'} $text{'eacl_pdn'}")
|
||||
if !&can('rw', \%access, $sha, 1);
|
||||
@@ -44,10 +44,10 @@ if ($in{'options'}) {
|
||||
}
|
||||
else {
|
||||
if ($in{'delete'}) {
|
||||
$whatfailed = $text{'sshared_faildel'};
|
||||
&error_setup($text{'sshared_faildel'});
|
||||
}
|
||||
else {
|
||||
$whatfailed = $text{'sshared_failsave'};
|
||||
&error_setup($text{'sshared_failsave'});
|
||||
$in{'name'} =~ /^\S+$/ ||
|
||||
&error($text{'sshared_invalidsname'});
|
||||
$sha->{'values'} = [ $in{'name'} ];
|
||||
@@ -101,7 +101,7 @@ else {
|
||||
}
|
||||
}
|
||||
|
||||
$whatfailed = "<blink><font color=red>$text{'eacl_aviol'}</font></blink>";
|
||||
&error_setup($text{'eacl_aviol'});
|
||||
foreach $h (&unique(@wasin, @nowin)) {
|
||||
$was = &indexof($h, @wasin) != -1;
|
||||
$now = &indexof($h, @nowin) != -1;
|
||||
@@ -205,7 +205,7 @@ sub check_subnets
|
||||
local(@subnets);
|
||||
@subnets = &find("subnet", $_[0]->{'members'});
|
||||
if (@subnets == 0) {
|
||||
$whatfailed = $text{'sshared_failsave'};
|
||||
&error_setup($text{'sshared_failsave'});
|
||||
&error(&text('sshared_nosubnet', $_[0]->{'values'}->[0]));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ $parconf = $par->{'members'};
|
||||
|
||||
# check acls
|
||||
%access = &get_module_acl();
|
||||
&error_setup("<blink><font color=red>$text{'eacl_aviol'}</font></blink>");
|
||||
&error_setup($text{'eacl_aviol'});
|
||||
if ($in{'delete'}) {
|
||||
&error("$text{'eacl_np'} $text{'eacl_pds'}")
|
||||
if !&can('rw', \%access, $sub, 1);
|
||||
@@ -52,7 +52,7 @@ elsif ($in{'leases'}) {
|
||||
}
|
||||
else {
|
||||
if ($in{'delete'}) {
|
||||
$whatfailed = $text{'ssub_faildel'};
|
||||
&error_setup($text{'ssub_faildel'});
|
||||
if ($par->{'name'} eq "shared-network") {
|
||||
@subnets = &find("subnet", $par->{'members'});
|
||||
if (@subnets < 2) {
|
||||
@@ -61,7 +61,7 @@ else {
|
||||
}
|
||||
}
|
||||
else {
|
||||
$whatfailed = $text{'ssub_failsave'};
|
||||
&error_setup($text{'ssub_failsave'});
|
||||
# Validate and save inputs
|
||||
gethostbyname($in{'network'}) || &check_ipaddress($in{'network'}) ||
|
||||
&error("'$in{'network'}' $text{'ssub_invalidsubaddr'}");
|
||||
@@ -102,7 +102,7 @@ else {
|
||||
}
|
||||
}
|
||||
|
||||
$whatfailed = "<blink><font color=red>$text{'eacl_aviol'}</font></blink>";
|
||||
&error_setup($text{'eacl_aviol'});
|
||||
foreach $h (&unique(@wasin, @nowin)) {
|
||||
$was = &indexof($h, @wasin) != -1;
|
||||
$now = &indexof($h, @nowin) != -1;
|
||||
@@ -143,7 +143,7 @@ else {
|
||||
}
|
||||
|
||||
if (!$in{'delete'}) {
|
||||
$whatfailed = $text{'ssub_failsave'};
|
||||
&error_setup($text{'ssub_failsave'});
|
||||
for($i=0; defined($low = $in{"range_low_$i"}); $i++) {
|
||||
next if (!$low);
|
||||
$hi = $in{"range_hi_$i"}; $dyn = $in{"range_dyn_$i"};
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
#!/usr/local/bin/perl
|
||||
# start.cgi
|
||||
# Attempt to start dhcpd
|
||||
|
||||
require './dhcpd-lib.pl';
|
||||
%access = &get_module_acl();
|
||||
&error_setup("<blink><font color=red>$text{'eacl_aviol'}</font></blink>");
|
||||
&error_setup($text{'eacl_aviol'});
|
||||
&error("$text{'eacl_np'} $text{'eacl_papply'}") unless $access{'apply'};
|
||||
|
||||
$whatfailed = $text{'start_failstart'};
|
||||
&error_setup($text{'start_failstart'});
|
||||
$err = &start_dhcpd();
|
||||
&error($err) if ($err);
|
||||
&webmin_log("start");
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
|
||||
require './dhcpd-lib.pl';
|
||||
%access = &get_module_acl();
|
||||
&error_setup("<blink><font color=red>$text{'eacl_aviol'}</font></blink>");
|
||||
&error_setup($text{'eacl_aviol'});
|
||||
&error("$text{'eacl_np'} $text{'eacl_papply'}") unless $access{'apply'};
|
||||
|
||||
$whatfailed = $text{'stop_err'};
|
||||
&error_setup($text{'stop_err'});
|
||||
$err = &stop_dhcpd();
|
||||
&error($err) if ($err);
|
||||
&webmin_log("stop");
|
||||
|
||||
Reference in New Issue
Block a user