Go Back   nV News Forums > Linux Support Forums > NVIDIA Linux

Newegg Daily Deals

Reply
 
Thread Tools
Old 01-04-10, 09:51 AM   #1
Fuss
Registered User
 
Join Date: Jan 2010
Posts: 2
Default 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:

Code:
$ /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).

Thanks.

*edit: tried the suid bit as well, without luck (see below).
Code:
$ /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:

    http://www.gtk.org/setuid.html

Refusing to initialize GTK+.
$
gksudo fails as well, with and without suid bit on the nvidia-settings binary:
Code:
$ gksudo -u fuss /usr/bin/nvidia-settings -c :0 -tq GPUCoreTemp

(gksudo:27274): Gtk-WARNING **: cannot open display:
$
Fuss is offline   Reply With Quote
Old 01-05-10, 05:57 AM   #2
Lysius
Registered User
 
Join Date: Oct 2008
Posts: 98
Default Re: Running nvidia-settings as different user

At least on fedora it works to add
Code:
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
Lysius is offline   Reply With Quote
Old 01-05-10, 07:59 AM   #3
Fuss
Registered User
 
Join Date: Jan 2010
Posts: 2
Default 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.
Fuss is offline   Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 03:54 AM.


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