sys-admin 1.5.4 → 1.5.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +8 -0
- data/Rakefile +12 -13
- data/ext/extconf.rb +66 -54
- data/ext/sys/admin.c +1 -1
- data/ext/sys/admin.h +28 -2
- data/sys-admin.gemspec +1 -1
- data/test/test_sys_admin.rb +1 -1
- data/test/test_sys_admin_windows.rb +306 -295
- metadata +20 -20
data/CHANGES
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
== 1.5.5 - 5-Jul-2011
|
2
|
+
* Modified lastlog handling, and ignore getpwent_r and getgrent_r, on AIX.
|
3
|
+
Thanks go to Rick Ohnemus for the spot and patches.
|
4
|
+
* Explicitly set spec.cpu on Windows to 'universal' in the gem creation task.
|
5
|
+
* Fixed a bug in the User.get_login and User.get_group methods where the query
|
6
|
+
being generated was incorrect if no options were passed. Thanks go to
|
7
|
+
Matthew Brown for the spot.
|
8
|
+
|
1
9
|
== 1.5.4 - 7-Oct-2010
|
2
10
|
* Prefer the getlastlogx() function over lastlog() where supported.
|
3
11
|
|
data/Rakefile
CHANGED
@@ -2,21 +2,19 @@ require 'rake'
|
|
2
2
|
require 'rake/clean'
|
3
3
|
require 'rake/testtask'
|
4
4
|
require 'rbconfig'
|
5
|
+
include Config
|
5
6
|
|
6
|
-
WINDOWS =
|
7
|
+
WINDOWS = CONFIG['host_os'] =~ /msdos|mswin|win32|mingw|cygwin|windows/i
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
9
|
+
CLEAN.include(
|
10
|
+
'**/*.gem', # Gem files
|
11
|
+
'**/*.rbc', # Rubinius
|
12
|
+
'**/*.o', # C object file
|
13
|
+
'**/*.log', # Ruby extension build log
|
14
|
+
'**/Makefile', # C Makefile
|
15
|
+
'**/conftest.dSYM', # OS X build directory
|
16
|
+
"**/*.#{CONFIG['DLEXT']}" # C shared object
|
17
|
+
)
|
20
18
|
|
21
19
|
desc "Build the sys-admin library on UNIX systems (but don't install it)"
|
22
20
|
task :build => [:clean] do
|
@@ -37,6 +35,7 @@ namespace :gem do
|
|
37
35
|
|
38
36
|
if WINDOWS
|
39
37
|
spec.platform = Gem::Platform::CURRENT
|
38
|
+
spec.platform.cpu = 'universal'
|
40
39
|
spec.files = spec.files.reject{ |f| f.include?('ext') }
|
41
40
|
spec.add_dependency('win32-security', '>= 0.1.2')
|
42
41
|
else
|
data/ext/extconf.rb
CHANGED
@@ -1,60 +1,72 @@
|
|
1
1
|
require "mkmf"
|
2
|
+
require "rbconfig"
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
AIX = Config::CONFIG['host_os'] =~ /aix/i
|
5
|
+
|
6
|
+
# TODO: Just run the rake install task.
|
7
|
+
if File::ALT_SEPARATOR
|
8
|
+
STDERR.puts "Use the 'rake install' task to install on MS Windows."
|
9
|
+
STDERR.puts "Exiting. The sys-admin package was NOT installed."
|
10
|
+
exit
|
7
11
|
else
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
12
|
+
dir_config('admin')
|
13
|
+
|
14
|
+
# Some versions of AIX apparently have buggy implementations of certain
|
15
|
+
# re-entrant functions, so they're skipped for now.
|
16
|
+
|
17
|
+
have_func("getlogin_r")
|
18
|
+
have_func("getlogin")
|
19
|
+
have_func("getenv")
|
20
|
+
|
21
|
+
have_func("getpwuid_r")
|
22
|
+
have_func("getpwuid")
|
23
|
+
have_func("getpwnam_r")
|
24
|
+
have_func("getpwnam")
|
25
|
+
have_func("getpwent_r") unless AIX
|
26
|
+
have_func("getpwent")
|
27
|
+
|
28
|
+
have_func("getgrgid_r")
|
29
|
+
have_func("getgrgid")
|
30
|
+
have_func("getgrnam_r")
|
31
|
+
have_func("getgrnam")
|
32
|
+
have_func("getgrent_r") unless AIX
|
33
|
+
have_func("getgrent")
|
34
|
+
|
35
|
+
have_struct_member("struct passwd", "pw_gecos", "pwd.h")
|
36
|
+
have_struct_member("struct passwd", "pw_change", "pwd.h")
|
37
|
+
have_struct_member("struct passwd", "pw_quota", "pwd.h")
|
38
|
+
have_struct_member("struct passwd", "pw_age", "pwd.h")
|
39
|
+
have_struct_member("struct passwd", "pw_class", "pwd.h")
|
40
|
+
have_struct_member("struct passwd", "pw_comment", "pwd.h")
|
41
|
+
have_struct_member("struct passwd", "pw_expire", "pwd.h")
|
42
|
+
have_struct_member("struct passwd", "pw_passwd", "pwd.h")
|
43
|
+
|
44
|
+
have_struct_member("struct group", "gr_passwd", "grp.h")
|
45
|
+
|
46
|
+
if have_header("usersec.h") # AIX
|
47
|
+
have_func("getuserattr", "usersec.h")
|
48
|
+
else
|
49
|
+
utmp = have_header("utmp.h")
|
50
|
+
lastlog = have_header("lastlog.h")
|
51
|
+
|
52
|
+
if have_header("utmpx.h")
|
53
|
+
have_func("getlastlogx")
|
54
|
+
end
|
55
|
+
|
56
|
+
if utmp || lastlog
|
57
|
+
have_struct_member(
|
58
|
+
"struct lastlog",
|
59
|
+
"ll_time",
|
60
|
+
["utmp.h", "time.h", "lastlog.h"]
|
61
|
+
)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
$CFLAGS += " -D_POSIX_PTHREAD_SEMANTICS"
|
66
|
+
|
67
|
+
if RUBY_PLATFORM =~ /linux|bsd/i
|
68
|
+
$CFLAGS += " -D_GNU_SOURCE -D_REENTRANT"
|
69
|
+
end
|
58
70
|
end
|
59
71
|
|
60
72
|
create_makefile('sys/admin', 'sys')
|
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.5.
|
11
|
+
#define SYS_ADMIN_VERSION "1.5.5"
|
12
12
|
|
13
13
|
#if defined(__MACH__) || defined(__APPLE__)
|
14
14
|
#define __BSD__
|
@@ -18,6 +18,9 @@
|
|
18
18
|
#define __BSD__
|
19
19
|
#endif
|
20
20
|
|
21
|
+
#if defined(HAVE_USERSEC_H)
|
22
|
+
#include <usersec.h>
|
23
|
+
#else
|
21
24
|
#if defined(HAVE_UTMPX_H) && defined(HAVE_GETLASTLOGX)
|
22
25
|
#include <utmpx.h>
|
23
26
|
#else
|
@@ -27,6 +30,7 @@
|
|
27
30
|
#include <utmp.h>
|
28
31
|
#endif
|
29
32
|
#endif
|
33
|
+
#endif
|
30
34
|
|
31
35
|
#ifndef _POSIX_LOGIN_NAME_MAX
|
32
36
|
#define _POSIX_LOGIN_NAME_MAX 9
|
@@ -249,7 +253,7 @@ static VALUE get_user(struct passwd* pwd){
|
|
249
253
|
rb_iv_set(v_user, "@change", rb_time_new(pwd->pw_change, 0));
|
250
254
|
#endif
|
251
255
|
|
252
|
-
#if defined(HAVE_LASTLOG_H) || defined(HAVE_UTMP_H)
|
256
|
+
#if defined(HAVE_LASTLOG_H) || defined(HAVE_UTMP_H) || defined(HAVE_USERSEC_H)
|
253
257
|
get_lastlog_info(pwd, v_user);
|
254
258
|
#endif
|
255
259
|
|
@@ -426,6 +430,27 @@ void get_group_from_value(VALUE v_group, struct group* grp){
|
|
426
430
|
* still be empty or nil.
|
427
431
|
*/
|
428
432
|
int get_lastlog_info(struct passwd* pwd, VALUE v_user){
|
433
|
+
#ifdef HAVE_USERSEC_H
|
434
|
+
char *lasthost;
|
435
|
+
int lasttime;
|
436
|
+
char *lasttty;
|
437
|
+
|
438
|
+
if (setuserdb(S_READ) == -1) {
|
439
|
+
return -1;
|
440
|
+
}
|
441
|
+
|
442
|
+
if (getuserattr(pwd->pw_name, S_LASTTIME, &lasttime, SEC_INT) == -1
|
443
|
+
|| getuserattr(pwd->pw_name, S_LASTTTY, &lasttty, SEC_CHAR) == -1
|
444
|
+
|| getuserattr(pwd->pw_name, S_LASTHOST, &lasthost, SEC_CHAR) == -1) {
|
445
|
+
enduserdb();
|
446
|
+
return -1;
|
447
|
+
}
|
448
|
+
|
449
|
+
rb_iv_set(v_user, "@login_time", rb_time_new(lasttime, 0));
|
450
|
+
rb_iv_set(v_user, "@login_device", rb_str_new2(lasttty));
|
451
|
+
rb_iv_set(v_user, "@login_host", rb_str_new2(lasthost));
|
452
|
+
enduserdb();
|
453
|
+
#else
|
429
454
|
#ifdef HAVE_GETLASTLOGX
|
430
455
|
struct lastlogx log;
|
431
456
|
|
@@ -461,6 +486,7 @@ int get_lastlog_info(struct passwd* pwd, VALUE v_user){
|
|
461
486
|
rb_iv_set(v_user, "@login_device", rb_str_new2(log.ll_line));
|
462
487
|
rb_iv_set(v_user, "@login_host", rb_str_new2(log.ll_host));
|
463
488
|
}
|
489
|
+
#endif
|
464
490
|
#endif
|
465
491
|
|
466
492
|
return 0;
|
data/sys-admin.gemspec
CHANGED
data/test/test_sys_admin.rb
CHANGED
@@ -13,321 +13,332 @@ gem 'test-unit'
|
|
13
13
|
require 'test/unit'
|
14
14
|
require 'sys/admin'
|
15
15
|
require 'socket'
|
16
|
+
require 'etc'
|
16
17
|
include Sys
|
17
18
|
|
18
19
|
class TC_Sys_Admin_Win32 < Test::Unit::TestCase
|
19
|
-
|
20
|
-
|
21
|
-
|
20
|
+
def self.startup
|
21
|
+
@@host = Socket.gethostname
|
22
|
+
end
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
24
|
+
def setup
|
25
|
+
@user = User.new
|
26
|
+
@user_name = 'Guest'
|
27
|
+
@user_id = 501 # best guess, may fail
|
28
|
+
@group = Group.new
|
29
|
+
@group_name = 'Guests'
|
30
|
+
@group_id = 546 # best guess, may fail
|
31
|
+
end
|
31
32
|
|
32
|
-
|
33
|
+
# Admin singleton methods
|
33
34
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
35
|
+
def test_01_add_user
|
36
|
+
assert_respond_to(Admin, :add_user)
|
37
|
+
assert_nothing_raised{
|
38
|
+
Admin.add_user(:name => 'foo', :password => 'a1b2c3D4')
|
39
|
+
}
|
40
|
+
end
|
40
41
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
def test_01_add_group
|
59
|
-
assert_respond_to(Admin, :add_group)
|
60
|
-
assert_nothing_raised{ Admin.add_group(:name => 'bar') }
|
61
|
-
end
|
62
|
-
|
63
|
-
def test_02_configure_group
|
64
|
-
assert_respond_to(Admin, :configure_group)
|
65
|
-
assert_nothing_raised{
|
66
|
-
Admin.configure_group(:name => 'bar', :description => 'delete me')
|
67
|
-
}
|
68
|
-
end
|
69
|
-
|
70
|
-
def test_03_delete_group
|
71
|
-
assert_respond_to(Admin, :delete_group)
|
72
|
-
assert_nothing_raised{ Admin.delete_group('bar') }
|
73
|
-
end
|
74
|
-
|
75
|
-
def test_get_login_basic
|
76
|
-
assert_respond_to(Admin, :get_login)
|
77
|
-
assert_nothing_raised{ Admin.get_login }
|
78
|
-
end
|
42
|
+
def test_02_config_user
|
43
|
+
assert_respond_to(Admin, :configure_user)
|
44
|
+
assert_nothing_raised{
|
45
|
+
Admin.configure_user(
|
46
|
+
:name => 'foo',
|
47
|
+
:description => 'delete me',
|
48
|
+
:fullname => 'fubar',
|
49
|
+
:password => ['a1b2c3D4', 'd1c2b3A4']
|
50
|
+
)
|
51
|
+
}
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_03_delete_user
|
55
|
+
assert_respond_to(Admin, :delete_user)
|
56
|
+
assert_nothing_raised{ Admin.delete_user('foo') }
|
57
|
+
end
|
79
58
|
|
80
|
-
|
81
|
-
|
82
|
-
|
59
|
+
def test_01_add_group
|
60
|
+
assert_respond_to(Admin, :add_group)
|
61
|
+
assert_nothing_raised{ Admin.add_group(:name => 'bar') }
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_02_configure_group
|
65
|
+
assert_respond_to(Admin, :configure_group)
|
66
|
+
assert_nothing_raised{
|
67
|
+
Admin.configure_group(:name => 'bar', :description => 'delete me')
|
68
|
+
}
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_03_delete_group
|
72
|
+
assert_respond_to(Admin, :delete_group)
|
73
|
+
assert_nothing_raised{ Admin.delete_group('bar') }
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_get_login_basic
|
77
|
+
assert_respond_to(Admin, :get_login)
|
78
|
+
assert_nothing_raised{ Admin.get_login }
|
79
|
+
end
|
83
80
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
def test_get_user_basic
|
89
|
-
assert_respond_to(Admin, :get_user)
|
90
|
-
end
|
91
|
-
|
92
|
-
def test_get_user_by_string
|
93
|
-
assert_nothing_raised{ Admin.get_user(@user_name, :localaccount => true) }
|
94
|
-
assert_kind_of(User, Admin.get_user(@user_name, :localaccount => true))
|
95
|
-
end
|
81
|
+
def test_get_login
|
82
|
+
assert_kind_of(String, Admin.get_login)
|
83
|
+
end
|
96
84
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
assert_nothing_raised{ Admin.get_user(@user_name, options) }
|
105
|
-
assert_kind_of(User, Admin.get_user(@user_name, options))
|
106
|
-
end
|
85
|
+
def test_get_login_expected_errors
|
86
|
+
assert_raise(ArgumentError){ Admin.get_login('foo') }
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_get_user_basic
|
90
|
+
assert_respond_to(Admin, :get_user)
|
91
|
+
end
|
107
92
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
end
|
93
|
+
def test_get_user_by_string
|
94
|
+
assert_nothing_raised{ Admin.get_user(@user_name, :localaccount => true) }
|
95
|
+
assert_kind_of(User, Admin.get_user(@user_name, :localaccount => true))
|
96
|
+
end
|
113
97
|
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
98
|
+
def test_get_user_by_uid
|
99
|
+
assert_nothing_raised{ Admin.get_user(@user_id, :localaccount => true) }
|
100
|
+
assert_kind_of(User, Admin.get_user(@user_id, :localaccount => true))
|
101
|
+
end
|
102
|
+
|
103
|
+
def test_get_user_by_string_with_options
|
104
|
+
options = {:host => @@host, :localaccount => true}
|
105
|
+
assert_nothing_raised{ Admin.get_user(@user_name, options) }
|
106
|
+
assert_kind_of(User, Admin.get_user(@user_name, options))
|
107
|
+
end
|
122
108
|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
109
|
+
def test_get_user_by_uid_with_options
|
110
|
+
options = {:host => @@host, :localaccount => true}
|
111
|
+
assert_nothing_raised{ Admin.get_user(@user_id, options) }
|
112
|
+
assert_kind_of(User, Admin.get_user(@user_id, options))
|
113
|
+
end
|
127
114
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
}
|
133
|
-
assert_kind_of(User, array[0])
|
134
|
-
end
|
115
|
+
def test_get_user_with_no_options
|
116
|
+
assert_nothing_raised{ Admin.get_user(Etc.getlogin) }
|
117
|
+
assert_kind_of(User, Admin.get_user(Etc.getlogin))
|
118
|
+
end
|
135
119
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
120
|
+
def test_get_user_expected_errors
|
121
|
+
assert_raises(ArgumentError){ Admin.get_user }
|
122
|
+
end
|
123
|
+
|
124
|
+
def test_users_basic
|
125
|
+
assert_respond_to(Admin, :users)
|
126
|
+
assert_nothing_raised{ Admin.users(:localaccount => true) }
|
127
|
+
end
|
144
128
|
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
def test_get_group_with_options
|
151
|
-
assert_nothing_raised{ Admin.get_group(@group_name, :localaccount => true) }
|
152
|
-
assert_kind_of(Group, Admin.get_group(@group_name, :localaccount => true))
|
153
|
-
end
|
129
|
+
def test_users
|
130
|
+
assert_kind_of(Array, Admin.users(:localaccount => true))
|
131
|
+
assert_kind_of(User, Admin.users(:localaccount => true).first)
|
132
|
+
end
|
154
133
|
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
end
|
134
|
+
def test_users_with_block
|
135
|
+
array = []
|
136
|
+
assert_nothing_raised{
|
137
|
+
Admin.users(:localaccount => true){ |u| array << u }
|
138
|
+
}
|
139
|
+
assert_kind_of(User, array[0])
|
140
|
+
end
|
163
141
|
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
Admin.groups(:localaccount => true){ |g| array << g }
|
173
|
-
}
|
174
|
-
assert_kind_of(Group, array[0])
|
175
|
-
end
|
142
|
+
def test_get_group_basic
|
143
|
+
assert_respond_to(Admin, :get_group)
|
144
|
+
end
|
145
|
+
|
146
|
+
def test_get_group_by_name
|
147
|
+
assert_nothing_raised{ Admin.get_group(@group_name, :localaccount => true) }
|
148
|
+
assert_kind_of(Group, Admin.get_group(@group_name, :localaccount => true))
|
149
|
+
end
|
176
150
|
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
assert_respond_to(@user, :description=)
|
187
|
-
end
|
188
|
-
|
189
|
-
def test_user_instance_domain
|
190
|
-
assert_respond_to(@user, :domain)
|
191
|
-
assert_respond_to(@user, :domain=)
|
192
|
-
end
|
193
|
-
|
194
|
-
def test_user_instance_password
|
195
|
-
assert_respond_to(@user, :password)
|
196
|
-
assert_respond_to(@user, :password=)
|
197
|
-
end
|
198
|
-
|
199
|
-
def test_user_instance_full_name
|
200
|
-
assert_respond_to(@user, :full_name)
|
201
|
-
assert_respond_to(@user, :full_name=)
|
202
|
-
end
|
203
|
-
|
204
|
-
def test_user_instance_name
|
205
|
-
assert_respond_to(@user, :name)
|
206
|
-
assert_respond_to(@user, :name=)
|
207
|
-
end
|
208
|
-
|
209
|
-
def test_user_instance_sid
|
210
|
-
assert_respond_to(@user, :sid)
|
211
|
-
assert_respond_to(@user, :sid=)
|
212
|
-
end
|
213
|
-
|
214
|
-
def test_user_instance_status
|
215
|
-
assert_respond_to(@user, :status)
|
216
|
-
assert_respond_to(@user, :status=)
|
217
|
-
end
|
218
|
-
|
219
|
-
def test_user_instance_disabled
|
220
|
-
assert_respond_to(@user, :disabled?)
|
221
|
-
assert_respond_to(@user, :disabled=)
|
222
|
-
end
|
223
|
-
|
224
|
-
def test_user_instance_local
|
225
|
-
assert_respond_to(@user, :local?)
|
226
|
-
assert_respond_to(@user, :local=)
|
227
|
-
end
|
228
|
-
|
229
|
-
def test_user_instance_lockout
|
230
|
-
assert_respond_to(@user, :lockout?)
|
231
|
-
assert_respond_to(@user, :lockout=)
|
232
|
-
end
|
233
|
-
|
234
|
-
def test_user_instance_password_changeable
|
235
|
-
assert_respond_to(@user, :password_changeable?)
|
236
|
-
assert_respond_to(@user, :password_changeable=)
|
237
|
-
end
|
238
|
-
|
239
|
-
def test_user_instance_password_expires
|
240
|
-
assert_respond_to(@user, :password_expires?)
|
241
|
-
assert_respond_to(@user, :password_expires=)
|
242
|
-
end
|
243
|
-
|
244
|
-
def test_user_instance_password_required
|
245
|
-
assert_respond_to(@user, :password_required?)
|
246
|
-
assert_respond_to(@user, :password_required=)
|
247
|
-
end
|
248
|
-
|
249
|
-
def test_user_instance_account_type
|
250
|
-
assert_respond_to(@user, :account_type)
|
251
|
-
assert_respond_to(@user, :account_type=)
|
252
|
-
end
|
151
|
+
def test_get_group_by_gid
|
152
|
+
assert_nothing_raised{ Admin.get_group(@group_id, :localaccount => true) }
|
153
|
+
assert_kind_of(Group, Admin.get_group(@group_id, :localaccount => true))
|
154
|
+
end
|
155
|
+
|
156
|
+
def test_get_group_with_options
|
157
|
+
assert_nothing_raised{ Admin.get_group(@group_name, :localaccount => true) }
|
158
|
+
assert_kind_of(Group, Admin.get_group(@group_name, :localaccount => true))
|
159
|
+
end
|
253
160
|
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
161
|
+
def test_get_group_with_no_options
|
162
|
+
assert_nothing_raised{ Admin.get_group("Administrators") }
|
163
|
+
assert_kind_of(Group, Admin.get_group("Administrators"))
|
164
|
+
end
|
165
|
+
|
166
|
+
def test_get_group_expected_errors
|
167
|
+
assert_raise(ArgumentError){ Admin.get_group }
|
168
|
+
end
|
169
|
+
|
170
|
+
def test_groups_basic
|
171
|
+
assert_respond_to(Admin, :groups)
|
172
|
+
assert_nothing_raised{ Admin.groups(:localaccount => true) }
|
173
|
+
end
|
174
|
+
|
175
|
+
def test_groups
|
176
|
+
assert_kind_of(Array, Admin.groups(:localaccount => true))
|
177
|
+
assert_kind_of(Group, Admin.groups(:localaccount => true).first)
|
178
|
+
end
|
179
|
+
|
180
|
+
def test_groups_with_block
|
181
|
+
array = []
|
182
|
+
assert_nothing_raised{
|
183
|
+
Admin.groups(:localaccount => true){ |g| array << g }
|
184
|
+
}
|
185
|
+
assert_kind_of(Group, array[0])
|
186
|
+
end
|
187
|
+
|
188
|
+
# User class
|
189
|
+
|
190
|
+
def test_user_instance_caption
|
191
|
+
assert_respond_to(@user, :caption)
|
192
|
+
assert_respond_to(@user, :caption=)
|
193
|
+
end
|
194
|
+
|
195
|
+
def test_user_instance_description
|
196
|
+
assert_respond_to(@user, :description)
|
197
|
+
assert_respond_to(@user, :description=)
|
198
|
+
end
|
199
|
+
|
200
|
+
def test_user_instance_domain
|
201
|
+
assert_respond_to(@user, :domain)
|
202
|
+
assert_respond_to(@user, :domain=)
|
203
|
+
end
|
204
|
+
|
205
|
+
def test_user_instance_password
|
206
|
+
assert_respond_to(@user, :password)
|
207
|
+
assert_respond_to(@user, :password=)
|
208
|
+
end
|
209
|
+
|
210
|
+
def test_user_instance_full_name
|
211
|
+
assert_respond_to(@user, :full_name)
|
212
|
+
assert_respond_to(@user, :full_name=)
|
213
|
+
end
|
214
|
+
|
215
|
+
def test_user_instance_name
|
216
|
+
assert_respond_to(@user, :name)
|
217
|
+
assert_respond_to(@user, :name=)
|
218
|
+
end
|
219
|
+
|
220
|
+
def test_user_instance_sid
|
221
|
+
assert_respond_to(@user, :sid)
|
222
|
+
assert_respond_to(@user, :sid=)
|
223
|
+
end
|
224
|
+
|
225
|
+
def test_user_instance_status
|
226
|
+
assert_respond_to(@user, :status)
|
227
|
+
assert_respond_to(@user, :status=)
|
228
|
+
end
|
229
|
+
|
230
|
+
def test_user_instance_disabled
|
231
|
+
assert_respond_to(@user, :disabled?)
|
232
|
+
assert_respond_to(@user, :disabled=)
|
233
|
+
end
|
234
|
+
|
235
|
+
def test_user_instance_local
|
236
|
+
assert_respond_to(@user, :local?)
|
237
|
+
assert_respond_to(@user, :local=)
|
238
|
+
end
|
239
|
+
|
240
|
+
def test_user_instance_lockout
|
241
|
+
assert_respond_to(@user, :lockout?)
|
242
|
+
assert_respond_to(@user, :lockout=)
|
243
|
+
end
|
244
|
+
|
245
|
+
def test_user_instance_password_changeable
|
246
|
+
assert_respond_to(@user, :password_changeable?)
|
247
|
+
assert_respond_to(@user, :password_changeable=)
|
248
|
+
end
|
249
|
+
|
250
|
+
def test_user_instance_password_expires
|
251
|
+
assert_respond_to(@user, :password_expires?)
|
252
|
+
assert_respond_to(@user, :password_expires=)
|
253
|
+
end
|
254
|
+
|
255
|
+
def test_user_instance_password_required
|
256
|
+
assert_respond_to(@user, :password_required?)
|
257
|
+
assert_respond_to(@user, :password_required=)
|
258
|
+
end
|
259
|
+
|
260
|
+
def test_user_instance_account_type
|
261
|
+
assert_respond_to(@user, :account_type)
|
262
|
+
assert_respond_to(@user, :account_type=)
|
263
|
+
end
|
264
|
+
|
265
|
+
def test_user_instance_uid
|
266
|
+
assert_respond_to(@user, :uid)
|
267
|
+
assert_respond_to(@user, :uid=)
|
268
|
+
end
|
269
|
+
|
270
|
+
def test_user_dir_basic
|
271
|
+
assert_respond_to(@user, :dir)
|
272
|
+
assert_respond_to(@user, :dir=)
|
273
|
+
end
|
274
|
+
|
275
|
+
def test_user_dir
|
276
|
+
assert_nothing_raised{ @user = Admin.get_user(@user_name, :localaccount => true) }
|
277
|
+
assert_kind_of([String, NilClass], @user.dir)
|
278
|
+
end
|
279
|
+
|
280
|
+
# Group class
|
281
|
+
|
282
|
+
def test_group_instance_caption
|
283
|
+
assert_respond_to(@group, :caption)
|
284
|
+
assert_respond_to(@group, :caption=)
|
285
|
+
end
|
286
|
+
|
287
|
+
def test_group_instance_description
|
288
|
+
assert_respond_to(@group, :description)
|
289
|
+
assert_respond_to(@group, :description=)
|
290
|
+
end
|
291
|
+
|
292
|
+
def test_group_instance_domain
|
293
|
+
assert_respond_to(@group, :domain)
|
294
|
+
assert_respond_to(@group, :domain=)
|
295
|
+
end
|
296
|
+
|
297
|
+
def test_group_instance_install_date
|
298
|
+
assert_respond_to(@group, :install_date)
|
299
|
+
assert_respond_to(@group, :install_date=)
|
300
|
+
end
|
301
|
+
|
302
|
+
def test_group_instance_name
|
303
|
+
assert_respond_to(@group, :name)
|
304
|
+
assert_respond_to(@group, :name)
|
305
|
+
end
|
306
|
+
|
307
|
+
def test_group_instance_gid
|
308
|
+
assert_respond_to(@group, :gid)
|
309
|
+
assert_respond_to(@group, :gid=)
|
310
|
+
end
|
311
|
+
|
312
|
+
def test_group_instance_status
|
313
|
+
assert_respond_to(@group, :status)
|
314
|
+
assert_respond_to(@group, :status=)
|
315
|
+
end
|
316
|
+
|
317
|
+
def test_group_instance_sid
|
318
|
+
assert_respond_to(@group, :sid)
|
319
|
+
assert_respond_to(@group, :sid=)
|
320
|
+
end
|
321
|
+
|
322
|
+
def test_group_instance_sid_type
|
323
|
+
assert_respond_to(@group, :sid_type)
|
324
|
+
assert_respond_to(@group, :sid_type=)
|
325
|
+
end
|
326
|
+
|
327
|
+
def test_group_instance_local
|
328
|
+
assert_respond_to(@group, :local?)
|
329
|
+
assert_respond_to(@group, :local=)
|
330
|
+
end
|
320
331
|
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
332
|
+
def teardown
|
333
|
+
@user = nil
|
334
|
+
@user_name = nil
|
335
|
+
@user_id = nil
|
336
|
+
@group = nil
|
337
|
+
@group_name = nil
|
338
|
+
@group_id = nil
|
339
|
+
end
|
329
340
|
|
330
|
-
|
331
|
-
|
332
|
-
|
341
|
+
def self.shutdown
|
342
|
+
@@host = nil
|
343
|
+
end
|
333
344
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sys-admin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 9
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 5
|
9
|
-
-
|
10
|
-
version: 1.5.
|
9
|
+
- 5
|
10
|
+
version: 1.5.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Daniel J. Berger
|
@@ -15,8 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
19
|
-
default_executable:
|
18
|
+
date: 2011-07-05 00:00:00 Z
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
21
|
name: test-unit
|
@@ -46,25 +45,26 @@ extra_rdoc_files:
|
|
46
45
|
- MANIFEST
|
47
46
|
- ext/sys/admin.c
|
48
47
|
files:
|
49
|
-
-
|
50
|
-
- doc/sys-admin-unix.txt
|
51
|
-
- doc/sys-admin-windows.txt
|
52
|
-
- examples/groups.rb
|
53
|
-
- examples/users.rb
|
54
|
-
- ext/extconf.rb
|
55
|
-
- ext/sys/admin.c
|
48
|
+
- sys-admin.gemspec
|
56
49
|
- ext/sys/admin.h
|
57
|
-
-
|
58
|
-
-
|
50
|
+
- ext/sys/admin.c
|
51
|
+
- ext/extconf.rb
|
59
52
|
- README
|
60
|
-
-
|
61
|
-
- test/test_sys_admin.rb
|
53
|
+
- Rakefile
|
62
54
|
- test/test_sys_admin_unix.rb
|
55
|
+
- test/test_sys_admin.rb
|
63
56
|
- test/test_sys_admin_windows.rb
|
64
|
-
|
57
|
+
- MANIFEST
|
58
|
+
- doc/sys-admin-unix.txt
|
59
|
+
- doc/sys-admin-windows.txt
|
60
|
+
- CHANGES
|
61
|
+
- examples/groups.rb
|
62
|
+
- examples/users.rb
|
65
63
|
homepage: http://www.github.com/djberg96/sysutils
|
66
64
|
licenses:
|
67
65
|
- Artistic 2.0
|
66
|
+
metadata: {}
|
67
|
+
|
68
68
|
post_install_message:
|
69
69
|
rdoc_options: []
|
70
70
|
|
@@ -91,9 +91,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
91
91
|
requirements: []
|
92
92
|
|
93
93
|
rubyforge_project: sysutils
|
94
|
-
rubygems_version: 1.
|
94
|
+
rubygems_version: 1.8.5
|
95
95
|
signing_key:
|
96
|
-
specification_version:
|
96
|
+
specification_version: 4
|
97
97
|
summary: A unified, cross platform replacement for the "etc" library.
|
98
98
|
test_files:
|
99
99
|
- test/test_sys_admin.rb
|