To test behavior on read error the test file can be linked to something
like /proc/self/mem that does not support read() but currently all
symlinks are skipped. Use fstatat instead of the directory entry type to
determine file type.
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.
Fixes: 68bda21952
LIBICONV is already defined in the top level Makefile, so it does not
need to be redefined in prog/sensors/Module.mk.
In addition the latter version causes a.out file to be created when
running make targets, even "make clean".
Fixes: 68bda21952
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.
Fixes: 89548dab2a ("Add SENSORS_SYSFS_ROOT environment support")
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.
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.
This fixes commit c1a1f4ff20 ("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.
ms: adjust test
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>
Cast of (const char **) to (char **) avoids one warning to introduce
another. Drop it. rrd upstream should not need the cast anymore.
Signed-off-by: Michal Suchanek <msuchanek@suse.de>
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.")