From 7d89ecdc523aab7b9908501b6743da2c26a53825 Mon Sep 17 00:00:00 2001 From: akr Date: Mon, 30 Apr 2012 14:37:54 +0000 Subject: * lib/fileutils.rb (copy_metadata): use File.lchown and File.lchmod to update meta data of symlinks. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35499 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/fileutils.rb | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/fileutils.rb b/lib/fileutils.rb index 84bd6b968c..65e9bb9e8e 100644 --- a/lib/fileutils.rb +++ b/lib/fileutils.rb @@ -1444,14 +1444,37 @@ private def copy_metadata(path) st = lstat() - File.utime st.atime, st.mtime, path + if !st.symlink? + File.utime st.atime, st.mtime, path + end begin - File.chown st.uid, st.gid, path + if st.symlink? + begin + File.lchown st.uid, st.gid, path + rescue NotImplementedError + end + else + File.chown st.uid, st.gid, path + end rescue Errno::EPERM # clear setuid/setgid - File.chmod st.mode & 01777, path + if st.symlink? + begin + File.lchmod st.mode & 01777, path + rescue NotImplementedError + end + else + File.chmod st.mode & 01777, path + end else - File.chmod st.mode, path + if st.symlink? + begin + File.lchmod st.mode, path + rescue NotImplementedError + end + else + File.chmod st.mode, path + end end end -- cgit v1.2.3