If you've got freedesktop-compliant session manager, you can use DBus to invoke restart from inside the X session. The command goes:
dbus-send --system --dest=org.freedesktop.Hal --type=method_call \
--print-reply /org/freedesktop/Hal/devices/computer \
org.freedesktop.Hal.Device.SystemPowerManagement.Reboot int32:0
(this is probably more than necessary; works for me). I use this in a shell script. You don't need to run this from root, but you need to run it from inside an X session (f.e. in a terminal). You can find more on this topic at https://wiki.ubuntu.com/DebuggingGNOMEPowerManager