learningequality / kolibri-installer-debian

Kolibri installer source for Debian
MIT License
1 stars 8 forks source link

Incorrect value of KOLIBRI_HOME in /etc/default/kolibri #62

Closed richsegal closed 5 years ago

richsegal commented 5 years ago

Observed behavior

The value of the environment variable KOLIBRI_HOME is set incorrectly by the script /etc/default/kolibri. The value is set to "~/.kolibri", which incorrectly assumes that the current user is the KOLIBRI_USER.

Expected behavior

The script should set the KOLIBRI_HOME to the correct value of the Kolibri home directory in all cases. This should work correctly if the KOLIBRI_USER is set to a value other than 'root' and should also work correctly if the KOLIBRI_HOME directory is manually set to an alternative value such as '/var/kolibri'.

User-facing consequences

I do not know if the KOLIBRI_HOME variable is used by kolibri itself. I suspect it may not as its often set incorrectly and using it would likely produce an error. However, the value of KOLIBRI_HOME is important for third-party scripts that may need to know the value of KOLIBRI_HOME. Currently, there is no way to accurately to determine the value of KOLIBRI_HOME in a script due to this bug.

Errors and logs

n/a

Steps to reproduce

Context

Suggested Fix

Set KOLIBRI_HOME in /etc/default/kolibri using the following command:

KOLIBRI_HOME=$(getent passwd $KOLIBRI_USER | cut -d: -f6)/.kolibri

Note, the above assumes that the home directory is always ~$USER/.kolibri for some user. I believe this is currently always the case.

indirectlylit commented 5 years ago

transferring issue to kolibri-installer-debian - cc @benjaoming @jredrejo

jredrejo commented 5 years ago

Thanks @richsegal for the information. You are 'mostly' right :) In another package it has already been set almost exactly as you recommend here ( https://github.com/learningequality/kolibri-server/blob/master/debian/kolibri-server.init#L32 ) , but in the kolibri package is not changed (yet).

It's not a problem for the way this variable is used by the kolibri package, as it's always called under the kolibri user, but definitively, it's not safe (other scripts can't relay on /etc/default/kolibri) and will be fixed.

benjaoming commented 5 years ago

Great work, since it's a very simple change and quite easy to test, I'll go ahead and release it as a new build for 0.11.1 in the stable PPA: https://launchpad.net/~learningequality/+archive/ubuntu/kolibri