]> granicus.if.org Git - postgresql-autodoc/commitdiff
Toshio Kuratomi wrote a patch to allow a password to be provided via prompt.
authorrbt <rbt>
Tue, 2 Jan 2007 13:53:19 +0000 (13:53 +0000)
committerrbt <rbt>
Tue, 2 Jan 2007 13:53:19 +0000 (13:53 +0000)
configure.ac
postgresql_autodoc.pl

index c5a34367b6fdc7a12488aa683393662c5afe2d0d..7af2abec4c8979955aa20f0501175e026e2c7221 100644 (file)
@@ -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)
index c4dc25a6dea83b950d4f107fe92c68225808e040..9c5c634bb68712491ff45a51f7f8af57f91bd8b8 100755 (executable)
@@ -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 <port>       Specify database server port (default: 5432)
   -u <username>   Specify database username (default: $dbuser)
   --password=<pw> Specify database password (default: blank)
+  --password      Have $basename prompt for a password
 
   -l <path>       Path to the templates (default: @@TEMPLATE-DIR@@)
   -t <output>     Type of output wanted (default: All in template library)