sys-admin 1.4.3 → 1.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES +7 -0
- data/doc/sys-admin-unix.txt +2 -2
- data/doc/sys-admin-windows.txt +3 -3
- data/ext/sys/admin.c +1 -1
- data/ext/sys/admin.h +6 -6
- data/test/tc_admin.rb +3 -3
- data/test/tc_unix.rb +1 -1
- data/test/tc_windows.rb +41 -27
- metadata +4 -6
data/CHANGES
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
== 1.4.4 - 19-Nov-2008
|
2
|
+
* Added the User#uid method for MS Windows (which is just the user's relative
|
3
|
+
identifier).
|
4
|
+
* Now requires test-unit 2.x.
|
5
|
+
* Some updates to the test suite to take advantage of test-unit 2.x features.
|
6
|
+
* Some minor gemspec tweaks.
|
7
|
+
|
1
8
|
== 1.4.3 - 2-Mar-2008
|
2
9
|
* The block form of Admin.users now properly ensures that endpwent() is
|
3
10
|
called. Likewise, the block form of Admin.groups now properly ensures
|
data/doc/sys-admin-unix.txt
CHANGED
@@ -148,13 +148,13 @@ User#uid
|
|
148
148
|
Ruby's
|
149
149
|
|
150
150
|
== Copyright
|
151
|
-
Copyright 2002-
|
151
|
+
Copyright 2002-2008, Daniel J. Berger
|
152
152
|
|
153
153
|
All Rights Reserved. This module is free software. It may be used,
|
154
154
|
redistributed and/or modified under the same terms as Ruby itself.
|
155
155
|
|
156
156
|
== Warranty
|
157
|
-
This
|
157
|
+
This library is provided "as is" and without any express or
|
158
158
|
implied warranties, including, without limitation, the implied
|
159
159
|
warranties of merchantability and fitness for a particular purpose.
|
160
160
|
|
data/doc/sys-admin-windows.txt
CHANGED
@@ -23,7 +23,7 @@ get information about users and groups.
|
|
23
23
|
= Constants
|
24
24
|
== Sys::Admin
|
25
25
|
VERSION
|
26
|
-
The version of this
|
26
|
+
The version of this library, returned as a String.
|
27
27
|
|
28
28
|
== Sys::Admin::User
|
29
29
|
TEMP_DUPLICATE
|
@@ -314,13 +314,13 @@ User#status
|
|
314
314
|
Ruby's
|
315
315
|
|
316
316
|
== Copyright
|
317
|
-
Copyright 2002-
|
317
|
+
Copyright 2002-2008, Daniel J. Berger
|
318
318
|
|
319
319
|
All Rights Reserved. This module is free software. It may be used,
|
320
320
|
redistributed and/or modified under the same terms as Ruby itself.
|
321
321
|
|
322
322
|
== Warranty
|
323
|
-
This
|
323
|
+
This library is provided "as is" and without any express or
|
324
324
|
implied warranties, including, without limitation, the implied
|
325
325
|
warranties of merchantability and fitness for a particular purpose.
|
326
326
|
|
data/ext/sys/admin.c
CHANGED
data/ext/sys/admin.h
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
#include <errno.h>
|
9
9
|
#include <string.h>
|
10
10
|
|
11
|
-
#define SYS_ADMIN_VERSION "1.4.
|
11
|
+
#define SYS_ADMIN_VERSION "1.4.4"
|
12
12
|
|
13
13
|
#ifdef HAVE_LASTLOG_H
|
14
14
|
#include <lastlog.h>
|
@@ -117,7 +117,7 @@ static VALUE get_user_by_name(VALUE v_name){
|
|
117
117
|
|
118
118
|
v_user = get_user(pwd);
|
119
119
|
#else
|
120
|
-
rb_raise(rb_eNotImpError, "getting user by name not supported");
|
120
|
+
rb_raise(rb_eNotImpError, "getting user by name not supported");
|
121
121
|
#endif
|
122
122
|
|
123
123
|
return v_user;
|
@@ -148,7 +148,7 @@ static VALUE get_group_by_num(VALUE v_gid){
|
|
148
148
|
struct group* grp;
|
149
149
|
if( (grp = getgrgid(gid)) == NULL)
|
150
150
|
rb_raise(cAdminError, "no group found for group ID: %i", gid);
|
151
|
-
|
151
|
+
|
152
152
|
v_group = get_group(grp);
|
153
153
|
#else
|
154
154
|
rb_raise(rb_eNotImpError, "getting group by group ID not supported");
|
@@ -188,7 +188,7 @@ static VALUE get_group_by_name(VALUE v_name){
|
|
188
188
|
#endif
|
189
189
|
|
190
190
|
return v_group;
|
191
|
-
}
|
191
|
+
}
|
192
192
|
|
193
193
|
/*
|
194
194
|
* :no-doc:
|
@@ -302,7 +302,7 @@ void get_user_from_value(VALUE v_user, struct passwd* pwd){
|
|
302
302
|
VALUE v_gecos = rb_iv_get(v_user, "@gecos");
|
303
303
|
if(!NIL_P(v_gecos)){
|
304
304
|
SafeStringValue(v_gecos);
|
305
|
-
pwd->pw_gecos = StringValuePtr(v_gecos);
|
305
|
+
pwd->pw_gecos = StringValuePtr(v_gecos);
|
306
306
|
}
|
307
307
|
#endif
|
308
308
|
|
@@ -409,7 +409,7 @@ void get_group_from_value(VALUE v_group, struct group* grp){
|
|
409
409
|
*
|
410
410
|
* Helper function that gets lastlog information for the User object.
|
411
411
|
*/
|
412
|
-
int get_lastlog_info(struct passwd* pwd, VALUE v_user){
|
412
|
+
int get_lastlog_info(struct passwd* pwd, VALUE v_user){
|
413
413
|
int fd;
|
414
414
|
ssize_t bytes_read;
|
415
415
|
struct lastlog log;
|
data/test/tc_admin.rb
CHANGED
@@ -5,10 +5,10 @@
|
|
5
5
|
# test suite based on the platform.
|
6
6
|
###############################################################################
|
7
7
|
$LOAD_PATH.unshift Dir.pwd
|
8
|
-
$LOAD_PATH.unshift Dir.pwd
|
8
|
+
$LOAD_PATH.unshift File.join(Dir.pwd, 'test')
|
9
9
|
|
10
10
|
if File::ALT_SEPARATOR
|
11
|
-
require
|
11
|
+
require 'tc_windows'
|
12
12
|
else
|
13
|
-
require
|
13
|
+
require 'tc_unix'
|
14
14
|
end
|
data/test/tc_unix.rb
CHANGED
data/test/tc_windows.rb
CHANGED
@@ -7,29 +7,35 @@
|
|
7
7
|
#
|
8
8
|
# It is assumed that this test will be run via the 'rake test' task.
|
9
9
|
###############################################################################
|
10
|
-
require
|
11
|
-
|
12
|
-
|
10
|
+
require 'rubygems'
|
11
|
+
gem 'test-unit'
|
12
|
+
|
13
|
+
require 'test/unit'
|
14
|
+
require 'sys/admin'
|
15
|
+
require 'socket'
|
13
16
|
include Sys
|
14
17
|
|
15
18
|
class TC_Sys_Admin_Win32 < Test::Unit::TestCase
|
19
|
+
def self.startup
|
20
|
+
@@host = Socket.gethostname
|
21
|
+
end
|
22
|
+
|
16
23
|
def setup
|
17
|
-
@
|
18
|
-
@
|
19
|
-
@
|
20
|
-
@
|
21
|
-
@
|
22
|
-
@
|
23
|
-
@group_id = 546 # best guess, may fail
|
24
|
+
@user = User.new
|
25
|
+
@user_name = 'guest'
|
26
|
+
@user_id = 501 # best guess, may fail
|
27
|
+
@group = Group.new
|
28
|
+
@group_name = 'guests'
|
29
|
+
@group_id = 546 # best guess, may fail
|
24
30
|
end
|
25
31
|
|
26
32
|
def test_version
|
27
|
-
assert_equal('1.4.
|
33
|
+
assert_equal('1.4.4', Admin::VERSION)
|
28
34
|
end
|
29
35
|
|
30
36
|
def test_01_add_local_user
|
31
37
|
assert_respond_to(Admin, :add_local_user)
|
32
|
-
assert_nothing_raised{ Admin.add_local_user(
|
38
|
+
assert_nothing_raised{ Admin.add_local_user('foo') }
|
33
39
|
end
|
34
40
|
|
35
41
|
def test_add_global_user
|
@@ -39,7 +45,7 @@ class TC_Sys_Admin_Win32 < Test::Unit::TestCase
|
|
39
45
|
def test_02_config_local_user
|
40
46
|
assert_respond_to(Admin, :config_local_user)
|
41
47
|
assert_nothing_raised{
|
42
|
-
Admin.config_local_user("foo",{
|
48
|
+
Admin.config_local_user("foo", {
|
43
49
|
:description => "delete me",
|
44
50
|
:fullname => "fubar"
|
45
51
|
})
|
@@ -71,7 +77,7 @@ class TC_Sys_Admin_Win32 < Test::Unit::TestCase
|
|
71
77
|
def test_02_config_local_group
|
72
78
|
assert_respond_to(Admin, :config_local_group)
|
73
79
|
assert_nothing_raised{
|
74
|
-
Admin.config_local_group(
|
80
|
+
Admin.config_local_group('bar', {:description => 'delete me'})
|
75
81
|
}
|
76
82
|
end
|
77
83
|
|
@@ -107,10 +113,10 @@ class TC_Sys_Admin_Win32 < Test::Unit::TestCase
|
|
107
113
|
end
|
108
114
|
|
109
115
|
def test_get_user_remote
|
110
|
-
assert_nothing_raised{ Admin.get_user(@user_name,
|
111
|
-
assert_nothing_raised{ Admin.get_user(@user_id,
|
112
|
-
assert_kind_of(User, Admin.get_user(@user_name,
|
113
|
-
assert_kind_of(User, Admin.get_user(@user_id,
|
116
|
+
assert_nothing_raised{ Admin.get_user(@user_name, @@host) }
|
117
|
+
assert_nothing_raised{ Admin.get_user(@user_id, @@host) }
|
118
|
+
assert_kind_of(User, Admin.get_user(@user_name, @@host))
|
119
|
+
assert_kind_of(User, Admin.get_user(@user_id, @@host))
|
114
120
|
end
|
115
121
|
|
116
122
|
def test_users
|
@@ -127,8 +133,8 @@ class TC_Sys_Admin_Win32 < Test::Unit::TestCase
|
|
127
133
|
end
|
128
134
|
|
129
135
|
def test_users_remote
|
130
|
-
assert_nothing_raised{ Admin.users(
|
131
|
-
assert_nothing_raised{ Admin.users(
|
136
|
+
assert_nothing_raised{ Admin.users(@@host) }
|
137
|
+
assert_nothing_raised{ Admin.users(@@host){ |u| } }
|
132
138
|
end
|
133
139
|
|
134
140
|
def test_user_instance_caption
|
@@ -205,6 +211,11 @@ class TC_Sys_Admin_Win32 < Test::Unit::TestCase
|
|
205
211
|
assert_respond_to(@user, :account_type)
|
206
212
|
assert_respond_to(@user, :account_type=)
|
207
213
|
end
|
214
|
+
|
215
|
+
def test_user_instance_uid
|
216
|
+
assert_respond_to(@user, :uid)
|
217
|
+
assert_respond_to(@user, :uid=)
|
218
|
+
end
|
208
219
|
|
209
220
|
def test_get_group
|
210
221
|
assert_respond_to(Admin, :get_group)
|
@@ -219,8 +230,8 @@ class TC_Sys_Admin_Win32 < Test::Unit::TestCase
|
|
219
230
|
end
|
220
231
|
|
221
232
|
def test_get_group_remote
|
222
|
-
assert_nothing_raised{ Admin.get_group(@group_name,
|
223
|
-
assert_kind_of(Group, Admin.get_group(@group_name,
|
233
|
+
assert_nothing_raised{ Admin.get_group(@group_name, @@host) }
|
234
|
+
assert_kind_of(Group, Admin.get_group(@group_name, @@host))
|
224
235
|
end
|
225
236
|
|
226
237
|
def test_groups
|
@@ -235,10 +246,10 @@ class TC_Sys_Admin_Win32 < Test::Unit::TestCase
|
|
235
246
|
end
|
236
247
|
|
237
248
|
def test_groups_remote
|
238
|
-
assert_nothing_raised{ Admin.groups(
|
239
|
-
assert_nothing_raised{ Admin.groups(
|
240
|
-
assert_kind_of(Array, Admin.groups(
|
241
|
-
assert_kind_of(Group, Admin.groups(
|
249
|
+
assert_nothing_raised{ Admin.groups(@@host) }
|
250
|
+
assert_nothing_raised{ Admin.groups(@@host){ |g| } }
|
251
|
+
assert_kind_of(Array, Admin.groups(@@host))
|
252
|
+
assert_kind_of(Group, Admin.groups(@@host).first)
|
242
253
|
end
|
243
254
|
|
244
255
|
def test_group_instance_caption
|
@@ -292,7 +303,6 @@ class TC_Sys_Admin_Win32 < Test::Unit::TestCase
|
|
292
303
|
end
|
293
304
|
|
294
305
|
def teardown
|
295
|
-
@host = nil
|
296
306
|
@user = nil
|
297
307
|
@user_name = nil
|
298
308
|
@user_id = nil
|
@@ -300,4 +310,8 @@ class TC_Sys_Admin_Win32 < Test::Unit::TestCase
|
|
300
310
|
@group_name = nil
|
301
311
|
@group_id = nil
|
302
312
|
end
|
313
|
+
|
314
|
+
def self.shutdown
|
315
|
+
@@host = nil
|
316
|
+
end
|
303
317
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sys-admin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel J. Berger
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-11-19 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -36,8 +36,6 @@ files:
|
|
36
36
|
- MANIFEST
|
37
37
|
- Rakefile
|
38
38
|
- README
|
39
|
-
- ext/extconf.rb
|
40
|
-
- ext/sys
|
41
39
|
- ext/sys/admin.c
|
42
40
|
- ext/sys/admin.h
|
43
41
|
has_rdoc: true
|
@@ -51,7 +49,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
51
49
|
requirements:
|
52
50
|
- - ">="
|
53
51
|
- !ruby/object:Gem::Version
|
54
|
-
version: 1.8.
|
52
|
+
version: 1.8.2
|
55
53
|
version:
|
56
54
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
55
|
requirements:
|
@@ -62,7 +60,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
62
60
|
requirements: []
|
63
61
|
|
64
62
|
rubyforge_project: sysutils
|
65
|
-
rubygems_version: 1.0
|
63
|
+
rubygems_version: 1.2.0
|
66
64
|
signing_key:
|
67
65
|
specification_version: 2
|
68
66
|
summary: A unified, cross platform replacement for the "etc" package.
|