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