login_records 0.1.1 → 0.1.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bcab735dc5e17c94520381018a41e6eca41f1a27ed49749c04dd16ec4882da8c
4
- data.tar.gz: 61c9cc1608848aeb981e5a160fca671c4cacc007a4226fb446eb9d37bd86bf6d
3
+ metadata.gz: f274799ebf478a248cd69c80c08fef6ae1ace4b2e0e465511c584f40fed8f420
4
+ data.tar.gz: 2563fdaf7705cd8eac96be961391352a8e088f06f7ea0c32ebcd59b3feafe022
5
5
  SHA512:
6
- metadata.gz: d15fc66dda2a1514790ac7a979a86356a9350c30e0a9fece223ce44b38a993b7ca709d9d8d66c0f67451ae4be7a3773ff850fd3668c2fdbb9dc14474054f4ad0
7
- data.tar.gz: 8bbb56adadd36759dc0344c88fac4f92e315a34a858b48fabbdab3276352b406e54e1fa75b7dad08bd82ab7c3aac3a69d1cb22d20b2224adb9224bd591d1b652
6
+ metadata.gz: 9c9821002c5a5d38515725a47077f96a1aefc75ee0fbc8b4c54f70e323bb140ace21c9cfacb5122a747b9c57b91f54964f3ddd1b9ca5098f51be75a3eeca0ba2
7
+ data.tar.gz: deae6d466c7d042bcdae08997ca495d287b3beea9860e3e7c6f8b83d1cd391a662cb979cb963b2c9496b4ee679e1db561461804e384ef53bc50c0366eaa9e2fc
@@ -1,10 +1,42 @@
1
1
  #include <utmpx.h>
2
2
  #include <paths.h>
3
+ #include <unistd.h>
3
4
  #include "ruby.h"
4
5
 
6
+ #ifndef _PATH_UTMP
7
+ #define _PATH_UTMP "/var/log/wtmp"
8
+ #endif
9
+
10
+ #ifndef _PATH_UTMP
11
+ #define _PATH_UTMP "/var/run/utmp"
12
+ #endif
13
+
14
+ #ifndef _PATH_BTMP
15
+ #define _PATH_BTMP "/var/log/btmp"
16
+ #endif
17
+
18
+ #ifndef R_OK
19
+ #define R_OK 4
20
+ #endif
21
+
22
+ #ifndef F_OK
23
+ #define F_OK 0
24
+ #endif
25
+
5
26
  void read_log(VALUE ary, char *log_path) {
6
- if(access(log_path, R_OK))
27
+ if(access(log_path, R_OK)) {
28
+ char message[256] ;
29
+
30
+ if(access(log_path, F_OK) == 0) {
31
+ sprintf(message, "Permission denied while reading %s", log_path) ;
32
+ rb_raise(rb_eRuntimeError, message, 0) ;
33
+ } else {
34
+ sprintf(message, "No such file or directory %s", log_path) ;
35
+ rb_raise(rb_eRuntimeError, message, 0) ;
36
+ }
37
+
7
38
  return ;
39
+ }
8
40
 
9
41
  struct utmpx data ;
10
42
 
@@ -59,9 +91,16 @@ VALUE utmp(VALUE obj) {
59
91
  return ary ;
60
92
  }
61
93
 
94
+ VALUE btmp(VALUE obj) {
95
+ VALUE ary = rb_ary_new() ;
96
+ read_log(ary, _PATH_BTMP) ;
97
+ return ary ;
98
+ }
99
+
62
100
  void Init_login_records() {
63
101
  VALUE _login_records = rb_define_module("LoginRecords") ;
64
102
 
65
103
  rb_define_module_function(_login_records, "wtmp", wtmp, 0) ;
66
104
  rb_define_module_function(_login_records, "utmp", utmp, 0) ;
105
+ rb_define_module_function(_login_records, "btmp", btmp, 0) ;
67
106
  }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LoginRecords
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: login_records
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sourav Goswami
@@ -10,7 +10,8 @@ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2021-01-26 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: LoginRecords Allows you to read UTML and WMTP files on Linux
13
+ description: Using utmpx.h, LoginRecords Allows you to parse UTMP, WMTP and BTMP files
14
+ on Linux
14
15
  email:
15
16
  - souravgoswami@protonmail.com
16
17
  executables: []
@@ -35,7 +36,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
35
36
  requirements:
36
37
  - - ">="
37
38
  - !ruby/object:Gem::Version
38
- version: '2.1'
39
+ version: '1.9'
39
40
  required_rubygems_version: !ruby/object:Gem::Requirement
40
41
  requirements:
41
42
  - - ">="
@@ -45,5 +46,6 @@ requirements: []
45
46
  rubygems_version: 3.1.4
46
47
  signing_key:
47
48
  specification_version: 4
48
- summary: LoginRecords Allows you to read UTML and WMTP files on Linux
49
+ summary: Using utmpx.h, LoginRecords Allows you to parse UTMP, WMTP and BTMP files
50
+ on Linux
49
51
  test_files: []