From 1abce3eb910e3e7af86ea451c62a30a6578fdc67 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 14 Oct 2020 09:46:03 +0100 Subject: [PATCH 1/2] manager: Return MCT_MANAGER_ERROR_DISABLED if no accountsservice In distributions that package shared libraries and daemons separately, it's possible to have the shared library (because it's required to run something like Flatpak) but not the accountsservice daemon or its malcontent extension (because the administrator of this particular installation has no interest in parental controls, and their choice of desktop environment is such that nothing else depends on accountsservice either). This minimizes the memory and disk space cost of enabling the libmalcontent feature in Flatpak for those who do not need it, while keeping it available for those that do. Treat this the same as if accountsservice is available but the malcontent extension is not: fail open, by returning MCT_MANAGER_ERROR_DISABLED. Resolves: https://gitlab.freedesktop.org/pwithnall/malcontent/-/issues/27 Bug-Debian: https://bugs.debian.org/972145 Signed-off-by: Simon McVittie --- libmalcontent/manager.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libmalcontent/manager.c b/libmalcontent/manager.c index 1a69ba2..4fc35db 100644 --- a/libmalcontent/manager.c +++ b/libmalcontent/manager.c @@ -286,6 +286,14 @@ bus_error_to_manager_error (const GError *bus_error, bus_remote_error_matches (bus_error, "org.freedesktop.Accounts.Error.Failed")) return g_error_new (MCT_MANAGER_ERROR, MCT_MANAGER_ERROR_INVALID_USER, _("User %u does not exist"), (guint) user_id); + else if (g_error_matches (bus_error, G_DBUS_ERROR, G_DBUS_ERROR_SERVICE_UNKNOWN) || + g_error_matches (bus_error, G_DBUS_ERROR, G_DBUS_ERROR_NAME_HAS_NO_OWNER)) + /* If accountsservice is not available on the system bus, then the + * com.endlessm.ParentalControls.AppFilter extension interface + * certainly can't be available. */ + return g_error_new_literal (MCT_MANAGER_ERROR, + MCT_MANAGER_ERROR_DISABLED, + _("System accounts service not available")); else return g_error_copy (bus_error); } From b5b1ac26a28eb11c64972b7a3ac3156683591c87 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 15 Oct 2020 09:05:56 +0100 Subject: [PATCH 2/2] manager: Make an error message less specific Philip Withnall pointed out that if mct_manager_get_session_limits() fails with G_DBUS_ERROR_ACCESS_DENIED or org.freedesktop.Accounts.Error.PermissionDenied, the error message will wrongly refer to app filter data. Make it more generally applicable. Signed-off-by: Simon McVittie --- libmalcontent/manager.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmalcontent/manager.c b/libmalcontent/manager.c index 4fc35db..4a02aa8 100644 --- a/libmalcontent/manager.c +++ b/libmalcontent/manager.c @@ -280,7 +280,7 @@ bus_error_to_manager_error (const GError *bus_error, if (g_error_matches (bus_error, G_DBUS_ERROR, G_DBUS_ERROR_ACCESS_DENIED) || bus_remote_error_matches (bus_error, "org.freedesktop.Accounts.Error.PermissionDenied")) return g_error_new (MCT_MANAGER_ERROR, MCT_MANAGER_ERROR_PERMISSION_DENIED, - _("Not allowed to query app filter data for user %u"), + _("Not allowed to query parental controls data for user %u"), (guint) user_id); else if (g_error_matches (bus_error, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD) || bus_remote_error_matches (bus_error, "org.freedesktop.Accounts.Error.Failed"))