[Fedora-directory-commits] console/src/com/netscape/management/client/console Console.java, 1.12, 1.13

Richard Allen Megginson (rmeggins) fedora-directory-commits at redhat.com
Mon Jun 23 23:03:07 UTC 2008


Author: rmeggins

Update of /cvs/dirsec/console/src/com/netscape/management/client/console
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv14572/bug442187/src/com/netscape/management/client/console

Modified Files:
	Console.java 
Log Message:
Resolves: bug 442187
Description: [PATCH] support for providing console password in STDIN
Fix Description: Add support for -w - to read password from stdin, and add a new -y argument to read the password from a password file.



Index: Console.java
===================================================================
RCS file: /cvs/dirsec/console/src/com/netscape/management/client/console/Console.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- Console.java	7 Dec 2007 20:44:38 -0000	1.12
+++ Console.java	23 Jun 2008 23:03:05 -0000	1.13
@@ -1515,7 +1515,7 @@
       */
 
     static public void main(String argv[]) {
-		GetOpt opt = new GetOpt("h:a:A:f:l:u:w:s:D:x:", argv);
+		GetOpt opt = new GetOpt("h:a:A:f:l:u:w:y:s:D:x:", argv);
          
         if (opt.hasOption('f')) {
             String outFile = opt.getOptionParam('f');
@@ -1594,6 +1594,10 @@
             System.err.println("         -f <file> capture stderr and stdout to <file> (like Unix tee command)");
             System.err.println("         -s server DN (cn=...) or instance ID (e.g. slapd-host)");
             System.err.println("         -x extra options (javalaf,nowinpos,nologo)");
+            System.err.println("         -u username");
+            System.err.println("         -w password");
+            System.err.println("         -w - (read password from standard input)");
+            System.err.println("         -y password_file (read password from a file)");
             System.err.println("\nExample: Console -a https://hostname:10021 -l en");
             waitForKeyPress(); // allow the user to read the msg on Win NT
             System.exit(0);
@@ -1632,7 +1636,34 @@
         String password = null;
         if (opt.hasOption('w')) {
             password = opt.getOptionParam('w');
+            // GetOpt works in such a twisted way that "-" argument values
+            // result in null values received:
+            if (password == null || password.equals("-")) {
+                try {
+                    password = (new BufferedReader(new InputStreamReader(
+                            System.in))).readLine();
+                } catch (IOException e) {
+                    System.err
+                            .println("Problem reading password from standard input "
+                                    + e.getMessage());
+                }
+            }
         }
+        
+        if (opt.hasOption('y')) {
+            String passwdFile = opt.getOptionParam('y');
+            try {
+                BufferedReader br = new BufferedReader(new FileReader(passwdFile));
+                password = br.readLine();
+                br.close();
+            } catch (FileNotFoundException e) {
+                System.err.println("Password file not found: " + e.getMessage());
+            } catch (IOException e) {
+                System.err.println("Problem reading from password file: " + e.getMessage());
+            }
+        }
+
+        
 
         _console = new Console(sAdminURL, localAdminURL, sLang, host, uid, password);
         return;




More information about the Fedora-directory-commits mailing list