Bug 1215538

Summary: systemd-sysusers fails when upgrading packages on WSL with Failed to take /etc/passwd lock
Product: [openSUSE] openSUSE Tumbleweed Reporter: Bruno Pitrus <brunopitrus>
Component: WSLAssignee: Matej Cepl <mcepl>
Status: IN_PROGRESS --- QA Contact: QE Containers and Public Cloud team qa-c <qa-c>
Severity: Normal    
Priority: P5 - None CC: kukuk, scott.bradnick, systemd-maintainers, werner
Version: Current   
Target Milestone: ---   
Hardware: x86-64   
OS: Windows 10   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Bruno Pitrus 2023-09-20 19:09:05 UTC
When trying to upgrade a Tumbleweed installation on WSL (Windows 10 19045.3448), several core system packages are failing to install:

/usr/bin/systemd-sysusers --replace=/usr/lib/sysusers.d/system-user-nobody.conf -
Failed to take /etc/passwd lock: Invalid argument
error: %prein(system-user-nobody-20170617-25.1.noarch) scriptlet failed, exit status 1
(0/5) Executing prein script for: system-user-nobody-20170617-25.1.noarch .................[błąd]
error: system-user-nobody-20170617-25.1.noarch: install failed
/usr/bin/systemd-sysusers --replace=/usr/lib/sysusers.d/system-user-man.conf -
Failed to take /etc/passwd lock: Invalid argument
error: %prein(system-user-man-20170617-25.1.noarch) scriptlet failed, exit status 1
(0/5) Executing prein script for: system-user-man-20170617-25.1.noarch ....................[błąd]
error: system-user-man-20170617-25.1.noarch: install failed
/usr/bin/systemd-sysusers --replace=/usr/lib/sysusers.d/system-user-lp.conf -
Failed to take /etc/passwd lock: Invalid argument
error: %prein(system-user-lp-20170617-25.1.noarch) scriptlet failed, exit status 1
(0/5) Executing prein script for: system-user-lp-20170617-25.1.noarch .....................[błąd]
error: system-user-lp-20170617-25.1.noarch: install failed
/usr/bin/systemd-sysusers --replace=/usr/lib/sysusers.d/system-user-games.conf -
Failed to take /etc/passwd lock: Invalid argument
error: %prein(system-user-games-20170617-25.1.noarch) scriptlet failed, exit status 1
(0/5) Executing prein script for: system-user-games-20170617-25.1.noarch ..................[błąd]
error: system-user-games-20170617-25.1.noarch: install failed
/usr/bin/systemd-sysusers --replace=/usr/lib/sysusers.d/dbus.conf -
Failed to take /etc/passwd lock: Invalid argument
error: %prein(dbus-1-common-1.14.8-1.3.noarch) scriptlet failed, exit status 1
(0/5) Executing prein script for: dbus-1-common-1.14.8-1.3.noarch .........................[błąd]
error: dbus-1-common-1.14.8-1.3.noarch: install failed
error: system-user-nobody-20170617-24.13.noarch: erase skipped
error: system-user-man-20170617-24.13.noarch: erase skipped
error: system-user-lp-20170617-24.13.noarch: erase skipped
error: system-user-games-20170617-24.13.noarch: erase skipped
error: dbus-1-common-1.14.8-1.2.noarch: erase skipped
Comment 1 Bruno Pitrus 2023-09-20 19:16:56 UTC
All of the broken packages have a dependency on sysuser-shadow which tries to execute this command only if systemd is installed.

systemd has absolutely no business bein installed inside WSL (or any container). I could uninstall it if it weren't pulled in as a dependency of `man` which I use.

Assigning this to the man maintainers.
Comment 2 Dr. Werner Fink 2024-01-19 09:47:54 UTC
(In reply to Bruno Pitrus from comment #1)
> All of the broken packages have a dependency on sysuser-shadow which tries
> to execute this command only if systemd is installed.
> 
> systemd has absolutely no business bein installed inside WSL (or any
> container). I could uninstall it if it weren't pulled in as a dependency of
> `man` which I use.
> 
> Assigning this to the man maintainers.

Why man maintainers?  This is more a systemd problem ... the message

  Failed to take /etc/passwd lock: Invalid argument

shows that some bigger problem.
Comment 3 Bruno Pitrus 2024-01-19 13:06:18 UTC
Because the dependency of `man` on `systemd` is unnecessary.
Comment 4 Dr. Werner Fink 2024-01-19 13:33:51 UTC
(In reply to Bruno Pitrus from comment #3)
> Because the dependency of `man` on `systemd` is unnecessary.

You mean that I should ignore that now man or better its mandb command will not be executed without systemd timer?

 rpm -qf /usr/lib/systemd/system/timers.target
 systemd-254.5-5.1.x86_64

 rpm -ql man | grep usr/lib/systemd/system
 /usr/lib/systemd/system/man-db-create.service
 /usr/lib/systemd/system/man-db.service
 /usr/lib/systemd/system/man-db.timer
Comment 5 Thorsten Kukuk 2024-01-19 14:06:11 UTC
(In reply to Dr. Werner Fink from comment #4)
> (In reply to Bruno Pitrus from comment #3)
> > Because the dependency of `man` on `systemd` is unnecessary.
> 
> You mean that I should ignore that now man or better its mandb command will
> not be executed without systemd timer?

On WSL and in containers mandb will never be executed by systemd timer, even with your Requires. Because systemd does not run in this environments, even if you add it as Requires.
On a "standard" installation, systemd is always installed and running, we don't support anything else.
Comment 6 Dr. Werner Fink 2024-01-19 14:22:00 UTC
(In reply to Thorsten Kukuk from comment #5)
> (In reply to Dr. Werner Fink from comment #4)
> > (In reply to Bruno Pitrus from comment #3)
> > > Because the dependency of `man` on `systemd` is unnecessary.
> > 
> > You mean that I should ignore that now man or better its mandb command will
> > not be executed without systemd timer?
> 
> On WSL and in containers mandb will never be executed by systemd timer, even
> with your Requires. Because systemd does not run in this environments, even
> if you add it as Requires.
> On a "standard" installation, systemd is always installed and running, we
> don't support anything else.

The problem is that running mandb in %post or %posttrans to create man data base  takes ages therefore I use due several bug reports now systemd API.

Are there possibilities to detect in %post or %posttrans during installation time what surrounding environment will be used (WSL, container, or systemd based).
Comment 7 Thorsten Kukuk 2024-01-19 14:59:41 UTC
(In reply to Dr. Werner Fink from comment #6)

> Are there possibilities to detect in %post or %posttrans during installation
> time what surrounding environment will be used (WSL, container, or systemd
> based).

I cannot say anything about WSL, but for container: no. This is like building disk images, you know the build environment, but not the final environment.
But for this cases (especially container), it is the responsibility of the person who builds the image to do that, not the one of the package maintainer. He cannot do anything except to make it worse by blowing up pre/post install scripts with more most of the time useless code.
Comment 8 Dr. Werner Fink 2024-01-26 10:02:18 UTC
Main problems are: Creation of system group/user man
                   Creation of /var/cache/man
                   Creation of the various index.db below /var/cache/man/
currently done with systemd.

I really want to know why one like to use man in a container ...
now I've readded the old why of adding group/user man if not already done
by systemd also creating /var/cache/man if not done by systemd as well as use filetriggers lua scriptlets to get the index.db below /var/cache/man/ created as well as uptodate
Comment 9 OBSbugzilla Bot 2024-01-26 11:35:03 UTC
This is an autogenerated message for OBS integration:
This bug (1215538) was mentioned in
https://build.opensuse.org/request/show/1141710 Factory / man
Comment 10 Thorsten Kukuk 2024-01-26 14:22:45 UTC
The useradd/groupadd is useless, if there is no systemd installed the fallback is even more clever and supports tools like busybox
Comment 11 Thorsten Kukuk 2024-01-26 14:27:02 UTC
For the user creation part I think we should better enhance the sysuser-tools script to use the fallbacks in the case systemd fails, too.
Will try to look at it after my sick leave.
Comment 12 Dr. Werner Fink 2024-01-29 15:05:33 UTC
(In reply to Thorsten Kukuk from comment #11)
> For the user creation part I think we should better enhance the
> sysuser-tools script to use the fallbacks in the case systemd fails, too.
> Will try to look at it after my sick leave.

Isn't that what /usr/sbin/sysusers2shadow does in case of missing
/usr/bin/systemd-sysusers? Nevertheless 

The creation of /var/cache/man by systemd-tmpfiles is also a problem if
/usr/bin/systemd-tmpfiles
does not exists
Comment 13 Thorsten Kukuk 2024-01-30 07:28:08 UTC
(In reply to Dr. Werner Fink from comment #12)
> (In reply to Thorsten Kukuk from comment #11)
> > For the user creation part I think we should better enhance the
> > sysuser-tools script to use the fallbacks in the case systemd fails, too.
> > Will try to look at it after my sick leave.
> 
> Isn't that what /usr/sbin/sysusers2shadow does in case of missing
> /usr/bin/systemd-sysusers?

If it is missing, yes. If it is failing like in this case, no.
Comment 14 Bruno Pitrus 2024-04-05 20:21:50 UTC
systemd appeared again on my WSL this time through DNF's dependency on python3-systemd.

python3-systemd likewise has no business requiring the systemd daemon (which is UNUSABLE on WSL), only libsystemd0. Reassigning to python-systemd's maintainer.

Debian and Fedora seem to do this correctly btw.