etc 1.4.5 → 1.4.6

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: 498daaac5148043cbab0229b5d3b61e9a21686221526d500e9a9e1230a87ee54
4
- data.tar.gz: 7795ea2122ceb03395ad234b35786bb6730689fbde1c7d1eb371e13a2c33e443
3
+ metadata.gz: 189d06e9fa0ddac3e7a4adfc9e57ae032463bc677b9e3890ccd4747bd143e5ed
4
+ data.tar.gz: cd3d52688c5aa5db9b5cdbaa9d68bb7d958c028aff7aa60a790b03dfc4342b85
5
5
  SHA512:
6
- metadata.gz: f5aaafa9514d0d6655cc50214ed8e6429618b0ab1ae400db59d31e454258e0e205d51b32c67b2bc9809c49f2fe34a0b79907c61458427f640529830753bebbec
7
- data.tar.gz: 6ffe4ac0df5f414a4f7e6ca3597267eec3487230e5b646a316ce22d1688e7b4b0490a9e4dee39f72cad16263e55bca6342c4fe40e32cb724b904d3d0b4e332fa
6
+ metadata.gz: 147fa5a4bda2946963fc1b3ee96b0dc71c5f5daf3087cb9f072a732431d39ba4cf7ceae1e02d84d1eeeab2b475219b2fbdafa9786c19a71f4954d987d28f9473
7
+ data.tar.gz: 47a4f90a79f6223b1870c26d037d240a5bb2a41c565c1606f26dba533c1efb4e3b590b42571bb4c8f197c5ae87c0b6f05048111c4f7e011b8385e74f53750e7f
data/COPYING ADDED
@@ -0,0 +1,56 @@
1
+ Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.jp>.
2
+ You can redistribute it and/or modify it under either the terms of the
3
+ 2-clause BSDL (see the file BSDL), or the conditions below:
4
+
5
+ 1. You may make and give away verbatim copies of the source form of the
6
+ software without restriction, provided that you duplicate all of the
7
+ original copyright notices and associated disclaimers.
8
+
9
+ 2. You may modify your copy of the software in any way, provided that
10
+ you do at least ONE of the following:
11
+
12
+ a. place your modifications in the Public Domain or otherwise
13
+ make them Freely Available, such as by posting said
14
+ modifications to Usenet or an equivalent medium, or by allowing
15
+ the author to include your modifications in the software.
16
+
17
+ b. use the modified software only within your corporation or
18
+ organization.
19
+
20
+ c. give non-standard binaries non-standard names, with
21
+ instructions on where to get the original software distribution.
22
+
23
+ d. make other distribution arrangements with the author.
24
+
25
+ 3. You may distribute the software in object code or binary form,
26
+ provided that you do at least ONE of the following:
27
+
28
+ a. distribute the binaries and library files of the software,
29
+ together with instructions (in the manual page or equivalent)
30
+ on where to get the original distribution.
31
+
32
+ b. accompany the distribution with the machine-readable source of
33
+ the software.
34
+
35
+ c. give non-standard binaries non-standard names, with
36
+ instructions on where to get the original software distribution.
37
+
38
+ d. make other distribution arrangements with the author.
39
+
40
+ 4. You may modify and include the part of the software into any other
41
+ software (possibly commercial). But some files in the distribution
42
+ are not written by the author, so that they are not under these terms.
43
+
44
+ For the list of those files and their copying conditions, see the
45
+ file LEGAL.
46
+
47
+ 5. The scripts and library files supplied as input to or produced as
48
+ output from the software do not automatically fall under the
49
+ copyright of the software, but belong to whomever generated them,
50
+ and may be sold commercially, and may be aggregated with this
51
+ software.
52
+
53
+ 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
54
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
55
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
56
+ PURPOSE.
data/ChangeLog CHANGED
@@ -1,9 +1,9 @@
1
1
  -*- coding: utf-8 -*-
2
2
 
3
- commit 5019f4314a899cd231c51e1e1225fe035adf4aac
3
+ commit c9c9b9d15e798d94c3ce148859f8b88c541bc567
4
4
  Author: Hiroshi SHIBATA <hsbt@ruby-lang.org>
5
- AuthorDate: 2024-12-03 13:53:43 +0900
5
+ AuthorDate: 2025-07-15 16:24:07 +0900
6
6
  Commit: Hiroshi SHIBATA <hsbt@ruby-lang.org>
7
- CommitDate: 2024-12-03 13:53:43 +0900
7
+ CommitDate: 2025-07-15 16:24:09 +0900
8
8
 
9
- Bump up 1.4.5
9
+ Bump up v1.4.6
data/README.md CHANGED
@@ -5,6 +5,7 @@ The Etc module provides access to information typically stored in files in the /
5
5
  The information accessible consists of the information found in the `/etc/passwd` and `/etc/group` files, plus information about he system's temporary directory (/tmp) and configuration directory (/etc).
6
6
 
7
7
  The Etc module provides a more reliable way to access information about the logged in user than environment variables such as +$USER+.
8
+ Read the [API RDoc](https://docs.ruby-lang.org/en/master/Etc.html).
8
9
 
9
10
  ## Installation
10
11
 
data/ext/etc/etc.c CHANGED
@@ -56,7 +56,7 @@ static VALUE sGroup;
56
56
  #endif
57
57
  RUBY_EXTERN char *getlogin(void);
58
58
 
59
- #define RUBY_ETC_VERSION "1.4.5"
59
+ #define RUBY_ETC_VERSION "1.4.6"
60
60
 
61
61
  #define SYMBOL_LIT(str) ID2SYM(rb_intern_const(str ""))
62
62
 
@@ -1163,14 +1163,26 @@ Init_etc(void)
1163
1163
  {
1164
1164
  VALUE mEtc;
1165
1165
 
1166
- #ifdef HAVE_RB_EXT_RACTOR_SAFE
1167
- RB_EXT_RACTOR_SAFE(true);
1168
- #endif
1169
1166
  mEtc = rb_define_module("Etc");
1170
1167
  /* The version */
1171
1168
  rb_define_const(mEtc, "VERSION", rb_str_new_cstr(RUBY_ETC_VERSION));
1172
1169
  init_constants(mEtc);
1173
1170
 
1171
+ /* Ractor-safe methods */
1172
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
1173
+ RB_EXT_RACTOR_SAFE(true);
1174
+ #endif
1175
+ rb_define_module_function(mEtc, "systmpdir", etc_systmpdir, 0);
1176
+ rb_define_module_function(mEtc, "uname", etc_uname, 0);
1177
+ rb_define_module_function(mEtc, "sysconf", etc_sysconf, 1);
1178
+ rb_define_module_function(mEtc, "confstr", etc_confstr, 1);
1179
+ rb_define_method(rb_cIO, "pathconf", io_pathconf, 1);
1180
+ rb_define_module_function(mEtc, "nprocessors", etc_nprocessors, 0);
1181
+
1182
+ /* Non-Ractor-safe methods, see https://bugs.ruby-lang.org/issues/21115 */
1183
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
1184
+ RB_EXT_RACTOR_SAFE(false);
1185
+ #endif
1174
1186
  rb_define_module_function(mEtc, "getlogin", etc_getlogin, 0);
1175
1187
 
1176
1188
  rb_define_module_function(mEtc, "getpwuid", etc_getpwuid, -1);
@@ -1186,13 +1198,9 @@ Init_etc(void)
1186
1198
  rb_define_module_function(mEtc, "setgrent", etc_setgrent, 0);
1187
1199
  rb_define_module_function(mEtc, "endgrent", etc_endgrent, 0);
1188
1200
  rb_define_module_function(mEtc, "getgrent", etc_getgrent, 0);
1201
+
1202
+ /* Uses RbConfig::CONFIG so does not work in a Ractor */
1189
1203
  rb_define_module_function(mEtc, "sysconfdir", etc_sysconfdir, 0);
1190
- rb_define_module_function(mEtc, "systmpdir", etc_systmpdir, 0);
1191
- rb_define_module_function(mEtc, "uname", etc_uname, 0);
1192
- rb_define_module_function(mEtc, "sysconf", etc_sysconf, 1);
1193
- rb_define_module_function(mEtc, "confstr", etc_confstr, 1);
1194
- rb_define_method(rb_cIO, "pathconf", io_pathconf, 1);
1195
- rb_define_module_function(mEtc, "nprocessors", etc_nprocessors, 0);
1196
1204
 
1197
1205
  sPasswd = rb_struct_define_under(mEtc, "Passwd",
1198
1206
  "name",
@@ -1303,4 +1311,8 @@ Init_etc(void)
1303
1311
  rb_extend_object(sGroup, rb_mEnumerable);
1304
1312
  rb_define_singleton_method(sGroup, "each", etc_each_group, 0);
1305
1313
  #endif
1314
+
1315
+ #if defined(HAVE_GETPWENT) || defined(HAVE_GETGRENT)
1316
+ (void)safe_setup_str;
1317
+ #endif
1306
1318
  }
data/ext/etc/extconf.rb CHANGED
@@ -10,8 +10,30 @@ headers = []
10
10
  have_library("sun", "getpwnam") # NIS (== YP) interface for IRIX 4
11
11
  have_func("uname((struct utsname *)NULL)", headers)
12
12
  have_func("getlogin")
13
- have_func("getpwent")
14
- have_func("getgrent")
13
+ if have_func("getpwent")
14
+ have_struct_member('struct passwd', 'pw_gecos', 'pwd.h')
15
+ have_struct_member('struct passwd', 'pw_change', 'pwd.h')
16
+ have_struct_member('struct passwd', 'pw_quota', 'pwd.h')
17
+ if have_struct_member('struct passwd', 'pw_age', 'pwd.h')
18
+ case what_type?('struct passwd', 'pw_age', 'pwd.h')
19
+ when "string"
20
+ f = "safe_setup_str"
21
+ when "long long"
22
+ f = "LL2NUM"
23
+ else
24
+ f = "INT2NUM"
25
+ end
26
+ $defs.push("-DPW_AGE2VAL="+f)
27
+ end
28
+ have_struct_member('struct passwd', 'pw_class', 'pwd.h')
29
+ have_struct_member('struct passwd', 'pw_comment', 'pwd.h') unless /cygwin/ === RUBY_PLATFORM
30
+ have_struct_member('struct passwd', 'pw_expire', 'pwd.h')
31
+ have_struct_member('struct passwd', 'pw_passwd', 'pwd.h')
32
+ end
33
+ if have_func("getgrent")
34
+ have_struct_member('struct group', 'gr_passwd', 'grp.h')
35
+ end
36
+
15
37
  if (sysconfdir = RbConfig::CONFIG["sysconfdir"] and
16
38
  !RbConfig.expand(sysconfdir.dup, "prefix"=>"", "DESTDIR"=>"").empty?)
17
39
  $defs.push("-DSYSCONFDIR=#{Shellwords.escape(sysconfdir.dump)}")
@@ -21,26 +43,6 @@ have_func("sysconf")
21
43
  have_func("confstr")
22
44
  have_func("fpathconf")
23
45
 
24
- have_struct_member('struct passwd', 'pw_gecos', 'pwd.h')
25
- have_struct_member('struct passwd', 'pw_change', 'pwd.h')
26
- have_struct_member('struct passwd', 'pw_quota', 'pwd.h')
27
- if have_struct_member('struct passwd', 'pw_age', 'pwd.h')
28
- case what_type?('struct passwd', 'pw_age', 'pwd.h')
29
- when "string"
30
- f = "safe_setup_str"
31
- when "long long"
32
- f = "LL2NUM"
33
- else
34
- f = "INT2NUM"
35
- end
36
- $defs.push("-DPW_AGE2VAL="+f)
37
- end
38
- have_struct_member('struct passwd', 'pw_class', 'pwd.h')
39
- have_struct_member('struct passwd', 'pw_comment', 'pwd.h') unless /cygwin/ === RUBY_PLATFORM
40
- have_struct_member('struct passwd', 'pw_expire', 'pwd.h')
41
- have_struct_member('struct passwd', 'pw_passwd', 'pwd.h')
42
- have_struct_member('struct group', 'gr_passwd', 'grp.h')
43
-
44
46
  # for https://github.com/ruby/etc
45
47
  srcdir = File.expand_path("..", __FILE__)
46
48
  constdefs = "#{srcdir}/constdefs.h"
@@ -58,7 +60,7 @@ end
58
60
  # TODO: remove when dropping 2.7 support, as exported since 3.0
59
61
  have_func('rb_deprecate_constant(Qnil, "None")')
60
62
 
61
- have_func("rb_io_descriptor")
63
+ have_func("rb_io_descriptor", "ruby/io.h")
62
64
 
63
65
  $distcleanfiles << "constdefs.h"
64
66
 
data/test/etc/test_etc.rb CHANGED
@@ -21,7 +21,7 @@ class TestEtc < Test::Unit::TestCase
21
21
  assert_instance_of(String, s.shell)
22
22
  assert_kind_of(Integer, s.change) if s.respond_to?(:change)
23
23
  assert_kind_of(Integer, s.quota) if s.respond_to?(:quota)
24
- assert(s.age.is_a?(Integer) || s.age.is_a?(String)) if s.respond_to?(:age)
24
+ assert(s.age.is_a?(Integer) || s.age.is_a?(String), s.age) if s.respond_to?(:age)
25
25
  assert_instance_of(String, s.uclass) if s.respond_to?(:uclass)
26
26
  assert_instance_of(String, s.comment) if s.respond_to?(:comment)
27
27
  assert_kind_of(Integer, s.expire) if s.respond_to?(:expire)
@@ -160,7 +160,7 @@ class TestEtc < Test::Unit::TestCase
160
160
  end
161
161
  IO.pipe {|r, w|
162
162
  val = w.pathconf(Etc::PC_PIPE_BUF)
163
- assert(val.nil? || val.kind_of?(Integer))
163
+ assert_kind_of(Integer, val) if val
164
164
  }
165
165
  end if defined?(Etc::PC_PIPE_BUF)
166
166
 
@@ -173,28 +173,85 @@ class TestEtc < Test::Unit::TestCase
173
173
  assert_operator(File, :absolute_path?, Etc.sysconfdir)
174
174
  end if File.method_defined?(:absolute_path?)
175
175
 
176
- def test_ractor
176
+ # All Ractor-safe methods should be tested here
177
+ def test_ractor_parallel
178
+ omit "This test is flaky and intermittently failing now on ModGC workflow" if ENV['GITHUB_WORKFLOW'] == 'ModGC'
179
+
180
+ assert_ractor(<<~RUBY, require: 'etc', timeout: 60)
181
+ 10.times.map do
182
+ Ractor.new do
183
+ 100.times do
184
+ raise unless String === Etc.systmpdir
185
+ raise unless Hash === Etc.uname
186
+ if defined?(Etc::SC_CLK_TCK)
187
+ raise unless Integer === Etc.sysconf(Etc::SC_CLK_TCK)
188
+ end
189
+ if defined?(Etc::CS_PATH)
190
+ raise unless String === Etc.confstr(Etc::CS_PATH)
191
+ end
192
+ if defined?(Etc::PC_PIPE_BUF)
193
+ IO.pipe { |r, w|
194
+ val = w.pathconf(Etc::PC_PIPE_BUF)
195
+ raise unless val.nil? || val.kind_of?(Integer)
196
+ }
197
+ end
198
+ raise unless Integer === Etc.nprocessors
199
+ end
200
+ end
201
+ end.each(&:join)
202
+ RUBY
203
+ end
204
+
205
+ def test_ractor_unsafe
206
+ assert_ractor(<<~RUBY, require: 'etc')
207
+ r = Ractor.new do
208
+ begin
209
+ Etc.passwd
210
+ rescue => e
211
+ e.class
212
+ end
213
+ end.value
214
+ assert_equal Ractor::UnsafeError, r
215
+ RUBY
216
+ end
217
+
218
+ def test_ractor_passwd
219
+ omit("https://bugs.ruby-lang.org/issues/21115")
177
220
  return unless Etc.passwd # => skip test if no platform support
178
221
  Etc.endpwent
179
222
 
180
223
  assert_ractor(<<~RUBY, require: 'etc')
181
- ractor = Ractor.new do
224
+ ractor = Ractor.new port = Ractor::Port.new do |port|
182
225
  Etc.passwd do |s|
183
- Ractor.yield :sync
184
- Ractor.yield s.name
226
+ port << :sync
227
+ port << s.name
185
228
  break :done
186
229
  end
187
230
  end
188
- ractor.take # => :sync
231
+ port.receive # => :sync
189
232
  assert_raise RuntimeError, /parallel/ do
190
233
  Etc.passwd {}
191
234
  end
192
- name = ractor.take # => first name
193
- ractor.take # => :done
235
+ name = port.receive # => first name
236
+ ractor.join # => :done
194
237
  name2 = Etc.passwd do |s|
195
238
  break s.name
196
239
  end
197
240
  assert_equal(name2, name)
198
241
  RUBY
199
242
  end
243
+
244
+ def test_ractor_getgrgid
245
+ omit("https://bugs.ruby-lang.org/issues/21115")
246
+
247
+ assert_ractor(<<~RUBY, require: 'etc')
248
+ 20.times.map do
249
+ Ractor.new do
250
+ 1000.times do
251
+ raise unless Etc.getgrgid(Process.gid).gid == Process.gid
252
+ end
253
+ end
254
+ end.each(&:join)
255
+ RUBY
256
+ end
200
257
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: etc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.5
4
+ version: 1.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yukihiro Matsumoto
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-12-03 00:00:00.000000000 Z
10
+ date: 2025-07-15 00:00:00.000000000 Z
12
11
  dependencies: []
13
12
  description: Provides access to information typically stored in UNIX /etc directory.
14
13
  email:
@@ -17,8 +16,9 @@ executables: []
17
16
  extensions:
18
17
  - ext/etc/extconf.rb
19
18
  extra_rdoc_files:
19
+ - BSDL
20
+ - COPYING
20
21
  - ChangeLog
21
- - LICENSE.txt
22
22
  - README.md
23
23
  - ext/etc/constdefs.h
24
24
  - ext/etc/etc.c
@@ -26,8 +26,9 @@ extra_rdoc_files:
26
26
  - ext/etc/mkconstants.rb
27
27
  - test/etc/test_etc.rb
28
28
  files:
29
+ - BSDL
30
+ - COPYING
29
31
  - ChangeLog
30
- - LICENSE.txt
31
32
  - README.md
32
33
  - ext/etc/constdefs.h
33
34
  - ext/etc/etc.c
@@ -39,7 +40,6 @@ licenses:
39
40
  - Ruby
40
41
  - BSD-2-Clause
41
42
  metadata: {}
42
- post_install_message:
43
43
  rdoc_options:
44
44
  - "--main"
45
45
  - README.md
@@ -56,8 +56,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
56
56
  - !ruby/object:Gem::Version
57
57
  version: '0'
58
58
  requirements: []
59
- rubygems_version: 3.5.11
60
- signing_key:
59
+ rubygems_version: 3.6.7
61
60
  specification_version: 4
62
61
  summary: Provides access to information typically stored in UNIX /etc directory.
63
62
  test_files: []
File without changes