sys-admin 1.5.3 → 1.5.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +3 -0
- data/Rakefile +1 -0
- data/ext/extconf.rb +9 -5
- data/ext/sys/admin.h +38 -24
- data/sys-admin.gemspec +1 -1
- data/test/test_sys_admin.rb +1 -1
- metadata +13 -13
data/CHANGES
CHANGED
data/Rakefile
CHANGED
@@ -10,6 +10,7 @@ task :clean do
|
|
10
10
|
Dir['*.gem'].each{ |f| File.delete(f) } # Remove any .gem files
|
11
11
|
unless WINDOWS
|
12
12
|
Dir.chdir('ext') do
|
13
|
+
rm_rf('conftest.dSYM') if File.exists?('conftest.dSYM') # OS X
|
13
14
|
build_file = 'admin.' + Config::CONFIG['DLEXT']
|
14
15
|
sh 'make distclean' if File.exists?(build_file)
|
15
16
|
File.delete("sys/#{build_file}") if File.exists?("sys/#{build_file}")
|
data/ext/extconf.rb
CHANGED
@@ -39,12 +39,16 @@ else
|
|
39
39
|
utmp = have_header("utmp.h")
|
40
40
|
lastlog = have_header("lastlog.h")
|
41
41
|
|
42
|
+
if have_header("utmpx.h")
|
43
|
+
have_func("getlastlogx")
|
44
|
+
end
|
45
|
+
|
42
46
|
if utmp || lastlog
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
47
|
+
have_struct_member(
|
48
|
+
"struct lastlog",
|
49
|
+
"ll_time",
|
50
|
+
["utmp.h", "time.h", "lastlog.h"]
|
51
|
+
)
|
48
52
|
end
|
49
53
|
|
50
54
|
$CFLAGS += " -D_POSIX_PTHREAD_SEMANTICS"
|
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.4"
|
12
12
|
|
13
13
|
#if defined(__MACH__) || defined(__APPLE__)
|
14
14
|
#define __BSD__
|
@@ -18,11 +18,15 @@
|
|
18
18
|
#define __BSD__
|
19
19
|
#endif
|
20
20
|
|
21
|
+
#if defined(HAVE_UTMPX_H) && defined(HAVE_GETLASTLOGX)
|
22
|
+
#include <utmpx.h>
|
23
|
+
#else
|
21
24
|
#ifdef HAVE_LASTLOG_H
|
22
25
|
#include <lastlog.h>
|
23
26
|
#else
|
24
27
|
#include <utmp.h>
|
25
28
|
#endif
|
29
|
+
#endif
|
26
30
|
|
27
31
|
#ifndef _POSIX_LOGIN_NAME_MAX
|
28
32
|
#define _POSIX_LOGIN_NAME_MAX 9
|
@@ -422,34 +426,44 @@ void get_group_from_value(VALUE v_group, struct group* grp){
|
|
422
426
|
* still be empty or nil.
|
423
427
|
*/
|
424
428
|
int get_lastlog_info(struct passwd* pwd, VALUE v_user){
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
429
|
+
#ifdef HAVE_GETLASTLOGX
|
430
|
+
struct lastlogx log;
|
431
|
+
|
432
|
+
if(getlastlogx(pwd->pw_uid, &log)){
|
433
|
+
rb_iv_set(v_user, "@login_time", rb_time_new(log.ll_tv.tv_sec, log.ll_tv.tv_usec));
|
434
|
+
rb_iv_set(v_user, "@login_device", rb_str_new2(log.ll_line));
|
435
|
+
rb_iv_set(v_user, "@login_host", rb_str_new2(log.ll_host));
|
436
|
+
}
|
437
|
+
#else
|
438
|
+
int fd;
|
439
|
+
ssize_t bytes_read;
|
440
|
+
struct lastlog log;
|
441
|
+
int ll_size = sizeof(struct lastlog);
|
442
|
+
|
443
|
+
/* The lastlog information is not necessarily readable by all users, so
|
444
|
+
* ignore open() errors if they occur.
|
445
|
+
*/
|
446
|
+
if((fd = open(_PATH_LASTLOG, O_RDONLY)) == -1)
|
447
|
+
return -1;
|
448
|
+
|
449
|
+
if((bytes_read = pread(fd, &log, ll_size, pwd->pw_uid * ll_size)) < 0){
|
450
|
+
close(fd);
|
451
|
+
rb_raise(cAdminError, "%s", strerror(errno));
|
452
|
+
}
|
440
453
|
|
441
|
-
|
454
|
+
close(fd);
|
442
455
|
|
443
|
-
|
456
|
+
if(bytes_read > 0){
|
444
457
|
#ifdef HAVE_ST_LL_TIME
|
445
|
-
|
446
|
-
|
458
|
+
if(log.ll_time != 0)
|
459
|
+
rb_iv_set(v_user, "@login_time", rb_time_new(log.ll_time, 0));
|
460
|
+
#endif
|
461
|
+
rb_iv_set(v_user, "@login_device", rb_str_new2(log.ll_line));
|
462
|
+
rb_iv_set(v_user, "@login_host", rb_str_new2(log.ll_host));
|
463
|
+
}
|
447
464
|
#endif
|
448
|
-
rb_iv_set(v_user, "@login_device", rb_str_new2(log.ll_line));
|
449
|
-
rb_iv_set(v_user, "@login_host", rb_str_new2(log.ll_host));
|
450
|
-
}
|
451
465
|
|
452
|
-
|
466
|
+
return 0;
|
453
467
|
}
|
454
468
|
|
455
469
|
/*
|
data/sys-admin.gemspec
CHANGED
data/test/test_sys_admin.rb
CHANGED
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:
|
4
|
+
hash: 11
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 5
|
9
|
-
-
|
10
|
-
version: 1.5.
|
9
|
+
- 4
|
10
|
+
version: 1.5.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Daniel J. Berger
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-10-
|
18
|
+
date: 2010-10-07 00:00:00 -06:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -46,21 +46,21 @@ extra_rdoc_files:
|
|
46
46
|
- MANIFEST
|
47
47
|
- ext/sys/admin.c
|
48
48
|
files:
|
49
|
-
-
|
50
|
-
- README
|
49
|
+
- CHANGES
|
51
50
|
- doc/sys-admin-unix.txt
|
52
51
|
- doc/sys-admin-windows.txt
|
53
|
-
- sys-admin.gemspec
|
54
|
-
- CHANGES
|
55
52
|
- examples/groups.rb
|
56
53
|
- examples/users.rb
|
57
|
-
-
|
58
|
-
- test/test_sys_admin_unix.rb
|
59
|
-
- test/test_sys_admin.rb
|
60
|
-
- MANIFEST
|
54
|
+
- ext/extconf.rb
|
61
55
|
- ext/sys/admin.c
|
62
56
|
- ext/sys/admin.h
|
63
|
-
-
|
57
|
+
- MANIFEST
|
58
|
+
- Rakefile
|
59
|
+
- README
|
60
|
+
- sys-admin.gemspec
|
61
|
+
- test/test_sys_admin.rb
|
62
|
+
- test/test_sys_admin_unix.rb
|
63
|
+
- test/test_sys_admin_windows.rb
|
64
64
|
has_rdoc: true
|
65
65
|
homepage: http://www.github.com/djberg96/sysutils
|
66
66
|
licenses:
|