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

This is a discussion on "Xlib: No protocol specified" while questioning xhost and trying to set it - X ; 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 ...

+ Reply to Thread
Results 1 to 3 of 3

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

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

    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
    INETluto
    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

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

    In article <5f495126.0412071419.4a6f2b8a@posting.google.com>, Axel Dahmen
    wrote:

    || 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.

    Think again. You're invading the desktop privacy of whoever is logged
    in, and the may in fact not be the right person to receive the message.

    It is probably better to let whoever needs to see the message allow
    display access through some mechanism in their session script.

    || 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

    I *think* I can see what you're trying in this garbled stuff.

    It's not going to work because of the chicken-and-egg problem: xhost
    needs access to the display in order to change the access.

    || 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"

    QED.

    You seem seriously stumped. Have a look at the Remote X Apps mini HOWTO
    for some insights into X security. Available at the usual places.

    || It doesn't matter wether I try xhost + localhost or xhost + pluto,
    || both don't work.
    || I tried with
    || /etc/X0.hosts
    || INET:localhost
    || INETluto
    || 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!

    From the terminal session you have access to the display (using xauth
    cookies, most probably).

    || 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.

    Of course. Probably several.

    By default these days, access to the display is arranged by default
    through magic cookies, set up by gdm (or kdm) when the session is started.
    It's usually hidden as /var/lib/gdm/:0.Xauth; the real location will be
    in your gdm configuration.

    Point XAUTHORITY to that file as root, and use it as you see fit.

    But as I said, that's probably not the way to go.

    Get the users who log in to modify their session script (~/.xsession?)
    so that it gives access to the popups. Set up a special user group
    if necessary.

    Ciao. Vincent.
    --
    Vincent Zweije | "If you're flamed in a group you
    | don't read, does anybody get burnt?"
    [Xhost should be taken out and shot] | -- Paul Tomblin on a.s.r.

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

    On Wed, 8 Dec 2004 01:08:44 +0100 (CET), Vincent Zweije staggered into
    the Black Sun and said:
    > In article <5f495126.0412071419.4a6f2b8a@posting.google.com>, Axel
    > Dahmen wrote:
    >> 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.

    > Think again. You're invading the desktop privacy of whoever is logged
    > in, and the may in fact not be the right person to receive the
    > message.


    I *think* Axel knows more about the situation than you do, so I'm
    inclined to take him at face value. The messages sent may directly
    affect the workstation's user ("Warning: router has gone FUBAR...") or
    something.

    > It is probably better to let whoever needs to see the message allow
    > display access through some mechanism in their session script.


    Aye.

    >> smbclient -M pluto < message-to-send
    >> # in smb.conf
    >> message command = /bin/sh -c 'sudo /usr/local/tools/smb-message.sh
    >> %f %m %s &'


    No way. This is bogus. I did a little investigation into a similar
    situation back in February and found a much better solution. Go to
    http://groups.google.com/advanced_group_search and put
    slrnc20ks3.ujl.danSPANceswitTRAPhcro...202.dyndns.org into
    the "Message-ID" field, then press the "Search" button. All you need to
    do is to install LinPopUp (it's on your distro CDs, almost certainly),
    then put a different string in for "message command=". LinPopUp should
    be started as part of the user's X session, via KDE's
    ~/Desktop/Autostart/ directory or via ~/.xsession or whatever.

    > It's usually hidden as /var/lib/gdm/:0.Xauth; the real location will be
    > in your gdm configuration. Point XAUTHORITY to that file as root, and
    > use it as you see fit. But as I said, that's probably not the way to
    > go.


    Yep! Don't mess around with magic cookies and xauth; have something
    like LinPopUp running and you'll get the messages will much less
    fiddling and aggravation. HTH,

    --
    Matt G|There is no Darkness in Eternity/But only Light too dim for us to see
    Brainbench MVP for Linux Admin / mail: TRAP + SPAN don't belong
    http://www.brainbench.com / Hire me!
    -----------------------------/ http://crow202.dyndns.org/~mhgraham/resume

+ Reply to Thread