Manual config file edit button for allowed hosts

This commit is contained in:
Jamie Cameron
2018-01-28 15:43:44 -08:00
parent f0a5bff4f5
commit 4393f0df19
6 changed files with 49 additions and 0 deletions

View File

@@ -76,3 +76,5 @@ Added an option to the restore form to limit the restore to only certain tables.
When creating a new database, a template database to copy from can now be selected.
---- Changes since 1.700 ----
When a database is deleted, any cron job for backing it up is also removed.
---- Changes since 1.870 ----
Added a page for manually editing the allowed hosts config file.

17
postgresql/edit_manual.cgi Executable file
View File

@@ -0,0 +1,17 @@
#!/usr/local/bin/perl
# Show a config file for manual editing
require './postgresql-lib.pl';
$access{'users'} || &error($text{'host_ecannot'});
&ui_print_header(undef, $text{'manual_title'}, "");
# Config editor
print &ui_form_start("save_manual.cgi", "form-data");
print $form_hiddens;
print &ui_table_start(undef, undef, 2);
print &ui_table_row(undef,
&ui_textarea("data", &read_file_contents($hba_conf_file), 20, 80), 2);
print &ui_table_end();
print &ui_form_end([ [ undef, $text{'save'} ] ]);
&ui_print_footer("", $text{'index_return'});

View File

@@ -307,6 +307,11 @@ host_ssl=SSL connection required?
host_viassl=Via SSL
host_derr=Failed to delete allowed hosts
host_enone=No hosts selected
host_manual=Edit Config File
host_manualdesc=Click this button to manually edit the allowed hosts configuration file.
manual_title=Edit Config File
manual_err=Failed to save config file
grant_title=Granted Privileges
grant_tvi=Object
@@ -412,6 +417,7 @@ log_backup=Backed up database $1
log_backup_l=Backed up database $1 to file $2
log_backup_all=Backed up all databases
log_backup_all_l=Backed up all databases to file $2
log_manual=Manually edited allowed hosts config file
acl_dbs=Databases this user can manage
acl_dbscannot=This access control will become effective, after starting the PostgreSQL database server.

View File

@@ -68,5 +68,11 @@ print &ui_columns_end();
print &ui_links_row(\@rowlinks);
print &ui_form_end([ [ "delete", $text{'user_delete'} ] ]);
print &ui_hr();
print &ui_buttons_start();
print &ui_buttons_row("edit_manual.cgi", $text{'host_manual'},
$text{'host_manualdesc'});
print &ui_buttons_end();
&ui_print_footer("", $text{'index_return'});

View File

@@ -69,6 +69,9 @@ elsif ($action eq 'backup') {
"<tt>$object</tt>",
"<tt>".&html_escape($p->{'file'})."</tt>");
}
elsif ($action eq 'manual') {
return $text{'log_manual'};
}
else {
return undef;
}

15
postgresql/save_manual.cgi Executable file
View File

@@ -0,0 +1,15 @@
#!/usr/local/bin/perl
# Save a manually edited config file
require './postgresql-lib.pl';
&ReadParseMime();
&error_setup($text{'manual_err'});
# Write the file
$in{'data'} =~ s/\r//g;
&open_lock_tempfile(MANUAL, ">$hba_conf_file");
&print_tempfile(MANUAL, $in{'data'});
&close_tempfile(MANUAL);
&webmin_log("manual");
&redirect("");