Skip to content

Commit

Permalink
all: Add { superuser: "try" } for things that might need Polkit
Browse files Browse the repository at this point in the history
Cockpit should always use the maximum privileges it has.  Otherwise
actions might be rejected that are actually allowed.

Cherry-picked from master commit 168f819, restricted to a safe and
non-intrusive subset.

https://bugzilla.redhat.com/show_bug.cgi?id=1841559

Closes #14184
  • Loading branch information
mvollmer authored and martinpitt committed Jun 3, 2020
1 parent a986621 commit 3adf7e8
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pkg/lib/machines.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ function Machines() {
conn_to = machine.connection_string;

if (!machine || machine.label !== values.label) {
hostnamed = cockpit.dbus("org.freedesktop.hostname1", { host: conn_to });
hostnamed = cockpit.dbus("org.freedesktop.hostname1", { host: conn_to, superuser: "try" });
call = hostnamed.call("/org/freedesktop/hostname1", "org.freedesktop.hostname1",
"SetPrettyHostname", [ values.label, true ])
.always(function() {
Expand Down
2 changes: 1 addition & 1 deletion pkg/networkmanager/firewall-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ function fetchZoneInfos(zones) {

initFirewalldDbus();

cockpit.spawn(['sh', '-c', 'pkcheck --action-id org.fedoraproject.FirewallD1.all --process $$ --allow-user-interaction 2>&1'])
cockpit.spawn(['sh', '-c', 'pkcheck --action-id org.fedoraproject.FirewallD1.all --process $$ --allow-user-interaction 2>&1'], { superuser: "try" })
.done(() => {
firewall.readonly = false;
firewall.dispatchEvent('changed');
Expand Down
2 changes: 1 addition & 1 deletion pkg/realmd/operation.js
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ function setup() {

function setup_realms_proxy() {
// HACK: need to reinitialize after installing realmd (https://github.com/cockpit-project/cockpit/pull/9125)
realmd = cockpit.dbus("org.freedesktop.realmd");
realmd = cockpit.dbus("org.freedesktop.realmd", { superuser: "try" });
realmd.watch(MANAGER);

$(realmd).on("close", function(ev, options) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/selinux/setroubleshoot-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ var dbusPathFixit = "/org/fedoraproject/SetroubleshootFixit/object";

client.init = function(capabilitiesChangedCallback) {
client.connected = false;
var dbusClientSeTroubleshoot = cockpit.dbus(busName);
var dbusClientSeTroubleshoot = cockpit.dbus(busName, { superuser: "try" });
client.proxy = dbusClientSeTroubleshoot.proxy(dbusInterface, dbusPath);

client.proxyFixit = cockpit.dbus(busNameFixit).proxy(dbusInterfaceFixit, dbusPathFixit);
client.proxyFixit = cockpit.dbus(busNameFixit, { superuser: "try" }).proxy(dbusInterfaceFixit, dbusPathFixit);

var dfd = cockpit.defer();

Expand Down

0 comments on commit 3adf7e8

Please sign in to comment.