sys-admin 1.8.2 → 1.8.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6c191067356dcf507ffbbed68d96c9a13bf7fa31cb6feaaadbcfd2f219ec873b
4
- data.tar.gz: db228e72e4c6a3c0bff4acb11f56066819aea11d1c2b4b82f36b387b245ac1b9
3
+ metadata.gz: 71c3663b6e540ada2dcca2c54a181b92269549bb5ee6bb129d2bb513edd61283
4
+ data.tar.gz: 0dc5d42a1e970f9af5920e4e20c5cadbf9521712ef6d00bdbb555158b758f205
5
5
  SHA512:
6
- metadata.gz: 3a63f387f83d94ad3654d1e1a02ed082e53ce2841f6cdb12c00d72a6cc9a89bbd2fbaceb4feb1c5f8c440c51bd9cbfe9feef6bb202a996033ab9ac98889f35dd
7
- data.tar.gz: b46f0d812861d7232c62d307ad6806c0e8de4b54a277ade7f0f30530239479fcd1bf86ba391301945499fe8f9e8a48c13355a0e27bd5ec5f35319575845ee287
6
+ metadata.gz: 99090f3e3d87d4f13d896845a9432815d8f9ff5287fab78c295263edbec8d40859025b6b1880c1ddde98b40efdee10fd8ef161c5a41a2cab8b52db2103f4c03a
7
+ data.tar.gz: d9ba7025f7254feaae09eb4feb2bde3cf915b7bf7b4ffaa546c1ff9ef9d6fe2f3c9b57511a6a9f893b0d93269cd546d5ff02b5fa0fd533c64c33fbbb6bdc42bf
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGES.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## 1.8.4 - 12-Jun-2024
2
+ * Fixes for DragonFly BSD support.
3
+
4
+ ## 1.8.3 - 20-Apr-2024
5
+ * Fixed up the get_group method on most platforms. Previously it was allocating
6
+ slightly more memory than it needed (wrong struct, oops). In addition, the
7
+ error handling wasn't consistent because I can't read a man page properly.
8
+ * More specs were added to properly test the get_group updates.
9
+ * The github actions test matrix was updated.
10
+
1
11
  ## 1.8.2 - 9-Apr-2023
2
12
  * Lots of rubocop related updates.
3
13
  * Refactored specs to use shared specs.
data/README.md CHANGED
@@ -162,7 +162,7 @@ None that I'm aware of. If you find any, please log them on the project page at:
162
162
  Apache-2.0
163
163
 
164
164
  ## Copyright
165
- (C) 2005-2020, Daniel J. Berger
165
+ (C) 2005-2024, Daniel J. Berger
166
166
  All Rights Reserved
167
167
 
168
168
  ## Author
data/Rakefile CHANGED
@@ -31,7 +31,7 @@ RSpec::Core::RakeTask.new(:spec) do |t|
31
31
  t.rspec_opts = '-Ilib/linux'
32
32
  when /sunos|solaris/i
33
33
  t.rspec_opts = '-Ilib/sunos'
34
- when /bsd/i
34
+ when /bsd|dragonfly/i
35
35
  t.rspec_opts = '-Ilib/bsd'
36
36
  when /windows|win32|mingw|cygwin|dos/i
37
37
  t.rspec_opts = '-Ilib/windows'
data/lib/bsd/sys/admin.rb CHANGED
@@ -43,7 +43,7 @@ module Sys
43
43
  pw_expire time_t
44
44
  ]
45
45
 
46
- if RbConfig::CONFIG['host_os'] =~ /freebsd/i
46
+ if RbConfig::CONFIG['host_os'] =~ /freebsd|dragonfly/i
47
47
  fields.push(:pw_fields, :int)
48
48
  end
49
49
 
@@ -131,7 +131,7 @@ module Sys
131
131
  def self.get_group(gid)
132
132
  size = 1024
133
133
  buf = FFI::MemoryPointer.new(:char, size)
134
- pbuf = FFI::MemoryPointer.new(PasswdStruct)
134
+ pbuf = FFI::MemoryPointer.new(GroupStruct)
135
135
  temp = GroupStruct.new
136
136
 
137
137
  begin
@@ -142,7 +142,14 @@ module Sys
142
142
  val = getgrgid_r(gid, temp, buf, buf.size, pbuf)
143
143
  fun = 'getgrgid_r'
144
144
  end
145
- raise SystemCallError.new(fun, val) if val != 0
145
+
146
+ if pbuf.null?
147
+ if val != 0
148
+ raise SystemCallError.new(fun, val)
149
+ else
150
+ raise Error, "group '#{gid}' not found"
151
+ end
152
+ end
146
153
  rescue Errno::ERANGE
147
154
  size += 1024
148
155
  raise if size > BUF_MAX
@@ -125,7 +125,7 @@ module Sys
125
125
  def self.get_group(gid)
126
126
  size = 1024
127
127
  buf = FFI::MemoryPointer.new(:char, size)
128
- pbuf = FFI::MemoryPointer.new(PasswdStruct)
128
+ pbuf = FFI::MemoryPointer.new(GroupStruct)
129
129
  temp = GroupStruct.new
130
130
 
131
131
  begin
@@ -136,7 +136,14 @@ module Sys
136
136
  val = getgrgid_r(gid, temp, buf, buf.size, pbuf)
137
137
  fun = 'getgrgid_r'
138
138
  end
139
- raise SystemCallError.new(fun, val) if val != 0
139
+
140
+ if pbuf.null?
141
+ if val != 0
142
+ raise SystemCallError.new(fun, val)
143
+ else
144
+ raise Error, "group '#{gid}' not found"
145
+ end
146
+ end
140
147
  rescue Errno::ERANGE
141
148
  size += 1024
142
149
  raise if size > BUF_MAX
@@ -120,7 +120,7 @@ module Sys
120
120
  def self.get_group(gid)
121
121
  size = 1024
122
122
  buf = FFI::MemoryPointer.new(:char, size)
123
- pbuf = FFI::MemoryPointer.new(PasswdStruct)
123
+ pbuf = FFI::MemoryPointer.new(GroupStruct)
124
124
  temp = GroupStruct.new
125
125
 
126
126
  begin
@@ -131,7 +131,14 @@ module Sys
131
131
  val = getgrgid_r(gid, temp, buf, buf.size, pbuf)
132
132
  fun = 'getgrgid_r'
133
133
  end
134
- raise SystemCallError.new(fun, val) if val != 0
134
+
135
+ if pbuf.null?
136
+ if val != 0
137
+ raise SystemCallError.new(fun, val)
138
+ else
139
+ raise Error, "group '#{gid}' not found"
140
+ end
141
+ end
135
142
  rescue Errno::ERANGE # Large groups
136
143
  size += 1024
137
144
  raise if size > BUF_MAX
data/lib/sys/admin.rb CHANGED
@@ -5,7 +5,7 @@ module Sys
5
5
  # The Admin class provides a unified, cross platform replacement for the Etc module.
6
6
  class Admin
7
7
  # The version of the sys-admin library.
8
- VERSION = '1.8.2'
8
+ VERSION = '1.8.4'
9
9
 
10
10
  private_class_method :new
11
11
  end
@@ -23,7 +23,7 @@ case RbConfig::CONFIG['host_os']
23
23
  require 'windows/sys/admin'
24
24
  when /darwin|mach/i
25
25
  require 'darwin/sys/admin'
26
- when /bsd/i
26
+ when /bsd|dragonfly/i
27
27
  require 'bsd/sys/admin'
28
28
  else
29
29
  require 'unix/sys/admin'
@@ -2,7 +2,7 @@
2
2
 
3
3
  RSpec.shared_examples Sys::Admin do
4
4
  example 'version is set to expected value' do
5
- expect(described_class::VERSION).to eq('1.8.2')
5
+ expect(described_class::VERSION).to eq('1.8.4')
6
6
  end
7
7
 
8
8
  example 'version constant is frozen' do
@@ -76,6 +76,12 @@ RSpec.describe Sys::Admin, :unix do
76
76
  end
77
77
 
78
78
  describe 'get_group' do
79
+ before do
80
+ described_class.class_eval do
81
+ public :getgrgid_r
82
+ end
83
+ end
84
+
79
85
  example 'get_group basic functionality' do
80
86
  expect(described_class).to respond_to(:get_group)
81
87
  expect{ described_class.get_group(group) }.not_to raise_error
@@ -100,8 +106,31 @@ RSpec.describe Sys::Admin, :unix do
100
106
  end
101
107
 
102
108
  example 'get_group raises an Error if the group cannot be found' do
109
+ expect{ described_class.get_group(123456789) }.to raise_error(Sys::Admin::Error)
103
110
  expect{ described_class.get_group('foofoofoo') }.to raise_error(Sys::Admin::Error)
104
111
  end
112
+
113
+ example 'get_group handles large groups and will retry an ERANGE' do
114
+ allow(Sys::Admin).to receive(:getgrgid_r).with(any_args).and_return(34)
115
+ allow(Sys::Admin).to receive(:getgrgid_r).with(any_args).and_call_original
116
+ expect{ described_class.get_group(group_id) }.not_to raise_error
117
+ end
118
+
119
+ example 'get_group will raise the expected error for an ENOENT' do
120
+ allow(Sys::Admin).to receive(:getgrgid_r).with(any_args).and_return(2)
121
+ expect{ described_class.get_group(group_id) }.to raise_error(Sys::Admin::Error)
122
+ end
123
+
124
+ example 'get_group will raise the expected error for a failed getgrxxx function call' do
125
+ allow(Sys::Admin).to receive(:getgrgid_r).with(any_args).and_return(22)
126
+ allow_any_instance_of(FFI::MemoryPointer).to receive(:null?).and_return(true)
127
+ expect{ described_class.get_group(group_id) }.to raise_error(Errno::EINVAL)
128
+ end
129
+
130
+ example 'get_group will not retry failures other than an ERANGE' do
131
+ allow(Sys::Admin).to receive(:getgrgid_r).with(any_args).and_return(35)
132
+ expect{ described_class.get_group(group_id) }.to raise_error(Sys::Admin::Error)
133
+ end
105
134
  end
106
135
 
107
136
  describe 'groups' do
data/sys-admin.gemspec CHANGED
@@ -3,7 +3,7 @@ require 'rubygems'
3
3
 
4
4
  Gem::Specification.new do |spec|
5
5
  spec.name = 'sys-admin'
6
- spec.version = '1.8.2'
6
+ spec.version = '1.8.4'
7
7
  spec.author = 'Daniel J. Berger'
8
8
  spec.license = 'Apache-2.0'
9
9
  spec.email = 'djberg96@gmail.com'
data.tar.gz.sig CHANGED
@@ -1,3 +1 @@
1
- ��.�)z�ۑ_jyS���OA��{*d���T��~N���`�ݾo�ϋ׸FRl�}��r���>Ĩ�ٳU�"H>?�<��U �������Yd��'y1vXj�����ݹ�\
2
- ��C ��'D�@�5��)A� �S6�߃�i� Y6�>{�5����_Rtpl�'���
3
- j��^�:�@�Q��^�A�@|uG� �
1
+ ��x0e��}�ت�:�l�ݵ-R��Q����D��f͚�<t]�?ie��y/Ɯhi'��`[h�[����T�7���*Gk. E�$�YH~�5[�s���y�����v��R��)�}E�k9x�F�3^��5H*��Puk�� �08M�X)���|���*!�uaf�y�b�����?�l��S�5g�G��{�(��J�27�V�><-� �{�إ6����U=�|�Zhǩ4�;�/e�p� a� ��M}4����7vlͮ04�n��Qx�d?�U����=G&�LW3ݱ*� �@H<�3�����0��`E����H]]�D���+zl��OB+��3�#I�e�� �@��0��-#oUJ�,Z��̶��R��b����,�NC+��YT���
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.8.2
4
+ version: 1.8.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel J. Berger
@@ -35,7 +35,7 @@ cert_chain:
35
35
  ORVCZpRuCPpmC8qmqxUnARDArzucjaclkxjLWvCVHeFa9UP7K3Nl9oTjJNv+7/jM
36
36
  WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
37
37
  -----END CERTIFICATE-----
38
- date: 2023-04-09 00:00:00.000000000 Z
38
+ date: 2024-06-12 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: ffi
metadata.gz.sig CHANGED
Binary file