I have a problem accessing the dcop server when I run a script as root.

I have a script that needs root privileges. It locks the machine when certain conditions are met. It used to work flawlessly, until I added a feedback system as a tray icon using konch. From that point onwards it started to fail.

I've been able to get all but one problem out of the script again. It's this line:
Code:
dcop --all-users kdesktop KScreensaverIface lock
It used to work. It works when I run it as user. It gives this error:
Code:
dcop --all-users kdesktop KScreensaverIface lock
call failed
call failed
DCOPClient::attachInternal. Attach failed Authentication Rejected, reason : None of the authentication protocols specified are supported and host-based authentication failed
DCOPClient::attachInternal. Attach failed Authentication Rejected, reason : None of the authentication protocols specified are supported and host-based authentication failed
ERROR: Couldn't attach to DCOP server!
I've tried to restart the dcop server from the root account by killing it ; removing the /root/.DCOP* files and starting it again. I've found several hints that that may work... but alas.

I've been looking at the .Xauthority and .DCOP* files... because I expect the problem to be there, but I can't seem to grasp how it works. Googling on the issue it seems root should by default be able to run the command, so I have a feeling I broke it

____
I can run alternatives such as kdesktop_lock --forcelock, but that just doesn't do exactly what I intend, namely kill the entire machine until certain conditions are met again. The dcop way is exactly what I want...



Any thoughts on how to get the dcop server working again?



EDIT: It works when I open a root session in KDE... but that's not a habit of me
Weird??