-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
selinux: Fix error reporting #18670
selinux: Fix error reporting #18670
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -107,69 +107,56 @@ client.init = function(capabilitiesChangedCallback) { | |
lastSeen: when the alert was seen for the last time, timestamp in ms | ||
level: "green", "yellow" or "red" | ||
*/ | ||
client.getAlert = function(localId) { | ||
return new Promise((resolve, reject) => { | ||
client.proxy.call("get_alert", [localId]) | ||
.then(result => { | ||
const details = { | ||
localId: result[0], | ||
summary: result[1], | ||
reportCount: result[2], | ||
auditEvent: result[3], | ||
pluginAnalysis: result[4], | ||
firstSeen: result[5] / 1000, | ||
lastSeen: result[6] / 1000, | ||
level: result[7], | ||
}; | ||
// cleanup analysis | ||
details.pluginAnalysis = details.pluginAnalysis.map(itm => ({ | ||
ifText: itm[0], | ||
thenText: itm[1], | ||
doText: itm[2], | ||
analysisId: itm[3], | ||
fixable: itm[4], | ||
reportBug: itm[5], | ||
})); | ||
resolve(details); | ||
}) | ||
.catch(ex => { | ||
console.warn("Unable to get alert for id " + localId); | ||
console.warn(ex); | ||
reject(new Error(cockpit.format(_("Unable to get alert: $0"), localId))); | ||
}); | ||
}); | ||
}; | ||
client.getAlert = localId => client.proxy.call("get_alert", [localId]) | ||
.then(result => { | ||
const details = { | ||
localId: result[0], | ||
summary: result[1], | ||
reportCount: result[2], | ||
auditEvent: result[3], | ||
pluginAnalysis: result[4], | ||
firstSeen: result[5] / 1000, | ||
lastSeen: result[6] / 1000, | ||
level: result[7], | ||
}; | ||
// cleanup analysis | ||
details.pluginAnalysis = details.pluginAnalysis.map(itm => ({ | ||
ifText: itm[0], | ||
thenText: itm[1], | ||
doText: itm[2], | ||
analysisId: itm[3], | ||
fixable: itm[4], | ||
reportBug: itm[5], | ||
})); | ||
return details; | ||
}) | ||
.catch(ex => { | ||
console.warn("Unable to get alert for id", localId, ":", JSON.stringify(ex)); | ||
return Promise.reject(new Error(`Unable to get alert for id ${localId}: ${ex.toString()}`)); | ||
}); | ||
|
||
/* Run a fix via SetroubleshootFixit | ||
The analysisId is given as part of pluginAnalysis entries in alert details | ||
*/ | ||
client.runFix = function(alertId, analysisId) { | ||
return new Promise((resolve, reject) => { | ||
client.proxyFixit.call("run_fix", [alertId, analysisId]) | ||
.then(result => resolve(result[0])) | ||
.catch(ex => reject(new Error(cockpit.format(_("Unable to run fix: $0"), ex)))); | ||
}); | ||
}; | ||
client.runFix = (alertId, analysisId) => client.proxyFixit.call("run_fix", [alertId, analysisId]) | ||
.then(result => result[0]) | ||
.catch(ex => { | ||
console.warn("Unable to run fix:", JSON.stringify(ex)); | ||
return Promise.reject(new Error(cockpit.format(_("Unable to run fix: $0"), ex.toString()))); | ||
Comment on lines
+143
to
+145
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These 3 added lines are not executed by any test. Details |
||
}); | ||
|
||
/* 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 = function(localId) { | ||
return new Promise((resolve, reject) => { | ||
client.proxy.call("delete_alert", [localId]) | ||
.then(success => { | ||
if (success) | ||
resolve(); | ||
else | ||
reject(new Error(cockpit.format(_("Failed to delete alert: $0"), localId))); | ||
}) | ||
.catch(ex => { | ||
console.warn("Unable to delete alert with id " + localId); | ||
console.warn(ex); | ||
reject(new Error(cockpit.format(_("Error while deleting alert: $0"), localId))); | ||
}); | ||
}); | ||
}; | ||
const 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))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This added line is not executed by any test. Details |
||
}) | ||
.catch(ex => { | ||
console.warn("Unable to delete alert with id", localId, ":", JSON.stringify(ex)); | ||
return Promise.reject(new Error(cockpit.format(_("Failed to delete alert: $0"), ex.toString()))); | ||
Comment on lines
+156
to
+158
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These 3 added lines are not executed by any test. Details |
||
}); | ||
|
||
// earlier versions of the dbus interface don't support alert deletion/dismissal | ||
// HACK https://bugzilla.redhat.com/show_bug.cgi?id=1306700 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These 3 added lines are not executed by any test. Details