sillsdev / sillsdev/libpalaso

GlobalMutex.LinuxGlobalMutexAdapter uses hardcoded /var/lock directory, which is deprecated in modern Linux and will go away

Open
#1,428 4 comments 0 reactions 1 assignee View on GitHub

@rmunn is already working on this.

Since Apr 28, 2025.

Dominant language
C#
Stars
46
Forks
50
Avg merge
6d 16h
Merged PRs (30d)
7

Description

On a recently-installed Arch Linux laptop, I ran into an issue where GlobalMutex.LinuxGlobalMutexAdapter threw "SIL.PlatformUtilities.NativeException: An error with the number, 13, ocurred." Error 13 in Linux is EPERM, permission denied.

On investigating, I found that LinuxGlobalMutexAdapter was trying to open a global mutex file in /var/lock. On recent systemd systems, /var/lock is a symlink to /run/lock and /run/lock is considered deprecated, and is expected to go away in systemd release 258 (current systemd release is 256). This comment from Lennart Poettering explains why:

"It [that is, /run/lock] is inherently legacy, and I can only advise your software to place the lock it needs in a more appropriate place, for example /run/$yoursoftware/ somewhere. These directories are typically generated via tmpfiles or RuntimeDirectory= and have the benefit that they are not a shared namespace, but a private one, and thus not prone to the security issues.

Sorry, but /run/lock/ really should die, there's zero benefit of using that dir over a proper, private runtime directory, like everyone else does.

We should update LinuxGlobalMutexAdapter to handle a "permission denied" error in /var/lock and try another path, /run/palaso/lock (creating /run/palaso/lock if it doesn't exist, and assuming that /run/palaso has already been created with appropriate permissions by the appropriate Linux package, e.g. the fieldworks .deb package should include a /usr/lib/tmpfiles.d/palaso-lock.conf file with the contents "d /run/palaso/lock 1777 root root -" so that systemd will automatically create /run/palaso/lock as a sticky-bit directory on bootup). That way we will future-proof any code that uses GlobalMutex on Linux systems, allowing it to continue to work after systemd 258 removes /var/lock support.

(Note: that last line comes from the comment in Arch Linux's conf file setting up /run/lock, which reads as follows:)

# This used to be created by systemd, but is considered part of legacy
# SystemV support, and that in turn will be removed with systemd v258
# ultimately. It is still used by differnt packages, so let's move it
# here... As /run is a tmpfs it has to be created by tmpfiles.
d /run/lock 0755 root root -

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.