Allow host list to be dited when login fails, and support ident sameuser mode

This commit is contained in:
Jamie Cameron
2012-03-24 10:36:39 -07:00
parent d5431cb648
commit b03fbf19e2
4 changed files with 50 additions and 27 deletions

View File

@ -60,7 +60,11 @@ local $found = !$host->{'db'} || $host->{'db'} eq 'all' ||
if ($v >= 7.3) {
push(@dbopts, [ "samegroup", "<$text{'host_gsame'}>" ]);
}
foreach $d (&list_databases()) {
eval {
$main::error_must_die = 1;
@dblist = &list_databases();
};
foreach $d (@dblist) {
push(@dbopts, $d);
$found++ if ($host->{'db'} eq $d);
}
@ -93,9 +97,14 @@ foreach $a ('password', 'crypt', ($v >= 7.2 ? ( 'md5' ) : ( )),
}
elsif ($a eq 'ident') {
# Ident server
$extra = &ui_checkbox("identarg", 1, $text{'host_identarg'},
$arg)." ".
&ui_textbox("ident", $arg, 20);
$identarg = $arg eq "" ? 0 : $arg eq "sameuser" ? 2 : 1;
$extra = &ui_radio_table("identarg", $identarg,
[ [ 0, $text{'host_identarg0'} ],
[ 2, $text{'host_identarg1'} ],
[ 1, $text{'host_identarg2'},
&ui_textbox("ident",
$identarg == 1 ? $arg : "", 40)." ".
&file_chooser_button("ident") ] ]);
}
elsif ($a eq 'pam') {
# PAM service

View File

@ -101,6 +101,12 @@ elsif ($r == -1) {
print &ui_form_end([ [ undef, $text{'save'} ] ]);
print &text('index_emsg', "<tt>$rout</tt>"),"<p>\n";
# Button to edit user permissions
if ($access{'users'}) {
print &ui_form_start("list_hosts.cgi");
print &ui_form_end([ [ undef, $text{'index_edithosts'} ] ]);
}
}
elsif ($r == -2) {
# Looks like a shared library problem
@ -250,38 +256,40 @@ else {
'images/hosts.gif', 'images/grants.gif' );
&icons_table(\@links, \@titles, \@images);
}
}
print &ui_hr();
print &ui_buttons_start();
print &ui_hr();
print &ui_buttons_start();
# Show stop server button
if ($access{'stop'} && &is_postgresql_local()) {
print &ui_buttons_row("stop.cgi", $text{'index_stop'},
$text{'index_stopmsg'});
}
# Show stop server button
if ($access{'stop'} && &is_postgresql_local()) {
print &ui_buttons_row("stop.cgi", $text{'index_stop'},
$text{'index_stopmsg'});
}
if ($r > 0) {
# Show backup all button
if ($can_all && $access{'backup'}) {
print &ui_buttons_row("backup_form.cgi", $text{'index_backup'},
$text{'index_backupmsg'},
&ui_hidden("all", 1));
}
}
print &ui_buttons_end();
print &ui_buttons_end();
# Check if the optional perl modules are installed
if (&foreign_available("cpan")) {
eval "use DBI";
push(@needs, "DBI") if ($@);
$nodbi++ if ($@);
eval "use DBD::Pg";
push(@needs, "DBD::Pg") if ($@);
if (@needs) {
$needs = &urlize(join(" ", @needs));
print "<center><b>",&text(@needs == 2 ? 'index_nomods' : 'index_nomod', @needs,
"/cpan/download.cgi?source=3&cpan=$needs&mode=2&return=/$module_name/&returndesc=".&urlize($text{'index_return'})),
"</b></center>\n";
}
# Check if the optional perl modules are installed
if (&foreign_available("cpan")) {
eval "use DBI";
push(@needs, "DBI") if ($@);
$nodbi++ if ($@);
eval "use DBD::Pg";
push(@needs, "DBD::Pg") if ($@);
if (@needs) {
$needs = &urlize(join(" ", @needs));
print "<center><b>",&text(@needs == 2 ? 'index_nomods' : 'index_nomod', @needs,
"/cpan/download.cgi?source=3&cpan=$needs&mode=2&return=/$module_name/&returndesc=".&urlize($text{'index_return'})),
"</b></center>\n";
}
}

View File

@ -47,6 +47,7 @@ index_hash=Hash
index_gist=Generalized Index Search Tree
index_jump=Or edit database:
index_jumpok=Open
index_edithosts=Configure Allowed Host Systems
login_err=Login failed
login_ecannot=You are not allowed to configure the database login
@ -279,7 +280,9 @@ host_krb4=Kerberos V4
host_krb5=Kerberos V5
host_pam=PAM
host_passwordarg=Use password file
host_identarg=Use user map
host_identarg0=Don't use any user map
host_identarg1=PostgreSQL and Unix users are the same
host_identarg2=Use user map file
host_pamarg=Use PAM service
host_create=Create Allowed Host
host_edit=Edit Allowed Host

View File

@ -75,10 +75,13 @@ else {
$in{'password'} =~ /^\S+$/ || &error($text{'host_epassword'});
$host->{'arg'} = $in{'password'};
}
elsif ($in{'auth'} eq 'ident' && $in{'identarg'}) {
elsif ($in{'auth'} eq 'ident' && $in{'identarg'} == 1) {
$in{'ident'} =~ /^\S+$/ || &error($text{'host_eident'});
$host->{'arg'} = $in{'ident'};
}
elsif ($in{'auth'} eq 'ident' && $in{'identarg'} == 2) {
$host->{'arg'} = 'sameuser';
}
elsif ($in{'auth'} eq 'pam' && $in{'pamarg'}) {
$in{'pam'} =~ /^\S+$/ || &error($text{'host_epam'});
$host->{'arg'} = $in{'pam'};