sys-admin 1.7.0 → 1.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/CHANGES +173 -168
- data/MANIFEST +18 -18
- data/README +148 -148
- data/Rakefile +47 -47
- data/certs/djberg96_pub.pem +21 -21
- 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 +39 -31
- data/test/test_sys_admin.rb +23 -19
- data/test/test_sys_admin_unix.rb +260 -260
- data/test/test_sys_admin_windows.rb +337 -337
- metadata +32 -26
- 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, 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
|
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,26 +1,26 @@
|
|
1
1
|
-----BEGIN CERTIFICATE-----
|
2
2
|
MIIEcDCCAtigAwIBAgIBATANBgkqhkiG9w0BAQsFADA/MREwDwYDVQQDDAhkamJl
|
3
3
|
cmc5NjEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPyLGQBGRYDY29t
|
4
|
-
|
4
|
+
MB4XDTE4MDMxODE1MjIwN1oXDTI4MDMxNTE1MjIwN1owPzERMA8GA1UEAwwIZGpi
|
5
5
|
ZXJnOTYxFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixkARkWA2Nv
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
6
|
+
bTCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoCggGBALgfaroVM6CI06cxr0/h
|
7
|
+
A+j+pc8fgpRgBVmHFaFunq28GPC3IvW7Nvc3Y8SnAW7pP1EQIbhlwRIaQzJ93/yj
|
8
|
+
u95KpkP7tA9erypnV7dpzBkzNlX14ACa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Xfbj2ke5u1hZj94Fsq9FfbEQg8ygCgwThnmkTrrKEiMSs3alYR
|
24
|
+
ORVCZpRuCPpmC8qmqxUnARDArzucjaclkxjLWvCVHeFa9UP7K3Nl9oTjJNv+7/jM
|
25
|
+
WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
|
26
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
|