XDMCP, KDE and artsd

John Sutton john at scl.co.uk
Tue Jul 22 13:36:12 BST 2003


Hi there

I've recently upgraded my server/diskless clients system from KDE1 to KDE2
(v2.1.1 - OK, I'm still a major release behind!) and am trying to get the
sound system to work.  I'd previously had _some_ success with KDE1
and ESD but it was pretty limited since most kde clients (including kde
itself) were not esd compatible.  In fact, as far as I recall correctly,
the only thing I ever got going was kmp3 and that was flaky!  So I gave up
and lived in silence...  Anyways, with the upgrade to KDE2 and artsd I
thought I'd have another go at bringing some music into my working life!

Here is what I want:  when a user sits down at a PC, they should be able
to login to any system presented by the chooser, whether that is the local
host or a remote host, and the sound generated by the clients should come
out on the local system.  I've managed to get this to work, but not without
some kludges (see below) and I wonder if anyone has a better (kludge-free)
solution?  The real problem I've had is getting artsshell to behave
itself.  Maybe the latest version of artsd/artsshell/etc behave better? If
so, I'd like to know and I'll have another go at building an uptodate
artsd.

Here is what I've got:

I am starting up artsd on each machine from /etc/inittab.  Since you need
to munge the environment to do this, inittab calls a script called
artsd-init:

-----------------------
#!/bin/bash

# See how we were called.
case "$1" in
  start)
                LOGNAME=`id -un` \
                DISPLAY=:0 \
                HOME=/etc \
                exec /usr/bin/artswrapper -F 10 -S 4096 -n
        ;;
  stop)
                /usr/bin/artsd-kill
        ;;
  *)
        echo "Usage: $0 {start|stop}"
        exit 1
esac
-----------------------

Notice that I've set HOME to ensure that .mcoprc gets picked up from /etc.
 This ensures that if root logs in on this machine, they cannot
(inadvertently) mess things up for all users by setting/unsetting any of
the sound options in kcontrol.  The upshot however is that you need to
setup .mcoprc (once only) thus:

echo GlobalComm=Arts::X11GlobalComm > /etc/.mcoprc

Then we can startup artsd along with xdm and X itself from inittab:

---------------------
x:5:respawn:/etc/X11/prefdm -nodaemon
xs:5:respawn:/usr/X11R6/bin/X -indirect diva
xa:5:respawn:/usr/bin/artsd-init start
---------------------

Every user then has to set up their kcontrol appropriately.  This means
that of the 4 options in Sound/Sound Server/General, they MUST check
"Exchange security and reference info..." and they MUST UNcheck "Start
aRts soundserver...".  The other 2 settings don't matter.

Now the problem is that whenever the X server resets (and it does this
quite a lot when being driven by xdm), artsd looses its connection/goes to
sleep/refuses to reauthenticate/whatever - I don't know.  Point is, the
only way I could find to get it to play ball was to kill it!  Then init
restarts it and it works OK.  But this is where the kludges start. 
Problem is, artsd is running as root and I'm logging in as non-root (or
root) AND it is not necessarily running on the same machine as the one I'm
logging into!  To solve this problem,  I inserted these 4 lines somewhere
near to the top of xdm/Xsession on every host:

------------------------------
ARTSDSERVER=$(echo $DISPLAY | sed 's/:.*//')
[ -n "$ARTSDSERVER" ] && ARTSDSERVER="rsh $ARTSDSERVER"
$ARTSDSERVER artsd-init stop
unset ARTSDSERVER
-------------------------------

(Of course, you can use ssh rather than rsh if you want.)  artsd-kill is a
root setuid:

--------------------------------
#include <stdio.h>
#include <errno.h>

static char *prog = "/usr/bin/killall";
static char *args[] = {
        "killall",
        "/usr/bin/artsd",
        NULL
};

int main(int argc, char **argv)
{
        if (setuid(0)) {
                perror(argv[0]);
                if (errno == EPERM) fprintf(stderr, "(did you chmod 4755?)\n");
                exit(255);
        }

        execv(prog, args);
}

// cc artsd-kill.c -o artsd-kill
--------------------------------

Well, it works, but what a mess!  I did a lot of playing around with
"artshell terminate" rather than using a root setuid to perform the kill
but it caused all kinds of grief to do with ownership of /tmp/mcop-<user>
directories.  Which is weird because the value of .mcoprc says not to use
these directories!  And I tried starting up artsd as the user from
Xsession (rather than from inittab) but even after getting over the
permissions issues with artswrapper and /dev/dsp, it still didn't work
consistently.

And anyway, *why* does artsd have to be killed and restarted for each
session?  Why doesn't it notice that the X server has reset and "do the
right thing" - reauthenticate, or whatever it needs to do?

Any ideas gratefully received!

TIA

***************************************************
John Sutton
SCL Internet
URL http://www.scl.co.uk/
Tel. +44 (0) 1239 711 888
***************************************************



More information about the kde-multimedia mailing list