You are not logged in.

#1 2011-04-07 12:49:44

Sathors
Member
Registered: 2011-02-23
Posts: 56

Boinc no gpu found because of xhost command error

Hello everybody,

The title is not very precise, so here is my problem :
I want to autostart the boinc client, so I've put the deamon in /etc/rc.conf.

I managed to get my graphic card (a HD5770 Radeon) working with boinc, but it needs one command to be issued :

xhost local:boinc

Indeed the daemon is launched by a dedicated user called boinc, whose groups are "video" and "boinc".
I've read that the command above enables boinc to find the ati drivers in order to recognise the graphic card, and it works alright if I write this command on my terminal (using my own user name) and then I restart the daemon.

The problem I have is that when autostarted the command xhost local:boinc I've add to the script generates an error which is :

No protocol specified
xhost:  unable to open display ":0"

I think that's because root can't open the display, but then if I put

su boinc -c xhost local:boinc

instead it doesn't work either.

Do you have an idea ?
I've put the boinc script (/etc/rc.d/boinc) below

Thank you for your help

Precision : the daemon is launched backgrounded (@boinc in the list in rc.conf).

/etc/rc.d/boinc

#!/bin/bash

. /etc/rc.conf
. /etc/rc.d/functions

set -x
echo "L'utilisateur est $USER"
env

BOINCUSER="boinc"
BOINCDIR="/var/lib/boinc"
PID=`pidof -o %PPID /usr/bin/boinc_client`
case "$1" in
  attach)
    echo "Enter the Project URL: "
    read url
    echo "Enter your Account Key: "
    read key
    echo "Attaching to project"
    cd $BOINCDIR
    su $BOINCUSER -c "boinccmd --project_attach $url $key"
;;
  start)
    stat_busy "Starting boinc"
    if [ -z "$PID" ]; then
      su $BOINCUSER -c xhost local:boinc
      su $BOINCUSER -c "nice -n 19 /usr/bin/boinc_client --daemon --dir ${BOINCDIR} --redirectio"
    else
      false
    fi
    if [ $? -gt 0 ]; then
      stat_fail
    else
      add_daemon boinc
      stat_done
    fi
    ;;
  stop)
    stat_busy "Stopping boinc"
    [ ! -z "$PID" ] && kill $PID &> /dev/null
    if [ $? -gt 0 ]; then
      stat_fail
    else
      rm_daemon boinc
      stat_done
    fi
    ;;
  restart)
    $0 stop
    sleep 2
    $0 start
    ;;
  *)
    echo "usage: $0 {attach|start|stop|restart}"
esac
exit 0

Offline

#2 2011-04-07 13:52:02

Lone_Wolf
Forum Moderator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 12,028

Re: Boinc no gpu found because of xhost command error

How do you start X ?

and it works alright if I write this command on my terminal (using my own user name) and then I restart the daemon.

Is that a terminal started from within X ?


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.


(A works at time B)  && (time C > time B ) ≠  (A works at time C)

Offline

#3 2011-04-07 14:07:32

Sathors
Member
Registered: 2011-02-23
Posts: 56

Re: Boinc no gpu found because of xhost command error

Sorry, I forgot to mention that I use KDE with X launched at startup (kdm in inittab).

The terminal in which the command works is graphical, when I try in a non-graphical one (tty ?) it doesn't work.

Offline

#4 2011-04-07 14:23:53

Lone_Wolf
Forum Moderator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 12,028

Re: Boinc no gpu found because of xhost command error

a timing issue seems the most likely explanation then.
When the rc.d script for boinc runs, X probably hasn't completed starting.

Some solutions for this :

- adding a 'sleep' command in the rc.d script, so the execution will be delayed .
you will need trial and error to find a correct value for sleep, and it's not a very good solution imo.


- use kde autostart / shutdown to start and stop the boinc daemon
Should work, but requires changes to KDE settings.

- edit the Boinc start command to start the daemon before you start boinc, and stop it afterwards.
since this solution doesn't impact any other functionality then that of boinc itself, this would be my favorite solution.


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.


(A works at time B)  && (time C > time B ) ≠  (A works at time C)

Offline

#5 2011-04-07 14:55:31

Sathors
Member
Registered: 2011-02-23
Posts: 56

Re: Boinc no gpu found because of xhost command error

To begin with thank you for your help.

I've tried to put sleep 10, but it doesn't work.

The thing that puzzles me is that when I try to execute the script once in my KDE session it is still the same problem, so I don't think it is related to X not having been launched completely.

When I run the script with :

sudo /etc/rc.d/boinc start

I get the following error :

No protocol specified
xhost:  unable to open display ":0"

If I change "xhost local:boinc" to "su boinc -c xhost local:boinc" so as to launch the command as the user boinc I still get the same error, whereas when issued from Konsole with my user name it says :

non-network local connections being added to access control list

and from now on I can restart the daemon and it will work.

So I think its something about root issuing the command in the script when it can't or something like that.

Offline

#6 2011-04-07 15:36:47

Lone_Wolf
Forum Moderator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 12,028

Re: Boinc no gpu found because of xhost command error

Sathors wrote:

So I think its something about root issuing the command in the script when it can't or something like that.

Looking at xhost man page (partially copied below) that seems to be correct.

DESCRIPTION
       The  xhost  program  is used to add and delete host names or user names to the list allowed to make connections to the X server.  In the case of hosts, this provides a
       rudimentary form of privacy control and security.  It is only sufficient for a workstation (single user) environment, although it does limit the worst  abuses.   Envi‐
       ronments  which require more sophisticated measures should implement the user-based mechanism or use the hooks in the protocol for passing other authentication data to
       the server.

OPTIONS
       Xhost accepts the following command line options described below.  For security, the options that affect access control may only be run from  the  "controlling  host".
       For workstations, this is the same machine as the server.  For X terminals, it is the login host.

that strongly suggest you must run the xhost command as the logged in user.

If you only have 1 user (besides root) you may be able to use su user in the rc.d script and keep starting it from rc.conf.
This doesn't seem like a good solution though.

Try adding the boincuser to the video group, and check if boinc will run that way.


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.


(A works at time B)  && (time C > time B ) ≠  (A works at time C)

Offline

#7 2011-04-07 17:59:03

Sathors
Member
Registered: 2011-02-23
Posts: 56

Re: Boinc no gpu found because of xhost command error

Lone_Wolf wrote:

If you only have 1 user (besides root) you may be able to use su user in the rc.d script and keep starting it from rc.conf.

That solution doesn't work either.
When the daemon is started from Konsole with "su my_user_name -c xhost local:boinc" the output is :

access control enabled, only authorized clients can connect

but boinc doesn't see the GPU.

So if I type "xhost local:boinc" it works, but with a script called with sudo issuing the command "su my_user_name -c xhost local:boinc" it does not work, and the output is different.

What am I missing ?

Lone_Wolf wrote:

Try adding the boincuser to the video group, and check if boinc will run that way.

Boinc user is already member of the video group.

Thank you for your time !

Offline

#8 2011-04-07 23:39:42

Lone_Wolf
Forum Moderator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 12,028

Re: Boinc no gpu found because of xhost command error

checking the manpage for xhost and xserver i may have find a way to get this working, but make sure you have an entry in KDM to do  a console login just in case there's trouble.


in /etc create the file X0.hosts
put 1 line in it with

local:boinc

No leading or trailing spaces !

remove all references of the xhost command from the boinc rc.d scripts , put boinc backgrounded in  rc.conf as you did before.

reboot and check.


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.


(A works at time B)  && (time C > time B ) ≠  (A works at time C)

Offline

Board footer

Powered by FluxBB