timja / jenkins-gh-issues-poc-06-18

0 stars 0 forks source link

[JENKINS-16005] CommandInstaller assumes write access to installation directory #2734

Open timja opened 11 years ago

timja commented 11 years ago

The Mercurial incorrectly assumes write-access to the Mercurial installation directory, triggering the following exception:

hudson.util.IOException2: Failed to create a temp file on /usr
    at hudson.FilePath.createTextTempFile(FilePath.java:1163)
    at hudson.FilePath.createTextTempFile(FilePath.java:1114)
    at hudson.tools.CommandInstaller.performInstallation(CommandInstaller.java:82)
    at hudson.tools.InstallerTranslator.getToolHome(InstallerTranslator.java:61)
    at hudson.tools.ToolLocationNodeProperty.getToolHome(ToolLocationNodeProperty.java:107)
    at hudson.tools.ToolInstallation.translateFor(ToolInstallation.java:203)
    at hudson.plugins.mercurial.MercurialInstallation.forNode(MercurialInstallation.java:103)
    at hudson.plugins.mercurial.MercurialSCM.findHgExe(MercurialSCM.java:201)
    at hudson.plugins.mercurial.HgExe.(HgExe.java:80)
    at hudson.plugins.mercurial.MercurialSCM.clone(MercurialSCM.java:554)
    at hudson.plugins.mercurial.MercurialSCM.checkout(MercurialSCM.java:389)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1324)
    at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:676)
    at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:581)
    at hudson.model.Run.execute(Run.java:1518)
    at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:477)
    at hudson.model.ResourceController.execute(ResourceController.java:88)
    at hudson.model.Executor.run(Executor.java:236)
Caused by: hudson.util.IOException2: remote file operation failed: /usr at hudson.remoting.Channel@26528fa4:Ubuntu 12.04
    at hudson.FilePath.act(FilePath.java:848)
    at hudson.FilePath.act(FilePath.java:825)
    at hudson.FilePath.createTextTempFile(FilePath.java:1141)
    ... 18 more

My configuration is as follows:

Installation directory = /usr
Executable = INSTALLATION/bin/hg
Installation Automatically using command: "sudo apt-get install mercurial"

Jenkin's user does not have general access to /usr, nor to "sudo". It only has executable permissions in /usr/bin and "sudoers" permission to "apt-get".

Expected behavior: write temporary files into the path specified by the "java.io.tmpdir" system property.


Originally reported by cowwoc, imported from: CommandInstaller assumes write access to installation directory
  • status: Open
  • priority: Major
  • resolution: Unresolved
  • imported: 2022/01/10
timja commented 11 years ago

cowwoc:

I forgot to mention, my environment is Ubuntu 12.04, 64-bit edition.

timja commented 11 years ago

cowwoc:

Workaround: Set "Installation directory" to Jenkins' home directory (which we have write access to) and "Tool Home" remains pointed to /usr.

PS: What's the difference between "Installation directory" and "Tool Home"? There is no help tooltip for "Installation directory".

timja commented 11 years ago

jglick:

The bug is actually in CommandInstaller.performInstallation, which assumes that it can use the tool home as a temporary directory—which is normally a safe assumption, but not when sudo or the like is being used to create files. Should just use the system temp directory.

timja commented 11 years ago

jglick:

If you click Install automatically then Installation directory disappears so I am not sure why you have it set—Installation directory only makes sense if you are not having Jenkins perform the installation.

It is Tool Home which should be set to /usr (or just set Executable to /usr/bin/hg and leave Tool Home blank).

timja commented 11 years ago

cowwoc:

>If you click Install automatically then Installation directory disappears so I am not sure why you have it set

I am using Hudson 1.492 and this isn't the case. Selecting "install automatically" does not cause the "installation directory" field to become hidden. Should I file an additional bug report for this?

timja commented 11 years ago

jglick:

It worked when I tried in 1.424 (baseline for the plugin), so if it is not working in 1.492 then that sounds like a regression which ought to be filed.

timja commented 11 years ago

cowwoc:

Filed JENKINS-16022.

timja commented 10 years ago

danielbeck:

Given that JENKINS-16022 cannot be reproduced with recent Jenkins and Mercurial plugin, this issue should also be obsolete.

timja commented 10 years ago

jglick:

I do not think so; JENKINS-16022 was a side issue. This problem is distinct and I think the bug summary reflects it properly.

timja commented 10 years ago

danielbeck:

Right, I misread the issue description. My apologies.

Issue is in core at AbstractCommandInstaller.performInstallation() line 74