From b31b67cc5d9c9662ddbaf84e4ac3da14656ba4d7 Mon Sep 17 00:00:00 2001 From: kohsuke Date: Wed, 5 May 2010 04:15:53 +0000 Subject: [PATCH] also do chmod(2) in an attempt to make a file writable. git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@30734 71c3de6d-444a-0410-be80-ed276b4c234a --- core/src/main/java/hudson/Util.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/hudson/Util.java b/core/src/main/java/hudson/Util.java index d595271229..f7add16e45 100644 --- a/core/src/main/java/hudson/Util.java +++ b/core/src/main/java/hudson/Util.java @@ -41,6 +41,8 @@ import org.apache.tools.ant.taskdefs.Chmod; import org.apache.tools.ant.taskdefs.Copy; import org.apache.commons.lang.time.FastDateFormat; import org.apache.commons.io.IOUtils; +import org.jruby.ext.posix.FileStat; +import org.jruby.ext.posix.POSIX; import org.kohsuke.stapler.Stapler; import org.jvnet.animal_sniffer.IgnoreJRERequirement; @@ -263,7 +265,7 @@ public class Util { } /** - * Makes the given file writable. + * Makes the given file writable by any means possible. */ @IgnoreJRERequirement private static void makeWritable(File f) { @@ -284,6 +286,16 @@ public class Util { } catch (NoSuchMethodError e) { // not JDK6 } + + try {// try libc chmod + POSIX posix = PosixAPI.get(); + String path = f.getAbsolutePath(); + FileStat stat = posix.stat(path); + posix.chmod(path, stat.mode()|0200); // u+w + } catch (Throwable t) { + LOGGER.log(Level.FINE,"Failed to chmod(2) "+f,t); + } + } public static void deleteRecursive(File dir) throws IOException { -- GitLab