LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   HDDtemp and normal user (https://www.linuxquestions.org/questions/linux-software-2/hddtemp-and-normal-user-484609/)

carl0ski 09-18-2006 07:43 AM

HDDtemp and normal user
 
Hi i want to be able to access hddtemp /dev/sda
as a standard user however it doesnt work

Apparently the only way for standard user to use hddtemp is when it's installed as a daemon

Anyone know how to do it?


PS if anyones interested this is a SuperKuramba thee to display CPU mainboard and Nvidia temperatures on your desktop.

Code:

##############################################################
#System Sensors V0.1
#Author: Carl0ski (carl0ski@gmail.com)
#License:GPL
##############################################################
karamba x=0 y=0 w=370 h=330 locked=true
text x=105 y=35 value="Vital Statistics:" color=255,255,255 fontsize=23 font="sans"


text x=0 y=70 sensor=program program="cat /proc/cpuinfo |grep 'model name'|cut -f2 -d':'" align=left color=255,255,255 fontsize=16


text x=40 y=130 value="CPU temp" color=255,255,255 align=left fontsize=16
font="sans"

text x=40 y=180 value="Mainboard temp" color=255,255,255 align=left fontsize=16
font="sans"

text x=40 y=230 value="Video Card temp" color=255,255,255 align=left fontsize=16
font="sans"


text x=280 y=130 sensor=program program="let cputemp=`sensors | grep 'CPU Temp' | awk '{print $3}'|cut -f1 -d'°'|cut -f2 -d '+'`; echo $cputemp°C" interval=10000 align=left color=255,255,255 fontsize=16

text x=280 y=180 sensor=program program="let mbtemp=`sensors | grep 'M/B Temp:' | awk '{print $3}'|cut -f1 -d'°'|cut -f2 -d '+'`; echo $mbtemp°C" interval=10000 align=left color=255,255,255 fontsize=16

text x=280 y=230 sensor=program program="let g=`nvclock -i|grep 'temperature:' | awk '{print $3}'|cut -f1 -d'C'`;echo $g°C" interval=10000 align=left color=255,255,255 fontsize=16


image x=37 y=160 path="bar1.png"
bar x=41 y=163 w=100 h=0'3 vertical=false path="bar2.png" max=70. interval=10000
image x=37 y=210 path="bar1.png"
image x=37 y=260 path="bar1.png"


David the H. 09-18-2006 10:31 AM

An much easier way is simply to set up a sudo command.

In case you're unfamiliar with how to do it (and for others reading this):

As root, run the command 'visudo' to edit the /etc/sudoers file. Under the "user privilege" section, enter a line for user david as:

david ALL=NOPASSWD: /usr/sbin/hddtemp

And save the file.

Restart the sudo daemon ('/etc/init.d/sudo restart' on Debian. Suse may be a bit different), and you're set.

Now, user david only has to type "sudo hddtemp /dev/hda" to get hda's temperature. You can make it even easier by setting up an alias to make hddtemp="sudo hddtemp" for that user.

matthewg42 09-18-2006 10:38 AM

You could configure sudo to let the user in question run this program without using the sudo password.

Install sudo if it's not on our system already. Use the visudo program to edit the sudo configuration and add a line something like this:

Code:

# where "matthew" is my username
matthew ALL = NOPASSWD: /usr/sbin/hddtemp

If it's a whole bunch of users you could create a new group and then allow members of that group to execute "sudo hddtemp" without a password, for example:

Code:

# Assuming you created an "hwmon" group, and added
# all the users you want to access hddtemp to it...
%hwmon ALL = NOPASSWD: /usr/sbin/hddtemp

By the way, I'm assuming the hddtemp program is safe. The specified user(s) will be able to launch this process with root prividiliges, so, as with any program you grant permissions like this to, you should be careful to check that it can't be used to get a shell or do other nasty things.

For more information on the format of the config file, see the sudoers(5) manpage.

HappyTux 09-18-2006 02:40 PM

You could set the suid bit on hddtemp that is how Debian does it and it works for normal users so if you wanted chmod +s /usr/sbin/hddtemp it should look like this.

Code:

>$ ls -l /usr/sbin/hddtemp
-rwsr-xr-x 1 root root 29K 2006-09-10 19:14 /usr/sbin/hddtemp


matthewg42 09-18-2006 03:16 PM

Quote:

Originally Posted by HappyTux
You could set the suid bit on hddtemp

I'm not sure if there is any sort of consensus about it, but I thought suid was considered a little risky and to be avoided when possible... It is simpler than the sudo solution (I for one found the sudoers file format confusing at first), but you lose some of the flexibility.

I guess it's a matter of using whatever is suitable for your environment.
:twocents:


All times are GMT -5. The time now is 11:28 PM.