fix: switch the daemon on after moving over from plasma-face-unlock
This commit is contained in:
1 parent
b37996d518
commit
b24703eeea
2 files changed
+18
-4
No files matched your search
+9
-1
@@ -48,7 +48,7 @@ _fu_pam_drop_old() {
|
|||||||
# The system settings, the faces, sudo and admin prompts and the daemon's
|
# The system settings, the faces, sudo and admin prompts and the daemon's
|
||||||
# socket, as plasma-face-unlock left them.
|
# socket, as plasma-face-unlock left them.
|
||||||
fu_migrate_system() {
|
fu_migrate_system() {
|
||||||
local service link
|
local service link used=0
|
||||||
|
|
||||||
if [[ -d $FU_OLD_SYSDIR ]]; then
|
if [[ -d $FU_OLD_SYSDIR ]]; then
|
||||||
if [[ -f $FU_OLD_SYSDIR/config && ! -e $FU_SYSCONFIG ]]; then
|
if [[ -f $FU_OLD_SYSDIR/config && ! -e $FU_SYSCONFIG ]]; then
|
||||||
@@ -63,6 +63,7 @@ fu_migrate_system() {
|
|||||||
install -d -m 0700 "$FU_STATEDIR" || return 1
|
install -d -m 0700 "$FU_STATEDIR" || return 1
|
||||||
rm -rf -- "$FU_STATEDIR/users"
|
rm -rf -- "$FU_STATEDIR/users"
|
||||||
mv -- "$FU_OLD_STATEDIR/users" "$FU_STATEDIR/users" || return 1
|
mv -- "$FU_OLD_STATEDIR/users" "$FU_STATEDIR/users" || return 1
|
||||||
|
used=1
|
||||||
fi
|
fi
|
||||||
rm -rf -- "$FU_OLD_STATEDIR"
|
rm -rf -- "$FU_OLD_STATEDIR"
|
||||||
fi
|
fi
|
||||||
@@ -70,12 +71,19 @@ fu_migrate_system() {
|
|||||||
for service in "${FU_PAM_SERVICES[@]}"; do
|
for service in "${FU_PAM_SERVICES[@]}"; do
|
||||||
_fu_pam_has_old "$service" || continue
|
_fu_pam_has_old "$service" || continue
|
||||||
_fu_pam_drop_old "$service" && fu_pam_enable "$service"
|
_fu_pam_drop_old "$service" && fu_pam_enable "$service"
|
||||||
|
used=1
|
||||||
done
|
done
|
||||||
|
|
||||||
link="$(_fu_old_socket_link)"
|
link="$(_fu_old_socket_link)"
|
||||||
if [[ -L $link ]]; then
|
if [[ -L $link ]]; then
|
||||||
systemctl disable --now "${FU_OLD_NAME}d.socket" > /dev/null 2>&1 || true
|
systemctl disable --now "${FU_OLD_NAME}d.socket" > /dev/null 2>&1 || true
|
||||||
rm -f -- "$link"
|
rm -f -- "$link"
|
||||||
|
used=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# The old package switches its socket off when it is removed, mostly before
|
||||||
|
# this runs. So its faces and PAM lines count as the sign that it was used.
|
||||||
|
if (( used )); then
|
||||||
systemctl enable --now "$FU_UNIT_SOCKET" > /dev/null 2>&1 || true
|
systemctl enable --now "$FU_UNIT_SOCKET" > /dev/null 2>&1 || true
|
||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
+9
-3
@@ -166,6 +166,10 @@ FU_SYSCONFIG="$tmp/new-etc/config"
|
|||||||
FU_SYSTEMD_ETC="$tmp/systemd"
|
FU_SYSTEMD_ETC="$tmp/systemd"
|
||||||
old_module=/usr/lib/security/pam_plasma_face_unlock.so
|
old_module=/usr/lib/security/pam_plasma_face_unlock.so
|
||||||
|
|
||||||
|
# systemctl is only written down.
|
||||||
|
# shellcheck disable=SC2329 # called by fu_migrate_system and fu_migrate_user
|
||||||
|
systemctl() { printf '%s\n' "$*" >> "$tmp/systemctl"; }
|
||||||
|
|
||||||
# What plasma-face-unlock wrote is what this writes, under the old name.
|
# What plasma-face-unlock wrote is what this writes, under the old name.
|
||||||
make_old() {
|
make_old() {
|
||||||
sed -i -e "s|^$FU_PAM_MARK\$|$FU_OLD_PAM_MARK|" -e "s|$FU_PAM_WRAPPER_MARK|$FU_OLD_PAM_WRAPPER_MARK|" \
|
sed -i -e "s|^$FU_PAM_MARK\$|$FU_OLD_PAM_MARK|" -e "s|$FU_PAM_WRAPPER_MARK|$FU_OLD_PAM_WRAPPER_MARK|" \
|
||||||
@@ -199,19 +203,21 @@ mkdir -p "$FU_OLD_SYSDIR" "$FU_OLD_STATEDIR/users"
|
|||||||
echo 'Liveness=heavy' > "$FU_OLD_SYSDIR/config"
|
echo 'Liveness=heavy' > "$FU_OLD_SYSDIR/config"
|
||||||
echo '{}' > "$FU_OLD_STATEDIR/users/1000.json"
|
echo '{}' > "$FU_OLD_STATEDIR/users/1000.json"
|
||||||
check "old settings and faces are found" 'fu_migrate_pending'
|
check "old settings and faces are found" 'fu_migrate_pending'
|
||||||
|
: > "$tmp/systemctl"
|
||||||
fu_migrate_system
|
fu_migrate_system
|
||||||
check "the system settings moved" '[[ $(cat "$FU_SYSCONFIG") == Liveness=heavy && ! -e $FU_OLD_SYSDIR ]]'
|
check "the system settings moved" '[[ $(cat "$FU_SYSCONFIG") == Liveness=heavy && ! -e $FU_OLD_SYSDIR ]]'
|
||||||
check "the faces moved" '[[ $(cat "$FU_STATEDIR/users/1000.json") == "{}" && ! -e $FU_OLD_STATEDIR ]]'
|
check "the faces moved" '[[ $(cat "$FU_STATEDIR/users/1000.json") == "{}" && ! -e $FU_OLD_STATEDIR ]]'
|
||||||
|
check "the socket is on, although the old package switched its own off" 'grep -qx "enable --now face-unlockd.socket" "$tmp/systemctl"'
|
||||||
|
|
||||||
mkdir -p "$FU_OLD_STATEDIR/users"
|
mkdir -p "$FU_OLD_STATEDIR/users"
|
||||||
echo old > "$FU_OLD_STATEDIR/users/1000.json"
|
echo old > "$FU_OLD_STATEDIR/users/1000.json"
|
||||||
|
: > "$tmp/systemctl"
|
||||||
fu_migrate_system
|
fu_migrate_system
|
||||||
check "faces set up under the new name win" '[[ $(cat "$FU_STATEDIR/users/1000.json") == "{}" && ! -e $FU_OLD_STATEDIR ]]'
|
check "faces set up under the new name win" '[[ $(cat "$FU_STATEDIR/users/1000.json") == "{}" && ! -e $FU_OLD_STATEDIR ]]'
|
||||||
|
check "and the socket is left as it is" '[[ ! -s $tmp/systemctl ]]'
|
||||||
check "nothing is left over at the end" '! fu_migrate_pending'
|
check "nothing is left over at the end" '! fu_migrate_pending'
|
||||||
|
|
||||||
# This user's side, with systemctl only written down.
|
# This user's side.
|
||||||
# shellcheck disable=SC2329 # called by fu_migrate_user
|
|
||||||
systemctl() { printf '%s\n' "$*" >> "$tmp/systemctl"; }
|
|
||||||
FU_XDG_CONFIG="$tmp/home-config"
|
FU_XDG_CONFIG="$tmp/home-config"
|
||||||
FU_CONFDIR="$FU_XDG_CONFIG/face-unlock"
|
FU_CONFDIR="$FU_XDG_CONFIG/face-unlock"
|
||||||
mkdir -p "$FU_XDG_CONFIG/plasma-face-unlock" "$FU_XDG_CONFIG/systemd/user/graphical-session.target.wants"
|
mkdir -p "$FU_XDG_CONFIG/plasma-face-unlock" "$FU_XDG_CONFIG/systemd/user/graphical-session.target.wants"
|
||||||
|
|||||||
Reference in new issue
Block a user