[moblab] Fix permission issue with ssh tmp directory.
If differnt users call this code the first will claim the ssh-master
directory and following users will get permission denied.
BUG=chromium:968127
TEST=tryjob, local moblab
Change-Id: I0f1b7007a0048e2053064c2fa796b35529e10b83
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/autotest/+/1638244
Reviewed-by: Keith Haddow <haddowk@chromium.org>
Commit-Queue: Keith Haddow <haddowk@chromium.org>
Tested-by: Keith Haddow <haddowk@chromium.org>
diff --git a/server/hosts/ssh_multiplex.py b/server/hosts/ssh_multiplex.py
index 803518c..4bb29b9 100644
--- a/server/hosts/ssh_multiplex.py
+++ b/server/hosts/ssh_multiplex.py
@@ -172,7 +172,8 @@
# crbug/945523 Swarming does not like too many top-level directories in
# /tmp.
# So use a shared parent directory in /tmp
- d = '/tmp/ssh-master'
+ user = os.environ.get("USER", "no_USER")[:8]
+ d = '/tmp/ssh-master_%s' % user
if not os.path.exists(d):
os.mkdir(d)
return d