Bug 170461 - Command Line perl scripts need non-standard Term::ReadKey for -w - option
Command Line perl scripts need non-standard Term::ReadKey for -w - option
Status: CLOSED CURRENTRELEASE
Product: Red Hat Directory Server
Classification: Red Hat
Component: Command Line Utilities (Show other bugs)
7.1
All Linux
medium Severity medium
: DS8.1
: ---
Assigned To: Nathan Kinder
Chandrasekar Kannan
:
Depends On:
Blocks: 152373 249650 FDS1.2.0
  Show dependency treegraph
 
Reported: 2005-10-11 18:34 EDT by Orla Hegarty
Modified: 2015-01-04 18:19 EST (History)
5 users (show)

See Also:
Fixed In Version: 8.1
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2009-04-29 18:57:59 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
CVS Diffs (16.10 KB, patch)
2009-01-09 18:58 EST, Nathan Kinder
no flags Details | Diff

  None (edit)
Description Orla Hegarty 2005-10-11 18:34:03 EDT
Description of problem:
Found when running db2index.pl and using the -w - option to provide the
password. Both the system perl and the version of perl shipped with Directory
i.e. nsperl are missing Term::ReadKey needed for this option 

Version-Release number of selected component (if applicable):
7.1 SP1

How reproducible:
Always

Steps to Reproduce:
1. nsperl db2index.pl -v -D "cn=Directory Manager" -w - -n example
  
Actual results:
The following message is displayed:

The '-w -' option requires an extension library (Term::ReadKey) which is not
part of the standard perl distribution. If you want to use it, you must
download and install the module. You can find it at
http://www.perl.com/CPAN/CPAN.html



Expected results:
I should be prompted to type in the password according to the usage message

Additional info:
Comment 1 To Ngan 2006-12-12 17:57:39 EST
The newer version of perl on all platform may be this already.
Comment 4 PGNet 2008-09-11 12:20:56 EDT
That's a result of code in, apparently, a numbed of the utils ... e.g., in "ldif2db.pl" as well.

There's a hardcoded 'die' in the script, used if passwd == "-" (which is the prompt flag), that needs to be removed, and some lines that need to be uncommented.

It's an easy patch, e.g.:

--- /usr/lib64/dirsrv/slapd-auth/ldif2db.pl.ORIG	2008-09-11 07:56:50.000000000 -0700
+++ /usr/lib64/dirsrv/slapd-auth/ldif2db.pl	2008-09-11 07:57:47.000000000 -0700
@@ -167,17 +167,17 @@
 	close(RPASS);
 } elsif ($passwd eq "-"){
 # Read the password from terminal
-	die "The '-w -' option requires an extension library (Term::ReadKey) which is not\n",
+#	die "The '-w -' option requires an extension library (Term::ReadKey) which is not\n",
 	    "part of the standard perl distribution. If you want to use it, you must\n",
 	    "download and install the module. You can find it at\n",
 	    "http://www.perl.com/CPAN/CPAN.html\n";
 # Remove the previous line and uncomment the following 6 lines once you have installed Term::ReadKey module.
-# use Term::ReadKey; 
-#	print "Bind Password: ";
-#	ReadMode('noecho'); 
-#	$passwd = ReadLine(0); 
-#	chomp($passwd);
-#	ReadMode('normal');
+ use Term::ReadKey; 
+	print "Bind Password: ";
+	ReadMode('noecho'); 
+	$passwd = ReadLine(0); 
+	chomp($passwd);
+	ReadMode('normal');
 }
 if (($instance eq "" && $included[0] eq "") || $ldiffiles[0] eq "" || $rootdn eq "" || $passwd eq "") { &usage; exit(1); }
 ($s, $m, $h, $dy, $mn, $yr, $wdy, $ydy, $r) = localtime(time);
Comment 5 Nathan Kinder 2009-01-09 18:58:31 EST
Created attachment 328607 [details]
CVS Diffs

This patch removes the dependency on Term::ReadKey for password prompting in our Perl scripts and instead uses the same method that we use in the setup code for non-echoed password prompts.
Comment 6 Nathan Kinder 2009-01-12 11:26:49 EST
Checked into ldapserver (HEAD).  Thanks to Rich for his review!

Checking in ldap/admin/src/scripts/template-bak2db.pl.in;
/cvs/dirsec/ldapserver/ldap/admin/src/scripts/template-bak2db.pl.in,v  <--  template-bak2db.pl.in
new revision: 1.5; previous revision: 1.4
done
Checking in ldap/admin/src/scripts/template-db2bak.pl.in;
/cvs/dirsec/ldapserver/ldap/admin/src/scripts/template-db2bak.pl.in,v  <--  template-db2bak.pl.in
new revision: 1.8; previous revision: 1.7
done
Checking in ldap/admin/src/scripts/template-db2index.pl.in;
/cvs/dirsec/ldapserver/ldap/admin/src/scripts/template-db2index.pl.in,v  <--  template-db2index.pl.in
new revision: 1.6; previous revision: 1.5
done
Checking in ldap/admin/src/scripts/template-db2ldif.pl.in;
/cvs/dirsec/ldapserver/ldap/admin/src/scripts/template-db2ldif.pl.in,v  <--  template-db2ldif.pl.in
new revision: 1.7; previous revision: 1.6
done
Checking in ldap/admin/src/scripts/template-fixup-memberof.pl.in;
/cvs/dirsec/ldapserver/ldap/admin/src/scripts/template-fixup-memberof.pl.in,v  <--  template-fixup-memberof.pl.in
new revision: 1.2; previous revision: 1.1
done
Checking in ldap/admin/src/scripts/template-ldif2db.pl.in;
/cvs/dirsec/ldapserver/ldap/admin/src/scripts/template-ldif2db.pl.in,v  <--  template-ldif2db.pl.in
new revision: 1.5; previous revision: 1.4
done
Checking in ldap/admin/src/scripts/template-ns-accountstatus.pl.in;
/cvs/dirsec/ldapserver/ldap/admin/src/scripts/template-ns-accountstatus.pl.in,v  <--  template-ns-accountstatus.pl.in
new revision: 1.5; previous revision: 1.4
done
Checking in ldap/admin/src/scripts/template-ns-activate.pl.in;
/cvs/dirsec/ldapserver/ldap/admin/src/scripts/template-ns-activate.pl.in,v  <--  template-ns-activate.pl.in
new revision: 1.5; previous revision: 1.4
done
Checking in ldap/admin/src/scripts/template-ns-inactivate.pl.in;
/cvs/dirsec/ldapserver/ldap/admin/src/scripts/template-ns-inactivate.pl.in,v  <--  template-ns-inactivate.pl.in
new revision: 1.5; previous revision: 1.4
done
Checking in ldap/admin/src/scripts/template-schema-reload.pl.in;
/cvs/dirsec/ldapserver/ldap/admin/src/scripts/template-schema-reload.pl.in,v  <--  template-schema-reload.pl.in
new revision: 1.2; previous revision: 1.1
done
Comment 7 Yi Zhang 2009-04-06 18:30:03 EDT
verified as Nathan suggested : as long as "-w -" prompt out for password enter, we are good.

[root@mv32a-vm ~]# /usr/lib/dirsrv/slapd-mv32a-vm/bak2db.pl -w -
Bind Password: 
Usage: /usr/lib/dirsrv/slapd-mv32a-vm/bak2db.pl [-v] -D rootdn { -w password | -w - | -j filename } 
     :    -a dirname [-t dbtype]
 Opts: -D rootdn   - Directory Manager
     : -w password - Directory Manager's password
     : -w -        - Prompt for Directory Manager's password
     : -j filename - Read Directory Manager's password from file
     : -a dirname  - backup directory
     : -t dbtype   - database type (default: ldbm database)
     : -n backend  - name of backend instance to restore
     : -v          - verbose
[root@mv32a-vm ~]# /usr/lib/dirsrv/slapd-mv32a-vm/db2index.pl -w -
Bind Password: rehag

Usage: /usr/lib/dirsrv/slapd-mv32a-vm/db2index.pl [-v] -D rootdn { -w password | -w - | -j filename } 
        -n instance [-t attributeName[:indextypes[:matchingrules]]]
 Opts: -D rootdn           - Directory Manager
     : -w password         - Directory Manager's password
     : -w -                - Prompt for Directory Manager's password
     : -j filename         - Read Directory Manager's password from file
     : -n instance         - instance to be indexed
     : -t attributeName[:indextypes[:matchingrules]]
                           - attributeName: name of the attribute to be indexed
                             If omitted, all the indexes defined 
                             for that instance are generated.
                           - indextypes: comma separated index types
                           - matchingrules: comma separated matrules
                           Example: -t foo:eq,pres
     : -T vlvAttributeName - vlvAttributeName: name of the vlv attribute to be indexed
     : -v                  - verbose
Comment 8 Chandrasekar Kannan 2009-04-29 18:57:59 EDT
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHEA-2009-0455.html

Note You need to log in before you can comment on or make changes to this bug.