From 61b9b59060aa060b42cf1eb1a70ba7ee9c5d0252 Mon Sep 17 00:00:00 2001
From: brinn <brinn>
Date: Thu, 6 Sep 2012 22:09:49 +0000
Subject: [PATCH] If the environment variable HOME is not set, set it to the
 current user directory before calling rsync to have a writable directory for
 ssh to create ~/.ssh and files therein.

SVN: 26547
---
 .../cisd/common/filesystem/rsync/RsyncCopier.java      | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/common/source/java/ch/systemsx/cisd/common/filesystem/rsync/RsyncCopier.java b/common/source/java/ch/systemsx/cisd/common/filesystem/rsync/RsyncCopier.java
index c10ca5ed44e..b5273ee0aeb 100644
--- a/common/source/java/ch/systemsx/cisd/common/filesystem/rsync/RsyncCopier.java
+++ b/common/source/java/ch/systemsx/cisd/common/filesystem/rsync/RsyncCopier.java
@@ -728,6 +728,12 @@ public final class RsyncCopier implements IPathCopier, IDirectoryImmutableCopier
             operationLog.trace(String.format("Trying to get lock for running command '%s'",
                     commandLine));
         }
+        Map<String, String> env = null;
+        if (System.getenv("HOME") == null)
+        {
+            env = new HashMap<String, String>();
+            env.put("HOME", System.getProperty("user.dir"));
+        }
         synchronized (this)
         {
             if (operationLog.isDebugEnabled())
@@ -735,8 +741,8 @@ public final class RsyncCopier implements IPathCopier, IDirectoryImmutableCopier
                 operationLog.debug(String.format("Running command '%s'", commandLine));
             }
             processHandler =
-                    ProcessExecutionHelper.runUnblocking(commandLine, operationLog, machineLog,
-                            ProcessIOStrategy.DEFAULT_IO_STRATEGY);
+                    ProcessExecutionHelper.runUnblocking(commandLine, env, false, operationLog,
+                            machineLog, ProcessIOStrategy.DEFAULT_IO_STRATEGY);
             rsyncTerminator.set(processHandler);
         }
         if (operationLog.isTraceEnabled())
-- 
GitLab