sys-admin 1.6.0 → 1.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGES +10 -0
- data/README +1 -1
- data/Rakefile +7 -2
- data/doc/sys-admin-unix.txt +164 -164
- data/doc/sys-admin-windows.txt +336 -336
- data/lib/sys/admin/common.rb +1 -1
- data/lib/windows/sys/admin.rb +28 -6
- data/sys-admin.gemspec +3 -1
- data/test/test_sys_admin.rb +1 -1
- data/test/test_sys_admin_windows.rb +17 -12
- metadata +31 -21
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3e8438dd57732dd476aa1ed09fc3bcce413b87f4
|
4
|
+
data.tar.gz: db05f72c2136416a0855fbe0531f972d4f43db82
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e20ecb5311383326d499bee97b8c6fa8d163f93d1ff4ba6d791c83f84ff52b23d15a0a26cdb4598518c08e2e278538772bf4471d8d23131c23348a3ba87ece9c
|
7
|
+
data.tar.gz: bc7bc00b37e8aae88025df06dd2c4279deb8d5a1b0ce6175b1da06ecd1984d7db56c89833e296e994a435db16bf45311df5f2f437dfee414924ecc461679e33c
|
data/CHANGES
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
== 1.6.1 - 24-Jan-2014
|
2
|
+
* Added the Admin.add_group_member and Admin.remove_group member methods. These
|
3
|
+
let you add a user to a specific group. Thanks go to Alexey Kolyanov for the
|
4
|
+
idea and the code.
|
5
|
+
* Modified the Admin.configure_user method so that you don't need to know the
|
6
|
+
old password. Just pass a single string argument for the new password.
|
7
|
+
* Fixed a potential encoding issue for the Admin.get_login method on JRuby.
|
8
|
+
* Updated the gem:create task in the Rakefile.
|
9
|
+
* Added rake as a development dependency.
|
10
|
+
|
1
11
|
== 1.6.0 - 5-Jan-2013
|
2
12
|
* Converted code to use FFI. This mostly only affects the unix flavors.
|
3
13
|
* The Admin.users and Admin.groups methods no longer accept a block.
|
data/README
CHANGED
data/Rakefile
CHANGED
@@ -9,11 +9,16 @@ namespace :gem do
|
|
9
9
|
desc "Create the sys-uname gem"
|
10
10
|
task :create => [:clean] do
|
11
11
|
spec = eval(IO.read('sys-admin.gemspec'))
|
12
|
-
Gem::
|
12
|
+
if Gem::VERSION < "2.0"
|
13
|
+
Gem::Builder.new(spec).build
|
14
|
+
else
|
15
|
+
require 'rubygems/package'
|
16
|
+
Gem::Package.build(spec)
|
17
|
+
end
|
13
18
|
end
|
14
19
|
|
15
20
|
desc "Install the sys-uname gem"
|
16
|
-
task :install => [:
|
21
|
+
task :install => [:create] do
|
17
22
|
file = Dir["*.gem"].first
|
18
23
|
sh "gem install #{file}"
|
19
24
|
end
|
data/doc/sys-admin-unix.txt
CHANGED
@@ -1,164 +1,164 @@
|
|
1
|
-
= Description
|
2
|
-
A unified, cross-platform replacement for the Etc module that allows you to
|
3
|
-
get information about users and groups.
|
4
|
-
|
5
|
-
= Synopsis
|
6
|
-
require 'sys/admin'
|
7
|
-
include Sys
|
8
|
-
|
9
|
-
Admin.get_login # -> 'djberge'
|
10
|
-
Admin.get_user('djberge') # -> Admin::User object
|
11
|
-
Admin.get_group(501) # -> Admin::Group object
|
12
|
-
|
13
|
-
# Iterate over all users
|
14
|
-
Admin.users do |usr|
|
15
|
-
p usr
|
16
|
-
end
|
17
|
-
|
18
|
-
# Iterate over all groups
|
19
|
-
Admin.groups do |grp|
|
20
|
-
p grp
|
21
|
-
end
|
22
|
-
|
23
|
-
= Constants
|
24
|
-
|
25
|
-
= Class Methods
|
26
|
-
== Sys::Admin
|
27
|
-
Admin.get_group(name)
|
28
|
-
Admin.get_group(gid)
|
29
|
-
Returns a Group object for the given name or gid. Raises an Admin::Error
|
30
|
-
if a group cannot be found for that name or GID.
|
31
|
-
|
32
|
-
Admin.get_login
|
33
|
-
Returns the login for the process. If this is called from a process that
|
34
|
-
has no controlling terminal, then it resorts to returning the "LOGNAME"
|
35
|
-
or "USER" environment variable. If neither of those is defined, then nil
|
36
|
-
is returned.
|
37
|
-
|
38
|
-
Note that this method will probably return the real user login, but may
|
39
|
-
return the effective user login. YMMV depending on your platform and how
|
40
|
-
the program is run.
|
41
|
-
|
42
|
-
Admin.get_user(name)
|
43
|
-
Admin.get_user(uid)
|
44
|
-
Returns a User object for the given name or uid. Raises an Admin::Error if
|
45
|
-
a user cannot be found for that name or user ID.
|
46
|
-
|
47
|
-
Admin.groups
|
48
|
-
Admin.groups{ |grp| ... }
|
49
|
-
In block form, yields a Group object for each group on the system. In
|
50
|
-
non-block form, returns an Array of Group objects.
|
51
|
-
|
52
|
-
Admin.users
|
53
|
-
Admin.users{ |grp| ... }
|
54
|
-
In block form, yields a User object for each group on the system. In
|
55
|
-
non-block form, returns an Array of User objects.
|
56
|
-
|
57
|
-
== Sys::Admin::Group
|
58
|
-
Group.new
|
59
|
-
Group.new{ |grp| ... }
|
60
|
-
Creates and returns a Group object, which encapsulates the information
|
61
|
-
typically found within an /etc/group entry, i.e. a struct group. If a
|
62
|
-
block is provided, yields the object back to the block.
|
63
|
-
|
64
|
-
At the moment this is only useful for MS Windows.
|
65
|
-
|
66
|
-
== Sys::Admin::User
|
67
|
-
User.new
|
68
|
-
User.new{ |usr| ... }
|
69
|
-
Creates and returns a User object, which encapsulates the information
|
70
|
-
typically found within an /etc/passwd entry, i.e. a struct passwd. If a
|
71
|
-
block is provided, yields the object back to the block.
|
72
|
-
|
73
|
-
At the moment this is only useful for MS Windows.
|
74
|
-
|
75
|
-
= Instance Methods
|
76
|
-
== Sys::Admin::Group
|
77
|
-
Group#gid
|
78
|
-
The group id.
|
79
|
-
|
80
|
-
Group#members
|
81
|
-
An array of users that are members of the group.
|
82
|
-
|
83
|
-
Group#name
|
84
|
-
The name of the group.
|
85
|
-
|
86
|
-
Group#passwd
|
87
|
-
The group password, if any.
|
88
|
-
|
89
|
-
== Sys::Admin::User
|
90
|
-
User#age
|
91
|
-
Used in the past for password aging. Deprecated in favor of /etc/shadow.
|
92
|
-
|
93
|
-
User#change
|
94
|
-
Next date a password change will be needed.
|
95
|
-
|
96
|
-
User#class
|
97
|
-
The user's access class.
|
98
|
-
|
99
|
-
User#comment
|
100
|
-
Another comment field. Rarely used.
|
101
|
-
|
102
|
-
User#dir
|
103
|
-
The absolute pathname of the user's home directory.
|
104
|
-
|
105
|
-
User#expire
|
106
|
-
Account expiration date.
|
107
|
-
|
108
|
-
User#gecos
|
109
|
-
A comment field. Rarely used.
|
110
|
-
|
111
|
-
User#gid
|
112
|
-
The user's primary group id.
|
113
|
-
|
114
|
-
User#login_device
|
115
|
-
The name of the terminal device the user last logged on with.
|
116
|
-
|
117
|
-
User#login_host
|
118
|
-
The hostname from which the user last logged in.
|
119
|
-
|
120
|
-
User#login_time
|
121
|
-
The last time the user logged in.
|
122
|
-
|
123
|
-
User#name
|
124
|
-
The user name associated with the account.
|
125
|
-
|
126
|
-
User#passwd
|
127
|
-
The user's encrypted password. Deprecated in favor of /etc/shadow.
|
128
|
-
|
129
|
-
User#quota
|
130
|
-
The user's alloted amount of disk space.
|
131
|
-
|
132
|
-
User#shell
|
133
|
-
The user's login shell.
|
134
|
-
|
135
|
-
User#uid
|
136
|
-
The user's user id.
|
137
|
-
|
138
|
-
== Notes
|
139
|
-
Not all platforms support all of the User members. The only ones that are
|
140
|
-
supported on all platforms are name, uid, gid, dir and shell. The rest
|
141
|
-
will simply return nil if they aren't supported.
|
142
|
-
|
143
|
-
== Known Bugs
|
144
|
-
None that I am aware of. Please log any bugs you find on the project
|
145
|
-
website at http://www.rubyforge.org/projects/sysutils.
|
146
|
-
|
147
|
-
== License
|
148
|
-
Artistic 2.0
|
149
|
-
|
150
|
-
== Copyright
|
151
|
-
Copyright 2002-2009, Daniel J. Berger
|
152
|
-
|
153
|
-
All Rights Reserved. This module is free software. It may be used,
|
154
|
-
redistributed and/or modified under the same terms as Ruby itself.
|
155
|
-
|
156
|
-
== Warranty
|
157
|
-
This library is provided "as is" and without any express or
|
158
|
-
implied warranties, including, without limitation, the implied
|
159
|
-
warranties of merchantability and fitness for a particular purpose.
|
160
|
-
|
161
|
-
== Author
|
162
|
-
Daniel J. Berger
|
163
|
-
djberg96 at nospam at gmail dot com
|
164
|
-
imperator on IRC (Freenode)
|
1
|
+
= Description
|
2
|
+
A unified, cross-platform replacement for the Etc module that allows you to
|
3
|
+
get information about users and groups.
|
4
|
+
|
5
|
+
= Synopsis
|
6
|
+
require 'sys/admin'
|
7
|
+
include Sys
|
8
|
+
|
9
|
+
Admin.get_login # -> 'djberge'
|
10
|
+
Admin.get_user('djberge') # -> Admin::User object
|
11
|
+
Admin.get_group(501) # -> Admin::Group object
|
12
|
+
|
13
|
+
# Iterate over all users
|
14
|
+
Admin.users do |usr|
|
15
|
+
p usr
|
16
|
+
end
|
17
|
+
|
18
|
+
# Iterate over all groups
|
19
|
+
Admin.groups do |grp|
|
20
|
+
p grp
|
21
|
+
end
|
22
|
+
|
23
|
+
= Constants
|
24
|
+
|
25
|
+
= Class Methods
|
26
|
+
== Sys::Admin
|
27
|
+
Admin.get_group(name)
|
28
|
+
Admin.get_group(gid)
|
29
|
+
Returns a Group object for the given name or gid. Raises an Admin::Error
|
30
|
+
if a group cannot be found for that name or GID.
|
31
|
+
|
32
|
+
Admin.get_login
|
33
|
+
Returns the login for the process. If this is called from a process that
|
34
|
+
has no controlling terminal, then it resorts to returning the "LOGNAME"
|
35
|
+
or "USER" environment variable. If neither of those is defined, then nil
|
36
|
+
is returned.
|
37
|
+
|
38
|
+
Note that this method will probably return the real user login, but may
|
39
|
+
return the effective user login. YMMV depending on your platform and how
|
40
|
+
the program is run.
|
41
|
+
|
42
|
+
Admin.get_user(name)
|
43
|
+
Admin.get_user(uid)
|
44
|
+
Returns a User object for the given name or uid. Raises an Admin::Error if
|
45
|
+
a user cannot be found for that name or user ID.
|
46
|
+
|
47
|
+
Admin.groups
|
48
|
+
Admin.groups{ |grp| ... }
|
49
|
+
In block form, yields a Group object for each group on the system. In
|
50
|
+
non-block form, returns an Array of Group objects.
|
51
|
+
|
52
|
+
Admin.users
|
53
|
+
Admin.users{ |grp| ... }
|
54
|
+
In block form, yields a User object for each group on the system. In
|
55
|
+
non-block form, returns an Array of User objects.
|
56
|
+
|
57
|
+
== Sys::Admin::Group
|
58
|
+
Group.new
|
59
|
+
Group.new{ |grp| ... }
|
60
|
+
Creates and returns a Group object, which encapsulates the information
|
61
|
+
typically found within an /etc/group entry, i.e. a struct group. If a
|
62
|
+
block is provided, yields the object back to the block.
|
63
|
+
|
64
|
+
At the moment this is only useful for MS Windows.
|
65
|
+
|
66
|
+
== Sys::Admin::User
|
67
|
+
User.new
|
68
|
+
User.new{ |usr| ... }
|
69
|
+
Creates and returns a User object, which encapsulates the information
|
70
|
+
typically found within an /etc/passwd entry, i.e. a struct passwd. If a
|
71
|
+
block is provided, yields the object back to the block.
|
72
|
+
|
73
|
+
At the moment this is only useful for MS Windows.
|
74
|
+
|
75
|
+
= Instance Methods
|
76
|
+
== Sys::Admin::Group
|
77
|
+
Group#gid
|
78
|
+
The group id.
|
79
|
+
|
80
|
+
Group#members
|
81
|
+
An array of users that are members of the group.
|
82
|
+
|
83
|
+
Group#name
|
84
|
+
The name of the group.
|
85
|
+
|
86
|
+
Group#passwd
|
87
|
+
The group password, if any.
|
88
|
+
|
89
|
+
== Sys::Admin::User
|
90
|
+
User#age
|
91
|
+
Used in the past for password aging. Deprecated in favor of /etc/shadow.
|
92
|
+
|
93
|
+
User#change
|
94
|
+
Next date a password change will be needed.
|
95
|
+
|
96
|
+
User#class
|
97
|
+
The user's access class.
|
98
|
+
|
99
|
+
User#comment
|
100
|
+
Another comment field. Rarely used.
|
101
|
+
|
102
|
+
User#dir
|
103
|
+
The absolute pathname of the user's home directory.
|
104
|
+
|
105
|
+
User#expire
|
106
|
+
Account expiration date.
|
107
|
+
|
108
|
+
User#gecos
|
109
|
+
A comment field. Rarely used.
|
110
|
+
|
111
|
+
User#gid
|
112
|
+
The user's primary group id.
|
113
|
+
|
114
|
+
User#login_device
|
115
|
+
The name of the terminal device the user last logged on with.
|
116
|
+
|
117
|
+
User#login_host
|
118
|
+
The hostname from which the user last logged in.
|
119
|
+
|
120
|
+
User#login_time
|
121
|
+
The last time the user logged in.
|
122
|
+
|
123
|
+
User#name
|
124
|
+
The user name associated with the account.
|
125
|
+
|
126
|
+
User#passwd
|
127
|
+
The user's encrypted password. Deprecated in favor of /etc/shadow.
|
128
|
+
|
129
|
+
User#quota
|
130
|
+
The user's alloted amount of disk space.
|
131
|
+
|
132
|
+
User#shell
|
133
|
+
The user's login shell.
|
134
|
+
|
135
|
+
User#uid
|
136
|
+
The user's user id.
|
137
|
+
|
138
|
+
== Notes
|
139
|
+
Not all platforms support all of the User members. The only ones that are
|
140
|
+
supported on all platforms are name, uid, gid, dir and shell. The rest
|
141
|
+
will simply return nil if they aren't supported.
|
142
|
+
|
143
|
+
== Known Bugs
|
144
|
+
None that I am aware of. Please log any bugs you find on the project
|
145
|
+
website at http://www.rubyforge.org/projects/sysutils.
|
146
|
+
|
147
|
+
== License
|
148
|
+
Artistic 2.0
|
149
|
+
|
150
|
+
== Copyright
|
151
|
+
Copyright 2002-2009, Daniel J. Berger
|
152
|
+
|
153
|
+
All Rights Reserved. This module is free software. It may be used,
|
154
|
+
redistributed and/or modified under the same terms as Ruby itself.
|
155
|
+
|
156
|
+
== Warranty
|
157
|
+
This library is provided "as is" and without any express or
|
158
|
+
implied warranties, including, without limitation, the implied
|
159
|
+
warranties of merchantability and fitness for a particular purpose.
|
160
|
+
|
161
|
+
== Author
|
162
|
+
Daniel J. Berger
|
163
|
+
djberg96 at nospam at gmail dot com
|
164
|
+
imperator on IRC (Freenode)
|
data/doc/sys-admin-windows.txt
CHANGED
@@ -1,336 +1,336 @@
|
|
1
|
-
= Description
|
2
|
-
A unified, cross-platform replacement for the Etc module that allows you to
|
3
|
-
get information about users and groups.
|
4
|
-
|
5
|
-
= Synopsis
|
6
|
-
require 'sys/admin'
|
7
|
-
include Sys
|
8
|
-
|
9
|
-
Admin.get_login # -> 'djberge'
|
10
|
-
Admin.get_user('djberge') # -> Admin::User object
|
11
|
-
Admin.get_group(501) # -> Admin::Group object
|
12
|
-
|
13
|
-
# Iterate over all users
|
14
|
-
Admin.users do |usr|
|
15
|
-
p usr
|
16
|
-
end
|
17
|
-
|
18
|
-
# Iterate over all groups
|
19
|
-
Admin.groups do |grp|
|
20
|
-
p grp
|
21
|
-
end
|
22
|
-
|
23
|
-
= Constants
|
24
|
-
== Sys::Admin
|
25
|
-
VERSION
|
26
|
-
The version of this library, returned as a String.
|
27
|
-
|
28
|
-
== Sys::Admin::User
|
29
|
-
TEMP_DUPLICATE
|
30
|
-
An account for users whose primary account is in another domain.
|
31
|
-
|
32
|
-
NORMAL
|
33
|
-
Default account type that represents a typical user.
|
34
|
-
|
35
|
-
INTERDOMAIN_TRUST
|
36
|
-
A permit to trust account for a domain that trusts other domains.
|
37
|
-
|
38
|
-
WORKSTATION_TRUST
|
39
|
-
An account for a Windows NT/2000 workstation or server that is a member
|
40
|
-
member of this domain.
|
41
|
-
|
42
|
-
SERVER_TRUST
|
43
|
-
A computer account for a backup domain controller that is a member of this
|
44
|
-
domain.
|
45
|
-
|
46
|
-
= Class Methods
|
47
|
-
== Sys::Admin
|
48
|
-
Admin.add_global_group(group, domain)
|
49
|
-
Adds the global +group+ on +domain+.
|
50
|
-
|
51
|
-
Admin.add_global_user(user, domain)
|
52
|
-
Adds the global +user+ on +domain+.
|
53
|
-
|
54
|
-
Admin.add_local_group(group, host=localhost)
|
55
|
-
Adds the local +group+ on +host+, or the localhost if no host is specified.
|
56
|
-
|
57
|
-
Admin.add_local_user(user, host=localhost)
|
58
|
-
Adds the local +user+ on +host+, or the localhost if no host is specified.
|
59
|
-
|
60
|
-
Admin.config_global_group(user, option, domain)
|
61
|
-
Configures +group+ on +domain+ using +options+. There are too many options
|
62
|
-
to list here.
|
63
|
-
|
64
|
-
See http://tinyurl.com/cjkzl for a list of valid options.
|
65
|
-
|
66
|
-
Admin.config_local_group(user, option, host=localhost)
|
67
|
-
Configures +group+ on +host+ using +options+. There are too many options
|
68
|
-
to list here.
|
69
|
-
|
70
|
-
See http://tinyurl.com/cjkzl for a list of valid options.
|
71
|
-
|
72
|
-
Admin.config_global_user(user, option, domain)
|
73
|
-
Configures +user+ on +domain+ using +options+. There are too many options
|
74
|
-
to list here.
|
75
|
-
|
76
|
-
See http://tinyurl.com/3hjv9 for a list of valid options.
|
77
|
-
|
78
|
-
Admin.config_local_user(user, options, host=localhost)
|
79
|
-
Configures the local +user+ on +host+ using +options+. If no host is
|
80
|
-
specified, the default is localhost.
|
81
|
-
|
82
|
-
See http://tinyurl.com/3hjv9 for a list of valid options.
|
83
|
-
|
84
|
-
Admin.delete_global_group(group, domain)
|
85
|
-
Deletes the global +group+ from +domain+.
|
86
|
-
|
87
|
-
Admin.delete_global_user(user, domain)
|
88
|
-
Deletes the global +user+ from +domain+.
|
89
|
-
|
90
|
-
Admin.delete_local_group(group, host=localhost)
|
91
|
-
Deletes the local +group+ from +host+, or localhost if no host is specified.
|
92
|
-
|
93
|
-
Admin.delete_local_user(user, host=localhost)
|
94
|
-
Deletes the local +user+ from +host+, or localhost if no host is specified.
|
95
|
-
|
96
|
-
Admin.get_group(name, host=localhost, local=true)
|
97
|
-
Admin.get_group(gid, host=localhost, local=true)
|
98
|
-
Returns a Group object for the given name or gid. Raises an Admin::Error
|
99
|
-
if a group cannot be found for that name or GID.
|
100
|
-
|
101
|
-
You may specify a host from which information is retrieved.
|
102
|
-
The default is the local machine. You can retrieve either a global or
|
103
|
-
local group, depending on the value of the +local+ argument.
|
104
|
-
|
105
|
-
Admin.get_login
|
106
|
-
Returns the user name of the current login.
|
107
|
-
|
108
|
-
Admin.get_user(name, host=localhost, local=true)
|
109
|
-
Admin.get_user(uid, host=localhost, local=true)
|
110
|
-
Returns a User object for the given name or uid. Raises an Admin::Error if
|
111
|
-
a user cannot be found for that name or user ID.
|
112
|
-
|
113
|
-
You may specify a +host+ from which information is retrieved. The
|
114
|
-
default is the local machine. You may also specify whether to
|
115
|
-
retrieve a local or global account. The default is local.
|
116
|
-
|
117
|
-
Admin.groups(host=localhost, local=true)
|
118
|
-
Admin.groups(host=localhost, local=true){ |grp| ... }
|
119
|
-
In block form, yields a Group object for each group on the system. In
|
120
|
-
non-block form, returns an Array of Group objects.
|
121
|
-
|
122
|
-
You may specify a +host+ from which information is retrieved. The default
|
123
|
-
is the local machine. You can retrieve either a global or local groups,
|
124
|
-
depending on the value of the +local+ argument. The default is local.
|
125
|
-
|
126
|
-
Admin.users(host=localhost, local=true)
|
127
|
-
Admin.users(host=localhost, local=true){ |grp| ... }
|
128
|
-
In block form, yields a User object for each group on the system. In
|
129
|
-
non-block form, returns an Array of User objects.
|
130
|
-
|
131
|
-
You may specify a +host+ from which information is retrieved. The default
|
132
|
-
is the local machine. You can retrieve either a global or local users,
|
133
|
-
depending on the value of the +local+ argument. The default is local.
|
134
|
-
|
135
|
-
== Sys::Admin::Group
|
136
|
-
Group.new
|
137
|
-
Group.new{ |grp| ... }
|
138
|
-
Creates and returns a Group object, which encapsulates the information
|
139
|
-
typically found within an /etc/group entry, i.e. a struct group. If a
|
140
|
-
block is provided, yields the object back to the block.
|
141
|
-
|
142
|
-
== Sys::Admin::User
|
143
|
-
User.new
|
144
|
-
User.new{ |usr| ... }
|
145
|
-
Creates and returns a User object, which encapsulates the information
|
146
|
-
typically found within an /etc/passwd entry, i.e. a struct passwd. If a
|
147
|
-
block is provided, yields the object back to the block.
|
148
|
-
|
149
|
-
= Instance Methods
|
150
|
-
== Sys::Admin::Group
|
151
|
-
Group#caption
|
152
|
-
Short description of the group.
|
153
|
-
|
154
|
-
Group#caption=
|
155
|
-
Sets the caption for the group. Use only when creating a new group.
|
156
|
-
|
157
|
-
Group#description
|
158
|
-
Description of the group.
|
159
|
-
|
160
|
-
Group#description=
|
161
|
-
Sets the description of the group. Use only when creating a new group.
|
162
|
-
|
163
|
-
Group#domain
|
164
|
-
The name of the Windows domain to which the group account belongs.
|
165
|
-
|
166
|
-
Group#domain=
|
167
|
-
Sets the name of the Windows domain to which the group account belongs.
|
168
|
-
Use only when creating a new group.
|
169
|
-
|
170
|
-
Group#install_date
|
171
|
-
The date the group was added.
|
172
|
-
|
173
|
-
Group#gid
|
174
|
-
The group id.
|
175
|
-
|
176
|
-
Group#local?
|
177
|
-
Returns whether or not the group is local (vs global).
|
178
|
-
|
179
|
-
Group#local=
|
180
|
-
Sets whether or not the group is local (vs global).
|
181
|
-
|
182
|
-
Group#name
|
183
|
-
The name of the Windows group account on the given domain.
|
184
|
-
|
185
|
-
Group#name=
|
186
|
-
Sets the name of the Windows group account on the given domain.
|
187
|
-
Use only when creating a new group.
|
188
|
-
|
189
|
-
Group#sid
|
190
|
-
The security identifer for the group.
|
191
|
-
|
192
|
-
Group#sid=
|
193
|
-
Sets the security identifer for the group.
|
194
|
-
|
195
|
-
Group#sid_type
|
196
|
-
The type of security identifier as a stringified value.
|
197
|
-
|
198
|
-
Group#sid_type=
|
199
|
-
Sets the type of security identifier as a stringified value. Use only when
|
200
|
-
creating a new group.
|
201
|
-
|
202
|
-
See the +constants+ section for a list of valid sid types.
|
203
|
-
|
204
|
-
Group#status
|
205
|
-
Current status for the group, such as "ok", "error", etc.
|
206
|
-
|
207
|
-
Group#status=
|
208
|
-
Sets the status for the group.
|
209
|
-
|
210
|
-
== Sys::Admin::User
|
211
|
-
User#account_type
|
212
|
-
Returns the account type as a human readable string.
|
213
|
-
|
214
|
-
User#account_type=
|
215
|
-
Sets the account type. See the +constants+ section for a list of valid
|
216
|
-
values you can set this to.
|
217
|
-
|
218
|
-
User#caption
|
219
|
-
Domain and username of the account.
|
220
|
-
|
221
|
-
User#caption=
|
222
|
-
Sets the domain and username of the account.
|
223
|
-
|
224
|
-
User#description
|
225
|
-
Description of the account.
|
226
|
-
|
227
|
-
User#description=
|
228
|
-
Sets the description of the account.
|
229
|
-
|
230
|
-
User#dir
|
231
|
-
Returns the user's home directory.
|
232
|
-
|
233
|
-
User#dir=
|
234
|
-
Sets the user's home directory.
|
235
|
-
|
236
|
-
User#disabled?
|
237
|
-
Returns whether or not the account is disabled.
|
238
|
-
|
239
|
-
User#disabled=
|
240
|
-
Sets whether or not the account is disabled.
|
241
|
-
|
242
|
-
User#domain
|
243
|
-
Name of the Windows domain to which a user account belongs.
|
244
|
-
|
245
|
-
User#domain=
|
246
|
-
Sets the name of the Windows domain to which a user account belongs.
|
247
|
-
|
248
|
-
User#full_name
|
249
|
-
Full name of a local user.
|
250
|
-
|
251
|
-
User#full_name=
|
252
|
-
Sets the full name of a local user.
|
253
|
-
|
254
|
-
User#install_date
|
255
|
-
Date the user account was created.
|
256
|
-
|
257
|
-
User#local?
|
258
|
-
Returns whether or not the account is defined on the local computer.
|
259
|
-
|
260
|
-
User#local=
|
261
|
-
Sets whether or not the account is defined on the local computer.
|
262
|
-
|
263
|
-
User#lockout?
|
264
|
-
Returns whether or not the account is locked out of the OS.
|
265
|
-
|
266
|
-
User#lockout=
|
267
|
-
Sets whether or not the account is locked out of the OS.
|
268
|
-
|
269
|
-
User#name
|
270
|
-
Name of the Windows user account on the domain that the User#domain
|
271
|
-
property specifies.
|
272
|
-
|
273
|
-
User#name=
|
274
|
-
Sets the name of the Windows user account on the domain that the User#domain
|
275
|
-
property specifies.
|
276
|
-
|
277
|
-
User#password
|
278
|
-
The user's password.
|
279
|
-
|
280
|
-
User#password=
|
281
|
-
Sets the user's password.
|
282
|
-
|
283
|
-
User#password_changeable?
|
284
|
-
Returns whether or not the password for the account can be changed.
|
285
|
-
|
286
|
-
User#password_changeable=
|
287
|
-
Sets whether or not the password for the account can be changed.
|
288
|
-
|
289
|
-
User#password_expires?
|
290
|
-
Returns whether or not the password for the account expires.
|
291
|
-
|
292
|
-
User#password_expires=
|
293
|
-
Sets whether or not the password for the account expires.
|
294
|
-
|
295
|
-
User#password_required?
|
296
|
-
Returns whether or not a password is required for the account.
|
297
|
-
|
298
|
-
User#password_required=
|
299
|
-
Sets whether or not a password is required for the account.
|
300
|
-
|
301
|
-
User#sid
|
302
|
-
The user's security identifier.
|
303
|
-
|
304
|
-
User#sid=
|
305
|
-
Sets the user's security identifier.
|
306
|
-
|
307
|
-
User#status
|
308
|
-
Current status for the user, such as "ok", "error", etc.
|
309
|
-
|
310
|
-
== Notes
|
311
|
-
Not all platforms support all of the User members. The only ones that are
|
312
|
-
supported on all platforms are name, uid, gid, dir and shell. The rest
|
313
|
-
will simply return nil if they aren't supported.
|
314
|
-
|
315
|
-
== Known Bugs
|
316
|
-
None that I am aware of. Please log any bugs you find on the project
|
317
|
-
website at http://www.rubyforge.org/projects/sysutils.
|
318
|
-
|
319
|
-
== License
|
320
|
-
Artistic 2.0
|
321
|
-
|
322
|
-
== Copyright
|
323
|
-
Copyright 2002-2009, Daniel J. Berger
|
324
|
-
|
325
|
-
All Rights Reserved. This module is free software. It may be used,
|
326
|
-
redistributed and/or modified under the same terms as Ruby itself.
|
327
|
-
|
328
|
-
== Warranty
|
329
|
-
This library is provided "as is" and without any express or
|
330
|
-
implied warranties, including, without limitation, the implied
|
331
|
-
warranties of merchantability and fitness for a particular purpose.
|
332
|
-
|
333
|
-
== Author
|
334
|
-
Daniel J. Berger
|
335
|
-
djberg96 at nospam at gmail dot com
|
336
|
-
imperator on IRC (Freenode)
|
1
|
+
= Description
|
2
|
+
A unified, cross-platform replacement for the Etc module that allows you to
|
3
|
+
get information about users and groups.
|
4
|
+
|
5
|
+
= Synopsis
|
6
|
+
require 'sys/admin'
|
7
|
+
include Sys
|
8
|
+
|
9
|
+
Admin.get_login # -> 'djberge'
|
10
|
+
Admin.get_user('djberge') # -> Admin::User object
|
11
|
+
Admin.get_group(501) # -> Admin::Group object
|
12
|
+
|
13
|
+
# Iterate over all users
|
14
|
+
Admin.users do |usr|
|
15
|
+
p usr
|
16
|
+
end
|
17
|
+
|
18
|
+
# Iterate over all groups
|
19
|
+
Admin.groups do |grp|
|
20
|
+
p grp
|
21
|
+
end
|
22
|
+
|
23
|
+
= Constants
|
24
|
+
== Sys::Admin
|
25
|
+
VERSION
|
26
|
+
The version of this library, returned as a String.
|
27
|
+
|
28
|
+
== Sys::Admin::User
|
29
|
+
TEMP_DUPLICATE
|
30
|
+
An account for users whose primary account is in another domain.
|
31
|
+
|
32
|
+
NORMAL
|
33
|
+
Default account type that represents a typical user.
|
34
|
+
|
35
|
+
INTERDOMAIN_TRUST
|
36
|
+
A permit to trust account for a domain that trusts other domains.
|
37
|
+
|
38
|
+
WORKSTATION_TRUST
|
39
|
+
An account for a Windows NT/2000 workstation or server that is a member
|
40
|
+
member of this domain.
|
41
|
+
|
42
|
+
SERVER_TRUST
|
43
|
+
A computer account for a backup domain controller that is a member of this
|
44
|
+
domain.
|
45
|
+
|
46
|
+
= Class Methods
|
47
|
+
== Sys::Admin
|
48
|
+
Admin.add_global_group(group, domain)
|
49
|
+
Adds the global +group+ on +domain+.
|
50
|
+
|
51
|
+
Admin.add_global_user(user, domain)
|
52
|
+
Adds the global +user+ on +domain+.
|
53
|
+
|
54
|
+
Admin.add_local_group(group, host=localhost)
|
55
|
+
Adds the local +group+ on +host+, or the localhost if no host is specified.
|
56
|
+
|
57
|
+
Admin.add_local_user(user, host=localhost)
|
58
|
+
Adds the local +user+ on +host+, or the localhost if no host is specified.
|
59
|
+
|
60
|
+
Admin.config_global_group(user, option, domain)
|
61
|
+
Configures +group+ on +domain+ using +options+. There are too many options
|
62
|
+
to list here.
|
63
|
+
|
64
|
+
See http://tinyurl.com/cjkzl for a list of valid options.
|
65
|
+
|
66
|
+
Admin.config_local_group(user, option, host=localhost)
|
67
|
+
Configures +group+ on +host+ using +options+. There are too many options
|
68
|
+
to list here.
|
69
|
+
|
70
|
+
See http://tinyurl.com/cjkzl for a list of valid options.
|
71
|
+
|
72
|
+
Admin.config_global_user(user, option, domain)
|
73
|
+
Configures +user+ on +domain+ using +options+. There are too many options
|
74
|
+
to list here.
|
75
|
+
|
76
|
+
See http://tinyurl.com/3hjv9 for a list of valid options.
|
77
|
+
|
78
|
+
Admin.config_local_user(user, options, host=localhost)
|
79
|
+
Configures the local +user+ on +host+ using +options+. If no host is
|
80
|
+
specified, the default is localhost.
|
81
|
+
|
82
|
+
See http://tinyurl.com/3hjv9 for a list of valid options.
|
83
|
+
|
84
|
+
Admin.delete_global_group(group, domain)
|
85
|
+
Deletes the global +group+ from +domain+.
|
86
|
+
|
87
|
+
Admin.delete_global_user(user, domain)
|
88
|
+
Deletes the global +user+ from +domain+.
|
89
|
+
|
90
|
+
Admin.delete_local_group(group, host=localhost)
|
91
|
+
Deletes the local +group+ from +host+, or localhost if no host is specified.
|
92
|
+
|
93
|
+
Admin.delete_local_user(user, host=localhost)
|
94
|
+
Deletes the local +user+ from +host+, or localhost if no host is specified.
|
95
|
+
|
96
|
+
Admin.get_group(name, host=localhost, local=true)
|
97
|
+
Admin.get_group(gid, host=localhost, local=true)
|
98
|
+
Returns a Group object for the given name or gid. Raises an Admin::Error
|
99
|
+
if a group cannot be found for that name or GID.
|
100
|
+
|
101
|
+
You may specify a host from which information is retrieved.
|
102
|
+
The default is the local machine. You can retrieve either a global or
|
103
|
+
local group, depending on the value of the +local+ argument.
|
104
|
+
|
105
|
+
Admin.get_login
|
106
|
+
Returns the user name of the current login.
|
107
|
+
|
108
|
+
Admin.get_user(name, host=localhost, local=true)
|
109
|
+
Admin.get_user(uid, host=localhost, local=true)
|
110
|
+
Returns a User object for the given name or uid. Raises an Admin::Error if
|
111
|
+
a user cannot be found for that name or user ID.
|
112
|
+
|
113
|
+
You may specify a +host+ from which information is retrieved. The
|
114
|
+
default is the local machine. You may also specify whether to
|
115
|
+
retrieve a local or global account. The default is local.
|
116
|
+
|
117
|
+
Admin.groups(host=localhost, local=true)
|
118
|
+
Admin.groups(host=localhost, local=true){ |grp| ... }
|
119
|
+
In block form, yields a Group object for each group on the system. In
|
120
|
+
non-block form, returns an Array of Group objects.
|
121
|
+
|
122
|
+
You may specify a +host+ from which information is retrieved. The default
|
123
|
+
is the local machine. You can retrieve either a global or local groups,
|
124
|
+
depending on the value of the +local+ argument. The default is local.
|
125
|
+
|
126
|
+
Admin.users(host=localhost, local=true)
|
127
|
+
Admin.users(host=localhost, local=true){ |grp| ... }
|
128
|
+
In block form, yields a User object for each group on the system. In
|
129
|
+
non-block form, returns an Array of User objects.
|
130
|
+
|
131
|
+
You may specify a +host+ from which information is retrieved. The default
|
132
|
+
is the local machine. You can retrieve either a global or local users,
|
133
|
+
depending on the value of the +local+ argument. The default is local.
|
134
|
+
|
135
|
+
== Sys::Admin::Group
|
136
|
+
Group.new
|
137
|
+
Group.new{ |grp| ... }
|
138
|
+
Creates and returns a Group object, which encapsulates the information
|
139
|
+
typically found within an /etc/group entry, i.e. a struct group. If a
|
140
|
+
block is provided, yields the object back to the block.
|
141
|
+
|
142
|
+
== Sys::Admin::User
|
143
|
+
User.new
|
144
|
+
User.new{ |usr| ... }
|
145
|
+
Creates and returns a User object, which encapsulates the information
|
146
|
+
typically found within an /etc/passwd entry, i.e. a struct passwd. If a
|
147
|
+
block is provided, yields the object back to the block.
|
148
|
+
|
149
|
+
= Instance Methods
|
150
|
+
== Sys::Admin::Group
|
151
|
+
Group#caption
|
152
|
+
Short description of the group.
|
153
|
+
|
154
|
+
Group#caption=
|
155
|
+
Sets the caption for the group. Use only when creating a new group.
|
156
|
+
|
157
|
+
Group#description
|
158
|
+
Description of the group.
|
159
|
+
|
160
|
+
Group#description=
|
161
|
+
Sets the description of the group. Use only when creating a new group.
|
162
|
+
|
163
|
+
Group#domain
|
164
|
+
The name of the Windows domain to which the group account belongs.
|
165
|
+
|
166
|
+
Group#domain=
|
167
|
+
Sets the name of the Windows domain to which the group account belongs.
|
168
|
+
Use only when creating a new group.
|
169
|
+
|
170
|
+
Group#install_date
|
171
|
+
The date the group was added.
|
172
|
+
|
173
|
+
Group#gid
|
174
|
+
The group id.
|
175
|
+
|
176
|
+
Group#local?
|
177
|
+
Returns whether or not the group is local (vs global).
|
178
|
+
|
179
|
+
Group#local=
|
180
|
+
Sets whether or not the group is local (vs global).
|
181
|
+
|
182
|
+
Group#name
|
183
|
+
The name of the Windows group account on the given domain.
|
184
|
+
|
185
|
+
Group#name=
|
186
|
+
Sets the name of the Windows group account on the given domain.
|
187
|
+
Use only when creating a new group.
|
188
|
+
|
189
|
+
Group#sid
|
190
|
+
The security identifer for the group.
|
191
|
+
|
192
|
+
Group#sid=
|
193
|
+
Sets the security identifer for the group.
|
194
|
+
|
195
|
+
Group#sid_type
|
196
|
+
The type of security identifier as a stringified value.
|
197
|
+
|
198
|
+
Group#sid_type=
|
199
|
+
Sets the type of security identifier as a stringified value. Use only when
|
200
|
+
creating a new group.
|
201
|
+
|
202
|
+
See the +constants+ section for a list of valid sid types.
|
203
|
+
|
204
|
+
Group#status
|
205
|
+
Current status for the group, such as "ok", "error", etc.
|
206
|
+
|
207
|
+
Group#status=
|
208
|
+
Sets the status for the group.
|
209
|
+
|
210
|
+
== Sys::Admin::User
|
211
|
+
User#account_type
|
212
|
+
Returns the account type as a human readable string.
|
213
|
+
|
214
|
+
User#account_type=
|
215
|
+
Sets the account type. See the +constants+ section for a list of valid
|
216
|
+
values you can set this to.
|
217
|
+
|
218
|
+
User#caption
|
219
|
+
Domain and username of the account.
|
220
|
+
|
221
|
+
User#caption=
|
222
|
+
Sets the domain and username of the account.
|
223
|
+
|
224
|
+
User#description
|
225
|
+
Description of the account.
|
226
|
+
|
227
|
+
User#description=
|
228
|
+
Sets the description of the account.
|
229
|
+
|
230
|
+
User#dir
|
231
|
+
Returns the user's home directory.
|
232
|
+
|
233
|
+
User#dir=
|
234
|
+
Sets the user's home directory.
|
235
|
+
|
236
|
+
User#disabled?
|
237
|
+
Returns whether or not the account is disabled.
|
238
|
+
|
239
|
+
User#disabled=
|
240
|
+
Sets whether or not the account is disabled.
|
241
|
+
|
242
|
+
User#domain
|
243
|
+
Name of the Windows domain to which a user account belongs.
|
244
|
+
|
245
|
+
User#domain=
|
246
|
+
Sets the name of the Windows domain to which a user account belongs.
|
247
|
+
|
248
|
+
User#full_name
|
249
|
+
Full name of a local user.
|
250
|
+
|
251
|
+
User#full_name=
|
252
|
+
Sets the full name of a local user.
|
253
|
+
|
254
|
+
User#install_date
|
255
|
+
Date the user account was created.
|
256
|
+
|
257
|
+
User#local?
|
258
|
+
Returns whether or not the account is defined on the local computer.
|
259
|
+
|
260
|
+
User#local=
|
261
|
+
Sets whether or not the account is defined on the local computer.
|
262
|
+
|
263
|
+
User#lockout?
|
264
|
+
Returns whether or not the account is locked out of the OS.
|
265
|
+
|
266
|
+
User#lockout=
|
267
|
+
Sets whether or not the account is locked out of the OS.
|
268
|
+
|
269
|
+
User#name
|
270
|
+
Name of the Windows user account on the domain that the User#domain
|
271
|
+
property specifies.
|
272
|
+
|
273
|
+
User#name=
|
274
|
+
Sets the name of the Windows user account on the domain that the User#domain
|
275
|
+
property specifies.
|
276
|
+
|
277
|
+
User#password
|
278
|
+
The user's password.
|
279
|
+
|
280
|
+
User#password=
|
281
|
+
Sets the user's password.
|
282
|
+
|
283
|
+
User#password_changeable?
|
284
|
+
Returns whether or not the password for the account can be changed.
|
285
|
+
|
286
|
+
User#password_changeable=
|
287
|
+
Sets whether or not the password for the account can be changed.
|
288
|
+
|
289
|
+
User#password_expires?
|
290
|
+
Returns whether or not the password for the account expires.
|
291
|
+
|
292
|
+
User#password_expires=
|
293
|
+
Sets whether or not the password for the account expires.
|
294
|
+
|
295
|
+
User#password_required?
|
296
|
+
Returns whether or not a password is required for the account.
|
297
|
+
|
298
|
+
User#password_required=
|
299
|
+
Sets whether or not a password is required for the account.
|
300
|
+
|
301
|
+
User#sid
|
302
|
+
The user's security identifier.
|
303
|
+
|
304
|
+
User#sid=
|
305
|
+
Sets the user's security identifier.
|
306
|
+
|
307
|
+
User#status
|
308
|
+
Current status for the user, such as "ok", "error", etc.
|
309
|
+
|
310
|
+
== Notes
|
311
|
+
Not all platforms support all of the User members. The only ones that are
|
312
|
+
supported on all platforms are name, uid, gid, dir and shell. The rest
|
313
|
+
will simply return nil if they aren't supported.
|
314
|
+
|
315
|
+
== Known Bugs
|
316
|
+
None that I am aware of. Please log any bugs you find on the project
|
317
|
+
website at http://www.rubyforge.org/projects/sysutils.
|
318
|
+
|
319
|
+
== License
|
320
|
+
Artistic 2.0
|
321
|
+
|
322
|
+
== Copyright
|
323
|
+
Copyright 2002-2009, Daniel J. Berger
|
324
|
+
|
325
|
+
All Rights Reserved. This module is free software. It may be used,
|
326
|
+
redistributed and/or modified under the same terms as Ruby itself.
|
327
|
+
|
328
|
+
== Warranty
|
329
|
+
This library is provided "as is" and without any express or
|
330
|
+
implied warranties, including, without limitation, the implied
|
331
|
+
warranties of merchantability and fitness for a particular purpose.
|
332
|
+
|
333
|
+
== Author
|
334
|
+
Daniel J. Berger
|
335
|
+
djberg96 at nospam at gmail dot com
|
336
|
+
imperator on IRC (Freenode)
|