sys-admin 1.8.0-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile ADDED
@@ -0,0 +1,44 @@
1
+ require 'rake'
2
+ require 'rake/clean'
3
+ require 'rspec/core/rake_task'
4
+ require 'rbconfig'
5
+
6
+ CLEAN.include("**/*.gem", "**/*.rbx", "**/*.rbc", "ruby.core", "**/*.lock")
7
+
8
+ namespace :gem do
9
+ desc "Create the sys-uname gem"
10
+ task :create => [:clean] do
11
+ require 'rubygems/package'
12
+ spec = Gem::Specification.load('sys-admin.gemspec')
13
+ spec.signing_key = File.join(Dir.home, '.ssh', 'gem-private_key.pem')
14
+ Gem::Package.build(spec)
15
+ end
16
+
17
+ desc "Install the sys-uname gem"
18
+ task :install => [:create] do
19
+ file = Dir["*.gem"].first
20
+ sh "gem install -l #{file}"
21
+ end
22
+ end
23
+
24
+ desc "Run the specs for the sys-admin library"
25
+ RSpec::Core::RakeTask.new(:spec) do |t|
26
+ t.pattern = 'spec/sys_admin_unix_spec.rb'
27
+ case RbConfig::CONFIG['host_os']
28
+ when /darwin|osx/i
29
+ t.rspec_opts = '-Ilib/darwin'
30
+ when /linux/i
31
+ t.rspec_opts = '-Ilib/linux'
32
+ when /sunos|solaris/i
33
+ t.rspec_opts = '-Ilib/sunos'
34
+ when /bsd/i
35
+ t.rspec_opts = '-Ilib/bsd'
36
+ when /windows|win32|mingw|cygwin|dos/i
37
+ t.rspec_opts = '-Ilib/windows'
38
+ t.pattern = 'spec/sys_admin_windows_spec.rb'
39
+ else
40
+ t.rspec_opts = '-Ilib/unix'
41
+ end
42
+ end
43
+
44
+ task :default => :spec
@@ -0,0 +1,26 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIEcDCCAtigAwIBAgIBATANBgkqhkiG9w0BAQsFADA/MREwDwYDVQQDDAhkamJl
3
+ cmc5NjEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPyLGQBGRYDY29t
4
+ MB4XDTE4MDMxODE1MjIwN1oXDT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+ 6L1iRcEDtanGCIvjqlCXO9+BmsnCfEVehqZkQHeYczA03tpOWb6pon2wzvMKSsKH
21
+ ks0ApVdstSLz1kzzAqem/uHdG9FyXdbTAwH1G4ZPv69sQAFAOCgAqYmdnzedsQtE
22
+ 1LQfaQrx0twO+CZJPcRLEESjq8ScQxWRRkfuh2VeR7cEU7L7KqT10mtUwrvw7APf
23
+ DYoeCY9KyjIBjQXfbj2ke5u1hZj94Fsq9FfbEQg8ygCgwThnmkTrrKEiMSs3alYR
24
+ ORVCZpRuCPpmC8qmqxUnARDArzucjaclkxjLWvCVHeFa9UP7K3Nl9oTjJNv+7/jM
25
+ WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
26
+ -----END CERTIFICATE-----
@@ -0,0 +1,162 @@
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-2014, 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
@@ -0,0 +1,346 @@
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#gid
255
+ Returns the primary group ID number.
256
+
257
+ User#gid=
258
+ Sets the primary group ID number.
259
+
260
+ User#install_date
261
+ Date the user account was created.
262
+
263
+ User#local?
264
+ Returns whether or not the account is defined on the local computer.
265
+
266
+ User#local=
267
+ Sets whether or not the account is defined on the local computer.
268
+
269
+ User#lockout?
270
+ Returns whether or not the account is locked out of the OS.
271
+
272
+ User#lockout=
273
+ Sets whether or not the account is locked out of the OS.
274
+
275
+ User#name
276
+ Name of the Windows user account on the domain that the User#domain
277
+ property specifies.
278
+
279
+ User#name=
280
+ Sets the name of the Windows user account on the domain that the User#domain
281
+ property specifies.
282
+
283
+ User#password
284
+ The user's password.
285
+
286
+ User#password=
287
+ Sets the user's password.
288
+
289
+ User#password_changeable?
290
+ Returns whether or not the password for the account can be changed.
291
+
292
+ User#password_changeable=
293
+ Sets whether or not the password for the account can be changed.
294
+
295
+ User#password_expires?
296
+ Returns whether or not the password for the account expires.
297
+
298
+ User#password_expires=
299
+ Sets whether or not the password for the account expires.
300
+
301
+ User#password_required?
302
+ Returns whether or not a password is required for the account.
303
+
304
+ User#password_required=
305
+ Sets whether or not a password is required for the account.
306
+
307
+ User#sid
308
+ The user's security identifier.
309
+
310
+ User#sid=
311
+ Sets the user's security identifier.
312
+
313
+ User#status
314
+ Current status for the user, such as "ok", "error", etc.
315
+
316
+ User#uid
317
+ The user's user ID. This is the RID of the SID.
318
+
319
+ User#uid=
320
+ Sets the user's user ID.
321
+
322
+ == Notes
323
+ Not all platforms support all of the User members. The only ones that are
324
+ supported on all platforms are name, uid, gid, dir and shell. The rest
325
+ will simply return nil if they aren't supported.
326
+
327
+ == Known Bugs
328
+ None that I am aware of. Please log any bugs you find on the project
329
+ website at http://www.rubyforge.org/projects/sysutils.
330
+
331
+ == License
332
+ Artistic 2.0
333
+
334
+ == Copyright
335
+ Copyright 2002-2014, Daniel J. Berger
336
+
337
+ All Rights Reserved. This module is free software. It may be used,
338
+ redistributed and/or modified under the same terms as Ruby itself.
339
+
340
+ == Warranty
341
+ This library is provided "as is" and without any express or
342
+ implied warranties, including, without limitation, the implied
343
+ warranties of merchantability and fitness for a particular purpose.
344
+
345
+ == Author
346
+ Daniel J. Berger