forked from pkrumins/node-passwd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreadme.txt
50 lines (35 loc) · 1.56 KB
/
readme.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
This is a node.js module for controlling /etc/passwd. I needed to do that
in my http://browserling.com startup.
It was written by Peteris Krumins ([email protected], @pkrumins on twitter).
His blog is at http://www.catonmat.net -- good coders code, great reuse.
------------------------------------------------------------------------------
Here is an example usage:
var passwd = require('passwd');
// add a new user (calls `useradd -m -p shadowPass pkrumins`)
passwd.add('pkrumins', 'password', { createHome : true }, function (status) {
if (status == 0) {
console.log('great success! pkrumins added!');
}
else {
console.log('not so great success! pkrumins not added! useradd command returned: ' + status);
}
});
// calls `userdel pkrumins`
passwd.del('pkrumins', function (status) { ... });
// locks user pkrumins via `usermod -L pkrumins`
passwd.lock('pkrumins', function (status) { ... })
// unlocks user pkrumins via `usermod -U pkrumins`
passwd.unlock('pkrumins', function (status) { ... })
// gets 'pkrumins' user entry from /etc/passwd
passwd.get('pkrumins', function (user) { ... })
// gets all users from /etc/passwd
passwd.getAll(function (users) {
users.forEach(function (user) {
console.log(user.username);
});
});
That's it.
------------------------------------------------------------------------------
Sincerely,
Peteris Krumins (twitter: @pkrumins)
http://www.catonmat.net