Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- main () {
- #include <stdio.h>
- #include <unistd.h>
- setuid( 0 );
- //printf( "C Program\n" );
- system ( "/var/www/lock/lock.sh" );
- }
- So rdieter told me I needed DBUS_SESSION_BUS_ADDRESS.
- I believe this works, as it outputs:
- <unix:abstract=/tmp/dbus-L10p2odN6R,guid=b399a25e904a2ecd9fb969210001258f>
- #!/bin/bash
- # We must set the DISPLAY variable so dbus is happy.
- export DISPLAY=:0.0
- # We must find the DBUS_SESSION_BUS_ADDRESS so dbus is happy.
- for pid in $(pgrep -u $USER)
- do
- declare DBUS_SESSION_BUS_ADDRESS=$(cat /proc/${pid}/environ | \
- tr '\0' '\n' | grep "DBUS_SESSION_BUS_ADDRESS=")
- # I looked for the first DBUS_SESSION_BUS_ADDRESS found.
- [ -z "${DBUS_SESSION_BUS_ADDRESS}" ] || break
- done
- # Strip off the DBUS_SESSION_BUS_ADDRESS= string at the beginning.
- DBUS_SESSION_BUS_ADDRESS="${DBUS_SESSION_BUS_ADDRESS:25}"
- # I echo it for debugging purposes...you probably don't want to echo it.
- echo "Set bus address to<${DBUS_SESSION_BUS_ADDRESS}>"
- lock.sh:
- #/usr/kde/3.5/bin/dcop --user emmelin kdesktop KScreensaverIface lock
- XAUTHORITY="/home/emmelin/.Xauthority" DISPLAY=":0" /usr/bin/qdbus org.kde.screensaver /ScreenSaver Lock
- XAUTHORITY="/home/emmelin/.Xauthority" DISPLAY=":0" /usr/bin/xset dpms force off
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement