Makefile: do not use a temporary file to test iconv
Using a predictible temporary file name in /tmp is a security risk. It
could be used to overwrite or delete arbitrary files through a symlink,
possibly as root when running for instance "sudo make install".
Use "-o /dev/null" instead, which is supported by at least clang and
gcc.
Emit missing sensor warning only if SENSORS_SYSFS_ROOT is defined
The lm-sensors library is widely used in various software, which could
be run in VMs where HWMON support may be absent (e.g. cloud kernels in
Debian). To avoid a confusing "/sys: No sensors at /sys/class/hwmon" on
the console or in the logs, only emit the message if the user specifies
an alternative path through SENSORS_SYSFS_ROOT. This behavior mirrors
what is done for the "Not a sysfs mount" message.
Michael Lettrich [Fri, 25 Jul 2025 08:31:03 +0000 (10:31 +0200)]
[FIX] ISA sysfs address parsing allow dashes
The ISA sensor chip address is obtained by parsing the hwmon
`/sysfs` device path. The regular expression extracting the
device address will fail if the device name contains dashes and
sets the address to 0. If multiple instances of the same
board are plugged into the same system, cards can no longer be
distinguished, because their addresses will be set to 0 incorrectly.
This fix changes the address-parsing regular expression to recognize
device names with dashes.
graysky [Sat, 16 Aug 2025 11:01:21 +0000 (07:01 -0400)]
Fix iconv linking detection for glibc-based builds
The current iconv detection checks if libiconv.so exists via ldconfig,
but fails on glibc systems where iconv is built into libc and doesn't
require separate linking. This causes build failures:
ld: cannot find -liconv: No such file or directory
Replace the ldconfig check with a compile test that actually verifies
if iconv functions are available without additional libraries. This
correctly detects glibc's built-in iconv while still linking -liconv
on musl/uclibc systems that need it.
Fixes build on glibc-based systems including OpenWrt glibc targets.
xaizek [Sat, 7 Jun 2025 10:33:11 +0000 (13:33 +0300)]
pwm: fix bad scaling due to use of integer type
This fixes commit c1a1f4ff206c0e6959c3e4d6b19ba27963076d5e ("pwm: Move
scaling factor from sensors prog to library") which didn't account for
return type of `get_type_scaling()` being `int` rather than `double` or
`float`, so the scaling was done by a factor of 2 instead of 2.55, thus
making the result off by quite a lot.
Michal Suchanek [Sun, 7 Jan 2024 14:59:13 +0000 (15:59 +0100)]
Add SENSORS_SYSFS_ROOT environment support
With this the hardcoded /sys location for reading sensor data can be
changed. In particular it makes it possible to tar up the /sys directory
when a problem is encountered, and then reproduce it on another system.
Signed-off-by: Michal Suchanek <msuchanek@suse.de>
Michal Suchanek [Sat, 30 Dec 2023 14:01:23 +0000 (15:01 +0100)]
sensors_parse_chip_name: Initialize path
sensors_parse_chip_name claims to overwrite all of result but path is
not set. This is generally not a problem when using statically allocated
data that is pre-zeroed but the parser uses dynamic allocation and the
chip name may contain garbage depending on the specific code flow
resulting from compiling the parser.
Setting the path was dropped when it was renamed from busname.
Fixes: 8896ba3b ("Rename sensors_chip_name.busname to path, as this is
what we are using it for by now.")
Michal Suchanek [Fri, 29 Dec 2023 13:49:49 +0000 (14:49 +0100)]
Correct parser file dependencies
The dependencies for the parser files are not correct.
There is baroque irule adding header prerequisites to the parser but the
parser may still fail to build.
The real dependency is on conf-parse.h
There is no way to tell make that a rule produces two targets, such as
parse.c and parse.h. However, the dependency files are generated by a
separate rule, and not as a byproduct of building the source so they can
themselves have dependencies.
And dependencies they do have: when the header is generated it's in lib
but when the header is missing while generating dependency file it's
searched in top directory, and then the file that depends on it cannot
be built because the header neveer appears there.
When the generated .c file is addded as prerequisite to the dependency
file that should reference the header generated together with the .c
file the dependency file is generated correctly with the header present.
This is not easily reproducible with the current source but adding
conf-lex.h generated with conf-lex.c and including it in conf-parse.c
now makes both conf-lex.ad depend on conf-parse.h and conf-lex.ad on
conf-lex.h making the build 100% fail.
Michal Suchanek [Wed, 27 Dec 2023 12:05:07 +0000 (13:05 +0100)]
sysfs: Specific match has to go before generic match
This is not really a problem when the specific scaling factors happen to
be for factors not matched by a generic match but this may not hold in
general over time.
Fixes: 1bd92120 ("Fill the magnitude field of dynamically generated device entries.")
Jean Delvare [Thu, 11 Feb 2021 14:41:45 +0000 (14:41 +0000)]
pwmconfig: Further raise the fan threshold
Modern 4-pin fans can have a minimum speed (PWM=0) which is still
relatively high. I've seen 4500 RPM fans lower their speed to only
3500 RPM, which is 77% of the maximum speed, above our current
detection threshold (3/4 or 75%). Increase the threshold to 5/6
(roughly 83%) to make sure such fans are handled properly.
References: boo#1181890 Signed-off-by: Jean Delvare <jdelvare@suse.de>
Jean Delvare [Mon, 26 Apr 2021 13:06:50 +0000 (13:06 +0000)]
/var/run is deprecated
Systemd now wants PID files in /run, not /var/run. Service files have
been updated upstream already, but not the path used by the actual
programs. Change them too so that things don't break when the
/var/run symlink is eventually dropped.