summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2021-03-02 11:23:42 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2021-03-02 11:23:42 +0000
commit82019f272dff1990e7a273125a8414d056f6306d (patch)
tree4e5c2b970690abbe61eba9a9f6ec0c5eea04c0d4
parentdad70fa6a85990f61ec76a62456fde153e093af4 (diff)
merge revision(s) a19228f8: [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. --- lib/fileutils.rb | 3 ++- test/pathname/test_pathname.rb | 2 +- test/ruby/test_notimp.rb | 19 ++++++++++++------- 3 files changed, 15 insertions(+), 9 deletions(-) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_6@67907 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--lib/fileutils.rb3
-rw-r--r--test/pathname/test_pathname.rb2
-rw-r--r--test/ruby/test_notimp.rb19
-rw-r--r--version.h2
4 files changed, 16 insertions, 10 deletions
diff --git a/lib/fileutils.rb b/lib/fileutils.rb
index 8981ef98e8..6332fcd6f1 100644
--- a/lib/fileutils.rb
+++ b/lib/fileutils.rb
@@ -1320,6 +1320,7 @@ module FileUtils
else
File.chmod mode, path()
end
+ rescue Errno::EOPNOTSUPP
end
def chown(uid, gid)
@@ -1411,7 +1412,7 @@ module FileUtils
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 f8e4937802..750fabf039 100644
--- a/test/pathname/test_pathname.rb
+++ b/test/pathname/test_pathname.rb
@@ -824,7 +824,7 @@ class TestPathname < Test::Unit::TestCase
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 ddebb657bf..daa5a82d7b 100644
--- a/test/ruby/test_notimp.rb
+++ b/test/ruby/test_notimp.rb
@@ -13,11 +13,11 @@ class TestNotImplement < Test::Unit::TestCase
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
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 2409c2bc7d..dc472d558b 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.6.7"
#define RUBY_RELEASE_DATE "2021-03-02"
-#define RUBY_PATCHLEVEL 166
+#define RUBY_PATCHLEVEL 167
#define RUBY_RELEASE_YEAR 2021
#define RUBY_RELEASE_MONTH 3