Subject: bug#49724: 27.2; Tramp /sudoedit:: does not preserve file security context

From: Eli Zaretskii <[email-masked]>
Date: Sat, 24 Jul 2021 21:27:58 +0300

> Date: Sat, 24 Jul 2021 19:47:20 +0200 (CEST)
> From: xenodasein--- via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <[email-masked]>
> 
> The command: ls -Z /etc/fstab
> Outputs: unconfined_u:object_r:etc_t:s0 /etc/fstab
> On an unmodified fstab file. If I modify the file using 'sudoedit'
> command, which uses GNU Nano on this system, preserves the same extended
> file attributes. However, after using emacs -Q:
> C-x C-f /sudoedit::/etc/fstab
> <any file modification>
> C-x C-s
> The command: ls -Z /etc/fstab
> Outputs: unconfined_u:object_r:user_tmp_t:s0 /etc/fstab
> Which will prevent system from booting.

Did you try to use backup-by-copying, with or without
backup-by-copying-when-privileged-mismatch?