volkszaehler / vzlogger

Logging utility for various meters & sensors
http://wiki.volkszaehler.org/software/controller/vzlogger
GNU General Public License v3.0
145 stars 123 forks source link

adduser problem - Package installation via cloudsmith #678

Closed kmecke closed 1 month ago

kmecke commented 1 month ago

After the package installation via cloudsmith as described in the Readme in section "Debian and Raspberry Pi OS Packages" everything works out nice, until the configuration of the package. I think there is just the option missing so that the user _vzlogger user will be created correctly.

vz2@rpi:~ $ sudo apt install vzlogger
[...]
Get:4 https://dl.cloudsmith.io/public/volkszaehler/volkszaehler-org-project/deb/raspbian bullseye/main armhf vzlogger armhf 0.8.7 [251 kB]
Fetched 476 kB in 1s (325 kB/s)
Selecting previously unselected package libmbus0.
(Reading database ... 53780 files and directories currently installed.)
Preparing to unpack .../libmbus0_0.9.0+git20240530-1_armhf.deb ...
Unpacking libmbus0 (0.9.0+git20240530-1) ...
Selecting previously unselected package libmicrohttpd12:armhf.
Preparing to unpack .../libmicrohttpd12_0.9.72-2+deb11u1_armhf.deb ...
Unpacking libmicrohttpd12:armhf (0.9.72-2+deb11u1) ...
Selecting previously unselected package libsml1:armhf.
Preparing to unpack .../libsml1_1.1.3_armhf.deb ...
Unpacking libsml1:armhf (1.1.3) ...
Selecting previously unselected package vzlogger.
Preparing to unpack .../vzlogger_0.8.7_armhf.deb ...
Unpacking vzlogger (0.8.7) ...
Setting up libmbus0 (0.9.0+git20240530-1) ...
Setting up libsml1:armhf (1.1.3) ...
Setting up libmicrohttpd12:armhf (0.9.72-2+deb11u1) ...
Setting up vzlogger (0.8.7) ...
adduser: Please enter a username matching the regular expression configured
via the NAME_REGEX configuration variable.  Use the `--force-badname'
option to relax this check or reconfigure NAME_REGEX.
dpkg: error processing package vzlogger (--configure):
 installed vzlogger package post-installation script subprocess returned error exit status 1
Processing triggers for man-db (2.9.4-2) ...
Processing triggers for libc-bin (2.31-13+rpt2+rpi1+deb11u11) ...
Errors were encountered while processing:
 vzlogger
E: Sub-process /usr/bin/dpkg returned an error code (1)

vz2@rpi:/etc $ cat os-release
PRETTY_NAME="Raspbian GNU/Linux 11 (bullseye)"
NAME="Raspbian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=raspbian
ID_LIKE=debian

My workaround, which does not work (but why?):

sudo nano /etc/adduser.conf
NAME_REGEX="^[a-z_][-a-z0-9_]*\$"

Maybe you want to change the username OR add the --force-badname

... and thank you for your great work at this project!

J-A-U commented 1 month ago

Can you generate the needed user on the command line? sudo useradd -M vzlogger

kmecke commented 1 month ago

Hi - yes that works fine.... Having said that... is the underscore the issue? I understood that the service user is _vzlogger? As mentioned here.

I just created the _vzlogger user as well, without issues. So I guess the modified regex pattern in adduser.conf has some effect.

Surprise.. here wo go:

vz2@rpi:/usr/local/bin $ sudo dpkg --configure -a
Setting up vzlogger (0.8.7) ...
Created symlink /etc/systemd/system/multi-user.target.wants/vzlogger.service → /lib/systemd/system/vzlogger.service.
vz2@rpi:/usr/local/bin $

So I guess the workaround works now.

J-A-U commented 1 month ago

As mentioned here.

Sorry. Missed that one.

So I guess the workaround works now.

Did you delete the created users before you retried installing the package?

If not, my bet is the needed user already existing "solved" the problem.

kmecke commented 1 month ago

Hi - no, I did not delete the user. I think you are right. I feel like I am pretty close to get my volkszähler up an running... this weekend.

Shall I change the pattern back to the original expression too reproduce the issue in the installation process, or do you have enough information? I think its a pretty small thing that breaks the package installation. Let me know if I can assist you...

In the meantime, I am a happy customer by adding the user manually ; ) I leave the ticket open and up to you how to proceed. Thanks for your support and your great work!

Zugschlus commented 1 month ago

adduser maintainer from Debian here. Yes, to create a user with an underscore you need --force-badname, as mentioned in the error message.

J-A-U commented 1 month ago

@Zugschlus is there a best practice how to name "system"-users (without home directory) for Debian?

r00t- commented 1 month ago

this was introduced by #628 https://github.com/volkszaehler/vzlogger/commit/8e28a5c61f27bbbc33f24105e197b4a9c406b136 detail: https://github.com/volkszaehler/vzlogger/pull/628/files#diff-ce3462eeac5a3c192b69b87295bf537536adfd72fdf8bac44d989ddfbed79ac0R15 it looks like the underscore username was recommended to @narc-Ontakac2 as a best practice... @narc-Ontakac2: can you comment?

r00t- commented 1 month ago

as referenced in #628 : https://www.debian.org/doc/debian-policy/ch-opersys.html#users-and-groups

When maintainers choose a new hardcoded or dynamically generated username for packages to use, they should start this username with an underscore. This minimizes collisions with locally created user accounts.

this appears to entail that scripts generating such an account have to use --force-badname, even if that seems strange.

narc-Ontakac2 commented 1 month ago

I have asked about the issue on the Debian developer list. I'll fix this according to the outcome.

narc-Ontakac2 commented 1 month ago

The script is creating a system user. Therefore

# System user- and groupnames are checked against this regular
# expression.
# Default: SYS_NAME_REGEX="^[a-z_][-a-z0-9_]*\$?$"

should be applied. This however allows a leading underscore. The above is however from Debian trixie. @kmecke What is your unmodified /etc/adduser.conf?

r00t- commented 1 month ago

https://metadata.ftp-master.debian.org/changelogs//main/a/adduser/adduser_3.134_changelog

adduser (3.131) unstable; urgency=medium

  • Fix a bug: system user names are now allowed to begin with an underscore. Thanks to Guillem Jover for spotting this. -- Marc Haber mh+debian-packages@zugschlus.de Tue, 07 Feb 2023 12:08:36 +0100

https://packages.debian.org/search?keywords=adduser&searchon=names&suite=all&section=all

buster (oldoldstable) 3.118: all bullseye (oldstable) 3.118+deb11u1: all bookworm (stable) 3.134: all trixie (testing) 3.137: all sid (unstable) 3.137: all

so this should work on stable and beyond, and only break on oldstable. but @kmecke is installing on bullseye/oldstable. as of his log... if we want to support that, we need to add the force flag. i guess just adding it makes more sense than special-casing on the distribution or adduser-version.

kmecke commented 1 month ago

Even though you, @r00t- have it all together, I still want to answer your @narc-Ontakac2 question, maybe 8 hrs late...

@kmecke What is your unmodified /etc/adduser.conf?

The regex line was a comment and the regex was missing the underscore. Last two lines:

# check user and group names also against this regular expression.
# NAME_REGEX="^[a-z][-a-z0-9_]*\$"

I felt reluctant to upgrade to stable, since lots of stuff on that Raspi 3B (PiHole, z-wave controller... soon volkszähler) seem to be tested toward bullseye. But you are right - its about time. Stable should stable enough for an dist-upgrade

narc-Ontakac2 commented 1 month ago

Unfortunately the trixie man page for adduser states

       --force-badname
       --allow-badname
              These are the deprecated forms of --allow-bad-names.  It will  be
              removed  during  the  release  cycle  of the Debian release after
              bookworm.

So special-casing is needed unless we bet on the adduser maintainers being sloppy regarding their announcement.

Will be done, but since it is not completely trivial it might take a day.

r00t- commented 1 month ago

@Zugschlus: as you are here anyway, do you have an idea of how this should be handled for packages that want to support old and new releases?

narc-Ontakac2 commented 1 month ago

There is PR #679 by now, I do however still need to test it.

narc-Ontakac2 commented 1 month ago

@kmecke In case you haven't upgraded yet - could you remove vzlogger, do a deluser _vzlogger and install it again. The issue should be fixed in 0.8.8. However I haven't been able to test it.

kmecke commented 1 month ago

Hi @narc-Ontakac2 - sorry, I did the upgrade (vzloggger still not running, but the user is not the issue I guess). I have a backup of the old system, but I will not find the time to restore it and test it soon (maybe in two weeks)...

narc-Ontakac2 commented 1 month ago

I have a backup of the old system, but I will not find the time to restore it and test it soon (maybe in two weeks)...

Don't, that is too much effort.

narc-Ontakac2 commented 1 month ago

Inzwischen hat auch der Test für die Installation auf bullseye mit piuparts geklappt.