Skip to content

Commit daa728f

Browse files
jellymartinpitt
authored andcommitted
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
1 parent 5819b05 commit daa728f

File tree

2 files changed

+7
-28
lines changed

2 files changed

+7
-28
lines changed

pkg/selinux/selinux.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ const initStore = function(rootElement) {
129129
* This function will only be called if the backend functionality is actually present
130130
*/
131131
const deleteAlert = function(alertId) {
132-
return dataStore.client.capabilities.deleteAlert(alertId)
132+
return dataStore.client.deleteAlert(alertId)
133133
.then(() => {
134134
let idx;
135135
for (idx = dataStore.entries.length - 1; idx >= 0; --idx) {
@@ -155,15 +155,15 @@ const initStore = function(rootElement) {
155155
const render = function() {
156156
if (!dataStore.reactRoot)
157157
dataStore.reactRoot = createRoot(rootElement);
158-
const enableDeleteAlert = ('capabilities' in dataStore.client && 'deleteAlert' in dataStore.client.capabilities);
158+
159159
dataStore.reactRoot.render(React.createElement(SETroubleshootPage, {
160160
connected: dataStore.connected,
161161
connecting: dataStore.connecting,
162162
error: dataStore.error,
163163
dismissError,
164164
entries: dataStore.entries,
165165
runFix,
166-
deleteAlert: enableDeleteAlert ? deleteAlert : undefined,
166+
deleteAlert,
167167
selinuxStatus: dataStore.selinuxStatus,
168168
selinuxStatusError: dataStore.selinuxStatusError,
169169
changeSelinuxMode: selinuxChangeMode,
@@ -255,19 +255,14 @@ const initStore = function(rootElement) {
255255

256256
dataStore.connectionTimeout = 5000;
257257

258-
function capablitiesChanged(capabilities) {
259-
dataStore.capabilities = capabilities;
260-
render();
261-
}
262-
263258
// try to connect
264259
dataStore.tryConnect = function() {
265260
if (dataStore.connecting === null) {
266261
dataStore.connecting = window.setTimeout(setErrorIfNotConnected, dataStore.connectionTimeout);
267262
render();
268263
// initialize our setroubleshootd client
269-
dataStore.client.init(capablitiesChanged)
270-
.then(capablitiesChanged => {
264+
dataStore.client.init()
265+
.then(() => {
271266
dataStore.connected = true;
272267
window.clearTimeout(dataStore.connecting);
273268
dataStore.connecting = null;

pkg/selinux/setroubleshoot-client.js

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const busNameFixit = "org.fedoraproject.SetroubleshootFixit";
3131
const dbusInterfaceFixit = busNameFixit;
3232
const dbusPathFixit = "/org/fedoraproject/SetroubleshootFixit/object";
3333

34-
client.init = function(capabilitiesChangedCallback) {
34+
client.init = function() {
3535
client.connected = false;
3636
const dbusClientSeTroubleshoot = cockpit.dbus(busName, { superuser: "try" });
3737
client.proxy = dbusClientSeTroubleshoot.proxy(dbusInterface, dbusPath);
@@ -148,7 +148,7 @@ client.init = function(capabilitiesChangedCallback) {
148148
/* Delete an alert from the database (will be removed for all users), returns true on success
149149
* Only assign this to the client variable if the dbus interface actually supports the operation
150150
*/
151-
const deleteAlert = localId => client.proxy.call("delete_alert", [localId])
151+
client.deleteAlert = localId => client.proxy.call("delete_alert", [localId])
152152
.then(success => {
153153
if (!success)
154154
return Promise.reject(new Error(cockpit.format(_("Failed to delete alert: $0"), localId)));
@@ -158,22 +158,6 @@ client.init = function(capabilitiesChangedCallback) {
158158
return Promise.reject(new Error(cockpit.format(_("Failed to delete alert: $0"), ex.toString())));
159159
});
160160

161-
// earlier versions of the dbus interface don't support alert deletion/dismissal
162-
// HACK https://bugzilla.redhat.com/show_bug.cgi?id=1306700
163-
// once every client we ship to handles these features, we can remove the capabilities check
164-
client.capabilities = { };
165-
166-
// wait for metadata - if this has the method delete_alert, we can use that
167-
dbusClientSeTroubleshoot.addEventListener("meta", function(event, meta) {
168-
if (dbusInterface in meta && 'methods' in meta[dbusInterface] && 'delete_alert' in meta[dbusInterface].methods)
169-
client.capabilities.deleteAlert = deleteAlert;
170-
else
171-
delete client.capabilities.deleteAlert;
172-
173-
if (capabilitiesChangedCallback)
174-
capabilitiesChangedCallback(client.capabilities);
175-
});
176-
177161
// connect to dbus and start setroubleshootd
178162
return connectPromise;
179163
};

0 commit comments

Comments
 (0)