mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-16 16:23:25 +00:00
Updated notify-send fallback, so that it will only try to su to logged in user if the current user is root.
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -124,8 +124,17 @@ function Toaster()
|
|||||||
if (require('message-box').notifysend)
|
if (require('message-box').notifysend)
|
||||||
{
|
{
|
||||||
// Using notify-send
|
// Using notify-send
|
||||||
retVal.child = require('child_process').execFile('/bin/sh', ['sh']);
|
if (require('user-sessions').whoami() == 'root')
|
||||||
retVal.child.stdin.write('su - ' + retVal.username + ' -c "DISPLAY=\'' + retVal.xinfo.display + '\' notify-send \'' + retVal.title + '\' \'' + retVal.caption + '\'"\nexit\n');
|
{
|
||||||
|
// We're root, so we must run in correct context
|
||||||
|
retVal.child = require('child_process').execFile('/bin/sh', ['sh']);
|
||||||
|
retVal.child.stdin.write('su - ' + retVal.username + ' -c "DISPLAY=\'' + retVal.xinfo.display + '\' notify-send \'' + retVal.title + '\' \'' + retVal.caption + '\'"\nexit\n');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// We're a regular user, so we don't need to do anything special
|
||||||
|
retVal.child = require('child_process').execFile(require('message-box').notifysend.path, ['notify-send', retVal.title, retVal.caption]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user