From e64270ebc378cf2b5a52ae879a79b7eb6581babf Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Wed, 26 Mar 2025 20:07:14 -0700 Subject: [PATCH] calibre: Remove existing data directory before a restore operation Fixes: #2500. systemd 257 has introduced in which DynamicUser= services will use id-mapped mounts[1] instead of performing chown on the entire data directory. On Debian stable release, calibre service will contain data folders with a dynamic user ownership while on testing release, calibre service will contain data folders with nobody:nogroup ownership. When a backup from stable release is restored on testing release, the two directories are merged. The top level directory will be still owned by nobody:nogroup while the files instead will be owned by dynamic user and group. In this case, systemd will not recursively update the ownership. Calibre will fail to access the library files. The fix is to completely wipe the existing data folder before a restore. When systemd notices that the directory ownership is not properly it will recursively change the ownership before starting the service. Links: 1) https://www.freedesktop.org/software/systemd/man/latest/systemd.exec.html#RuntimeDirectory= Tests: - Without patch, restore the app on testing from a backup on stable machine and notice that the data folder is owned by nobody:nogroup but files inside are owned by a calibre-server-freedombox user and group. This leads to failure when accessing the library. - With patch, restore again notice that the library is accessible and all the files are owned by nobody:nogroup. Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- plinth/modules/calibre/manifest.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plinth/modules/calibre/manifest.py b/plinth/modules/calibre/manifest.py index 005fcc64a..022503af4 100644 --- a/plinth/modules/calibre/manifest.py +++ b/plinth/modules/calibre/manifest.py @@ -14,7 +14,8 @@ backup = { 'data': { 'directories': ['/var/lib/private/calibre-server-freedombox/'] }, - 'services': ['calibre-server-freedombox'] + 'services': ['calibre-server-freedombox'], + 'delete_before_restore': ['/var/lib/private/calibre-server-freedombox/'] } tags = [_('Ebook'), _('Library'), _('Ebook reader')]