How to start 3dxsrv without admin rights?

Questions and answers about 3Dconnexion devices on UNIX and Linux.

Moderator: Moderators

Post Reply
skyechraebs
Posts: 12
Joined: Mon Jan 16, 2012 2:40 pm
Location: Zurich

How to start 3dxsrv without admin rights?

Post by skyechraebs »

Hi,

I have three questions about start etc/3DxWare/daemon/3dxsrv that I didn't find answered in this forum yet:

1) Why needs the 3dxsrv driver write permission on usb (that's why it needs admin rights, isn't it?)

2) What happens if I start the driver in init.d (ubuntu 11.10) but the 3dConnexion device is not plugged in yet? Do I you have to start the driver manually as soon as I plugged in the device?

3) Is there a possibility to start 3dxsrv without typing the password for admin rights (on Ubuntu)? Especially, I intend to launch the driver out from a open source Qt project by using QProcesshttp://qt-project.org/doc/qt-4.8/qprocess.html. At the moment it works like this with gksudo which pops up a window with password request:

Code: Select all

        QString processProgramm = "gksudo";
        QStringList processArguments;
        processArguments << "/etc/3DxWare/daemon/3dxsrv -d usb";
        QProcess* process3dxDaemon = new QProcess();
        process3dxDaemon->start(processProgramm, processArguments);
But in favor of convenience (and of the delay of starting the program when waiting on user's password input) it would be great if I can directly call 3dxsrv without gksudo. Changing the permission with a udev rule like this failed, i.e. I still have to call sudo!

Code: Select all

KERNEL=="event[0-9]*", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c603", SYMLINK+="input/spacemouse", GROUP="plugdev", MODE="664"
KERNEL=="event[0-9]*", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c623", SYMLINK+="input/spacetraveler", GROUP="plugdev", MODE="664"
KERNEL=="event[0-9]*", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c626", SYMLINK+="input/spacenavigator", GROUP="plugdev", MODE="664"

Code: Select all

matthias@matthias-PC:~/skye/qgroundcontrol$ /etc/3DxWare/daemon/3dxsrv -d usbError: Access Error! To get access to /dev/bus/usb/006/002 you have to be user: root!
Error: Access Error! To get access to /dev/bus/usb/006/002 you have to be member of group: root!
[2012-04-14 14:35:52] Error: Could not open USB port or no supported device found! Exiting!
UtaSH
Moderator
Moderator
Posts: 3754
Joined: Mon Nov 27, 2006 10:34 am
Location: Munich, Germany
Contact:

Re: How to start 3dxsrv without admin rights?

Post by UtaSH »

skyechraebs wrote: 1) Why needs the 3dxsrv driver write permission on usb (that's why it needs admin rights, isn't it?)
The device is accessed via the usbfs and as we need read and write access the device has to be opened as root.
skyechraebs wrote: 2) What happens if I start the driver in init.d (ubuntu 11.10) but the 3dConnexion device is not plugged in yet? Do I you have to start the driver manually as soon as I plugged in the device?
If thedriver is started and it doesn't find a device it exits. Thus you have to start it manually as soon as you plug a device in.
skyechraebs wrote: 3) Is there a possibility to start 3dxsrv without typing the password for admin rights (on Ubuntu)?
Use the start from the /etc/inittab. If no device is connected the driver sleeps for 10 min and then exits. The init process restarts it then and it is looking for a device again. The time the driver sleeps before exiting (if started from the /etc/inittab) can be changed with the option -sleepdelay and the number of seconds. Default is 600.

Code: Select all

3d:2345:respawn:/etc/3DxWare/daemon/3dxsrv -d usb -sleepdelay 360</dev>/dev/null 2>&1
would cause a delay of 6 minutes.
skyechraebs
Posts: 12
Joined: Mon Jan 16, 2012 2:40 pm
Location: Zurich

Post by skyechraebs »

Hi, thanks a lot for your reply!

Unfortunately

Code: Select all

3d:2345:respawn:/etc/3DxWare/daemon/3dxsrv -d usb -sleepdelay 360</dev>/dev/null 2>&1 
seems not to work on Ubuntu 11.10 when written in a script placed in /etc/init. I'm not very sure about how to create an autostart in ubuntu - Propabely I'll have to look for it once more.. And yess, I know that 3dConnexion software is not officially supported on Ubuntu :(

It seems as I'll have to keep starting the driver with

Code: Select all

/etc/3DxWare/daemon/3dxsrv -d usb
manually in the terminal..
UtaSH
Moderator
Moderator
Posts: 3754
Joined: Mon Nov 27, 2006 10:34 am
Location: Munich, Germany
Contact:

Post by UtaSH »

Hi skyechraebs,

no the line from the /etc/inittab makes sense only in the inittab. If you want to launch the driver from within a script I recommend this one:

Code: Select all

/etc/3DxWare/daemon/3dxsrv -d usb &
Unfortunately I am not familiar with the scripting in the /etc/init folder. But you have to make sure the driver is started only after the user is logged in and X is started.
skyechraebs
Posts: 12
Joined: Mon Jan 16, 2012 2:40 pm
Location: Zurich

Post by skyechraebs »

Hi UtaSH

ok, thanks a lot for these explanations. Ubuntu replaced inittab by upstart some time ago, therefore I won't do it in inittab.

Is the argument -sleepdelay also available when launching the driver from within a script (e.g. in terminal)? Is there anywhere a documentation of 3dxsrv (possible arguments etc.)?

Regards,
skyechraebs
UtaSH
Moderator
Moderator
Posts: 3754
Joined: Mon Nov 27, 2006 10:34 am
Location: Munich, Germany
Contact:

Post by UtaSH »

Code: Select all

3dxsrv -help

shows all available options.

-sleepdelay only makes sense if the driver is started from the /etc/inittab as it only sleeps for 10 min if started from the /etc/inittab. If started from anywhere else, like command line or script it stops immediately. I don't know if the processes in the /etc/init are re-started like the processes in the /etc/inittab?
skyechraebs
Posts: 12
Joined: Mon Jan 16, 2012 2:40 pm
Location: Zurich

Post by skyechraebs »

Hi,

I just achieved that 3dxsrv was successfully started automatically.. On ubuntu 11.10, i created a script ( /etc/init/connexion.conf ) for upstart.

Code: Select all

# 3dxsrv - driver for 3dConnexion's spacenavigator
description	"spacenavigator driver"

start on (runlevel [12345])
stop on runlevel [!12345]

exec /etc/3DxWare/daemon/3dxsrv -d usb
Now, 3dxsrv is launched automativally when I start the system with the mouse plugged.
But unfortunately, it only starts after I opened a terminal (I think this behaviour is strange). There still must something be wrong :?
skyechraebs
Posts: 12
Joined: Mon Jan 16, 2012 2:40 pm
Location: Zurich

Post by skyechraebs »

And because I'm a bit confused because of the upstart behaviour I retried now creating a udev rule instead to start 3dxsrv when the device is plugged in. I tried this llready some time ago when I was absolute Ubuntu beginner and then I failed.

Now it is properly working with this: /etc/rules/91-spacenavigator.rules
KERNEL=="event[0-9]*", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c603", SYMLINK+="input/spacemouse", GROUP="plugdev", MODE="664", RUN+="/etc/3DxWare/daemon/3dxsrv -d usb"
KERNEL=="event[0-9]*", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c623", SYMLINK+="input/spacetraveler", GROUP="plugdev", MODE="664", RUN+="/etc/3DxWare/daemon/3dxsrv -d usb"
KERNEL=="event[0-9]*", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c626", SYMLINK+="input/spacenavigator", GROUP="plugdev", MODE="664", RUN+="/etc/3DxWare/daemon/3dxsrv -d usb"
KERNEL=="event[0-9]*", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c628", SYMLINK+="input/spacenavigator", GROUP="plugdev", MODE="664", RUN+="/etc/3DxWare/daemon/3dxsrv -d usb"
When the rule is written new, a system newstart or the following command reloads udev rules:
sudo service udev reload
With this solution I'm happy :D

Best regards,
skyechraebs
skyechraebs
Posts: 12
Joined: Mon Jan 16, 2012 2:40 pm
Location: Zurich

Post by skyechraebs »

update: also the method using udev rules requires a terminal that is open.. :?:
Only then, the driver starts..
Post Reply