whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ru...@apache.org
Subject [whimsy] branch master updated: prompt for password in irb
Date Thu, 22 Jun 2017 20:22:22 GMT
This is an automated email from the ASF dual-hosted git repository.

rubys pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git


The following commit(s) were added to refs/heads/master by this push:
     new 5841304  prompt for password in irb
5841304 is described below

commit 58413043156e2ec145e06a97016c8a54a11b5556
Author: Sam Ruby <rubys@intertwingly.net>
AuthorDate: Thu Jun 22 16:22:10 2017 -0400

    prompt for password in irb
---
 lib/whimsy/asf/ldap.rb | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/lib/whimsy/asf/ldap.rb b/lib/whimsy/asf/ldap.rb
index afe1350..e0a213a 100644
--- a/lib/whimsy/asf/ldap.rb
+++ b/lib/whimsy/asf/ldap.rb
@@ -118,7 +118,18 @@ module ASF
     # connect to LDAP with a user and password; generally required for
     # update operations.  If a block is passed, the connection will be
     # closed after the block executes.
-    def self.bind(user, password, &block)
+    #
+    # when run in irb, will default user and prompt for password
+    def self.bind(user=nil, password=nil, &block)
+      if not user or not password
+        raise ArgumentError.new('wrong number of arguments') unless $0 == 'irb'
+
+        require 'etc'
+        require 'io/console'
+        user ||= Etc.getlogin
+        password = STDIN.getpass("Password:")
+      end
+
       dn = ASF::Person.new(user).dn
       raise ::LDAP::ResultError.new('Unknown user') unless dn
 

-- 
To stop receiving notification emails like this one, please contact
['"commits@whimsical.apache.org" <commits@whimsical.apache.org>'].

Mime
View raw message