Skip to content

dabos-GFI/pwd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pwd NPM version

<pwd.h> binding for node.

var fs = require('fs');
var pwd = require('pwd2');

var stat = fs.statSync(path);

var passwd = pwd.getpwuid(stat.uid);
console.log('the username for "' + path + '" is: ' + passwd.pw_name);

Installation

$ npm install pwd2 --save

Features

There is two available functions:

  • getpwuid(uid)
    var passwd = pwd.getpwuid(0);
  • getpwnam(name)
    var passwd = pwd.getpwnam('root');

These functions obtain information from opendirectoryd(8), including records in /etc/master.passwd which is described in master.passwd(5). Each entry in the database is defined by the structure passwd found in the include file <pwd.h>:

{
    pw_name,       /* user name */
    pw_passwd,     /* encrypted password - NOT SUPPORTED IN V1.0.0 */
    pw_uid,        /* user uid */
    pw_gid,        /* user gid */
    pw_change,     /* password change time - NOT SUPPORTED IN V1.0.0 */
    pw_class,      /* user access class - NOT SUPPORTED IN V1.0.0 */
    pw_gecos,      /* Honeywell login info - NOT SUPPORTED IN V1.0.0 */
    pw_dir,        /* home directory */
    pw_shell,      /* default shell */
    pw_expire,     /* account expiration - NOT SUPPORTED IN V1.0.0 */
    pw_fields      /* internal: fields filled in - NOT SUPPORTED IN V1.0.0 */
}

More Information

$ man 3 getpwuid

License

MIT