0

I have the following script (alert.sh) which has been setuid'd:

DISPLAY=:0.0 notify-send --urgency=low -i python "The job has finished"

and the following PHP file alert.php:

<?php
echo exec("/path/to/alert.sh")

When I su to www-data and run php alert.php, I get an alert on my screen. All good.

However, when I open alert.php in the browser, nothing happens.

I suspect some environment variable needs to be set, but I'm not sure which.

Manishearth
  • 1,007
  • 2
  • 10
  • 12

1 Answers1

0

Just figured it out while digging through the environment variables, I also have to set $XAUTHORITY to whatever the variable is in the normal login.

XAUTHORITY=/home/myusername/.Xauthority DISPLAY=:0.0 notify-send --urgency=low -i python "The job has finished"
Manishearth
  • 1,007
  • 2
  • 10
  • 12