Openhab 4 - failed to set user environment

As the last remaining issue of my update from FreeBSD 13.2 to FreeBSD 14 and general packages update, I updated OpenHAB from v3 to v4 and I'm getting the following error when trying to start the service:
Code:
Starting openhab.
daemon: failed to set user environment

My user and group is still set in rc.conf and the openhab rc.d file seems mostly the same as far as I can tell, the most noticeable change being the way name is set but the name itself should be the same as far as I can tell so I'm confused about what this means.

Any idea what could cause this error?
 
Maybe you accidentally removed the user with a merge during the upgrade? Does the set user account and group still exist?
 
If I check the passwd file, the user is still in there and if I do groups openhab(which is the user name), it does show the correct group as well.
 
It was something to check. But speaking of the user, failed to set user environment seems to indicate it can't switch to the user. Maybe the home directory isn't set correctly? Or something happened to the permissions of that directory? The Linux instructions talk about a OPENHAB_HOME and OPENHAB_USERDATA. On FreeBSD OPENHAB_HOME is probably /usr/local/share/openhab, but I'm not sure where /var/lib/openhab is supposed to go. On FreeBSD it's not common to use /var/lib/ for this kind of data. Maybe it should be stored in the user's home directory?

Can't help any further, don't know the actual software being used. Looks interesting though.
 
Reading the package message;
Code:
When the openhab docs talk about "userdata", look into /var/db/openhab.
You might want to check the permissions/ownership on that directory. You may need to chown(8) it to the user account you created for it. The package install/update may have reset this to 'root'.
 
I did check /var/db/openhab when I looked at the passwd file. It was set to /var/db/openhab2/home where openhab2 was owned by root:wheel but home folder was set to openhab: openhab. I tried changing the openhab2 ownership which didn't help(which didn't surprise me) and I also changed the home to /var/db/openhab/home which also already existed but is better to use since the rest of the data is stored in various folders inside /var/db/openhab and that already had the right ownership and permissions but didn't help either.

Those are the various dirs from the rc file:
Code:
eval "_openhab_backup_dir=\${${name}_backup_dir:-'/var/db/openhab/backups'}"
eval "_openhab_home_dir=\${${name}_home_dir:-'/usr/local/libexec/openhab'}"
eval "_openhab_conf_dir=\${${name}_conf_dir:-'/usr/local/etc/openhab'}"
eval "_openhab_runtime_dir=\${${name}_runtime_dir:-'/usr/local/libexec/openhab/runtime'}"
eval "_openhab_userdata_dir=\${${name}_userdata_dir:-'/var/db/openhab/userdata'}"
eval "_openhab_log_dir=\${${name}_log_dir:-'/var/log/openhab'}"
eval "_openhab_piddir=\${${name}_piddir:-/var/run/${name}}"

/usr/local/libexec/openhab was also owned by root so I tried to change that and everything inside to openhab but no luck still.
 
/usr/local/libexec/openhab was also owned by root
That should be fine, as long as the openhab user has read and execute access there. The software isn't supposed to write in this directory.

It was set to /var/db/openhab2/home where openhab2 was owned by root:wheel but home folder was set to openhab: openhab.
The "home" directory should definitely be owned by the openhab user. But looking at the directories, you may need to move things around, I guess a previous version used /var/db/openhab2/ as a base, and the newer version uses /var/db/openhab/.
 
I'm guessing my user got created when I installed openhab 2 first by accident and then I removed it to install openhab 3 but the user already existed so it kept the same.
That home directory(it is a directory, I forgot to put the / at the end of my paths in the previous post) is empty anyway so I don't think it even gets used since it has been set to it for months now with no issue. It is and was owned by the openhab user, it's just the parent directory that wasn't(but is now).
I changed it to /var/db/openhab/home/ but the previous was empty so nothing to move around. Everything else is also located in the folders as specified by the rc script as far as I can tell with proper permissions so I'm really at a loss for what could be preventing the user switch.
 
Weird, I finally figured out how to fix it, although I'm having other issues atm, but what was creating the problem was me specifying the user and group in the rc.conf file, which is the same as the default so commenting the lines just fixes that, but seems odd.

The rc.conf entries:
Code:
openhab_enable="YES"
openhab_user="openhab"
openhab_group="openhab"
openhab_http_port="8088"

And the rc.d/openhab file:
Code:
case $0 in
/etc/rc*)
        # during boot (shutdown) $0 is /etc/rc (/etc/rc.shutdown),
        # so get the name of the script from $_file
        name=$_file
        ;;
*)
        name=$0
        ;;
esac

name=${name##*/}
rcvar=${name}_enable

load_rc_config "${name}"

eval "${rcvar}=\${${rcvar}:-'NO'}"
eval "_openhab_user=\${${name}_user:-'openhab'}"
eval "_openhab_group=\${${name}_group:-'openhab'}"

eval "_openhab_http_port=\${${name}_http_port:-'8080'}"

Since the openhab_enable is working, I don't understand why the user and group would cause problems.

Edit: At least the port works fine too. Ended up having to flush all of my old userdata files except the jsondb folder to make things work.
 
Last edited:
Back
Top