Skip to content

Commit

Permalink
fix pkexec support and do not call pkexec at all if the install dir i…
Browse files Browse the repository at this point in the history
…s not found (#274)
  • Loading branch information
illwieckz authored Dec 15, 2023
1 parent 410cd91 commit 8fee2fb
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions freon@UshakovVasilii_Github.yahoo.com/pkexecUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@ export default class PkexecUtil {
this._pkexec = GLib.find_program_in_path('pkexec');
// Currently hardcoded in policy file.
this._bin = '/usr/sbin/' + name;
this._dir = this.dir();
this._dir = this.dir();
}

dir() {
let uri = (new Error()).stack.split('\n')[1];
if (!uri.startsWith('install@file://')) {
let prefix = this.constructor.name + '@file://'
if (!uri.startsWith(prefix)) {
log('[FREON] failed to guess extension directory');
return null;
}
return Gio.File.new_for_path(uri.substring(15)).get_parent().get_path();
return Gio.File.new_for_path(uri.substring(prefix.length)).get_parent().get_path();
}

available_pkexec() {
Expand All @@ -37,6 +39,11 @@ export default class PkexecUtil {
}

install() {
if (!this._dir)
{
log('[FREON] cannot find ' + this._name + ' pkexec policy file ' + this._policy);
return false;
}
try {
this.run('install "' + this._dir + '/policies/' + this._policy + '" ' + this._actions);
} catch(e) {}
Expand Down

0 comments on commit 8fee2fb

Please sign in to comment.