You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by fr...@apache.org on 2017/04/20 18:39:56 UTC

[07/44] incubator-trafficcontrol git commit: Term::ReadPassword fix: TC-185

Term::ReadPassword fix: TC-185

(cherry picked from commit 290e4bc082df416a727490dfc4a8210b3ff5d778)


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/610bdbfa
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/610bdbfa
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/610bdbfa

Branch: refs/heads/2.0.x
Commit: 610bdbfa29c6452a2dd38fc0f29312b18c829b81
Parents: 5f7d02a
Author: Jeff Martin <ma...@gmail.com>
Authored: Fri Apr 7 13:31:52 2017 -0400
Committer: Dan Kirkwood <da...@gmail.com>
Committed: Wed Apr 19 15:34:36 2017 -0600

----------------------------------------------------------------------
 traffic_ops/build/traffic_ops.spec      |  2 +-
 traffic_ops/install/lib/InstallUtils.pm | 36 +++++++++++++++-------------
 2 files changed, 20 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/610bdbfa/traffic_ops/build/traffic_ops.spec
----------------------------------------------------------------------
diff --git a/traffic_ops/build/traffic_ops.spec b/traffic_ops/build/traffic_ops.spec
index a4d63d2..7d359a1 100644
--- a/traffic_ops/build/traffic_ops.spec
+++ b/traffic_ops/build/traffic_ops.spec
@@ -35,7 +35,7 @@ AutoReqProv:      no
 Requires:         cpanminus, expat-devel, gcc-c++, libcurl, libpcap-devel, mkisofs, tar
 Requires:         openssl-devel, perl, perl-core, perl-DBD-Pg, perl-DBI, perl-Digest-SHA1
 Requires:	  libidn-devel, libcurl-devel
-Requires:         perl-JSON, perl-libwww-perl, perl-Test-CPAN-Meta, perl-WWW-Curl
+Requires:         perl-JSON, perl-libwww-perl, perl-Test-CPAN-Meta, perl-WWW-Curl, perl-TermReadKey
 Requires(pre):    /usr/sbin/useradd, /usr/bin/getent
 Requires(postun): /usr/sbin/userdel
 

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/610bdbfa/traffic_ops/install/lib/InstallUtils.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/install/lib/InstallUtils.pm b/traffic_ops/install/lib/InstallUtils.pm
index 57f2e14..1b9cf72 100644
--- a/traffic_ops/install/lib/InstallUtils.pm
+++ b/traffic_ops/install/lib/InstallUtils.pm
@@ -34,7 +34,7 @@ package InstallUtils;
 # under the License.
 
 
-use Term::ReadPassword;
+use Term::ReadKey;
 use JSON;
 use IO::Pipe;
 use base qw{ Exporter };
@@ -172,25 +172,27 @@ sub promptUser {
     }
 
     if ( defined $noEcho && $noEcho ) {
-        my $response = read_password('');
-        if ( ( !defined $response || $response eq '' ) && ( defined $defaultValue && $defaultValue ne '' ) ) {
-            $response = $defaultValue;
-        }
-        return $response;
+        # Set echo mode to off via ReadMode 2
+        ReadMode 2;
     }
-    else {
-        $| = 1;
-        $_ = <STDIN>;
-        chomp;
 
-        if ("$defaultValue") {
-            return $_ ? $_ : $defaultValue;
-        }
-        else {
-            return $_;
-        }
-        return $_;
+    $| = 1;
+    $_ = <STDIN>;
+    chomp;
+
+    if ( defined $noEcho && $noEcho ) {
+        # Set echo mode to on via ReadMode 1
+        ReadMode 1;
+        # Print extra line because echo mode was off during the STDIN
+        print "\n";
+    }
+
+    if ("$defaultValue") {
+        return $_ ? $_ : $defaultValue;
     }
+
+    # If we have gotten here, return what is left
+    return $_;
 }
 
 sub promptRequired {