Skip to content
This repository has been archived by the owner on May 17, 2021. It is now read-only.

wrong file permissions in openhab-runtime from apt-repo #1429

Closed
hoedlmoser opened this issue Sep 15, 2014 · 19 comments
Closed

wrong file permissions in openhab-runtime from apt-repo #1429

hoedlmoser opened this issue Sep 15, 2014 · 19 comments
Assignees
Labels

Comments

@hoedlmoser
Copy link

hi!

as I reported already on [email protected]

after successfull fresh (!) install of openhab-runtime 1.5.1 from
apt-repo it didn't start. no error, nothing. then I started it the same
way the init.d script does, but removed the option --background from
start-stop-deamon. and voila ...

root@inucha:~# start-stop-daemon --start --quiet --pidfile [...]
<title>Invalid Configuration Location</title>The configuration area at
'/var/lib/openhab/workspace' is not writable.  Please choose a writable
location using the '-configuration' command line option.

uh, oh, wrong permissions on /var/lib/openhab/workspace? lets check.

root@inucha:~# ls -la /var/lib/openhab/workspace
total 8
drwxr-xr-x 2 root    openhab 4096 Sep 12 22:41 .
drwxr-xr-x 4 openhab openhab 4096 Sep 13 17:30 ..
root@inucha:~#

indeed. lets fix it.

chown openhab: /var/lib/openhab/workspace

oh no, next error.

17:33:51,510 |-ERROR in ch.qos.logback.core.FileAppender[FILE] -
openFile(/var/log/openhab/openhab.log,true) call failed.
java.io.FileNotFoundException: /var/log/openhab/openhab.log (Permission
denied)
root@inucha:~# ls -la /var/log/openhab/
total 8
drwxr-xr-x 2 root openhab 4096 Sep 12 22:41 .
drwxr-xr-x 8 root root    4096 Sep 13 17:30 ..
root@inucha:~#
chown openhab: /var/log/openhab/

next try.

17:36:16.596 ERROR o.o.c.internal.CoreActivator[:117] - Couldn't create
file 'webapps/static/uuid'. java.io.FileNotFoundException:
webapps/static/uuid (Permission denied)
17:36:16.599 ERROR o.o.c.internal.CoreActivator[:117] - Couldn't create
file 'webapps/static/version'. java.io.FileNotFoundException:
webapps/static/version (Permission denied)
root@inucha:~# ls -la /var/lib/openhab/webapps
total 12
drwxr-xr-x 3 root    root    4096 Sep 13 17:30 .
drwxr-xr-x 4 openhab openhab 4096 Sep 13 17:30 ..
drwxr-xr-x 2 root    openhab 4096 Sep 12 22:41 static
root@inucha:~#
chown openhab: /var/lib/openhab/webapps/static/

now its running.

to compare I've purged openhab-runtime 1.5.1 cleaned up all openhab
files and directories (just removed them) and installed openhab-runtime
1.5.0. have a look on the permissions.

root@inucha:~# ls -la /var/lib/openhab/workspace
total 8
drwxrwsr-x 2 root    openhab 4096 Jun 18 18:56 .
drwxr-xr-x 4 openhab openhab 4096 Sep 13 17:42 ..
root@inucha:~# ls -la /var/log/openhab/
total 8
drwxrwsr-x 2 root openhab 4096 Jun 18 18:56 .
drwxr-xr-x 8 root root    4096 Sep 13 17:42 ..
root@inucha:~# ls -la /var/lib/openhab/webapps
total 12
drwxr-xr-x 3 root    root    4096 Sep 13 17:42 .
drwxr-xr-x 4 openhab openhab 4096 Sep 13 17:42 ..
drwxrwsr-x 2 root    openhab 4096 Jun 18 18:56 static
root@inucha:~#

can someone of you please fix?

btw, if you are upgrading from 1.5.0 you will not face that wrong
permissions. let's call it workaround for now.

in the group also Samuel Lorette reported that he needed to fix permissions:

chown -R openhab /var/lib/openhab/
chown -R openhab /var/log/openhab/
chown -R openhab /etc/openhab/
chown -R openhab /usr/share/openhab/

gre3tings, Klaus

@teichsta
Copy link
Member

Hi Klaus, thanks for investigating this! I will have a detailed look tonight or tomorrow. Best, Thomas E.-E.

@teichsta teichsta added the bug label Sep 16, 2014
@teichsta
Copy link
Member

sorry @hoedlmoser, but i didn't find the time yet … any chance that you could provide your findings as a Pull Request? Thanks, Thomas E.-E.

@hoedlmoser
Copy link
Author

no problem at all @teichsta , but neither I'm the expert in git nor in maven, not now. :-) but I've had a look into some details and I'm sure it has something todo with c6c5f51 and #1195

but, let me doublecheck, from what I've seen for now in the distribution/pom.xml there are just missing to set permissions for /var/lib/openhab/workspace, /var/lib/openhab/webapps/static and /var/log/openhab/ (its wrongly set for /var/log), as it was done before the commit mentioned above.

@gregeva
Copy link

gregeva commented Dec 3, 2014

I too am experiencing this (runtime 1.5.1 from apt-repo).

I must comment that although the new daemon start script with telnet based OSGi console sounds/looks pretty nice; not having a mechanism to at lease spit out some debugging/verbose log messages is a pain for troubleshooting. Perhaps a future version of /etc/init.d/openhab could include a DEBUG=0 sort of mechanism for quickly improving verbosity.

@gezuppe
Copy link

gezuppe commented Jan 10, 2015

I have this issue as well on Rasperian with OpenHAB 1.6.1 from apt-repo listed in the Wiki

@teichsta
Copy link
Member

any proposal how to fix that?

@theoweiss
Copy link
Member

I think this happens if you start openHAB as root using the start.sh script and afterwards use the init-script for starting.
I think this is partly a regression in the init-script. This code has been removed:
if [ x"${USER_AND_GROUP}" != x ]; then
chown -R ${USER_AND_GROUP} "${OPENHAB_LOG_DIR}"
chown -R ${USER_AND_GROUP} "${OPENHAB_WORKSPACE_DIR}"
fi
Is @dpslavov working on this?

@teichsta teichsta changed the title wrong file permissions in openhab-runtime 1.5.1 from apt-repo wrong file permissions in openhab-runtime from apt-repo Jan 16, 2015
@theoweiss
Copy link
Member

I've started to work on this issue. systemd support will also be available (debian 8 is around the corner). Hope I have a PR ready in a few days.

@anno73
Copy link

anno73 commented Apr 22, 2015

Hi!

I have a similar issue with file permissions here too.
Installed freshly apt repo version of openhab 1.6.2 on a cubietruck A20 as described on the wiki and I get

2015-04-22 21:52:02.388 [ERROR] [.o.core.internal.CoreActivator] - Couldn't create file 'webapps/static/version'.
java.io.FileNotFoundException: webapps/static/uuid (Permission denied)

The only difference is, that openHab tries to create in
**/usr/share/**openhab/webapps/static
instead of
**/var/lib/openhab/**webapps/static
(as stated in the wiki).

OS version installed, if that matters:

# cat /proc/version
Linux version 3.4.79 (sam@sam-System-Product-Name) (gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) ) #1 SMP PREEMPT Tue Sep 30 15:09:57 CST 2014

# cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 7 (wheezy)"
NAME="Debian GNU/Linux"
VERSION_ID="7"
VERSION="7 (wheezy)"
ID=debian
ANSI_COLOR="1;31"
HOME_URL="http://www.debian.org/"
SUPPORT_URL="http://www.debian.org/support/"
BUG_REPORT_URL="http://bugs.debian.org/"

Regards,
Alex.

@theoweiss
Copy link
Member

Fixed with 1.7.

@mastix
Copy link

mastix commented Oct 1, 2015

Hey guys, has this been really fixed?

Fresh (apt-get) install of 1.7.1 on my raspbian jessie:

2015-10-01 12:55:58.896 [ERROR] [.o.core.internal.CoreActivator] - Couldn't create file 'webapps/static/version'.
java.io.FileNotFoundException: webapps/static/version (Permission denied)
        at java.io.FileOutputStream.open(Native Method) ~[na:1.7.0_40]
        at java.io.FileOutputStream.<init>(FileOutputStream.java:221) ~[na:1.7.0_40]
        at java.io.FileOutputStream.<init>(FileOutputStream.java:171) ~[na:1.7.0_40]
        at org.openhab.core.internal.CoreActivator.writeFile(CoreActivator.java:114) [org.openhab.core_1.7.1.jar:na]
        at org.openhab.core.internal.CoreActivator.createVersionFile(CoreActivator.java:107) [org.openhab.core_1.7.1.jar:na]
        at org.openhab.core.internal.CoreActivator.start(CoreActivator.java:59) [org.openhab.core_1.7.1.jar:na]
        at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:711) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
        at java.security.AccessController.doPrivileged(Native Method) [na:1.7.0_40]
        at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:702) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
        at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:683) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
        at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:381) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
        at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:390) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
        at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1176) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
        at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:559) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
        at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:544) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
        at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:457) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
        at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:243) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
        at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:438) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
        at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:1) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
        at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
        at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
2015-10-01 12:55:58.918 [INFO ] [.o.core.internal.CoreActivator] - openHAB runtime has been started (v1.7.1).

@theoweiss
Copy link
Member

Hi mastix,

could you please check the permissions of the webapps/static folder:
ls -l /usr/share/openhab/webapps/

Regards,
Theo

@mastix
Copy link

mastix commented Oct 2, 2015

Hi,

the webapps folder has been created with rwx for my user:

drwxr-xr-x  4 mastix mastix 4.0K Oct  1 10:46 webapps

but the static folder within the webapps folder has been created with rwx for the openhab user:

drwxr-xr-x 2 openhab openhab 4.0K Oct  1 11:57 static 

That might be the problem.

So I changed the group from all files to openhab:

/usr/share/openhab$ sudo chown -R mastix:openhab *

And gave the group write access to the files and folders:

/usr/share/openhab$ sudo chmod -R g+w *

Now it seems to work. But I had to do this manually...

Thanks for the hint!

@theoweiss
Copy link
Member

Was this the first installation of openHAB on this host or have you purged an older one before reinstalling openHAB?

@mastix
Copy link

mastix commented Oct 5, 2015

Fresh installation on a Raspberry Pi 2 (Debian Jessie).

@theoweiss
Copy link
Member

OK. I will try if I can reproduce this.

@pvizeli
Copy link

pvizeli commented Nov 16, 2015

On my Pi2 with raspbian (wheezy) I don't see this bug with OpenHab 1.7.1

@theoweiss
Copy link
Member

I've tested this with jessie and can't reproduce it:

root@raspberrypi:/usr/share/openhab/webapps# cat /etc/issue
Raspbian GNU/Linux 8 \n \l
root@raspberrypi:/usr/share/openhab# ll
total 36
drwxr-xr-x 2 root root  4096 Nov 12 21:57 addons
drwxr-xr-x 2 root root  4096 Nov 12 21:57 bin
lrwxrwxrwx 1 root root    27 Jul 31 21:43 configurations -> /etc/openhab/configurations
lrwxrwxrwx 1 root root    27 Jul 31 21:43 contexts -> /etc/openhab/jetty/contexts
lrwxrwxrwx 1 root root    22 Jul 31 21:43 etc -> /etc/openhab/jetty/etc
-rw-r--r-- 1 root root 11232 Jul 31 21:43 LICENSE.TXT
-rw-r--r-- 1 root root   652 Jul 31 21:43 README.TXT
drwxr-xr-x 6 root root  4096 Nov 12 21:57 server
drwxr-xr-x 2 root root  4096 Nov 12 21:57 sounds
drwxr-xr-x 4 root root  4096 Nov 12 21:57 webapps

We'll have to wait if this ever comes up again.

@SteveQuinn1
Copy link

Hi,
Using a Raspberry Pi with a vanilla Jessie 2016-03-18-raspbian-jessie.img I've just done an apt-get install with OH 1.8.3;

wget -qO - 'https://bintray.com/user/downloadSubjectPublicKey?username=openhab' |sudo apt-key add -
echo "deb http://dl.bintray.com/openhab/apt-repo stable main" | sudo tee /etc/apt/sources.list.d/openhab.list
sudo apt-get update
sudo apt-get install openhab-runtime

and get the following when OH is run up;

2016-06-21 20:21:23.706 [INFO ] [penhab.io.rest.RESTApplication] - Stopped REST API
2016-06-21 20:22:30.126 [ERROR] [.o.core.internal.CoreActivator] - Couldn't create file 'webapps/static/version'.
java.io.FileNotFoundException: webapps/static/version (Permission denied)
at java.io.FileOutputStream.open0(Native Method) ~[na:1.8.0_65]
at java.io.FileOutputStream.open(FileOutputStream.java:270) ~[na:1.8.0_65]
at java.io.FileOutputStream.(FileOutputStream.java:213) ~[na:1.8.0_65]
at java.io.FileOutputStream.(FileOutputStream.java:162) ~[na:1.8.0_65]
at org.openhab.core.internal.CoreActivator.writeFile(CoreActivator.java:114) [org.openhab.core_1.8.3.jar:na]
at org.openhab.core.internal.CoreActivator.createVersionFile(CoreActivator.java:107) [org.openhab.core_1.8.3.jar:na]
at org.openhab.core.internal.CoreActivator.start(CoreActivator.java:59) [org.openhab.core_1.8.3.jar:na]
at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:711) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
at java.security.AccessController.doPrivileged(Native Method) [na:1.8.0_65]
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:702) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:683) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:381) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:390) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1176) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:559) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:544) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:457) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:243) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:438) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:1) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
2016-06-21 20:22:30.181 [INFO ] [.o.core.internal.CoreActivator] - openHAB runtime has been started (v1.8.3).
2016-06-21 20:22:47.671 [INFO ] [o.o.i.s.i.DiscoveryServiceImpl] - mDNS service has been started
2016-06-21 20:22:47.878 [DEBUG] [.io.transport.mqtt.MqttService] - Starting MQTT Service...
2016-06-21 20:22:48.397 [INFO ] [o.o.i.s.i.DiscoveryServiceImpl] - Service Discovery initialization completed.
2016-06-21 20:22:48.411 [TRACE] [.io.transport.mqtt.MqttService] - Processing property: mosquitto.retain = true
2016-06-21 20:22:48.479 [TRACE] [.io.transport.mqtt.MqttService] - Processing property: mosquitto.url = tcp://MQTTSVR.local:1883
2016-06-21 20:22:48.497 [INFO ] [.io.transport.mqtt.MqttService] - MQTT Service initialization completed.
2016-06-21 20:22:48.507 [INFO ] [o.i.t.m.i.MqttBrokerConnection] - Starting MQTT broker connection 'mosquitto'
2016-06-21 20:22:48.703 [DEBUG] [o.i.t.m.i.MqttBrokerConnection] - Creating new client for 'tcp://MQTTSVR.local:1883' using id 'openhab.1466536968673' and file store '/tmp/mosquitto'
2016-06-21 20:22:53.756 [INFO ] [c.internal.ModelRepositoryImpl] - Loading model 'rrd4j.persist'
2016-06-21 20:22:55.397 [INFO ] [c.internal.ModelRepositoryImpl] - Loading model 'stevequinnhousehold.items'
2016-06-21 20:23:18.612 [INFO ] [c.internal.ModelRepositoryImpl] - Loading model 'stevequinnhousehold.sitemap'
2016-06-21 20:23:24.200 [INFO ] [penhab.io.rest.RESTApplication] - Started REST API at /rest
2016-06-21 20:23:29.914 [INFO ] [.o.u.w.i.servlet.WebAppServlet] - Started Classic UI at /classicui/openhab.app
2016-06-21 20:23:39.017 [WARN ] [o.p.m.i.MqttPersistenceService] - mqtt-persistence:broker
2016-06-21 20:23:39.025 [WARN ] [o.p.m.i.MqttPersistenceService] - mqtt-persistence:topic
2016-06-21 20:23:39.032 [WARN ] [o.p.m.i.MqttPersistenceService] - mqtt-persistence:message

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

No branches or pull requests

9 participants