"Xlib: No protocol specified" while questioning xhost and trying to set it

From: Axel Dahmen (axda_at_arcor.de)
Date: 12/07/04


Date: 7 Dec 2004 14:19:53 -0800

Hi Folks,

merely since a week (at night time after work) I am googleing around
to find an answer but Iam stuck now, so I like to ask the community
for help.

My linux machines:
I am running some unix machines in a home network, a RH9 router, RH9
file server, a Solaris 9 Sparc backup server and a SuSE 8.1
workstation with Gnome 2.2.3 Desktop. All machines run Samba Ver.
3.0.9

My Problem:
Due to shell scripting on some occasions the router has to send a
"Popup" announcement to the user who is logged in at the Gnome
Workstation.
whithin the script at the router:
smbclient -M pluto < message-to-send

the smb.conf at pluto, the Gnome Workstation contains:
message command = /bin/sh -c 'sudo /usr/local/tools/smb-message.sh %f
%m %s &'
(I tried to get it work with sudo but it isn't successful, with sudo
or without)

the smb-message.sh at pluto contains:
export DISPLAY=:0
echo "/usr/X11R6/bin/xhost + $HOSTNAME" >>
/var/log/samba/smbmessage.log
/usr/X11R6/bin/xhost + $HOSTNAME >> /var/log/samba/smbmessage.log
2>&1
/usr/X11R6/bin/xmessage -center -display :0 -title "Message from
$1@$2" -file $3 >> /var/log/samba/smbmessage.log 2>&1
rm -f $3

when I send the message from router to pluto, I can only find the
error messages in the log file:
/usr/X11R6/bin/xhost + pluto
Xlib: connection to ":0.0" refused by server
Xlib: No protocol specified
/usr/X11R6/bin/xhost: unable to open display ":0"

It doesn't matter wether I try xhost + localhost or xhost + pluto,
both don't work.
I tried with
/etc/X0.hosts
    INET:localhost
    INET:pluto
I also checked my xauth
.Xauthority contains
    localhost:0
    localhost/unix:0
    localhost.localdomain/unix:0

As the message command within samba is run under the nobody user I
thought that sudo could do the job but it has no effect at all!

My manual workaround is:
within a terminal session issuing the command as root:
xhost + localhost
and voila, everything is fine!

How can I automate this workaround?
Has anybody found a practical solution for sending a message to
another user / host via smbclient?

Somehow there must be a way.

Axel



Relevant Pages