From 8e3ebde901f1fd63858bc0833acd32d202313d21 Mon Sep 17 00:00:00 2001 From: Jelle van der Waa Date: Mon, 9 Dec 2024 16:39:04 +0100 Subject: [PATCH] selinux: stop checking for deleteAlert method of setroubleshoot The lack of deleteAlert has already been resolved in RHEL 7, as we no longer support this the capability check can be removed. https://bugzilla.redhat.com/show_bug.cgi?id=1306700 --- pkg/selinux/selinux.js | 15 +++++---------- pkg/selinux/setroubleshoot-client.js | 20 ++------------------ 2 files changed, 7 insertions(+), 28 deletions(-) diff --git a/pkg/selinux/selinux.js b/pkg/selinux/selinux.js index e9dd395df269..86109923fb82 100644 --- a/pkg/selinux/selinux.js +++ b/pkg/selinux/selinux.js @@ -129,7 +129,7 @@ const initStore = function(rootElement) { * This function will only be called if the backend functionality is actually present */ const deleteAlert = function(alertId) { - return dataStore.client.capabilities.deleteAlert(alertId) + return dataStore.client.deleteAlert(alertId) .then(() => { let idx; for (idx = dataStore.entries.length - 1; idx >= 0; --idx) { @@ -155,7 +155,7 @@ const initStore = function(rootElement) { const render = function() { if (!dataStore.reactRoot) dataStore.reactRoot = createRoot(rootElement); - const enableDeleteAlert = ('capabilities' in dataStore.client && 'deleteAlert' in dataStore.client.capabilities); + dataStore.reactRoot.render(React.createElement(SETroubleshootPage, { connected: dataStore.connected, connecting: dataStore.connecting, @@ -163,7 +163,7 @@ const initStore = function(rootElement) { dismissError, entries: dataStore.entries, runFix, - deleteAlert: enableDeleteAlert ? deleteAlert : undefined, + deleteAlert, selinuxStatus: dataStore.selinuxStatus, selinuxStatusError: dataStore.selinuxStatusError, changeSelinuxMode: selinuxChangeMode, @@ -255,19 +255,14 @@ const initStore = function(rootElement) { dataStore.connectionTimeout = 5000; - function capablitiesChanged(capabilities) { - dataStore.capabilities = capabilities; - render(); - } - // try to connect dataStore.tryConnect = function() { if (dataStore.connecting === null) { dataStore.connecting = window.setTimeout(setErrorIfNotConnected, dataStore.connectionTimeout); render(); // initialize our setroubleshootd client - dataStore.client.init(capablitiesChanged) - .then(capablitiesChanged => { + dataStore.client.init() + .then(() => { dataStore.connected = true; window.clearTimeout(dataStore.connecting); dataStore.connecting = null; diff --git a/pkg/selinux/setroubleshoot-client.js b/pkg/selinux/setroubleshoot-client.js index f12897d0bf3a..2c6b76b87d5f 100644 --- a/pkg/selinux/setroubleshoot-client.js +++ b/pkg/selinux/setroubleshoot-client.js @@ -31,7 +31,7 @@ const busNameFixit = "org.fedoraproject.SetroubleshootFixit"; const dbusInterfaceFixit = busNameFixit; const dbusPathFixit = "/org/fedoraproject/SetroubleshootFixit/object"; -client.init = function(capabilitiesChangedCallback) { +client.init = function() { client.connected = false; const dbusClientSeTroubleshoot = cockpit.dbus(busName, { superuser: "try" }); client.proxy = dbusClientSeTroubleshoot.proxy(dbusInterface, dbusPath); @@ -148,7 +148,7 @@ client.init = function(capabilitiesChangedCallback) { /* Delete an alert from the database (will be removed for all users), returns true on success * Only assign this to the client variable if the dbus interface actually supports the operation */ - const deleteAlert = localId => client.proxy.call("delete_alert", [localId]) + client.deleteAlert = localId => client.proxy.call("delete_alert", [localId]) .then(success => { if (!success) return Promise.reject(new Error(cockpit.format(_("Failed to delete alert: $0"), localId))); @@ -158,22 +158,6 @@ client.init = function(capabilitiesChangedCallback) { return Promise.reject(new Error(cockpit.format(_("Failed to delete alert: $0"), ex.toString()))); }); - // earlier versions of the dbus interface don't support alert deletion/dismissal - // HACK https://bugzilla.redhat.com/show_bug.cgi?id=1306700 - // once every client we ship to handles these features, we can remove the capabilities check - client.capabilities = { }; - - // wait for metadata - if this has the method delete_alert, we can use that - dbusClientSeTroubleshoot.addEventListener("meta", function(event, meta) { - if (dbusInterface in meta && 'methods' in meta[dbusInterface] && 'delete_alert' in meta[dbusInterface].methods) - client.capabilities.deleteAlert = deleteAlert; - else - delete client.capabilities.deleteAlert; - - if (capabilitiesChangedCallback) - capabilitiesChangedCallback(client.capabilities); - }); - // connect to dbus and start setroubleshootd return connectPromise; };