ruby-changes:61951
From: nagachika <ko1@a...>
Date: Sat, 27 Jun 2020 12:29:57 +0900 (JST)
Subject: [ruby-changes:61951] 799c5766a4 (ruby_2_7): merge revision(s) a19228f878d955eaf2cce086bcf53f46fdf894b9: [Backport #16979]
https://git.ruby-lang.org/ruby.git/commit/?id=799c5766a4 From 799c5766a4dc215d139d2c26ac68636f43a64fbf Mon Sep 17 00:00:00 2001 From: nagachika <nagachika@r...> Date: Sat, 27 Jun 2020 12:29:42 +0900 Subject: merge revision(s) a19228f878d955eaf2cce086bcf53f46fdf894b9: [Backport #16979] brace the fact that lchmod(2) can EOPNOTSUPP Musl libc has this function as a tiny wrapper of fchmodat(3posix). On the other hand Linux kernel does not support changing modes of a symlink. The operation always fails with EOPNOTSUPP. This fchmodat behaviour is defined in POSIX. We have to take care of such exceptions. diff --git a/lib/fileutils.rb b/lib/fileutils.rb index a7ad65a..04788e2 100644 --- a/lib/fileutils.rb +++ b/lib/fileutils.rb @@ -1345,6 +1345,7 @@ module FileUtils https://github.com/ruby/ruby/blob/trunk/lib/fileutils.rb#L1345 else File.chmod mode, path() end + rescue Errno::EOPNOTSUPP end def chown(uid, gid) @@ -1439,7 +1440,7 @@ module FileUtils https://github.com/ruby/ruby/blob/trunk/lib/fileutils.rb#L1440 if st.symlink? begin File.lchmod mode, path - rescue NotImplementedError + rescue NotImplementedError, Errno::EOPNOTSUPP end else File.chmod mode, path diff --git a/test/pathname/test_pathname.rb b/test/pathname/test_pathname.rb index 792510b..2ce32a6 100644 --- a/test/pathname/test_pathname.rb +++ b/test/pathname/test_pathname.rb @@ -818,7 +818,7 @@ class TestPathname < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/pathname/test_pathname.rb#L818 old = path.lstat.mode begin path.lchmod(0444) - rescue NotImplementedError + rescue NotImplementedError, Errno::EOPNOTSUPP next end assert_equal(0444, path.lstat.mode & 0777) diff --git a/test/ruby/test_notimp.rb b/test/ruby/test_notimp.rb index b069154..e13db69 100644 --- a/test/ruby/test_notimp.rb +++ b/test/ruby/test_notimp.rb @@ -13,11 +13,11 @@ class TestNotImplement < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_notimp.rb#L13 def test_respond_to_lchmod assert_include(File.methods, :lchmod) - if /linux/ =~ RUBY_PLATFORM - assert_equal(false, File.respond_to?(:lchmod)) - end - if /freebsd/ =~ RUBY_PLATFORM + case RUBY_PLATFORM + when /freebsd/, /linux-musl/ assert_equal(true, File.respond_to?(:lchmod)) + when /linux/ + assert_equal(false, File.respond_to?(:lchmod)) end end @@ -57,9 +57,14 @@ class TestNotImplement < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_notimp.rb#L57 File.open(f, "w") {} File.symlink f, g newmode = 0444 - File.lchmod newmode, "#{d}/g" - snew = File.lstat(g) - assert_equal(newmode, snew.mode & 0777) + begin + File.lchmod newmode, "#{d}/g" + rescue Errno::EOPNOTSUPP + skip $! + else + snew = File.lstat(g) + assert_equal(newmode, snew.mode & 0777) + end } end end diff --git a/version.h b/version.h index 725fab3..248fdbe 100644 --- a/version.h +++ b/version.h @@ -2,7 +2,7 @@ https://github.com/ruby/ruby/blob/trunk/version.h#L2 # define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR #define RUBY_VERSION_TEENY 1 #define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR -#define RUBY_PATCHLEVEL 86 +#define RUBY_PATCHLEVEL 87 #define RUBY_RELEASE_YEAR 2020 #define RUBY_RELEASE_MONTH 6 -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/