From 8bd6e4128661edaebee5aebfd45162b241202d91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alfonso=20S=C3=A1nchez-Beato?= Date: Thu, 22 Jan 2026 13:32:37 -0500 Subject: [PATCH] static/usr/lib/systemd: mount /etc/{group,gshadow,passwd,shadow} when running in recover mount and we find those files under /run/snapd/hybrid-users/. This is needed for hybrid systems in recover mode. --- .../systemd/system-generators/hybrid-users | 22 +++++++++++++++++++ static/usr/lib/systemd/system/etc-group.mount | 5 +++++ .../usr/lib/systemd/system/etc-gshadow.mount | 5 +++++ .../usr/lib/systemd/system/etc-passwd.mount | 5 +++++ .../usr/lib/systemd/system/etc-shadow.mount | 5 +++++ 5 files changed, 42 insertions(+) create mode 100755 static/usr/lib/systemd/system-generators/hybrid-users create mode 100644 static/usr/lib/systemd/system/etc-group.mount create mode 100644 static/usr/lib/systemd/system/etc-gshadow.mount create mode 100644 static/usr/lib/systemd/system/etc-passwd.mount create mode 100644 static/usr/lib/systemd/system/etc-shadow.mount diff --git a/static/usr/lib/systemd/system-generators/hybrid-users b/static/usr/lib/systemd/system-generators/hybrid-users new file mode 100755 index 00000000..ba249490 --- /dev/null +++ b/static/usr/lib/systemd/system-generators/hybrid-users @@ -0,0 +1,22 @@ +#!/bin/bash + +set -eu + +mode="$(/usr/libexec/core/get-mode mode)" || mode="$(/usr/libexec/core/get-arg snapd_recovery_mode)" || mode="unknown" + +WANTS="${1}/local-fs.target.wants" + +enable() { + ln -s "/usr/lib/systemd/system/${1}" "${WANTS}/" +} + +USERS_P=/run/snapd/hybrid-users + +# Only for hybrid in recover mode +if [ -f "$USERS_P"/passwd ] && [ "${mode}" = "recover" ]; then + mkdir -p "${WANTS}" + enable etc-passwd.mount + enable etc-shadow.mount + enable etc-group.mount + enable etc-gshadow.mount +fi diff --git a/static/usr/lib/systemd/system/etc-group.mount b/static/usr/lib/systemd/system/etc-group.mount new file mode 100644 index 00000000..39bc7fc7 --- /dev/null +++ b/static/usr/lib/systemd/system/etc-group.mount @@ -0,0 +1,5 @@ +[Mount] +Where=/etc/group +What=/run/snapd/hybrid-users/group +Type=none +Options=bind diff --git a/static/usr/lib/systemd/system/etc-gshadow.mount b/static/usr/lib/systemd/system/etc-gshadow.mount new file mode 100644 index 00000000..d55ad9ed --- /dev/null +++ b/static/usr/lib/systemd/system/etc-gshadow.mount @@ -0,0 +1,5 @@ +[Mount] +Where=/etc/gshadow +What=/run/snapd/hybrid-users/gshadow +Type=none +Options=bind diff --git a/static/usr/lib/systemd/system/etc-passwd.mount b/static/usr/lib/systemd/system/etc-passwd.mount new file mode 100644 index 00000000..3e53d001 --- /dev/null +++ b/static/usr/lib/systemd/system/etc-passwd.mount @@ -0,0 +1,5 @@ +[Mount] +Where=/etc/passwd +What=/run/snapd/hybrid-users/passwd +Type=none +Options=bind diff --git a/static/usr/lib/systemd/system/etc-shadow.mount b/static/usr/lib/systemd/system/etc-shadow.mount new file mode 100644 index 00000000..f3fb5cc1 --- /dev/null +++ b/static/usr/lib/systemd/system/etc-shadow.mount @@ -0,0 +1,5 @@ +[Mount] +Where=/etc/shadow +What=/run/snapd/hybrid-users/shadow +Type=none +Options=bind