From d8f17525d5d66a4c6694ec9ebf32a174ea74f3e3 Mon Sep 17 00:00:00 2001
From: Michael Biebl <biebl@debian.org>
Date: Thu, 2 Jun 2022 12:56:11 +0200
Subject: Run binfmt-support.service after systemd-binfmt.service

This fixes a race condition during boot when both services try to access
/proc/sys/fs/binfmt_misc/register at the same time which can lead to the
following error:

 systemd[1]: Starting Enable support for additional executable binary formats...
 update-binfmts[536]: update-binfmts: warning: unable to close /proc/sys/fs/binfmt_misc/register: File exists
 update-binfmts[536]: update-binfmts: warning: unable to close /proc/sys/fs/binfmt_misc/register: File exists
 update-binfmts[536]: update-binfmts: warning: unable to close /proc/sys/fs/binfmt_misc/register: File exists
 update-binfmts[536]: update-binfmts: exiting due to previous errors
 systemd[1]: binfmt-support.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
 systemd[1]: binfmt-support.service: Failed with result 'exit-code'.
 systemd[1]: Failed to start Enable support for additional executable binary formats.

Fixes Debian bug #1012154.

Origin: upstream, https://gitlab.com/cjwatson/binfmt-support/-/commit/54f0e1af8ac6bcaf4594747df8965b5c5bdd3744
Bug-Debian: https://bugs.debian.org/1012154
Bug-Debian: https://bugs.debian.org/1021822
Last-Update: 2022-10-15

Patch-Name: systemd-ordering.patch
---
 init/systemd/binfmt-support.service.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/init/systemd/binfmt-support.service.in b/init/systemd/binfmt-support.service.in
index 25c30e2..f6d0d4d 100644
--- a/init/systemd/binfmt-support.service.in
+++ b/init/systemd/binfmt-support.service.in
@@ -20,7 +20,7 @@
 Description=Enable support for additional executable binary formats
 Documentation=man:update-binfmts(8)
 DefaultDependencies=false
-After=local-fs.target proc-sys-fs-binfmt_misc.automount
+After=local-fs.target proc-sys-fs-binfmt_misc.automount systemd-binfmt.service
 
 [Service]
 Type=oneshot
