← Back to team overview

debcrafters-packages team mailing list archive

[Bug 2069555] Re: Failed to take /etc/passwd lock: Invalid argument on upgrade

 

@vampire0

The problem comes down to modern versions of SystemD have changed the
locking mechanism they use for updated /etc/passwd and likely other
files. They are hard-coded now to use the Linux-specific
`fcntl(F_OFD_SETLKW)` instead of the older, POSIX-compliant
`fcntl(F_SETLKW)`. While the latter is implemented under WSL1, albeit as
a no-op it seems, they don't implement the former and instead return the
EINVAL errno. This causes all uses of `systemd-sysusers` in various
post-install scripts in Debian packages to throw an error and fail to
finish their upgrade.

I have been able to workaround it by modifying each postinst script that
calls `systemd-sysusers` in /var/lib/dpkg/info/*.postinst to ignore
errors on the call to systemd-sysusers. I added `|| true` to the end of
each line running that command. This allowed all the post-install
scripts to print out the error, but otherwise proceed and complete
successfully as far as `dpkg` is concerned. The users, however, were not
created and it's possible some services are broken, but I have not seen
any issues yet. They can be manually created latter if needed.

The only real fix for this issue is a modified systemd package which
changes the locking mechanism to one that is supported (or claims to be
supported) by WSL1. A change of the ofd argument from `true` to `false`
of the calls to `fcntl_lock()` inside `unposix_lock()` and
`unposix_unlockpp()` in the file src/basic/lock-util.c should do it. A
slightly better patch would be to have it detect the lack of support for
F_OFD_SETLKW or WSL1 and fallback to the other locking mechanism.

-- 
You received this bug notification because you are a member of
Debcrafters packages, which is subscribed to systemd in Ubuntu.
https://bugs.launchpad.net/bugs/2069555

Title:
  Failed to take /etc/passwd lock: Invalid argument on upgrade

Status in systemd package in Ubuntu:
  Confirmed

Bug description:
  When I install Ubuntu 24.04 on WSL and then do an `apt-get update`
  followed by `apt-get upgrade --yes`, the process fails with message
  "Failed to take /etc/passwd lock: Invalid argument" when trying to
  execute the post-installation script of systemd.

  The full error with context can be seen at
  https://github.com/Vampire/setup-
  wsl/actions/runs/9532264682/job/26274230057#step:4:258

  This started to fail on June 5th with the systemd version 255.4-1ubuntu8.1 being available.
  The day before the `apt-get upgrade --yes` did not contain a systemd update and it worked without problem: https://github.com/Vampire/setup-wsl/actions/runs/9359599784/job/25763680833#step:4:296

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/2069555/+subscriptions