Help needed with systemd script

Mattia Verga mattia.verga at tiscali.it
Sat Dec 14 14:00:56 UTC 2013


Il 14/12/2013 12:55, Dridi Boukelmoune ha scritto:
> Hi,
>
> On Sat, Dec 14, 2013 at 12:44 PM, Mattia Verga <mattia.verga at tiscali.it> wrote:
>> Hello,
>> I'm trying to give a user access rights to X with xhost command.
>> I've created a script named '/usr/bin/boincxhost' (chmod 555) like this:
>>
>> #!/bin/sh
>> xhost +SI:localuser:boinc &> /dev/null
>> exit 0
> "exit 0" will hide a non-zero exit status of the previous command.
>
> In this case I'm not sure what's happening, but if you're running the
> command in background, and don't wait for it to complete, you may be
> facing a race condition.
>

Ok, I tried to edit the boincxhost script in this way:

#!/bin/sh
xhost +SI:localuser:boinc
sleep 1

Now if I run the script from console I get:
$ /usr/bin/boincxhost
localuser:boinc being added to access control list

$ xhost
access control enabled, only authorized clients can connect
SI:localuser:boinc
SI:localuser:marvin

But if I run it within systemd unit the service is started, but xhost 
command "silently" fails:
# systemctl start boinc-client.service
# systemctl status boinc-client.service
boinc-client.service - Berkeley Open Infrastructure Network Computing Client
    Loaded: loaded (/usr/lib/systemd/system/boinc-client.service; disabled)
    Active: active (running) since sab 2013-12-14 14:52:25 CET; 4s ago
   Process: 2843 ExecStopPost=/bin/rm -f /var/lib/boinc/lockfile 
(code=exited, status=0/SUCCESS)
*Process: 2947 ExecStartPre=/usr/bin/boincxhost (code=exited, 
status=0/SUCCESS)*
   Process: 2944 ExecStartPre=/usr/bin/chown boinc:boinc 
/var/log/boinc.log /var/log/boincerr.log (code=exited, status=0/SUCCESS)
   Process: 2941 ExecStartPre=/usr/bin/touch /var/log/boinc.log 
/var/log/boincerr.log (code=exited, status=0/SUCCESS)
   Process: 2938 ExecStartPre=/bin/sleep 1 (code=exited, status=0/SUCCESS)
  Main PID: 2952 (boinc)
    CGroup: name=systemd:/system/boinc-client.service
            ??2952 /bin/bash /usr/bin/boinc --dir /var/lib/boinc
            ??2953 /usr/bin/boinc_client --allow_multiple_clients --dir 
/var/l...

dic 14 14:52:23 deneb systemd[1]: Starting Berkeley Open Infrastructure 
Net.....
*dic 14 14:52:24 deneb boincxhost[2947]: xhost:  unable to open display ""*
dic 14 14:52:25 deneb systemd[1]: Started Berkeley Open Infrastructure 
Netw...t.

# xhost
access control enabled, only authorized clients can connect
SI:localuser:marvin


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.fedoraproject.org/pipermail/devel/attachments/20131214/9dedc4ae/attachment.html>


More information about the devel mailing list