#!/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"}, ""); } # Start of form block print &ui_form_start("save_host.cgi", "post"); print &ui_hidden("idx", $in{'idx'}); print &ui_hidden("new", $in{'new'}); print &ui_table_start($text{'host_header'}, "width=100%", 2); # XXX $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 " $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", $mode == 4 ? $host->{'cidr'} : ''; if ($type eq "hostssl" || $v >= 7.3) { print "    \n"; printf " %s \n", $typeq eq "hostssl" ? "checked" : "", $text{'host_ssl'}; } local $found = !$host->{'db'} || $host->{'db'} eq 'all' || $host->{'db'} eq 'sameuser'; print " $text{'host_db'}\n"; print "\n"; printf " \n", $found ? "" : join(" ", split(/,/, $host->{'db'})); if ($v >= 7.3) { print " $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 " \n", $host->{'user'} eq 'all' ? "" : join(" ", split(/,/, $host->{'user'})); } print " $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"; print "\n"; if ($in{'new'}) { print "\n"; } else { print "\n"; print "\n"; } print "
\n"; &ui_print_footer("list_hosts.cgi", $text{'host_return'});