Skip to content

Commit

Permalink
Merge pull request #546 from prey/Fix-ubuntu-installation
Browse files Browse the repository at this point in the history
fix ubuntu installation
  • Loading branch information
javo authored Jan 26, 2022
2 parents ae94557 + feb09e7 commit 2b05824
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
21 changes: 13 additions & 8 deletions lib/agent/plugins/control-panel/secure.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,19 @@ exports.open_config = function(device_key, cb) {
else if (os_name == 'mac')
return run_as_user('open', [link], cb);
// Open the logged user's default browser, the prey user doesn't have one

// For linux
system.spawn_as_logged_user('xdg-open', [link], {env: {DISPLAY: process.env.DISPLAY}}, (err, child) => {
setTimeout(() => {
child.kill();
}, 10000);
return cb() && cb(err);
cb();
system.get_logged_user((error, logged_user) => {
if(error) return;
exec(`sudo -u ${logged_user} ${common.root_path}/openwebbrowser.sh ${link} &`,
{
timeout: 200
}, (err, stderr, stdout) => {
if(err || stderr) return;
process.exit();
});
});
return;
});
}, 3000);
}
Expand All @@ -149,7 +154,7 @@ exports.reset_keys = function(cb) {
})
}

exports.decrypt_and_notify = function(encrypted_key, cb) {
exports.decrypt_and_notify = function(encrypted_key, cb) {
var decrypted_key;

try {
Expand All @@ -176,4 +181,4 @@ exports.decrypt_and_notify = function(encrypted_key, cb) {

exports.public_keys = function() { return public_keys; };
exports.notify_linked = notify_linked;
exports.notify_error = notify_error;
exports.notify_error = notify_error;
9 changes: 9 additions & 0 deletions openwebbrowser.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

webbrowser=`xdg-settings get default-web-browser`
if [ "$webbrowser" == "firefox.desktop" ]; then
firefox -CreateProfile Prey
firefox -P Prey -url $1
else
xdg-open $1
fi

0 comments on commit 2b05824

Please sign in to comment.