Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adduser problem - Package installation via cloudsmith #678

Closed
kmecke opened this issue Oct 2, 2024 · 19 comments
Closed

adduser problem - Package installation via cloudsmith #678

kmecke opened this issue Oct 2, 2024 · 19 comments

Comments

@kmecke
Copy link

kmecke commented Oct 2, 2024

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
Copy link
Collaborator

J-A-U commented Oct 2, 2024

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

@kmecke
Copy link
Author

kmecke commented Oct 2, 2024

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
Copy link
Collaborator

J-A-U commented Oct 2, 2024

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
Copy link
Author

kmecke commented Oct 3, 2024

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
Copy link
Contributor

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
Copy link
Collaborator

J-A-U commented Oct 4, 2024

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

@r00t-
Copy link
Contributor

r00t- commented Oct 5, 2024

this was introduced by #628 8e28a5c
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-
Copy link
Contributor

r00t- commented Oct 5, 2024

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
Copy link
Collaborator

narc-Ontakac2 commented Oct 5, 2024

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

@narc-Ontakac2
Copy link
Collaborator

narc-Ontakac2 commented Oct 5, 2024

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-
Copy link
Contributor

r00t- commented Oct 6, 2024

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
Copy link
Author

kmecke commented Oct 6, 2024

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
Copy link
Collaborator

narc-Ontakac2 commented Oct 6, 2024

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-
Copy link
Contributor

r00t- commented Oct 6, 2024

@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
Copy link
Collaborator

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

@narc-Ontakac2
Copy link
Collaborator

@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
Copy link
Author

kmecke commented Oct 10, 2024

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
Copy link
Collaborator

narc-Ontakac2 commented Oct 10, 2024

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
Copy link
Collaborator

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

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

No branches or pull requests

5 participants