Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-Dexec.garden breaks script execution with trailing slash #837

Closed
FinalDoom opened this issue Dec 9, 2017 · 1 comment
Closed

-Dexec.garden breaks script execution with trailing slash #837

FinalDoom opened this issue Dec 9, 2017 · 1 comment
Assignees
Milestone

Comments

@FinalDoom
Copy link

Having a trailing slash on the -Dexec.garden parameter makes it impossible to execute scripts.

Log:

12-09-2017 16:17:42.873 WARN Could not execute request: /usr/local/HaBridge/bin//ha-105.sh 192.168.8.14 off with message: Cannot run program "/usr/local/HaBridge/bin//ha-105.sh": error=2, No such file or directory com.bwssystems.HABridge.plugins.exec.CommandHome

Jar execution:

/usr/local/bin/java -Djava.net.preferIPv4Stack=true -Dconfig.file=/usr/local
/HaBridge/data/habridge.config -Dexec.garden=/usr/local/HaBridge/bin/ -jar /usr/l
ocal/HaBridge/ha-bridge-5.0.0.jar

Note the trailing slash on the /bin/ folder.

The script execute command:

ha-105.sh 192.168.8.14 off

It appears the program is prepending the script execution with a / (it does this using exec:https://ha-105.sh as well) and then joining that (strings?) to the garden path. Java should be able to resolve this path more robustly.

It looks like the code doing this is at line 47 of ComandHome.java:

		if(execGarden != null && !execGarden.trim().isEmpty()) {
			if(System.getProperty("os.name").toLowerCase().indexOf("win") >= 0)
				intermediate = execGarden + "\\" + intermediate;
			else
				intermediate = execGarden + "/" + intermediate;
		}

You can skip this custom logic by just using java File objects (or Paths, but those are needlessly complex for this), like this:

		if(execGarden != null && !execGarden.trim().isEmpty()) {
			intermediate = new File(execGarden, intermediate).getAbsolutePath();
		}
@bwssytems bwssytems added this to the V5.1.0 milestone Dec 11, 2017
@bwssytems bwssytems self-assigned this Dec 11, 2017
@bwssytems
Copy link
Owner

Much appreciated. Always good to have a second set of eyes help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants