Bug 170461 - Command Line perl scripts need non-standard Term::ReadKey for -w - option
Summary: Command Line perl scripts need non-standard Term::ReadKey for -w - option
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Directory Server
Classification: Red Hat
Component: Command Line Utilities
Version: 7.1
Hardware: All
OS: Linux
medium
medium
Target Milestone: DS8.1
: ---
Assignee: Nathan Kinder
QA Contact: Chandrasekar Kannan
URL:
Whiteboard:
Depends On:
Blocks: 152373 249650 FDS1.2.0
TreeView+ depends on / blocked
 
Reported: 2005-10-11 22:34 UTC by Orla Hegarty
Modified: 2015-01-04 23:19 UTC (History)
5 users (show)

Fixed In Version: 8.1
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2009-04-29 22:57:59 UTC
Target Upstream Version:
Embargoed:


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

Description Orla Hegarty 2005-10-11 22:34:03 UTC
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 22:57:39 UTC
The newer version of perl on all platform may be this already.

Comment 4 PGNet 2008-09-11 16:20:56 UTC
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 23:58:31 UTC
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 16:26:49 UTC
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 22:30:03 UTC
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 22:57:59 UTC
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.