Password:

Any easy and elegant way to do the ‘no output to the screen’ thing for
entering passwords. I don’t want to have to use ncurses. Also, can I
force stdin to be a tty like ‘su’ does?

Michael

mgarriss wrote:

Any easy and elegant way to do the ‘no output to the screen’ thing for
entering passwords. I don’t want to have to use ncurses. Also, can I
force stdin to be a tty like ‘su’ does?

Michael

I should mention that I’m on a GNU/Linux but it’d be nice to have a
cross-platform solution to this.

If the termios module works on windows ( I don’t know if it does ), the
attached should work. Either way it should work on Unix (and requires
termios, obviously).

It defines noecho() and getpass() for IO, and getpass() uses noecho().

Jim

termios-noecho.rb.txt (780 Bytes)

···

On Fri, 29 Aug 2003 04:15:03 +0900 mgarriss mgarriss@earthlink.net wrote:

mgarriss wrote:

Any easy and elegant way to do the ‘no output to the screen’ thing for
entering passwords. I don’t want to have to use ncurses. Also, can I
force stdin to be a tty like ‘su’ does?

Michael

I should mention that I’m on a GNU/Linux but it’d be nice to have a
cross-platform solution to this.

~ > cat ./password.rb
require ‘password’ # get from the RAA

def password
password = Password.get(‘Password’)
if block_given? # block form is safer!
begin
yield password
ensure
password.replace ‘’
end
else
# you should delete/replace this so strace can’t show it!
return password
end
end

password do |pswd|
puts pswd
end

puts password()

~ > ruby ./password.rb
Password:
foobar
Password:
barfoo

-a

···

On Fri, 29 Aug 2003, mgarriss wrote:

mgarriss wrote:

Any easy and elegant way to do the ‘no output to the screen’ thing for
entering passwords. I don’t want to have to use ncurses. Also, can I
force stdin to be a tty like ‘su’ does?

Michael

I should mention that I’m on a GNU/Linux but it’d be nice to have a
cross-platform solution to this.

====================================

Ara Howard
NOAA Forecast Systems Laboratory
Information and Technology Services
Data Systems Group
R/FST 325 Broadway
Boulder, CO 80305-3328
Email: ara.t.howard@noaa.gov
Phone: 303-497-7238
Fax: 303-497-7259
~ > ruby -e ‘p(%.\x2d\x29…intern)’
====================================