#!/usr/local/bin/perl # edit_host.cgi # Display a form for editing or creating an allowed host require './postgresql-lib.pl'; &ReadParse(); $v = &get_postgresql_version(); if ($in{'new'}) { $type = $in{'new'}; &ui_print_header(undef, $text{"host_create"}, ""); $host = { 'type' => $type, 'netmask' => '0.0.0.0', 'auth' => 'trust', 'db' => 'all' }; } else { @all = &get_hba_config($v); $host = $all[$in{'idx'}]; $type = $host->{'type'}; &ui_print_header(undef, $text{"host_edit"}, ""); } print "
\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
$text{'host_header'}
\n"; $mode = $type eq 'local' ? 3 : $host->{'cidr'} ne '' ? 4 : $host->{'netmask'} eq '0.0.0.0' ? 0 : $host->{'netmask'} eq '255.255.255.255' ? 1 : 2; print "\n", $mode == 4 ? $host->{'cidr'} : ''; if ($type eq "hostssl" || $v >= 7.3) { print "\n", $typeq eq "hostssl" ? "checked" : "", $text{'host_ssl'}; } local $found = !$host->{'db'} || $host->{'db'} eq 'all' || $host->{'db'} eq 'sameuser'; print "\n"; print "\n", $found ? "" : join(" ", split(/,/, $host->{'db'})); if ($v >= 7.3) { print "\n", $host->{'user'} eq 'all' ? "" : join(" ", split(/,/, $host->{'user'})); } print "\n"; print "
$text{'host_address'} \n"; printf " %s
\n", $mode == 3 ? 'checked' : '', $text{'host_local'}; printf " %s
\n", $mode == 0 ? 'checked' : '', $text{'host_any'}; printf " %s\n", $mode == 1 ? 'checked' : '', $text{'host_single'}; printf "
\n", $mode == 1 ? $host->{'address'} : ''; printf " %s\n", $mode == 2 ? 'checked' : '', $text{'host_network'}; printf " %s\n", $mode == 2 ? $host->{'address'} : '', $text{'host_netmask'}; printf "
\n", $mode == 2 ? $host->{'netmask'} : ''; printf " %s\n", $mode == 4 ? 'checked' : '', $text{'host_network'}; printf " %s\n", $mode == 4 ? $host->{'address'} : '', $text{'host_cidr'}; printf "
   \n"; printf " %s
$text{'host_db'}\n"; printf "
$text{'host_user'} \n"; printf " %s\n", $host->{'user'} eq 'all' || !$host->{'user'} ? "checked" : "", $text{'host_uall'}; printf " %s\n", $host->{'user'} eq 'all' || !$host->{'user'} ? "" : "checked", $text{'host_usel'}; printf "
$text{'host_auth'} \n"; foreach $a ('password', 'crypt', ($v >= 7.2 ? ( 'md5' ) : ( )), 'trust', 'reject', 'ident', 'krb4', 'krb5', ($v >= 7.3 ? ( 'pam' ) : ( )) ) { printf " %s\n", $a, $host->{'auth'} eq $a ? 'checked' : '', $text{"host_$a"}; $arg = $host->{'auth'} eq $a ? $host->{'arg'} : undef; if ($a eq 'password') { print "
   \n"; printf " %s\n", $arg ? 'checked' : '', $text{'host_passwordarg'}; print "\n"; } elsif ($a eq 'ident') { print "
   \n"; printf " %s\n", $arg ? 'checked' : '', $text{'host_identarg'}; print "\n"; } elsif ($a eq 'pam') { print "
   \n"; printf " %s\n", $arg ? 'checked' : '', $text{'host_pamarg'}; print "\n"; } print "
\n"; if ($a eq 'reject') { print "
\n"; } } print "
\n"; print "\n"; if ($in{'new'}) { print "\n"; } else { print "\n"; print "\n"; } print "
\n"; &ui_print_footer("list_hosts.cgi", $text{'host_return'});