mirror of
https://github.com/webmin/webmin.git
synced 2026-03-20 16:50:24 +00:00
ui-lib and strict conversion
This commit is contained in:
@@ -2,26 +2,23 @@
|
||||
# chown.cgi
|
||||
# Change permissions on cache/log/pid files after a user change
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
our (%text, %in, %access, $squid_version, %config);
|
||||
require './squid-lib.pl';
|
||||
$access{'admopts'} || &error($text{'eadm_ecannot'});
|
||||
$| = 1;
|
||||
&ui_print_header(undef, $text{'chown_header'}, "");
|
||||
$conf = &get_config();
|
||||
|
||||
&ui_print_unbuffered_header(undef, $text{'chown_header'}, "");
|
||||
my $conf = &get_config();
|
||||
|
||||
# Stop squid
|
||||
if ($pidstruct = &find_config("pid_filename", $conf)) {
|
||||
$pidfile = $pidstruct->{'values'}->[0];
|
||||
}
|
||||
else { $pidfile = $config{'pid_file'}; }
|
||||
if (open(PID, $pidfile)) {
|
||||
<PID> =~ /(\d+)/; $pid = $1;
|
||||
close(PID);
|
||||
}
|
||||
my $pid = &is_squid_running();
|
||||
my $stopped = 0;
|
||||
if ($pid && kill(0, $pid)) {
|
||||
print "<p>$text{'chown_stop'}<br>\n";
|
||||
system("$config{'squid_path'} -f $config{'squid_conf'} ".
|
||||
"-k shutdown >/dev/null 2>&1");
|
||||
for($i=0; $i<40; $i++) {
|
||||
for(my $i=0; $i<40; $i++) {
|
||||
if (!kill(0, $pid)) { last; }
|
||||
sleep(1);
|
||||
}
|
||||
@@ -31,17 +28,17 @@ if ($pid && kill(0, $pid)) {
|
||||
|
||||
# Change ownership
|
||||
print "<p>$text{'chown_chown'}<br>\n";
|
||||
($user, $group) = &get_squid_user($conf);
|
||||
my ($user, $group) = &get_squid_user($conf);
|
||||
&chown_files($user, $group, $conf);
|
||||
print "$text{'chown_done'}<br>\n";
|
||||
|
||||
# Re-start Squid
|
||||
if ($stopped) {
|
||||
print "<p>$text{'chown_restart'}<br>\n";
|
||||
$temp = &transname();
|
||||
my $temp = &transname();
|
||||
system("$config{'squid_path'} -sY -f $config{'squid_conf'} >$temp 2>&1 </dev/null &");
|
||||
sleep(3);
|
||||
$errs = `cat $temp`;
|
||||
my $errs = &read_file_contents($temp);
|
||||
unlink($temp);
|
||||
if ($errs) {
|
||||
system("$config{'squid_path'} -k shutdown -f $config{'squid_conf'} >/dev/null 2>&1");
|
||||
|
||||
@@ -2,95 +2,73 @@
|
||||
# edit_admin.cgi
|
||||
# A form for editing admin options
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
our (%text, %in, %access, $squid_version, %config);
|
||||
require './squid-lib.pl';
|
||||
$access{'admopts'} || &error($text{'eadm_ecannot'});
|
||||
&ui_print_header(undef, $text{'eadm_header'}, "", "edit_admin", 0, 0, 0, &restart_button());
|
||||
$conf = &get_config();
|
||||
my $conf = &get_config();
|
||||
|
||||
print "<form action=save_admin.cgi>\n";
|
||||
print "<table border width=100%>\n";
|
||||
print "<tr $tb> <td><b>$text{'eadm_aao'}</b></td> </tr>\n";
|
||||
print "<tr $cb> <td><table width=100%>\n";
|
||||
print &ui_form_start("save_admin.cgi", "post");
|
||||
print &ui_table_start($text{'eadm_aao'}, "width=100%", 4);
|
||||
|
||||
if ($squid_version < 2) {
|
||||
print "<tr>\n";
|
||||
$v = &find_config("cache_effective_user", $conf);
|
||||
print "<td><b>$text{'eadm_runasuu'}</b></td> <td colspan=3>\n";
|
||||
printf "<input type=radio name=effective_def value=1 %s> $text{'eadm_nochange'}\n",
|
||||
$v ? "" : "checked";
|
||||
printf " <input type=radio name=effective_def value=0 %s>\n",
|
||||
$v ? "checked" : "";
|
||||
print $text{'eadm_user'} ,&unix_user_input("effective_u",
|
||||
$v->{'values'}->[0]),"\n";
|
||||
print $text{'eadm_group'} ,&unix_group_input("effective_g",
|
||||
$v->{'values'}->[1]),"\n";
|
||||
print "</td> </tr>\n";
|
||||
my $v = &find_config("cache_effective_user", $conf);
|
||||
print &ui_table_row($text{'eadm_runasuu'},
|
||||
&ui_radio("effective_def", $v ? 0 : 1,
|
||||
[ [ 1, $text{'eadm_nochange'} ],
|
||||
[ 0, $text{'eadm_user'}." ".
|
||||
&unix_user_input("effective_u",
|
||||
$v ? $v->{'values'}->[0] : "")." ".
|
||||
$text{'eadm_group'}." ".
|
||||
&unix_group_input("effective_g",
|
||||
$v ? $v->{'values'}->[1] : "") ] ]));
|
||||
}
|
||||
else {
|
||||
print "<tr>\n";
|
||||
print &opt_input($text{'eadm_runasuu'}, "cache_effective_user", $conf,
|
||||
$text{'eadm_nochange'}, 8,
|
||||
&user_chooser_button("cache_effective_user", 0));
|
||||
print &opt_input($text{'eadm_runasug'}, "cache_effective_group", $conf,
|
||||
$text{'eadm_nochange'}, 8,
|
||||
&group_chooser_button("cache_effective_group", 0));
|
||||
print "</tr>\n";
|
||||
}
|
||||
|
||||
print "<tr>\n";
|
||||
print &opt_input($text{'eadm_cmemail'}, "cache_mgr",
|
||||
$conf, $text{'eadm_default'}, 35);
|
||||
print "</tr>\n";
|
||||
|
||||
print "<tr>\n";
|
||||
print &opt_input($text{'eadm_vhost'}, "visible_hostname",
|
||||
$conf, $text{'eadm_auto'}, 35);
|
||||
print "</tr>\n";
|
||||
|
||||
if ($squid_version < 2) {
|
||||
print "<tr>\n";
|
||||
print &opt_input($text{'eadm_annto'}, "announce_to",
|
||||
$conf, $text{'eadm_default'}, 40);
|
||||
print "</tr>\n";
|
||||
|
||||
print "<tr>\n";
|
||||
print &opt_input($text{'eadm_every'}, "cache_announce", $conf,
|
||||
$text{'eadm_never'}, 6, "hours");
|
||||
print "</tr>\n";
|
||||
}
|
||||
else {
|
||||
print "<tr>\n";
|
||||
print &opt_input($text{'eadm_uniq'}, "unique_hostname",
|
||||
$conf, $text{'eadm_auto'}, 35);
|
||||
print "</tr>\n";
|
||||
|
||||
if ($squid_version >= 2.4) {
|
||||
print "<tr>\n";
|
||||
print &opt_input($text{'eadm_haliases'}, "hostname_aliases",
|
||||
$conf, $text{'eadm_none'}, 35);
|
||||
print "</tr>\n";
|
||||
}
|
||||
|
||||
print "<tr>\n";
|
||||
print &opt_input($text{'eadm_cah'}, "announce_host", $conf,
|
||||
$text{'eadm_default'}, 20);
|
||||
print &opt_input($text{'eadm_cap'}, "announce_port", $conf,
|
||||
$text{'eadm_default'}, 6);
|
||||
print "</tr>\n";
|
||||
|
||||
print "<tr>\n";
|
||||
print &opt_input($text{'eadm_caf'}, "announce_file", $conf,
|
||||
$text{'eadm_none'}, 35, &file_chooser_button("announce_file"));
|
||||
print "</tr>\n";
|
||||
|
||||
print "<tr>\n";
|
||||
print &opt_time_input($text{'eadm_annp'}, "announce_period", $conf,
|
||||
$text{'eadm_default'}, 4);
|
||||
print "</tr>\n";
|
||||
}
|
||||
|
||||
print "</table></td></tr></table>\n";
|
||||
print "<input type=submit value=$text{'eadm_buttsave'}></form>\n";
|
||||
print &ui_table_end();
|
||||
print &ui_form_end([ [ undef, $text{'eadm_buttsave'} ] ]);
|
||||
|
||||
&ui_print_footer("", $text{'eadm_return'});
|
||||
|
||||
|
||||
@@ -2,20 +2,23 @@
|
||||
# save_admin.cgi
|
||||
# Save admin options
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
our (%text, %in, %access, $squid_version, %config);
|
||||
require './squid-lib.pl';
|
||||
$access{'admopts'} || &error($text{'eadm_ecannot'});
|
||||
&ReadParse();
|
||||
&lock_file($config{'squid_conf'});
|
||||
$conf = &get_config();
|
||||
$whatfailed = $text{'sadmin_ftsao'};
|
||||
my $conf = &get_config();
|
||||
&error_setup($text{'sadmin_ftsao'});
|
||||
|
||||
($olduser, $oldgroup) = &get_squid_user($conf);
|
||||
my ($olduser, $oldgroup) = &get_squid_user($conf);
|
||||
if ($squid_version < 2) {
|
||||
if ($in{'effective_def'}) {
|
||||
&save_directive($conf, "cache_effective_user", [ ]);
|
||||
}
|
||||
else {
|
||||
%dir = ( 'name', 'cache_effective_user',
|
||||
my %dir = ( 'name', 'cache_effective_user',
|
||||
'values', [ $in{'effective_u'}, $in{'effective_g'} ] );
|
||||
&save_directive($conf, "cache_effective_user", [ \%dir ]);
|
||||
}
|
||||
@@ -44,17 +47,22 @@ else {
|
||||
&unlock_file($config{'squid_conf'});
|
||||
&webmin_log("admin", undef, undef, \%in);
|
||||
|
||||
($user, $group) = &get_squid_user($conf);
|
||||
my ($user, $group) = &get_squid_user($conf);
|
||||
if (($olduser ne $user || $oldgroup ne $group) && $user && $group) {
|
||||
# User/group has changed! Ask user if he wants to chown log/cache/pid
|
||||
&ui_print_header(undef, $text{'sadmin_header'}, "");
|
||||
print $text{'sadmin_msg1'},"\n";
|
||||
print "<center><form action=chown.cgi>\n";
|
||||
print "<input type=submit value=\"$text{'sadmin_buttco'}\">\n";
|
||||
print "</form></center>\n";
|
||||
|
||||
print &ui_confirmation_form(
|
||||
"chown.cgi",
|
||||
$text{'sadmin_msg1'},
|
||||
[], [ [ undef, $text{'sadmin_buttco'} ] ],
|
||||
);
|
||||
|
||||
&ui_print_footer("", $text{'sadmin_return'});
|
||||
}
|
||||
else { &redirect(""); }
|
||||
else {
|
||||
&redirect("");
|
||||
}
|
||||
|
||||
sub check_email
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user