Advertisement
Guest User

Untitled

a guest
Nov 9th, 2012
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. main () {
  2.     #include <stdio.h>
  3.     #include <unistd.h>
  4.     setuid( 0 );
  5.     //printf( "C Program\n" );
  6.     system ( "/var/www/lock/lock.sh" );
  7. }
  8.  
  9. So rdieter told me I needed DBUS_SESSION_BUS_ADDRESS.
  10. I believe this works, as it outputs:
  11. <unix:abstract=/tmp/dbus-L10p2odN6R,guid=b399a25e904a2ecd9fb969210001258f>
  12.  
  13.  
  14. #!/bin/bash
  15. # We must set the DISPLAY variable so dbus is happy.
  16. export DISPLAY=:0.0
  17.  
  18. # We must find the DBUS_SESSION_BUS_ADDRESS so dbus is happy.
  19. for pid in $(pgrep -u $USER)
  20. do
  21.      declare DBUS_SESSION_BUS_ADDRESS=$(cat /proc/${pid}/environ | \    
  22.              tr '\0' '\n' | grep "DBUS_SESSION_BUS_ADDRESS=")
  23.  
  24. # I looked for the first DBUS_SESSION_BUS_ADDRESS found.
  25.      [ -z "${DBUS_SESSION_BUS_ADDRESS}" ] || break
  26.  
  27. done
  28.  
  29. # Strip off the DBUS_SESSION_BUS_ADDRESS= string at the beginning.
  30. DBUS_SESSION_BUS_ADDRESS="${DBUS_SESSION_BUS_ADDRESS:25}"
  31.  
  32. # I echo it for debugging purposes...you probably don't want to echo it.
  33. echo "Set bus address to<${DBUS_SESSION_BUS_ADDRESS}>"
  34.  
  35.  
  36.  
  37. lock.sh:
  38. #/usr/kde/3.5/bin/dcop --user emmelin kdesktop KScreensaverIface lock
  39. XAUTHORITY="/home/emmelin/.Xauthority" DISPLAY=":0" /usr/bin/qdbus org.kde.screensaver /ScreenSaver Lock
  40. XAUTHORITY="/home/emmelin/.Xauthority" DISPLAY=":0" /usr/bin/xset dpms force off
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement