From 17407b91c416de7913cc663ee1d6008895e395fc Mon Sep 17 00:00:00 2001 From: rbt Date: Tue, 2 Jan 2007 13:53:19 +0000 Subject: [PATCH] Toshio Kuratomi wrote a patch to allow a password to be provided via prompt. --- configure.ac | 5 +++-- postgresql_autodoc.pl | 28 ++++++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index c5a3436..7af2abe 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_PREREQ(2.53) -AC_REVISION($Header: /cvsroot/autodoc/autodoc/Attic/configure.ac,v 1.1 2004/05/12 16:00:34 rbt Exp $) +AC_REVISION($Header: /cvsroot/autodoc/autodoc/Attic/configure.ac,v 1.2 2007/01/02 13:53:19 rbt Exp $) AC_INIT(postgresql_autodoc.pl) @@ -37,9 +37,10 @@ AC_SUBST(PERL) # DBD::Pg # Fcntl # HTML::Template +# Term::ReadKey # # Output of if test redirected to /dev/null to keep quiet -for module in DBI DBD::Pg Fcntl HTML::Template ; do +for module in DBI DBD::Pg Fcntl HTML::Template Term::ReadKey ; do AC_MSG_CHECKING(${module}) if [ ! (${PERL} -e "use ${module}" 2>&1 /dev/null ) ]; then AC_MSG_RESULT(no) diff --git a/postgresql_autodoc.pl b/postgresql_autodoc.pl index c4dc25a..9c5c634 100755 --- a/postgresql_autodoc.pl +++ b/postgresql_autodoc.pl @@ -1,13 +1,13 @@ #!/usr/bin/env perl # -- # -*- Perl -*-w -# $Header: /cvsroot/autodoc/autodoc/postgresql_autodoc.pl,v 1.14 2006/05/16 19:01:27 rbt Exp $ +# $Header: /cvsroot/autodoc/autodoc/postgresql_autodoc.pl,v 1.15 2007/01/02 13:53:19 rbt Exp $ # Imported 1.22 2002/02/08 17:09:48 into sourceforge # Postgres Auto-Doc Version 1.30 # License # ------- -# Copyright (c) 2001-2005, Rod Taylor +# Copyright (c) 2001-2007, Rod Taylor # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -55,6 +55,9 @@ use Fcntl; # Allows file templates use HTML::Template; +# Allow reading a password from stdin +use Term::ReadKey; + sub main($) { my ($ARGV) = @_; @@ -78,6 +81,9 @@ sub main($) my $dbport = $ENV{'PGPORT'}; $dbport ||= ""; + # Determine whether we need a password to connect + my $needpass = 0; + my $dbpass = ""; my $output_filename_base = $database; @@ -138,6 +144,12 @@ sub main($) last; }; + # Make sure we get a password before attempting to conenct + /^--password$/ && do { + $needpass = 1; + last; + }; + # Set the base of the filename. The extensions pulled # from the templates will be appended to this name /^-f$/ && do { @@ -187,6 +199,17 @@ Msg ; } + # If needpass has been set but no password was provided, prompt the user + # for a password. + if ($needpass and not $dbpass) { + print "Password: "; + ReadMode 'noecho'; + $dbpass = ReadLine 0; + chomp $dbpass; + ReadMode 'normal'; + print "\n"; + } + # Database Connection my $dsn = "dbi:Pg:dbname=$database"; $dsn .= ";host=$dbhost" if ( "$dbhost" ne "" ); @@ -1830,6 +1853,7 @@ Options: -p Specify database server port (default: 5432) -u Specify database username (default: $dbuser) --password= Specify database password (default: blank) + --password Have $basename prompt for a password -l Path to the templates (default: @@TEMPLATE-DIR@@) -t Type of output wanted (default: All in template library) -- 2.50.0