diff --git a/postgresql/CHANGELOG b/postgresql/CHANGELOG
index 7a2cd03cd..acc8146ec 100644
--- a/postgresql/CHANGELOG
+++ b/postgresql/CHANGELOG
@@ -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.
diff --git a/postgresql/edit_manual.cgi b/postgresql/edit_manual.cgi
new file mode 100755
index 000000000..88ad8d52d
--- /dev/null
+++ b/postgresql/edit_manual.cgi
@@ -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'});
diff --git a/postgresql/lang/en b/postgresql/lang/en
index bf5340d05..b71282362 100644
--- a/postgresql/lang/en
+++ b/postgresql/lang/en
@@ -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.
diff --git a/postgresql/list_hosts.cgi b/postgresql/list_hosts.cgi
index e2161eec2..80dbbdf58 100755
--- a/postgresql/list_hosts.cgi
+++ b/postgresql/list_hosts.cgi
@@ -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'});
diff --git a/postgresql/log_parser.pl b/postgresql/log_parser.pl
index 923ae9572..b86a2b6ac 100755
--- a/postgresql/log_parser.pl
+++ b/postgresql/log_parser.pl
@@ -69,6 +69,9 @@ elsif ($action eq 'backup') {
"$object",
"".&html_escape($p->{'file'})."");
}
+elsif ($action eq 'manual') {
+ return $text{'log_manual'};
+ }
else {
return undef;
}
diff --git a/postgresql/save_manual.cgi b/postgresql/save_manual.cgi
new file mode 100755
index 000000000..9ff01df22
--- /dev/null
+++ b/postgresql/save_manual.cgi
@@ -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("");