Michal Suchánek [Mon, 8 Jan 2024 12:59:56 +0000 (13:59 +0100)]
Fix string truncation warnings related to PATH_MAX (#1244)
There are a number of places where rrdtool combines multiple PATH_MAX
sized strings into one.
PATH_MAX is a constant that tends to work in practice a lot of the time
but may not reflect the real capabilities of the system in real time.
In place of on-stack buffers of PATH_MAX size allocate memory
dynamically. Initialize the pointers to NULL so they can be all freed
unconditionally on exit.
Fixes: #1223 Signed-off-by: Michal Suchanek <msuchanek@suse.de>
Wolfgang Stöggl [Sat, 6 Jan 2024 17:00:45 +0000 (18:00 +0100)]
Fix failing test pdp-calc1
The number of decimal places or the format can be different in the
output depending on the platform.
- The failing test has appeared under msys2 (MINGW32 and MINGW64),
where the exponential notation has changed:
E.g. e+000 instead of e+00
- Use DIFF9 also in test pdp-calc1, which reduces the number of
decimal places to 7 using "%0.7e". See DIFF9 in tests/functions.
- Update the pdp-calc1 output files accordingly
- Fixes failing test pdp-calc1 under msys2
Michal Suchánek [Fri, 5 Jan 2024 14:31:48 +0000 (15:31 +0100)]
Constify argv, fix warnings. (#1242)
* Fix perl warnings
- cast POPs to void to avoid unused value warning
- declare functions that don't set RETVAL as returning void
Signed-off-by: Michal Suchanek <msuchanek@suse.de>
* Constify argv
rrd has no business modifying the string pointed to by passed agrv, and
as far as gcc can see it does indeed not modify them because it compiles
with const argv.
This fixes warnings when passing const strings into rrd, and avoids the
need to duplicate all strings in the tcl bindings.
This fixes warnings like these:
[ 3s] prog/sensord/rrd.c: In function 'rrdInit':
[ 3s] prog/sensord/rrd.c:302:40: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
[ 3s] 302 | ret = rrd_create(argc, (char**) argv);
[ 3s] | ^
[ 3s] prog/sensord/rrd.c: In function 'rrdUpdate':
[ 3s] prog/sensord/rrd.c:458:42: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
[ 3s] 458 | if ((ret = rrd_update(3, (char **) /* WEAK */ argv))) {
[ 3s] | ^
Signed-off-by: Michal Suchanek <msuchanek@suse.de>
* tcl: Do not duplicate const strings
---------
Signed-off-by: Michal Suchanek <msuchanek@suse.de>
Tobias Hintze [Fri, 20 Oct 2023 21:03:19 +0000 (23:03 +0200)]
rrdcached dump support (#1235)
* add missing newlines (\n) for TUNE
Help strings for TUNE command were lacking the trailing newline
character. This causes the FLUSH syntax printed in the same line as
TUNE's.
* fix sendall edge cases
The `sendall` func is implemented as a loop over multiple send() calls until all bytes are sent. Previously on subsequent calls the incorrect buffer was used for sending.
This change also forbids `allow_retry` when at least one byte was successfully sent already. This would otherwise mess up the protocol, when retrying from the start.
* rrcached: implement DUMP
* update tests for remote dump support
Previously, tests replaced the daemon-based dump use with a local use.
This is changed in this commit as dump is now supported via daemon.
Wolfgang Stöggl [Wed, 19 Apr 2023 06:23:27 +0000 (08:23 +0200)]
Update vcpkg GitHub Action (#1225)
- Update vcpkg to current release 2023.04.15, commit 501db0f
- Current versions of libraries are e.g.:
cairo 1.17.8, expat 2.5.0, fontconfig 2.14.2, freetype 2.12.1,
gettext 0.21.1, glib 2.76.1, libpng 1.6.39, pango 1.50.12,
pcre2 10.40, libxml2 2.10.3 and zlib 1.2.13
- Switch from windows-2019 to windows-2022, which includes
Visual Studio Enterprise 2022
To build the project on a (lean) Debian Bookworm system, there are
several more build dependencies which need to be installed in order for
the `make` command to succeed.
Also add the build dependencies for python bindings.
Wolfgang Stöggl [Tue, 7 Mar 2023 09:40:50 +0000 (10:40 +0100)]
Update msys2 GitHub Action (#1214)
- Add groff to required msys2 packages. It has been removed from group
base-devel: msys2/MSYS2-packages@66a18d1
- Fixes configure error:
I need a copy of *nroff to format the documentation
- `ci-build_MSYS2.sh`:
Add `set -e` to the bash script.
Otherwise CI seems OK despite a build error.
Enrico Scholz [Thu, 2 Mar 2023 16:00:25 +0000 (17:00 +0100)]
Allow to select locking mechanism (#1207)
* rrd: add _rrd_lock_xxx() helper functions and constants
This adds two sets of constants: these used in 'extra_flags' in various
parts of the extended api (e.g. rrd_updatex_r()), and these used within
rrd_open().
There are implemented some helper functions which help to parse command
line strings and environment variables, and to convert these two sets
of constants.
* rrd_update: pass custom RRD_LOCK_xxx flags to rrd_open()
* rrd_update: add '--locking' cli option
* rrd_open: handle RRD_LOCK_DEFAULT
When rrd_open() was called with RRD_LOCK_DEFAULT, read the locking
setup from $RRD_LOCKING environment.
* rrd_open: implement other locking methods
Allow locking to wait and make it possible to bypass locking
completely.
Wolfgang Stöggl [Thu, 2 Mar 2023 07:31:55 +0000 (08:31 +0100)]
Update vcpkg GitHub Action (#1212)
- Update vcpkg to current release 2023.02.24, commit a7b6122
- Use actions/checkout@v3 and actions/upload-artifact@v3 in order to
avoid the following warning:
Node.js 12 actions are deprecated.
- win32/collect_rrdtool_vcpkg_files.bat:
Add required pcre2-8.dll and pixman-1-0.dll
Remove pcre.dll, which is not required anymore
Enrico Scholz [Fri, 6 Jan 2023 11:02:12 +0000 (12:02 +0100)]
Set CLOEXEC flag when opening files and sockets (#1206)
* configure: check for O_CLOEXEC
* configure: check for SOCK_CLOEXEC
* configure: check whether fopen() supports the "e" flag
Although the "e" fopen() flag (atomic FD_CLOEXEC support) is scheduled
for being added to the next POSIX version, it is not supported by all
platforms.
Check whether it is accepted and working.
Because this flag can be tested at runtime only, configure.ac uses
AC_RUN_IFELSE. Cross compiling fallback assumes that "e" is supported.
* compat-cloexec: initial checkin
* compat-cloexec: implement missing HAVE_DECL_O_CLOEXEC case
Just define 'O_CLOEXEC' as 0; it is used always like in
| f = open(..., flags | O_CLOEXEC);
* compat-cloexec: implement missing HAVE_DECL_SOCK_CLOEXEC case
* compat-cloexec: implement missing RD_HAVE_WORKING_FOPEN_E case
When fopen() does not support the "e" flag, parse the mode string and
run an 'open(..., O_CLOEXEC) + fdopen()' sequence when it is set.
* rrd_open: open file with O_CLOEXEC
Avoid leaking file descriptors by set the O_CLOEXEC flag. This flag is
part of POSIX.1-2008 and there is implemented a fallback for systems
without it.
* open sockets with SOCK_CLOEXEC
* set "e" flag with fopen()
* tests: add test for _rrd_fopen()
Wolfgang Stöggl [Fri, 8 Apr 2022 16:00:47 +0000 (18:00 +0200)]
Update tarball download link in doc
The download location of the release tarball has been moved to GitHub.
- Update the download link in doc/rrdbuild.pod
- rrdtool-release:
Add substitution of version in download subdirectory, e.g. v1.8.0 in:
rrdtool-1.x/releases/download/v1.8.0/rrdtool-1.8.0.tar.gz
Wolfgang Stöggl [Tue, 5 Apr 2022 20:36:31 +0000 (22:36 +0200)]
Remove autogenerated files
The removed files are generated using bootstrap
(libtoolize, autoreconf) and they are available in release tarballs.
- Avoids outdated configure file in git
- Resolves #1163
- The following commands have been used for removal:
git rm configure
git rm -r conftools/
git rm Makefile.in
git rm *Makefile.in
git rm src/rrd_config.h.in
Wolfgang Stöggl [Fri, 1 Apr 2022 17:14:49 +0000 (19:14 +0200)]
Fix unsigned integer overflow in rrdtool first
This fixes a signed/unsigned conversion bug in the calculation of
"then". Background info:
pdp_cnt and pdp_step are both unsigned long, whereas timer is signed.
When multiplying signed and unsigned integers (same size), a signed is
implicitly typecast to unsigned.
- A similar fix has already been applied to rrd_dump.c
in commit e193975
- Resolves #1140
Wolfgang Stöggl [Fri, 25 Mar 2022 18:09:59 +0000 (19:09 +0100)]
Fix tests under MSYS2 (Windows)
This is a follow-up to commit 7cd748e considering running the tests
in Windows under MSYS2. A similar approach has already been used in
tests\graph2 and tests\xport1 (see also: 847d679)
- Updates the following tests:
graph1, rpn1, rpn2, vformatter1
- Avoid Windows drive letter in the path of DEF:vname=rrdfile
under MSYS or MSYS2. Use only the filename of the rrd and not
the full path if environmental variable MSYSTEM is set.
Wolfgang Stöggl [Thu, 24 Mar 2022 17:05:29 +0000 (18:05 +0100)]
ci-workflow.yml: Add autotools to msys2
- Add mingw-w64-x86_64-autotools to "install:"
Fixes:
./bootstrap: line 8: libtoolize: command not found
./bootstrap: line 11: autoreconf: command not found
- Minor modifications to ci-workflow.yml:
* Fix yamllint errors in line 8 and 10:
too many spaces inside brackets
* Add "workflow_dispatch:" to allow manual run of the Windows CI
workflow
Wolfgang Stöggl [Wed, 23 Mar 2022 16:58:45 +0000 (17:58 +0100)]
Fix BUILD_DATE in rrdtool help output
- This is a followup to #1102
- Fixes segfault when running "rrdtool --help"
- Change DATE_FMT to the same date format as the __DATE__ macro [1]:
mmm dd yyyy
Wolfgang Stöggl [Tue, 15 Mar 2022 17:13:35 +0000 (18:13 +0100)]
rrdtool-release: Create NUMVERS from VERSION file
In the script rrdtool-release, NUMVERS has been read from the
configure file so far, which may not be up-to-date.
Generate NUMVERS from the VERSION file instead. This ensures
that only one source is used vor the version - the VERSION file.
Use the same perl command for creating NUMVERS, as in configure.ac
This test was failing when LC_ALL was set to C.UTF-8 and using the C.UTF-8 locale which is part of glibc 2.35, which differs in a very minor way to that that has been used by Debian/Ubuntu for years. The tests sets LC_TIME to C, presumably to try to isolate itself from such things, but that does not have any effect if LC_ALL is set in the build environment.
Umer Saleem [Thu, 20 Jan 2022 14:29:36 +0000 (19:29 +0500)]
Fix for a race condition in journal_write
There is a race condition in journal_write() where journal_lock is
being acquired after checking whether journal_fh is NULL or not.
journal_fh is a static file handle that can be set to NULL by any
other thread, while current thread is blocked by
pthread_mutex_lock(). This commit fixes this race condition.
Dmitry Kalinkin [Thu, 21 Oct 2021 23:34:08 +0000 (19:34 -0400)]
Fix python bindings installation in case of empty DESTDIR
The current behaviour is to install the extension to ./usr/local (if
prefix is /usr/local), so it ends up in the temporary build directory
instead of the intended absolute prefix.
The slash after $(DESTDIR) is needed to make empty DESTDIR mean
installation to / instead of making the prefix to mean a relative
path. We make it triple slash as POSIX reserves double slashes to
possibly have a special treatment by the OS.
The change for travis is needed as "make install" is run as root, and
once the python extension is actually installed, it leaves a
root-owned .egg-info file.
Wolfgang Stöggl [Tue, 13 Jul 2021 18:23:54 +0000 (20:23 +0200)]
Add escapeJSON() to legend entries
Double quotes in legends are currently not escaped, if JSON imgformat
is used for rrdtool graph. This produces invalid JSON files.
See comment in #409 for further details.
Wolfgang Stöggl [Tue, 29 Jun 2021 19:16:53 +0000 (21:16 +0200)]
Update Windows GitHub Actions
- Update ci-workflow.yml and add GitHub Actions for Windows builds
using MSVC and vcpkg. Both, x64 and x86 builds are part of the CI.
The required vcpkg ports are installed and cached using
lukka/run-vcpkg@v7
- Add release-windows.yml, which enables building Windows binaries of
RRDtool. This GitHub action is run automatically upon new tags and
can be triggered manually. The required .exe and .dll files are
copied using collect_rrdtool_vcpkg_files.bat and deployed by
actions/upload-artifact@v2
- Makefile_vcpkg.msc:
Add include\harfbuzz, which is required for building pango. Fixes: pango-coverage.h(28): fatal error C1083:
Cannot open include file: 'hb.h': No such file or directory
Sven Panne [Mon, 22 Mar 2021 11:55:26 +0000 (12:55 +0100)]
Avoid segfault: Don't read and write into the same buffer.
Using CTX->rrd_error as a source *and* destination buffer at the same time
provokes undefined behavior. In real life you get funny error messages
and/or segfaults within vs(n)printf().
Simple solution: Use a temporary copy of the error message while writing
into it.