12

I am running Xubuntu 12.10 in my laptop and I would like to monitor the CPU and HDD temperatures. I have installed lm-sensors, hddtemp and xfce4-sensors-plugin and added the widget into the XFCE panel. Now, when I login or manually run xfce4-sensors in terminal, I get the following notification:

"hddtemp" was not executed correctly, although it is executable. This is most probably due to the disks requiring root privileges to read their temperatures, and "hddtemp" not being setuid root.

An easy but dirty solution is to run "chmod u+s /usr/sbin/hddtemp" as root user and restart this plugin or its panel.

Calling "/usr/sbin/hddtemp -n -q /dev/sda" gave the following error:
/dev/sda: Permission denied

with a return value of 256. 

When this happens I do not have any option to show the HDD temperature on the panel. However, if I run gksudo xfce4-sensors and enter the password I get no error and can show the HDD temperature on the pannel if I want to.

Since root permissions are needed in order to run hddtemp and chmod u+s /usr/sbin/hddtemp is not recommended, what alternative do I have to run hddtemp from xfce4-sensors plugin automatically at login?

2
  • Yet another hack, but possibly better: run hddtemp as a daemon on startup, then use a genmon panel item to query it, listen on the daemon port, or grab the tail of the log file, however you configure the daemon. I'm not sure how this panel plugin was supposed to work, honestly, but I agree that you should never chmod things in sbin. As a last resort you could make a script that needs sudo, lock down the permissions, and add it to /etc/sudoers[.d/something] as NOPASSWD. Then it can overwrite a log file that you poll, again with a genmon plugin.
    – John P
    Aug 11, 2017 at 7:47
  • In fact I'm surprised that this wasn't addressed in the 4 years since you posted it - if it was, no one bothered to reply here, even though it's very high in relevant search results. It's possible that you need to start the panel with gksudo, but if the permissions are inherited by the hddtemp item, that has implications for other plugins and their security, so I wouldn't recommend even trying it without more research.
    – John P
    Aug 11, 2017 at 7:51

2 Answers 2

3

I had the same Problem after upgrading to 13.04.

I would prefer a non-dirty solution also.

But This bugreport didn't provide any clean solution either

At least: The mentioned dirty solution worked for me:

set suid bit to hddtemp:

$ sudo chmod u+s /usr/sbin/hddtemp

$ xfce4-sensors

1
  • Currently (27.02.2022), when running the plug-in for the first time, it shows an error message and suggests this "dirty" solution. Anyway thanks for posting. The error message was to quick for me to fully read it. ;) Feb 27 at 15:04
1

An alternative would be running hddtemp as a daemon(eg. args: --listen=127.0.0.1 -dF) listening on some TCP port(default 7634) on localhost(or 127.0.0.1) and having xfce4-sensors-plugin query it on every refresh.

BUT, this only works if xfce4-sensors-plugin was compiled with --disable-netcat, otherwise(with --enable-netcat it instead attempts to execute hddtemp itself on every refresh! here's source code for my claims and I've also tested both ways (suid hddtemp and running hddtemp as daemon via a hddtemp.service).

Caveats:

  1. you have to specify all the HDD devices, that you want to monitor, when starting the hddtemp daemon.
    ie. sudo hddtemp --listen=127.0.0.1 -dF /dev/sda /dev/sdb /dev/sdc.
    Only the specified devices will be seen by xfce4-sensors-plugin.
  2. If any devices specified above(at point 1) aren't present, there will be a ? entry in xfce4-sensors-plugin which you can keep visible at all times until the device(s) are present. This may or may not be what you want. But with a suid hddtemp and enabled netcat, it will only list the HDD devices present currently, and probably(untested) won't automatically add new ones in the future, so you'll have to enter Properties and check/enable them yourself under Sensors type: Hard disks.
  3. xfce4-sensors-plugin (latest git for today 27 Sept.2018) will lookup localhost and connect(then disconnect) via TCP from the specified host/port on every refresh (eg. every 1 seconds if you have Update interval (seconds) set to 1) which means that you'll see(and I tested this) like 150 lines of TIME_WAIT in your netstat -pantuW command, so it will be hard to see anything else in there unless you pipe it through grep -v "127.0.0.1:7634.*TIME_WAIT" I suppose.

I'm keeping a gist up to date with any further information here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.