nV News Forums


nV News Forums (http://www.nvnews.net/vbulletin/index.php)
-   NVIDIA Linux (http://www.nvnews.net/vbulletin/forumdisplay.php?f=14)
-   -   Running nvidia-settings as different user (http://www.nvnews.net/vbulletin/showthread.php?t=143326)

Fuss 01-04-10 08:51 AM

Running nvidia-settings as different user
Hi there,

Here's what I want to do: I'd like to plot the GPU temperatures I get from the '/usr/bin/nvidia-settings -c :0 -tq GPUCoreTemp' command using Cacti. I'm able to run this command as root and as my personal username (which is the only one really running an X session).

However, I need to be able to get the temperature (in other words, to execute nvidia-settings) as user www-data, which is obviously not running an X session.

When I do this now, I get following information, as the display cannot be opened:


$ /usr/bin/nvidia-settings -c :0 -tq GPUCoreTemp
No protocol specified

ERROR: Cannot open display ':0'.

ERROR: Unable to query attribute GPUCoreTemp specified in query 'GPUCoreTemp' (no Display connection).


Is support for the above on a road map? Does anybody know a workaround for this?
I guess I could ssh to localhost to my account without a password (only using a key) and return the result but this would compromise security somehow (as the www-data user will have access to the key). Another alternative would be to cron this command and cat the output to a file every x minutes (which is what I'm planning to do if no better alternative can be found).


*edit: tried the suid bit as well, without luck (see below).

$ /usr/bin/nvidia-settings -c :0 -tq GPUCoreTemp

(process:27049): Gtk-WARNING **: This process is currently running setuid or setgid.
This is not a supported use of GTK+. You must create a helper
program instead. For further details, see:


Refusing to initialize GTK+.

gksudo fails as well, with and without suid bit on the nvidia-settings binary:

$ gksudo -u fuss /usr/bin/nvidia-settings -c :0 -tq GPUCoreTemp

(gksudo:27274): Gtk-WARNING **: cannot open display:

Lysius 01-05-10 04:57 AM

Re: Running nvidia-settings as different user
At least on fedora it works to add

www-data ALL= (username) NOPASSWD: /usr/bin/nvidia-settings -c \:0 -tq GPUCoreTemp
to /etc/sudoers

and then run
sudo -u username /usr/bin/nvidia-settings -c :0 -tq GPUCoreTemp
as www-data

"username" has to be replaced of course

Fuss 01-05-10 06:59 AM

Re: Running nvidia-settings as different user
Thanks Lysius - this solved the problem and is much more elegant than the workarounds I proposed. I hadn't heard about the NOPASSWD option yet.

All times are GMT -5. The time now is 06:13 AM.

Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2015, Jelsoft Enterprises Ltd.
Copyright 1998 - 2014, nV News.