binfmt: clear the ignored flush failure before the registration loop
The "flush out all rules" step writes to /proc/sys/fs/binfmt_misc/status and explicitly ignores failure, but it assigns the result to the same r that RET_GATHER() consumes below. RET_GATHER() keeps the first error it is given, so a failed flush is still returned from run() and systemd-binfmt exits 1 even when every rule in binfmt.d was registered successfully. Reset r after the ignored flush so it cannot be gathered. Tested on WSL2 (kernel 6.18.40.1-microsoft-standard-WSL2), systemd 261, where /proc/sys/fs/binfmt_misc/status is a read-only tmpfs. Before this, the binary registered /etc/binfmt.d/nixos.conf successfully and then exited 1; after, it exits 0. /proc/sys/fs/binfmt_misc/WSLInterop stays enabled in both cases. Fixes #44035. (cherry picked from commit 8fc6b2141b113f63427a766aa800539437138d6c)
This commit is contained in:
committed by
Luca Boccassi
parent
1de356e556
commit
f5ecd46e22
@@ -219,6 +219,8 @@ static int run(int argc, char *argv[]) {
|
||||
else
|
||||
log_debug("Flushed all binfmt_misc rules.");
|
||||
|
||||
r = 0;
|
||||
|
||||
STRV_FOREACH(f, files)
|
||||
RET_GATHER(r, apply_file(*f, true));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user