EXEC-Binding errors after update to Openhab2 2.5.2-1

Thanks but meanwhile problem is solved:

  • Removed the CRLF in the exec.whitelist file and replaced by LF only;

  • Restarted OpenHab;

Did solved my problem!

Hi to all,
the solution with CRLF and LF didn’t wok for me


I wrote this rule:
when
System started
then
executeCommandLine(“chmod -v 775 /etc/openhab2/misc/exec.whitelist”)
end

I found out every time (at startup of my openHAB) when I re-saved the exec.whitelist file the scripts start working until the next start of openhab

It’s only a workaround but I hope I could help a little bit as a newbie :wink:

This line ending character(s) behaviour is quite weird.

I had a quick look at the source code and the ExecWhitelistWatchService class uses Files.lines().forEach() which ultimately leads to BufferedReader.readLine().
The readLine method documentation states:
“Reads a line of text. A line is considered to be terminated by any one of a line feed (‘\n’), a carriage return (‘\r’), or a carriage return followed immediately by a linefeed.”
and its result is specified as:
“A String containing the contents of the line, not including any line-termination characters, or null if the end of the stream has been reached”

Also, the Java documentation states the following as valid line termination characters:

  • \u000D followed by \u000A , CARRIAGE RETURN followed by LINE FEED
  • \u000A , LINE FEED
  • \u000D , CARRIAGE RETURN

Could this be a character encoding issue?

Is everyone reporting issues here running on Linux or are there also Windows users?

For me it was CRLF. Changed to LF as it should be helpded.
but


after restart it does not work again.

No.

I logged this defect.

after openhab start try:
sudo -u openhab chmod -v 775 /etc/openhab2/misc/exec.whitelist
and look at the openhab.log/events.log if ur scripts are working correctly

for me it’s working and the rule does the rest after every start :wink:

2 Likes

I am on Linux and converting the file to DOS format did the job (after a while, you need to wait until the file observer detected the change). Reading the other comments in the thread it looks like DOS people need Linux line endings and Linux people DOS line endings. Or some other weird environment issues happen. Nothing in the code looks wrong to me.

Very strange indeed.

I can confirm this behavior: only changes to the exec.whitelist file makes it realized by openhab. No matter if you change characters or file permission settings.

My openhab : 2.5.2 running on openhabian/raspi/stretch

I guess we will have to live with that bug until 2.5.3

Only if you’re not bright enough to install the fix that already exists.

Thanks for kindness.
There may be more not bright enough like me.
I will live with it.

2 Likes

I’m definitely not bright enough, indeed.

Also - where do I find the 2.5.1 jar? That was my main question.

I found the newest version here:
https://openhab.jfrog.io/openhab/webapp/#/builds/PR-openHAB2-Addons/17461/1582472126712/published%20/org.openhab.addons.bundles:org.openhab.binding.exec:2.5.3-SNAPSHOT
first, I removed the existing binding via Paper-UI and then moved that jar file to the conf/addons folder in openhab
 I waited 1 min
 then it worked

1 Like

Thanks @papaPhiL, this did the trick for me. :smiley:

For others: lookup the correct location of the “conf/addons” folder in the documentation:
see “Additional add-on files” in https://www.openhab.org/docs/installation/linux.html

Whats with the misc directory? are we just inventing random configuration directories now? Where is this supposed to go? I’ve seen people mention /home/openhab2/conf (which I don’t have), /etc/openhab2 but there is no misc directory.

Are we supposed to just “know” where this non existent directory is intended to be?
There should be an option to disable this check in a config file (like addons.cfg, or runtime.cfg), or a reasonable alternative (like wildcards) until a workable solution can be implemented.

It does feel odd. Typically this whitelist sounds like the sort of thing that should go in /services/. Maybe the idea is that you can more easily lock down write access to a “special” directory.

So where does this file go? I’m also getting no log entries at all, the exec command just don’t work anymore.

OK I got this log entry:
26-Feb-2020 12:16:04.496 [DEBUG] [ab.binding.exec.internal.ExecWhitelistWatchService] - Updated command whitelist:

But that’s it, nothing when I actually try to trigger a command. log level is set to DEBUG. I’ve updated to the 2.5.3 SNAPSHOT build, but still nothing.

I’m assuming this means i have the exec.whitelist file in the right place /etc/openhab2/misc.

Honestly, I understand security concerns, but when the security prevents you from actually doing anything, well there is no point in having an exec binding in the first place.

Finally went back to 2.5.1 binding, and all works again, including logging.
Seriously WTF?

1 Like

This is strange to me. I have several “executeCommandLine” rules and they all still run flawlessly, no mention of whitelist errors in the logs.

Which OH version are you running?