From: zor Date: 2008-04-14T03:16:14+09:00 Subject: Re: getpass Sorry if I'm doing this wrong, but how do I get off the mailing list? I can't figure it out. On Apr 13, 2008, at 1:10 AM, Ken Bloom wrote: > On Thu, 10 Apr 2008 23:08:40 -0500, Yang Zhang wrote: > >> Thanks for prompting me to provide some context. getpass() is a >> standard POSIX function, described here: >> >> http://www.opengroup.org/pubs/online/7908799/xsh/getpass.html > > getpass() is not a POSIX anything. > > From the manpage: > > DESCRIPTION > This function is obsolete. Do not use it. > ... > CONFORMING TO > Present in SUSv2, but marked LEGACY. Removed in POSIX.1-2001. > > In theory, using Ruby/DL should work, like > > require 'dl/import' > module LibC > extend DL::Importable > dlload 'libc.so.6' > extern 'char *getpass( const char * prompt )' > end > > In theory, theory and practice are the same. > > /usr/lib/ruby/1.8/dl/import.rb:126:in `symbol': can't find the symbol > `getpass' (RuntimeError) > from /usr/lib/ruby/1.8/dl/import.rb:145:in `import' > from /usr/lib/ruby/1.8/dl/import.rb:61:in `extern' > > > But this works: > > require 'dl' > module LibC > extend self > LIB=DL.dlopen('libc.so.6') > SYMS={ :getpass => LIB['getpass','SS'] } > def getpass prompt > r,rs = SYMS[:getpass].call prompt > return r > end > end > > Again, don't use this. Use Highline instead. > > --Ken > > -- > Ken (Chanoch) Bloom. PhD candidate. Linguistic Cognition Laboratory. > Department of Computer Science. Illinois Institute of Technology. > http://www.iit.edu/~kbloom1/ >