Simple way for web to execute root shell script.

May 23, 2025 Last reply: 1 year ago 41 Replies

Ummm ... just sayin' ... do you REALLY want/need that ???

Seems like a recipe for sure disaster.

Lawrence is usually trolling more often than not.

A killfile entry helps with the "usually trolling" aspect.

I have a vague memory of an "shc" package which describes itself as a shell script compiler. In reality it isn't but its does package up the script in a directly executable format (i.e. ELF) and pass it to the shell at runtime. That would allow a SetUID flag to work. Seems to be listed as a Debian package but I haven't used it in decades.

Oh yes, some people seem to have incredibly strange requirements. I have (perhaps not entirely l-) managed to learn to resist arguing with them, it only took a few decades...

I have on, a number of occasions, found myself cleaning up the mess resulting from someone having been given a technological tool they didn’t really know how to use. (And at least once had to get a tradesman in to sort out a mess of my own creation, but the less said about that the better.)

I think lm-sensors. I have a compute module 3+ variant running but same SoC anyways and lm-sensors gives this:

cpu_thermal-virtual-0 Adapter: Virtual device temp1: +52.1°C

I don't have drives other than the eMMC on the Pi but on my router for example lm-sensors gives:

drivetemp-scsi-0-0 Adapter: SCSI adapter temp1: +50.0°C

That's for an mSATA SSD.

/sys/class/net/eth0/statistics

Ah I didn't know lm-sensors existed for ARM

Sadly USB attached SSDS do not show up...

That is handy.

Try smartctl(8) for them.

I suppose it needs support from the drives and whatever USB-ATA translator is in use. Seems a little odd though that smartctl works and this doesn't.

The kernel driver for this is called drivetemp so it's worth checking if it's loaded or if manually loading that driver changes anything.

Smartctl is a very generic interrogation. I suspect that the more intimately connected NVMe is accessible by other means than ATA commands

As I have repeatedly said. I stop at the first workable solution I find. Smarctl works.

It's no big deal. I have a solution that is *good enough* thanks to hints given here. And if I need to add another command that needs root access, I can easily do it.

There are parameters you can supply which may allow it to work. Do a lsusb to get the adapter name and search for it and smartctl. If it's a must have get another adapter which is known to work with smartctl.

---druck

It does work with smartcl, Not with lm-sensors

#sensors cpu_thermal-virtual-0 Adapter: Virtual device temp1: +55.5°C

rpi_volt-isa-0000 Adapter: ISA adapter in0: N/A

but #smartctl -a /dev/sda | grep -i temp

194 Temperature_Celsius 0x0022 061 050 000 Old_age Always - 39 (Min/Max 16/50)

Sorry, picked up on the wrong part of the post.

lm-sensors wont work with external USB drives as it only knows about things connected to the internal busses of a machine such as acpi and i2c, and the Pi only had the latter.

If you really want to measure the disc's temperature using lm-sensors, you could attach a i2c temperature sensor to it and add a device tree entry so it is detected. See:-

formatting link
But unless you are using the external drive somewhere with an incredibly high ambient temperature, it's very unlikely to overheat. The only hard drive I had problems with was inside a DVR in a rack of other equipment in an enclosed space. I had to tweak the fan configuration to keep it under it's alert temperature of 55C.

---druck

On Sun, 25 May 2025 09:42:32 -0000 (UTC), Lawrence D'Oliveiro snipped-for-privacy@nz.invalid wrote in <100uom7$1aabi$ snipped-for-privacy@dont-email.me:

Good call, but may need to specify a bridge for an external SSD, e.g.:

# smartctl -d sntasmedia -a /dev/sda smartctl 7.4 2023-08-01 r5530 [x86_64-linux-6.15.0] (local build) Copyright (C) 2002-23, Bruce Allen, Christian Franke,

formatting link

=== START OF INFORMATION SECTION === Model Number: WD_BLACK SN850XE 4000GB [...] Temperature: 31 Celsius [...]

Note that finding the right bridge could be a bit of a chore...

No. See for example here:

formatting link
the drivetemp driver uses ATA commands to read temperatures from drives or alternatively, using SMART attributes. lm-sensors either uses the drivetemp kernel driver or just reads from /sys/class/hwmon.

Which is why I said before, I find it odd if smartctl works and drivetemp does not, although AFAiK no one has actually tried that in this thread.

Unfortunately I don't have any recent USB HDs around. I do have an USB-SSD case but don't have a spare SSD to put into it right now.

formatting link
might be worth a look. I only had a short look and have no own experience yet.

cu Michael

The drives in question will be in an enclosure with the fanless Pi 4, and so far have peaked at over 60°C when they are rated only up to 70°C ambient. And I have had issues under heavy load but I strongly suspect these are power supply related not temperature.The reason for the monitor is to try and see if there is any correlation between temperature and temporary drive failure.

I will probably stick a scope on the USB power rails at some time to look for issues there.

I don't.

smartctl -a /dev/sd[ab] works fine...

And in the end solving the 'root script' problem was simpler than solving the 'how do I read the disk temp without root' problem.

I checked and drivetemp module is invoked in the kernel.

# zgrep -i temp /boot/config-6.12.25+rpt-rpi-2712 # CONFIG_SYSTEMPORT is not set CONFIG_SENSORS_DRIVETEMP=m # Temperature sensors # end of Temperature sensors

But I have no idea how to access anything with it.

How does one 'use' drivetemp?

PiOS is always a little bit 'a road less debugged' than

*x86...especially in terms of stuff that accesses hardware.

It reminds me of mainstream Linux 10 years ago. And hacking UDEV to get it to recognise a camera.

These days it JustWorks™

Intersting. In the end I added this to /etc/sudoers

#allow www to access to hwinfo.sh www-data ALL = (ALL) NOPASSWD: /usr/local/scripts/hwinfo.sh

and then invoking #!/bin/sh echo "content-type:text/html" echo sudo /usr/local/scripts/hwinfo.sh

from a script in /usr/lib/cgi-bin...

Apache and firefox seem happy enough and I can AJAX that from the browser to get uptodate info.

Load it with modprobe and data appears in /sys/class/hwmon somewhere. It doesn't seem to autoload always, I don't know what the trigger is. For example, on my router it's loaded, on my little pizza box it's not.

For example, on the pizza box, /sys/class/hwmon/hwmon2/temp1_input appears after loading drivetemp and it contains 36000 which means 36 degrees C.

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required