Skip to content

Commit

Permalink
selinux: stop checking for deleteAlert method of setroubleshoot
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jelly committed Dec 9, 2024
1 parent b468c29 commit 8e3ebde
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 28 deletions.
15 changes: 5 additions & 10 deletions pkg/selinux/selinux.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -155,15 +155,15 @@ 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,
error: dataStore.error,
dismissError,
entries: dataStore.entries,
runFix,
deleteAlert: enableDeleteAlert ? deleteAlert : undefined,
deleteAlert,
selinuxStatus: dataStore.selinuxStatus,
selinuxStatusError: dataStore.selinuxStatusError,
changeSelinuxMode: selinuxChangeMode,
Expand Down Expand Up @@ -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;
Expand Down
20 changes: 2 additions & 18 deletions pkg/selinux/setroubleshoot-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)));
Expand All @@ -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;
};

0 comments on commit 8e3ebde

Please sign in to comment.