class method
Etc.getpwnam
(::String name) -> ::Etc::Passwd
getpwnam(name) → Etc::Passwd
ext/etc/etc.c
View on GitHub ↗
static VALUE
etc_getpwnam(VALUE obj, VALUE nam)
{
#ifdef HAVE_GETPWENT
struct passwd *pwd;
const char *p = StringValueCStr(nam);
pwd = getpwnam(p);
if (pwd == 0) rb_raise(rb_eArgError, "can't find user for %"PRIsVALUE, nam);
return setup_passwd(pwd);
#else
return Qnil;
#endif
}
Returns the /etc/passwd information for the user with specified login name.
The information is returned as a Passwd struct.
See the unix manpage for getpwnam(3) for more detail.
Example:
Example
Etc.getpwnam('root') #=> #<struct Etc::Passwd name="root", passwd="x", uid=0, gid=0, gecos="root",dir="/root", shell="/bin/bash">