gradle-msbuild-plugin icon indicating copy to clipboard operation
gradle-msbuild-plugin copied to clipboard

Cannot execute ProjectFileParser.exe from user's temp dir in Windows 7

Open tekuser opened this issue 9 years ago • 7 comments

Hello,

I am using Windows 7 and gradle is not able to execute ProjectFileParser.exe from the users's temp directory (C:\Users\XXX\AppData\Local\Temp).

After a search on google, it seems that the problem comes from the security permission on the temp folder. The user should take ownership and full control of the temp folder.

Anyway, I think that it would be great to add a property (parserTempDir) to the MsBuild task. If this property is null we save the ProjectFileParser.exe in the user temp dir otherwise we save the file in the parserTempDir. So we can do something like that in Gradle:

msbuild { parserTempDir = temporaryDir ... }

With this, the ProjectFileParser will be saved in the build/tmp/msbuild directory.

tekuser avatar Apr 22 '15 20:04 tekuser

Well, in fact, for security reasons, it is possible in windows to forbid the execution of a program from the local temp dir. This is the case where I am working. So the only way for me to use this plugin is the copy the ProjectFileParser.exe file in the gradle's temporaryDir.

tekuser avatar Apr 23 '15 19:04 tekuser

it should extract to gradleUserHome dir (~/.gradle) instead (where gradle already put its binaries from wrapper download). Do you know if this folder would be executable-friendly (I'd think it is) ?

gluck avatar Apr 24 '15 12:04 gluck

It extracts to the user's temp directory because of this instruction: def tmp = File.createTempFile('ProjectFileParser', '.exe')

createTempFile will create a temporary file in the user's temp dir (C:\Users\XXX\AppData\Local\Temp)

I think it is better to extract to the gradle build directory of the plugin (build/tmp/msbuild/). This can be done by using the temporaryDir in the msbuild block.

I have done a correction here: https://github.com/tekuser/gradle-msbuild-plugin/commit/master

Do you think that it can be useful to merge to your master branch?

tekuser avatar Apr 24 '15 14:04 tekuser

FYI, this is back @tekuser @gluck. The binary is put in users temp folder and if there is a controlled security policy (managed by IT) which do not allow executing binaries from temp folder this causes problems

roshangautam avatar Sep 10 '19 03:09 roshangautam

@roshangautam are you using the latest version which contains the fix? We're using gradle's temporary directory now, but maybe it's still generating in the temp directory upon whatever reasons? The documention is not very clear on where the provided temp directory resides

timotei avatar Sep 10 '19 15:09 timotei

I did a fix to put the binary in the plugin directory but it seems that the commit below rolled back to use the user temp directory: https://github.com/Itiviti/gradle-msbuild-plugin/commit/ad1ab3a5f1097b882bbeff7cb2a70914c5d100b6

file: src/main/groovy/com/ullink/Msbuild.groovy line 76: File tempDir = Files.createTempDirectory('ProjectFileParser').toFile()

It is not a good idea to extract an exe file into a user temp directory and to execute it from there. Some antivirus may take it for a malware.

tekuser avatar Sep 10 '19 19:09 tekuser

@timotei Yes, I am using the latest version. Like @tekuser said the fix has been reverted by the above mentioned commit.

roshangautam avatar Sep 15 '19 18:09 roshangautam