Files
webmin/cron/edit_env.cgi
Ilia Ross c23b6b5b48
Some checks failed
Tests / prove (push) Has been cancelled
Package and upload artifacts / build (push) Has been cancelled
Fix Cron environment variable ACL checks
This patch completes the ACL added in [17ba87cbc](https://github.com/webmin/webmin/commit/17ba87cbc).

That change protected only the edit and save pages.

Users without environment-variable access could still change variables through delete, bulk actions, and moves.

This applies the permission everywhere and hides blocked controls.

It also applies create and delete permissions to variables and prevents job and variable endpoints from being mixed.
2026-10-11 15:31:06 +02:00

81 lines
2.1 KiB
Perl
Executable File

#!/usr/local/bin/perl
# edit_env.cgi
# Edit an existing or new environment variable
require './cron-lib.pl';
&ReadParse();
$access{'env'} || &error($text{'env_ecannot'});
if (!$in{'new'}) {
@jobs = &list_cron_jobs();
$env = $jobs[$in{'idx'}];
$env && $env->{'name'} || &error($text{'env_egone'});
&can_edit_user(\%access, $env->{'user'}) ||
&error($text{'edit_ecannot'});
&ui_print_header(undef, $text{'env_title1'}, "");
}
else {
$access{'create'} || &error($text{'save_ecannot2'});
&ui_print_header(undef, $text{'env_title2'}, "");
$env = { 'active' => 1 };
}
print "$text{'env_order'}<p>\n";
print &ui_form_start("save_env.cgi", "post");
print &ui_hidden("new", $in{'new'});
print &ui_hidden("idx", $in{'idx'});
print &ui_table_start($text{'env_details'}, "width=100%", 2);
# Under user
if ($access{'mode'} == 1) {
$usel = &ui_select("user", $env->{'user'},
[ split(/\s+/, $access{'users'}) ]);
}
elsif ($access{'mode'} == 3) {
$usel = "<tt>$remote_user</tt>";
print &ui_hidden("user", $remote_user);
}
else {
$usel = &ui_user_textbox("user", $env->{'user'});
}
print &ui_table_row($text{'env_user'}, $usel);
# Active or now
print &ui_table_row($text{'env_active'},
&ui_yesno_radio("active", $env->{'active'} ? 1 : 0));
# Variable name
print &ui_table_row($text{'env_name'},
&ui_textbox("name", $env->{'name'}, 50));
# Variable value
print &ui_table_row($text{'env_value'},
&ui_textbox("value", $env->{'value'}, 50));
if ($in{'new'}) {
# Location for new variable
print &ui_table_row($text{'env_where'},
&ui_radio("where", 1, [ [ 1, $text{'env_top'} ],
[ 0, $text{'env_bot'} ] ]));
}
elsif ($env->{'index'}) {
# Location for existing
print &ui_table_row($text{'env_where2'},
&ui_radio("where", 0, [ [ 1, $text{'env_top'} ],
[ 0, $text{'env_leave'} ]]));
}
print &ui_table_end();
if ($in{'new'}) {
print &ui_form_end([ [ undef, $text{'create'} ] ]);
}
else {
my @buttons = ( [ undef, $text{'save'} ] );
push(@buttons, [ "delete", $text{'delete'} ]) if ($access{'delete'});
print &ui_form_end(\@buttons);
}
&ui_print_footer("", $text{'index_return'});