Files
webmin/kea-dhcp/edit_text.cgi
Ilia Ross 184887d365
Some checks failed
Tests / prove (push) Has been cancelled
Build / build (push) Has been cancelled
Close inactive / close-inactive (push) Has been cancelled
Fix to use direct ACL checks in Kea DHCP module
*Note: Removes Kea-specific ACL wrapper helpers and switches ACL editor/runtime checks to standard Webmin handling with direct supplied ACL values and get_module_acl checks.
2026-05-30 02:53:48 +02:00

44 lines
1.4 KiB
Perl
Executable File

#!/usr/local/bin/perl
# Edit Kea files as raw text.
use strict;
use warnings;
require './kea-dhcp-lib.pl'; ## no critic
&ReadParse();
our (%in, %text);
&error_setup($text{'eacl_aviol'});
my %access = &get_module_acl();
&error("$text{'eacl_np'} $text{'eacl_pmanual'}") if (!$access{'manual'});
my @files = &kea_manual_edit_files();
&error($text{'edit_enofile'}) if (!@files);
my $info = &kea_manual_edit_file($in{'file'}) || $files[0];
my $file = $info->{'file'};
&error($text{'save_efile'}) if (!$file);
# The manual editor is intentionally constrained to known Kea config files and
# Control Agent password files discovered by the library.
my $data = "";
if (-r $file) {
&lock_file($file);
$data = &read_file_contents($file);
&unlock_file($file);
}
&ui_print_header(undef, $text{'index_edit_manual'}, "", undef, 1, 1);
# Keep file selection and file contents as separate forms, matching nftables.
print &ui_form_start("edit_text.cgi");
print &ui_tag('b', &html_escape($text{'edit_select'})),"\n";
print &ui_select("file", $file, [ map { $_->{'file'} } @files ]),"\n";
print &ui_submit($text{'edit_ok'});
print &ui_form_end();
print &ui_form_start("save_text.cgi", "form-data");
print &ui_hidden("file", $file);
print &ui_table_start(undef, undef, 2);
print &ui_table_row(undef, &ui_textarea("data", $data, 30, 120), 2);
print &ui_table_end();
print &ui_form_end([ [ "save", $text{'save'} ] ]);
&ui_print_footer("index.cgi", $text{'index_return'});