fhem-docker icon indicating copy to clipboard operation
fhem-docker copied to clipboard

Alleged permission issue regarding logfile (readonly)

Open passibe15 opened this issue 1 year ago • 3 comments

Describe the bug Starting a container with image tag 4-bullseye and env variables FHEM_UID and FHEM_GID set to a non-default value, FHEM gives the following error message: Messages collected while initializing FHEM:configfile: logfile is readonly, it is set in the FHEM_GLOBALATTR environment

However, the logfile is writeable without any problems. Also, all permissions get set correctly (i.e. entry.sh is doing its job correctly).

To Reproduce Steps to reproduce the behavior:

  1. Set FHEM_UID and FHEM_GID to some non-default value
  2. Start container
  3. Observe reading init_errors in device global
  4. Observe logfile and notice it is being written to despite the error message
  5. Change to 3-bullseye and observe that error message vanishes

Expected behavior No error message

Additional context Another user reported that they also get an error message for the PID file. This first occurred after switching from 3-bullseye to 4-bullseye. See here (also see following forum posts for additional context).

Also, I am not sure if this is an issue within fhem.pl or with the container environment, however, given that the issue was not present in 3-bullseye I am assuming it is an issue with the code in this repo, rather than FHEM itself.

For the sake of completeness, here is the content of /proc/$PID/environ: SHELL=/bin/bashFHEM_GLOBALATTR=nofork=0 updateInBackground=1 logfile=log/fhem-%Y-%m-%d.log pidfilename=log/fhem.pidHOSTNAME=ha_fhemtestLANGUAGE=en_US:enPERL_JSON_BACKEND=Cpanel::JSON::XS,JSON::XS,JSON::PP,JSON::backportPPLC_ADDRESS=de_DE.UTF-8LC_NAME=de_DE.UTF-8LC_MONETARY=de_DE.UTF-8UMASK=0037PWD=/opt/fhemLOGNAME=fhemTZ=Europe/BerlinLOGFILE=/opt/fhem/log/fhem-%Y-%m-%d.logHOME=/opt/fhemFHEM_UID=7073LANG=en_US.UTF-8LC_PAPER=de_DE.UTF-8PERL5LIB=/usr/src/app/core/lib/perl5:/usr/src/app/3rdparty/lib/perl5GPIO_GID=6002FHEM_GID=7067TERM=xtermUSER=fhemCONFIGTYPE=fhem.cfgDOCKER_GW=172.21.0.1I2C_GID=6003TIMEOUT=10SHLVL=1LC_TELEPHONE=de_DE.UTF-8LC_MESSAGES=en_DK.UTF-8LC_MEASUREMENT=de_DE.UTF-8FHEM_PERM_FILE=0640LC_TIME=de_DE.UTF-8DOCKER_HOST=172.21.0.1PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/binTELNETPORT=7072DOCKER_HOSTNETWORK=0MAIL=/var/mail/fhemFHEM_PERM_DIR=0750BLUETOOTH_GID=6001LC_NUMERIC=de_DE.UTF-8DOCKER_PRIVILEGED=1OLDPWD=/opt/fhem_=/usr/local/bin/perlroot

passibe15 avatar Dec 09 '24 21:12 passibe15

Same Problem with my Installation. Changed the Version from 3 to 4 bullseye yesterday evening. Reported the error also at the FHEM forum

also get an error. Essbare for the pidfile

no-Legend avatar Dec 09 '24 21:12 no-Legend

I don't think that this is an error, its more like some information https://github.com/fhem/fhem-mirror/blob/cfaeb4e68c0699bbefefffe767b79e4f94c23439/fhem/fhem.pl#L2938

Because if a attribute is defined via an environment variable you can't overwrite it from the fhem itself, it must be changed via the environment variable which is controlled by the container.

sidey79 avatar Dec 09 '24 21:12 sidey79

Oh. So "readonly" means that the attribute logfile is readonly? Not the logfile itself? Ok. Maybe that message should be clarified then (but not an issue for this repo, of course).

But that still doesn't explain why this only happens when UID/GID is changed to non-default …

passibe15 avatar Dec 09 '24 21:12 passibe15