sys-admin 1.6.4 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/CHANGES +168 -161
- data/MANIFEST +18 -18
- data/README +148 -154
- data/Rakefile +47 -47
- data/certs/djberg96_pub.pem +22 -17
- data/doc/sys-admin-unix.txt +162 -162
- data/doc/sys-admin-windows.txt +346 -346
- data/examples/example_groups.rb +27 -27
- data/examples/example_users.rb +41 -41
- data/lib/bsd/sys/admin.rb +256 -256
- data/lib/darwin/sys/admin.rb +237 -237
- data/lib/linux/sys/admin.rb +273 -273
- data/lib/sunos/sys/admin.rb +261 -261
- data/lib/sys-admin.rb +1 -1
- data/lib/sys/admin.rb +24 -24
- data/lib/sys/admin/common.rb +137 -137
- data/lib/sys/admin/custom.rb +16 -16
- data/lib/unix/sys/admin.rb +163 -163
- data/lib/windows/sys/admin.rb +997 -997
- data/sys-admin.gemspec +31 -31
- data/test/test_sys_admin.rb +19 -19
- data/test/test_sys_admin_unix.rb +260 -260
- data/test/test_sys_admin_windows.rb +337 -337
- metadata +51 -27
- metadata.gz.sig +0 -0
data/Rakefile
CHANGED
@@ -1,47 +1,47 @@
|
|
1
|
-
require 'rake'
|
2
|
-
require 'rake/clean'
|
3
|
-
require 'rake/testtask'
|
4
|
-
require 'rbconfig'
|
5
|
-
|
6
|
-
CLEAN.include("**/*.gem", "**/*.rbx", "**/*.rbc", "ruby.core")
|
7
|
-
|
8
|
-
namespace :gem do
|
9
|
-
desc "Create the sys-uname gem"
|
10
|
-
task :create => [:clean] do
|
11
|
-
require 'rubygems/package'
|
12
|
-
spec = eval(IO.read('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
|
-
Rake::TestTask.new('test') do |t|
|
25
|
-
case RbConfig::CONFIG['host_os']
|
26
|
-
when /darwin|osx/i
|
27
|
-
t.libs << 'lib/darwin'
|
28
|
-
when /linux/i
|
29
|
-
t.libs << 'lib/linux'
|
30
|
-
when /sunos|solaris/i
|
31
|
-
t.libs << 'lib/sunos'
|
32
|
-
when /bsd/i
|
33
|
-
t.libs << 'lib/bsd'
|
34
|
-
when /windows|win32|mingw|cygwin|dos/i
|
35
|
-
t.libs << 'lib/windows'
|
36
|
-
else
|
37
|
-
t.libs << 'lib/unix'
|
38
|
-
end
|
39
|
-
|
40
|
-
t.warning = true
|
41
|
-
t.verbose = true
|
42
|
-
|
43
|
-
t.libs << 'test'
|
44
|
-
t.test_files = FileList['test/test_sys_admin.rb']
|
45
|
-
end
|
46
|
-
|
47
|
-
task :default => :test
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/clean'
|
3
|
+
require 'rake/testtask'
|
4
|
+
require 'rbconfig'
|
5
|
+
|
6
|
+
CLEAN.include("**/*.gem", "**/*.rbx", "**/*.rbc", "ruby.core")
|
7
|
+
|
8
|
+
namespace :gem do
|
9
|
+
desc "Create the sys-uname gem"
|
10
|
+
task :create => [:clean] do
|
11
|
+
require 'rubygems/package'
|
12
|
+
spec = eval(IO.read('sys-admin.gemspec'))
|
13
|
+
spec.signing_key = File.join(Dir.home, '.ssh', 'gem-private_key.pem')
|
14
|
+
Gem::Package.build(spec, true)
|
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
|
+
Rake::TestTask.new('test') do |t|
|
25
|
+
case RbConfig::CONFIG['host_os']
|
26
|
+
when /darwin|osx/i
|
27
|
+
t.libs << 'lib/darwin'
|
28
|
+
when /linux/i
|
29
|
+
t.libs << 'lib/linux'
|
30
|
+
when /sunos|solaris/i
|
31
|
+
t.libs << 'lib/sunos'
|
32
|
+
when /bsd/i
|
33
|
+
t.libs << 'lib/bsd'
|
34
|
+
when /windows|win32|mingw|cygwin|dos/i
|
35
|
+
t.libs << 'lib/windows'
|
36
|
+
else
|
37
|
+
t.libs << 'lib/unix'
|
38
|
+
end
|
39
|
+
|
40
|
+
t.warning = true
|
41
|
+
t.verbose = true
|
42
|
+
|
43
|
+
t.libs << 'test'
|
44
|
+
t.test_files = FileList['test/test_sys_admin.rb']
|
45
|
+
end
|
46
|
+
|
47
|
+
task :default => :test
|
data/certs/djberg96_pub.pem
CHANGED
@@ -1,21 +1,26 @@
|
|
1
1
|
-----BEGIN CERTIFICATE-----
|
2
|
-
|
2
|
+
MIIEcDCCAtigAwIBAgIBATANBgkqhkiG9w0BAQsFADA/MREwDwYDVQQDDAhkamJl
|
3
3
|
cmc5NjEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPyLGQBGRYDY29t
|
4
|
-
|
4
|
+
MB4XDTE4MDIxOTIzMjIxMloXDTI4MDIxNzIzMjIxMlowPzERMA8GA1UEAwwIZGpi
|
5
5
|
ZXJnOTYxFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixkARkWA2Nv
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
6
|
+
bTCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoCggGBAOFYobQ3ovXNC4RexrdP
|
7
|
+
malr3eyK6lvQuS5DOQpHQrT3sRbrhAy5c2effNmznnUzDDGnHs+ZKkAeVmUDIi+K
|
8
|
+
lfXjV8uPEkLMXUpDndg9rbmQmfie07ixCdE9JYRPwfMTcE+jbtUyZqEUIg7XYmuJ
|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wlbazwYn+A+KB0TxXJndHY9e6x
|
24
|
+
u7vZCyU93PFHpp/w270tu8VbayZSbmxF/oCsRuzWD0+xVsgLejqfWBbyGqwis995
|
25
|
+
p1I1Aujksa9wuoPhNNl8J4zKV1YtYorUDA44xq1iJEUE+ChB
|
21
26
|
-----END CERTIFICATE-----
|
data/doc/sys-admin-unix.txt
CHANGED
@@ -1,162 +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
|
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
|