Compare commits

..

No commits in common. "master" and "development" have entirely different histories.

627 changed files with 99586 additions and 94528 deletions

12
.github/dependabot.yml vendored Normal file
View file

@ -0,0 +1,12 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: daily
time: "04:00"
reviewers:
- "waja"
pull-request-branch-name:
separator: "-"
open-pull-requests-limit: 10

36
.github/workflows/packaging_test.yml vendored Normal file
View file

@ -0,0 +1,36 @@
name: Packaging Test
on:
push:
branches:
- $default-branch
- development
- master
# Run tests for any PRs
pull_request:
env:
SOURCE_DIR: ./
ARTIFACTS_DIR: debian/build/release/
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
env:
DEBIAN_FRONTEND: "noninteractive"
- name: Remove github artefacts
run: |
rm -rf .github*
- name: Adjust distibution in changelog file
run: |
sed -i '0,/restricted/s//stable/' debian/changelog
- name: Build Debian package
uses: dawidd6/action-debian-package@v1.4.4
with:
artifacts_directory: debian/build/release/
os_distribution: testing
- name: Debug
run: |
ls -la

71
.github/workflows/release.yml vendored Normal file
View file

@ -0,0 +1,71 @@
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'debian/*' # Push events to matching debian/*, i.e. debian/1.0-2, debian/20.15.10, debian/23.20020326
name: Release Process
env:
SOURCE_DIR: ./
ARTIFACTS_DIR: debian/build/release/
jobs:
create-release:
name: Create Release
runs-on: ubuntu-latest
outputs:
release-id: ${{ steps.create_release.outputs.id }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install needed packages
run: |
if [ $(dpkg -l | grep -c dpkg-dev) -ne 1 ]; then sudo apt-get update && sudo apt-get install -y dpkg-dev; fi
- name: Gather changelog
run: |
ls -la
dpkg-parsechangelog | tail -n +9 > debian.changelog
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body_path: debian.changelog
draft: false
prerelease: false
build:
name: Build and upload packages
needs: create-release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
env:
DEBIAN_FRONTEND: "noninteractive"
- name: Remove github artefacts
run: |
rm -rf .github*
- name: Adjust distibution in changelog file
run: |
sed -i '0,/restricted/s//stable/' debian/changelog
- name: Build Debian package
uses: dawidd6/action-debian-package@v1.4.4
with:
artifacts_directory: debian/build/release/
os_distribution: testing
# - name: Build Debian package
# uses: pi-top/action-debian-package@v0.2.0
# with:
# artifacts_directory: debian/build/release/
# target_architectures: "amd64,i386"
- name: Upload the artifacts
uses: skx/github-action-publish-binaries@release-2.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
releaseId: ${{ needs.create-release.outputs.release-id }}
args: debian/build/release/*

View file

@ -20,7 +20,7 @@ Using the DLPI support on SysV systems to get the host MAC address in check_dhcp
Stenberg, Daniel Stenberg, Daniel
Copyright (c) 1996 - 2004, Daniel Stenberg, <daniel@haxx.se> Copyright (c) 1996 - 2004, Daniel Stenberg, <daniel@haxx.se>
http://curl.haxx.se/ http://curl.haxx.se/
Use of duplication of macros in m4/np_curl.m4 (slightly adapted for m4/uriparser.m4 too) Use of duplication of macros in m4/np_curl.m4 (slighly adapted for m4/uriparser.m4 too)
Coreutils team Coreutils team
Copyright (C) 91, 1995-2004 Free Software Foundation, Inc. Copyright (C) 91, 1995-2004 Free Software Foundation, Inc.

22959
ChangeLog

File diff suppressed because it is too large Load diff

View file

@ -1,8 +1,8 @@
Installation Instructions Installation Instructions
************************* *************************
Copyright (C) 1994-1996, 1999-2002, 2004-2017, 2020-2021 Free Copyright (C) 1994-1996, 1999-2002, 2004-2016 Free Software
Software Foundation, Inc. Foundation, Inc.
Copying and distribution of this file, with or without modification, Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright are permitted in any medium without royalty provided the copyright
@ -225,7 +225,7 @@ order to use an ANSI C compiler:
and if that doesn't work, install pre-built binaries of GCC for HP-UX. and if that doesn't work, install pre-built binaries of GCC for HP-UX.
HP-UX 'make' updates targets which have the same timestamps as their HP-UX 'make' updates targets which have the same time stamps as their
prerequisites, which makes it generally unusable when shipped generated prerequisites, which makes it generally unusable when shipped generated
files such as 'configure' are involved. Use GNU 'make' instead. files such as 'configure' are involved. Use GNU 'make' instead.

View file

@ -1,6 +1,6 @@
## Process this file with automake to produce Makefile.in ## Process this file with automake to produce Makefile.in
SUBDIRS = gl tap lib plugins plugins-scripts plugins-root @PERLMODS_DIR@ SUBDIRS = gl tap lib plugins plugins-scripts plugins-root po @PERLMODS_DIR@
EXTRA_DIST = config.rpath \ EXTRA_DIST = config.rpath \
ABOUT-NLS ACKNOWLEDGEMENTS AUTHORS CODING ChangeLog FAQ NEWS \ ABOUT-NLS ACKNOWLEDGEMENTS AUTHORS CODING ChangeLog FAQ NEWS \

File diff suppressed because it is too large Load diff

159
NEWS
View file

@ -1,143 +1,8 @@
This file documents the major additions and syntax changes between releases. This file documents the major additions and syntax changes between releases.
2.4.0 25th Jul 2024
FIXES
* check_dbi: Compiler warning for uninitialized variable
* check_curl: Initialize pointer before usage
* check_ntp: Initialize intermediate results in any case
* Fixes for -Wsign-compare
* check_tcp: Fixes an error with using the wrong type for a variable
* check_mailq: exit on empty strings and exit early
* check_users: Change option for sanity checking arguments to avoid segfault
* check_users: Update help to properly show that thresholds are ranges
* check_users: fix segfault
* check_dbi: Fix compiler warning for uninitialized variable
* check_curl: Initialize pointer before usage
* check_ntp: Initialize intermediate results in any case
* Fix logic in is_uint64_t to fix type-limit warning
* check_ntp_peer: Fixes for Wmaybe-unitialized and some restructuring
* check_dns: Remove unused variable
* check_ntp_peer: Fixes for Wmaybe-unitialized and some restructuring
* check_dns: Remove unused variable
* check_disk: fix ignore-missing in combination with includes
* check_procs: ignore our own children
* Prevent -lcrypto from showing up in Makefile dependencies
* Change irritating NULL assignment
* check_http: Remove self assignment of a variable and add some comments
* check_snmp: Remove unused variable
* check_dhcp: Make implicit conversion explicit to dismiss warning
* check_http: Remove self assignment of a variable and add some comments
* check_dhcp: Make implicit conversion explicit to dismiss warning
* Ini Parser: Avoid freeing symbols from text section
* check_icmp: keep performance data order in case of none-reachable hosts
* check_swap: Change another fake boolean to a real one
* check_swap: Rename type since *_t is reserved for C standard types
* check_ssh: Fix a typo in "remote-protocol parameter
* check_ssh: Handle non-alpha software versions
* check_ssh: properly parse a delayed version control string
* check_disk: Fail on missing arguments for --warning and --critical and fix a test case
* check_disk: Use new test function for percentage expressions
* check_load: remove unused code
* check_curl/check_http: clarified format of POST data
ENHANCEMENTS
* Use C99 booleans
* check_mailq: remove trailing whitespaces
* check_mailq: unify tabs/spaces
* check_oracle: Shellcheck fixes
* check_ups: output ups.realpower if supported
* check_disk: add -n short option for --ignore-missing
* check_procs: Improve help text, mentioning excluded processes
* check_procs: Generalise wording, remove mentioning of nrpe
* check_curl: add haproxy protocol option
* Improve negate plugin helptext
* check_disk: increase alert precision
* check_ircd: IPv6 support
* check_nwstat: adds percentage used space
* Add new test function for percentage expressions
* check_swap: Possibility to run check_swap without thresholds
* check_ups: additional alarm conditions
* check_http/check_curl: added a --regex-state option to change the state of a regex check
2.3.5 18th Oct 2023
FIXES
* Include maxfd.h in lib Makefile
2.3.4 18th Oct 2023
ENHANCEMENTS
* check_curl: added --cookie-jar and doing proper cleanup of libcurl
* check_curl: Include all IPs from getaddrinfo() in curl DNS cache
* check_dhcp: Add dhcp rogue detection
* check_disk: add ignore-missing option to return OK for missing fs
* check_disk_smb: allow checking 0-sized resource (ex. IPC$)
* check_disk: The options to include or exclude specific file systems now allow the usage of regex(7)
* check_icmp: Add support to Jitter, MOS and Score
* check_mysql: Detect running mysqldump and handle it more gracefully
* check_procs: Implement --exclude-process to exclude specific processes
* check_smtp: add new longoption --tls
* check_smtp: Add option to prefix PROXY header
* check_smtp: Add support for SMTP over TLS
* check_smtp: Add support for SNI
* check_snmp: Implement option to ignore mib file parsing errors
* check_users: prefer systemd-logind over utmp
FIXES
* check_disk: Display SI units correctly
* check_ircd: use pack_sockaddr_in rather than hand-rolled
* check_log/check_oracle/check_sensors: fixed the outputs of the help functionality
* check_mysql: Add mysql_close to avoid spamming the server logs
* check_smtp: add missing -r option in usage
* check_snmp: disable multiplier when unused
* check_wave: Use compile time determined path to snmpget
GENERAL
* Sync with the Gnulib code 668c0b8ffa
* Set autoconf prerequisite version to 2.64
* Remove sha1 and use sha256 in some parts of the plugin structure
* A lot of compiler warnings were fixed
* Some code was refactored a little bit
2.3.3 2nd Feb 2023
ENHANCEMENTS
using PRId64 and PRIu64 instead of %ld directly
check_http: Make faster with larger files
check_snmp: add 'multiplier' to modify current value
check_http: Implement chunked encoding decoding
check_http/check_curl: add chunked encoding test
check_log: Added --exclude to exclude patterns
check_log: Add tests
check_disk: Clarify usage possibilities
FIXES
fixed two PRId64 to PRIu64 in perfdata_uint64
check_pgsql: Removing is_pg_dbname altogether,using postgres API.
check_http: Remove superfluous CRLF in HTTP-Requests
check_curl: detect ipv6
check_icmp: fix parsing help/version long options
check_http: fix test plan
check_disk: Find accessible mount path if multiple are available
check_apt: Fix unknown escape sequence error output
check_curl: fix checking large bodys
check_snmp: Improve tests for check_snmp & multiply option
check_snmp: always apply format when applying multiplier
check_http: Use real booleans instead of ints
check_http: Document process_arguments a little bit better
check_http: Remove dead code
check_http: Fix several bug in the implementation of unchunking
check_http: Reformat a part to increase readability
check_apt: Put upgrade options in the root sections
check_apt: Fix comment
check_apt: Use real booleans
check_mailq: Fixing nullmailer regex
check_snmp: Fix regex matches
check_log: Fixed a bug when using --all
check_log: Cleaned up duplicated code in the args
check_http: Fix memory reallocation error in chunk decoding logic
check_http: Add space for ending NULL byte in array for chunked encoding
2.3.2 20th Oct 2022 2.3.2 20th Oct 2022
GENERAL GENERAL
Use netcat-openbsd for debian explicitly (by @RincewindsHat #1704) Use netcat-openbsd for debian explicitely (by @RincewindsHat #1704)
Replace egrep with grep -E (by @RincewindsHat #1791) Replace egrep with grep -E (by @RincewindsHat #1791)
Use silent automake by default (by @RincewindsHat #1747) Use silent automake by default (by @RincewindsHat #1747)
@ -220,7 +85,7 @@ This file documents the major additions and syntax changes between releases.
check_log: Modernize check log (by @RincewindsHat #1692) check_log: Modernize check log (by @RincewindsHat #1692)
check_mailq: remove duplicate W=i/C=i args in check_mailq.pl (by @ichdasich #1755) check_mailq: remove duplicate W=i/C=i args in check_mailq.pl (by @ichdasich #1755)
check_ntp: Check ntp remove unused variables (by @RincewindsHat #1781) check_ntp: Check ntp remove unused variables (by @RincewindsHat #1781)
check_pgsql: Using snprintf which honors the buffers size and guarantees null termination. (Closes: #1601) (by @waja #1663) check_pgsql: Using snprintf which honors the buffers size and guarantees null temination. (Closes: #1601) (by @waja #1663)
check_procs: Fix double percentage sign in usage (by @RincewindsHat #1743) check_procs: Fix double percentage sign in usage (by @RincewindsHat #1743)
check_sensors.sh: Make shellcheck happier (by @RincewindsHat #1679) check_sensors.sh: Make shellcheck happier (by @RincewindsHat #1679)
check_snmp: Fixed option description authpassword -> authpasswd + whitespaces (by @RincewindsHat #1676) check_snmp: Fixed option description authpassword -> authpasswd + whitespaces (by @RincewindsHat #1676)
@ -262,7 +127,7 @@ This file documents the major additions and syntax changes between releases.
check_apt: adding packages-warning option check_apt: adding packages-warning option
check_load: Adding top consuming processes option check_load: Adding top consuming processes option
check_http: Adding Proxy-Authorization and extra headers check_http: Adding Proxy-Authorization and extra headers
check_snmp: make calculation of timeout value in help output more clear check_snmp: make calcualtion of timeout value in help output more clear
check_uptime: new plugin for checking uptime to see how long the system is running check_uptime: new plugin for checking uptime to see how long the system is running
check_curl: check_http replacement based on libcurl check_curl: check_http replacement based on libcurl
check_http: Allow user to specify HTTP method after proxy CONNECT check_http: Allow user to specify HTTP method after proxy CONNECT
@ -292,7 +157,7 @@ This file documents the major additions and syntax changes between releases.
check_procs: improve command examples for 'at least' processes check_procs: improve command examples for 'at least' processes
check_swap: repaired "-n" behaviour check_swap: repaired "-n" behaviour
check_disk: include -P switch in help check_disk: include -P switch in help
check_mailq: restore accidentally removed options check_mailq: restore accidentially removed options
2.2 29th November 2016 2.2 29th November 2016
ENHANCEMENTS ENHANCEMENTS
@ -333,7 +198,7 @@ This file documents the major additions and syntax changes between releases.
check_ssh now returns CRITICAL for protocol/version errors check_ssh now returns CRITICAL for protocol/version errors
If a plugin is invoked with -h/--help or -V/--version, the exit status If a plugin is invoked with -h/--help or -V/--version, the exit status
is now UNKNOWN is now UNKNOWN
The superseded check_ntp.pl was removed, please use check_ntp_peer or The superseeded check_ntp.pl was removed, please use check_ntp_peer or
check_ntp_time instead check_ntp_time instead
2.1.2 16th October 2015 2.1.2 16th October 2015
@ -360,7 +225,7 @@ This file documents the major additions and syntax changes between releases.
New check_mysql -n option to ignore authentication failures New check_mysql -n option to ignore authentication failures
Added IP and port or socket name to error messages Added IP and port or socket name to error messages
New check_ntp_time -o option to add expected offset New check_ntp_time -o option to add expected offset
check_disk shows now troubled partitions in verbose mode check_disk shows now troubled partions in verbose mode
check_dig has now support for drill and dig check_dig has now support for drill and dig
check_dig has now support for -6 option check_dig has now support for -6 option
Add performance data to check_file_age Add performance data to check_file_age
@ -454,10 +319,10 @@ This file documents the major additions and syntax changes between releases.
New check_procs -k option to ignore kernel threads (on Linux) New check_procs -k option to ignore kernel threads (on Linux)
Let check_procs use /proc/<PID>/exe (if available) instead of getpid(2), unless -T is specified Let check_procs use /proc/<PID>/exe (if available) instead of getpid(2), unless -T is specified
Let check_mysql support SSL Let check_mysql support SSL
Let check_mysql add performance metrics for all checks Let check_mysql add perfromance metrics for all checks
New check_mysql -f option to specify a client options file New check_mysql -f option to specify a client options file
New check_mysql -g option to specify a client options group New check_mysql -g option to specify a client options group
New check_snmp --offset option to allow for adding/subtracting an offset value to sensor data New check_snmp --offset option to allow for adding/substracting an offset value to sensor data
Let check_snmp support an arbitrary number of OIDs Let check_snmp support an arbitrary number of OIDs
Let check_ide_smart support NetBSD Let check_ide_smart support NetBSD
@ -472,7 +337,7 @@ This file documents the major additions and syntax changes between releases.
Fix deprecated imports of check_nmap.py Fix deprecated imports of check_nmap.py
WARNINGS WARNINGS
check_http behaviour of -k/--header changed since it does not separate multiple headers by semicolons anymore. Use multiple -k switches instead. check_http behaviour of -k/--header changed since it does not seperate multiple headers by semicolons anymore. Use multiple -k switches instead.
check_http's --proxy_authorization option is now called --proxy-authorization (it was always documented this way) check_http's --proxy_authorization option is now called --proxy-authorization (it was always documented this way)
The contrib directory has been removed from this distribution The contrib directory has been removed from this distribution
@ -623,7 +488,7 @@ This file documents the major additions and syntax changes between releases.
check_ntp and check_ntp_peer now show proper jitter/stratum thresholds longopts in --help check_ntp and check_ntp_peer now show proper jitter/stratum thresholds longopts in --help
check_dns now allow to repeat -a to match multiple possibly returned address (common with load balancers) check_dns now allow to repeat -a to match multiple possibly returned address (common with load balancers)
check_mysql and check_radius now try clearing password in processlist just like check_mysql_query check_mysql and check_radius now try clearing password in processlist just like check_mysql_query
check_mysql and check_mysql_query now support sockets explicitly (-s, --socket) check_mysql and check_mysql_query now support sockets explicitely (-s, --socket)
negate now has the ability to replace the status text as well (-s, --substitute) negate now has the ability to replace the status text as well (-s, --substitute)
Added performance data to check_ping Added performance data to check_ping
Added support for --extra-opts in all C plugins (disabled by default, see configure --help) Added support for --extra-opts in all C plugins (disabled by default, see configure --help)
@ -663,7 +528,7 @@ This file documents the major additions and syntax changes between releases.
New check_disk option -L: Only check local filesystems, but call stat() on remote ones, too. New check_disk option -L: Only check local filesystems, but call stat() on remote ones, too.
Thus accessibility of remote filesystems can be checked without any threshold comparison. Thus accessibility of remote filesystems can be checked without any threshold comparison.
Check_disk's --help now prints some examples for the new features introduced in 1.4.8 Check_disk's --help now prints some examples for the new features introduced in 1.4.8
New check_disk -i/-I option to ignore paths/partitions based on regular expressions New check_disk -i/-I option to ignore pathes/partitions based on regular expressions
New check_disk -A option to select all filesystems explicitly New check_disk -A option to select all filesystems explicitly
WARNING: check_disk's -E option must now be passed before -p or -r/-R arguments WARNING: check_disk's -E option must now be passed before -p or -r/-R arguments
Passing -E after -p or -r results in UNKNOWN state, now Passing -E after -p or -r results in UNKNOWN state, now
@ -712,7 +577,7 @@ This file documents the major additions and syntax changes between releases.
Fixed MKINSTALLDIRS problem in po/ Fixed MKINSTALLDIRS problem in po/
./configure now detects if possible to compile check_mysql ./configure now detects if possible to compile check_mysql
Fixed broken HELO in check_smtp Fixed broken HELO in check_smtp
check_icmp now allows to set a minimum number of hosts required for success (-m) check_icmp now allows to set a minimum number of hosts required for successs (-m)
check_icmp fix for *BSD when running for long time check_icmp fix for *BSD when running for long time
check_ping times out 1 second quicker if host is unreachable check_ping times out 1 second quicker if host is unreachable
Root plugins installed with world executable Root plugins installed with world executable

View file

@ -6,7 +6,7 @@
SRC_ROOT=`dirname $0` SRC_ROOT=`dirname $0`
NPVF=NP-VERSION-FILE NPVF=NP-VERSION-FILE
DEF_VER=2.4.0 DEF_VER=2.3.2
LF=' LF='
' '

View file

@ -151,14 +151,14 @@ of testing against a set of desired exit status values.
=item * =item *
Firstly, if C<$desiredExitStatus> is a reference to an array of exit Firstly, if C<$desiredExitStatus> is a reference to an array of exit
statuses, if the actual exit status of the command is present in the stati, if the actual exit status of the command is present in the
array, it is used in the call to C<Test::ok(...)> when testing the array, it is used in the call to C<Test::ok(...)> when testing the
exit status. exit status.
=item * =item *
Alternatively, if C<$desiredExitStatus> is a reference to a hash of Alternatively, if C<$desiredExitStatus> is a reference to a hash of
exit statuses(mapped to the strings "continue" or "skip"), similar exit stati (mapped to the strings "continue" or "skip"), similar
processing to the above occurs with the side affect of determining if processing to the above occurs with the side affect of determining if
any generated output testing should proceed. Note: only the string any generated output testing should proceed. Note: only the string
"skip" will result in generated output testing being skipped. "skip" will result in generated output testing being skipped.
@ -207,7 +207,7 @@ under the same terms as the Monitoring Plugins release.
my( %CACHE ) = (); my( %CACHE ) = ();
# I'm not really sure whether to house a site-specific cache inside # I'm not really sure wether to house a site-specific cache inside
# or outside of the extracted source / build tree - lets default to outside # or outside of the extracted source / build tree - lets default to outside
my( $CACHEFILENAME ) = ( exists( $ENV{'NPTEST_CACHE'} ) && $ENV{'NPTEST_CACHE'} ) my( $CACHEFILENAME ) = ( exists( $ENV{'NPTEST_CACHE'} ) && $ENV{'NPTEST_CACHE'} )
? $ENV{'NPTEST_CACHE'} : "/var/tmp/NPTest.cache"; # "../Cache.pdd"; ? $ENV{'NPTEST_CACHE'} : "/var/tmp/NPTest.cache"; # "../Cache.pdd";

52
THANKS
View file

@ -2,25 +2,22 @@ This software is brought to you by the Monitoring Plugins Development Team. Howe
there have been many contributors to this project. Everyone below has helped in there have been many contributors to this project. Everyone below has helped in
raising bug reports, creating patches or contributing new plugins. raising bug reports, creating patches or contributing new plugins.
Matthias Hähnel
dag rob?le dag rob?le
Diego Elio Pettenò
Elan Ruusamäe
Thoralf Rickert-Wendt
Aksel Sjögren Aksel Sjögren
fabiodds
Nicolai Søborg
Arkadiusz Miśkiewicz
Wolfgang Karall-Ahlborn
Matthias Döhler
Marc Sánchez Marc Sánchez
Wolfgang Karall-Ahlborn
Randy O'Meara Randy O'Meara
Elan Ruusamäe
Matthias Hähnel
Nicolai Søborg
fabiodds
Diego Elio Pettenò
Oskar Ahner Oskar Ahner
Lance Albertson Lance Albertson
David Alden David Alden
Patrick Allen
Paul Allen
Rodger Allen Rodger Allen
Paul Allen
Patrick Allen
Felipe Gustavo de Almeida Felipe Gustavo de Almeida
Michael Almond Michael Almond
Michael Anthon Michael Anthon
@ -47,7 +44,6 @@ Hilko Bengen
Jason Benguerel Jason Benguerel
Allan Bennett Allan Bennett
Booker C. Bense Booker C. Bense
Björn Berg
Guy Van Den Bergh Guy Van Den Bergh
Andrew Berglund Andrew Berglund
Jimmy Bergman Jimmy Bergman
@ -59,7 +55,6 @@ Prathamesh Bhanuse
Daniel Bimschas Daniel Bimschas
Jeffery Blank Jeffery Blank
Tom De Blende Tom De Blende
Robert Bohne
Eric Bollengier Eric Bollengier
Aurelien Bompard Aurelien Bompard
Stéphane Bortzmeyer Stéphane Bortzmeyer
@ -79,7 +74,6 @@ Jethro Carr
Jim Carroll Jim Carroll
Ian Cass Ian Cass
Arnold Cavazos Arnold Cavazos
Patrick Cervicek
Alex Chaffee Alex Chaffee
Yannick Charton Yannick Charton
Stephane Chazelas Stephane Chazelas
@ -89,9 +83,9 @@ Lee Clemens
Ben Clewett Ben Clewett
Jean-Claude Computing Jean-Claude Computing
Lionel Cons Lionel Cons
Ollie Cook
Charlie Cook Charlie Cook
Garry Cook Garry Cook
Ollie Cook
Luca Corti Luca Corti
Greg Cox Greg Cox
Jason Crawford Jason Crawford
@ -135,8 +129,8 @@ Paulo Fessel
James Fidell James Fidell
Tobias Fiebig Tobias Fiebig
Roman Fiedler Roman Fiedler
Bernhard Fischer
Johan Fischer Johan Fischer
Bernhard Fischer
Matthias Flacke Matthias Flacke
Martin Foster Martin Foster
Felix Frank Felix Frank
@ -154,7 +148,6 @@ Flo Gleixner
Evgeni Golov Evgeni Golov
Joseph Gooch Joseph Gooch
Aravind Gottipati Aravind Gottipati
Ralph Gottschalkson
Kev Green Kev Green
Steve Greenland Steve Greenland
Roberto Greiner Roberto Greiner
@ -162,7 +155,6 @@ Olaf Greis
Alex Griffin Alex Griffin
Chris Grim Chris Grim
Steven Grimm Steven Grimm
Lorenz Gruenwald
Sebastien Guay Sebastien Guay
Linda Guo Linda Guo
Jon Hallett Jon Hallett
@ -171,10 +163,8 @@ Jacob Hansen
Ask Bjoern Hansen Ask Bjoern Hansen
Sebastian Harl Sebastian Harl
Michael Haro Michael Haro
Sven Hartge
Olli Hauer Olli Hauer
Gunnar Hellekson Gunnar Hellekson
Stuart Henderson
Geert Hendrickx Geert Hendrickx
Sebastian Herbszt Sebastian Herbszt
Johannes Herlitz Johannes Herlitz
@ -206,7 +196,6 @@ Konstantin Khomoutov
Serhan Kiymaz Serhan Kiymaz
Alexander A. Klimov Alexander A. Klimov
Denis Knauf Denis Knauf
Eric Knibbe
Harald Koch Harald Koch
Tilman Koschnick Tilman Koschnick
John Koyle John Koyle
@ -218,7 +207,6 @@ Frederic Krueger
Claudio Kuenzler Claudio Kuenzler
Marcel Kuiper Marcel Kuiper
Christian Kujau Christian Kujau
Thorsten Kukuk
Alexander Kulak Alexander Kulak
Bill Kunkel Bill Kunkel
Thomas Kurschel Thomas Kurschel
@ -246,12 +234,11 @@ Jason Lunn
Davide Madrisan Davide Madrisan
Guenther Mair Guenther Mair
Pawel Malachowski Pawel Malachowski
Gerardo Malazdrewicz
Ricardo Maraschini Ricardo Maraschini
Michael Markstaller Michael Markstaller
John Marquart John Marquart
Ernst-Dieter Martin
Jason Martin Jason Martin
Ernst-Dieter Martin
Christopher Maser Christopher Maser
Mathieu Masseboeuf Mathieu Masseboeuf
Alexander Matey Alexander Matey
@ -272,7 +259,6 @@ Jonathan Milby
Russell Miller Russell Miller
Eric J. Mislivec Eric J. Mislivec
Janos Mohacsi Janos Mohacsi
John Morrissey
Andreas Motl Andreas Motl
Tomas Mozes Tomas Mozes
Gerd Mueller Gerd Mueller
@ -283,7 +269,6 @@ Jan-Frode Myklebust
Sivakumar Nellurandi Sivakumar Nellurandi
Peter Newman Peter Newman
Truongchinh Nguyen Truongchinh Nguyen
Wolfgang Nieder
Simon L Nielsen Simon L Nielsen
Thomas Nilsen Thomas Nilsen
Sebastian Nohn Sebastian Nohn
@ -296,7 +281,6 @@ Remi Paulmier
Tom Payerle Tom Payerle
Nick Peelman Nick Peelman
Fabian Pehla Fabian Pehla
Alvar Penning
Chris Pepper Chris Pepper
Matt Perry Matt Perry
Matthew Peters Matthew Peters
@ -310,7 +294,6 @@ Matt Pounsett
Peter Pramberger Peter Pramberger
Joe Presbrey Joe Presbrey
Will Preston Will Preston
Platon Pronko
Arnaud Quette Arnaud Quette
Darian Rackham Darian Rackham
Peter Radcliffe Peter Radcliffe
@ -322,7 +305,6 @@ Abid Rasheed
Patrick Rauscher Patrick Rauscher
Jeremy Reed Jeremy Reed
Spenser Reinhardt Spenser Reinhardt
Eunice Remoquillo
Marc Remy Marc Remy
Alessandro Ren Alessandro Ren
Joe Rhett Joe Rhett
@ -330,7 +312,6 @@ Cliff Rice
Alain Richard Alain Richard
Didi Rieder Didi Rieder
Steve Rigler Steve Rigler
Emmanuel Riviere
Josip Rodin Josip Rodin
Kenny Root Kenny Root
Wolfgang Rosenauer Wolfgang Rosenauer
@ -341,21 +322,18 @@ Sascha Runschke
Dietmar Ruzicka Dietmar Ruzicka
Ralph Rye Ralph Rye
Alen Salamun Alen Salamun
Louis Sautier
Sven Schaffranneck Sven Schaffranneck
Christoph Schell Christoph Schell
Thomas Schimpke Thomas Schimpke
Benjamin Schmid Benjamin Schmid
Sebastian Schmidt
Christian Schmidt Christian Schmidt
Sebastian Schmidt
Henning Schmiedehausen Henning Schmiedehausen
Christian Schneemann Christian Schneemann
Cove Schneider Cove Schneider
Enrico Scholz Enrico Scholz
Sebastian Schubert Sebastian Schubert
Christopher Schultz Christopher Schultz
Kristian Schuster
Franz Schwartau
Russell Scibetti Russell Scibetti
Noel Sebastien Noel Sebastien
Andreas Seemueller Andreas Seemueller
@ -378,8 +356,6 @@ David Sullivan
Kjell Sundtjonn Kjell Sundtjonn
Ziya Suzen Ziya Suzen
Christian Tacke Christian Tacke
Stefan Taferner
Danijel Tasov
Michael Tiernan Michael Tiernan
Ben Timby Ben Timby
Ronald Tin Ronald Tin
@ -389,7 +365,6 @@ Gabriele Tozzi
Kyle Tucker Kyle Tucker
Jerome Tytgat Jerome Tytgat
Daniel Uhlmann Daniel Uhlmann
Patrick Uiterwijk
Stéphane Urbanovski Stéphane Urbanovski
Matthias Urlichs Matthias Urlichs
Matteo HCE Valsasna Matteo HCE Valsasna
@ -423,10 +398,9 @@ Shawn Wills
Rob Windsor Rob Windsor
Mario Witte Mario Witte
Alexander Wittig Alexander Wittig
Brian De Wolf
Tobias Wolf Tobias Wolf
Brian De Wolf
Eric Wunderlin Eric Wunderlin
Patric Wust Patric Wust
Jamie Zawinski Jamie Zawinski
Vadim Zhukov Vadim Zhukov
andrew bezella

3452
aclocal.m4 vendored

File diff suppressed because it is too large Load diff

View file

@ -3,7 +3,7 @@
scriptversion=2018-03-07.03; # UTC scriptversion=2018-03-07.03; # UTC
# Copyright (C) 1999-2021 Free Software Foundation, Inc. # Copyright (C) 1999-2020 Free Software Foundation, Inc.
# Written by Tom Tromey <tromey@cygnus.com>. # Written by Tom Tromey <tromey@cygnus.com>.
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify

1500
build-aux/config.guess vendored

File diff suppressed because it is too large Load diff

View file

@ -2,7 +2,7 @@
# Output a system dependent set of variables, describing how to set the # Output a system dependent set of variables, describing how to set the
# run time search path of shared libraries in an executable. # run time search path of shared libraries in an executable.
# #
# Copyright 1996-2023 Free Software Foundation, Inc. # Copyright 1996-2013 Free Software Foundation, Inc.
# Taken from GNU libtool, 2001 # Taken from GNU libtool, 2001
# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 # Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
# #
@ -367,11 +367,15 @@ else
dgux*) dgux*)
hardcode_libdir_flag_spec='-L$libdir' hardcode_libdir_flag_spec='-L$libdir'
;; ;;
freebsd2.[01]*) freebsd2.2*)
hardcode_libdir_flag_spec='-R$libdir'
hardcode_direct=yes
;;
freebsd2*)
hardcode_direct=yes hardcode_direct=yes
hardcode_minus_L=yes hardcode_minus_L=yes
;; ;;
freebsd* | dragonfly* | midnightbsd*) freebsd* | dragonfly*)
hardcode_libdir_flag_spec='-R$libdir' hardcode_libdir_flag_spec='-R$libdir'
hardcode_direct=yes hardcode_direct=yes
;; ;;
@ -544,11 +548,13 @@ case "$host_os" in
dgux*) dgux*)
library_names_spec='$libname$shrext' library_names_spec='$libname$shrext'
;; ;;
freebsd[23].*) freebsd* | dragonfly*)
library_names_spec='$libname$shrext$versuffix' case "$host_os" in
;; freebsd[123]*)
freebsd* | dragonfly* | midnightbsd*) library_names_spec='$libname$shrext$versuffix' ;;
library_names_spec='$libname$shrext' *)
library_names_spec='$libname$shrext' ;;
esac
;; ;;
gnu*) gnu*)
library_names_spec='$libname$shrext' library_names_spec='$libname$shrext'

2867
build-aux/config.sub vendored

File diff suppressed because it is too large Load diff

View file

@ -3,7 +3,7 @@
scriptversion=2018-03-07.03; # UTC scriptversion=2018-03-07.03; # UTC
# Copyright (C) 1999-2021 Free Software Foundation, Inc. # Copyright (C) 1999-2020 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by

View file

@ -189,7 +189,7 @@ func_basename ()
# to NONDIR_REPLACEMENT. # to NONDIR_REPLACEMENT.
# value returned in "$func_dirname_result" # value returned in "$func_dirname_result"
# basename: Compute filename of FILE. # basename: Compute filename of FILE.
# value returned in "$func_basename_result" # value retuned in "$func_basename_result"
# Implementation must be kept synchronized with func_dirname # Implementation must be kept synchronized with func_dirname
# and func_basename. For efficiency, we do not delegate to # and func_basename. For efficiency, we do not delegate to
# those functions but instead duplicate the functionality here. # those functions but instead duplicate the functionality here.
@ -522,7 +522,7 @@ func_mkdir_p ()
# While some portion of DIR does not yet exist... # While some portion of DIR does not yet exist...
while test ! -d "$my_directory_path"; do while test ! -d "$my_directory_path"; do
# ...make a list in topmost first order. Use a colon delimited # ...make a list in topmost first order. Use a colon delimited
# list in case some portion of path contains whitespace. # list incase some portion of path contains whitespace.
my_dir_list="$my_directory_path:$my_dir_list" my_dir_list="$my_directory_path:$my_dir_list"
# If the last portion added has no slash in it, the list is done # If the last portion added has no slash in it, the list is done
@ -4394,7 +4394,7 @@ EOF
{ {
/* however, if there is an option in the LTWRAPPER_OPTION_PREFIX /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
namespace, but it is not one of the ones we know about and namespace, but it is not one of the ones we know about and
have already dealt with, above (including dump-script), then have already dealt with, above (inluding dump-script), then
report an error. Otherwise, targets might begin to believe report an error. Otherwise, targets might begin to believe
they are allowed to use options in the LTWRAPPER_OPTION_PREFIX they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
namespace. The first time any user complains about this, we'll namespace. The first time any user complains about this, we'll

View file

@ -3,7 +3,7 @@
scriptversion=2018-03-07.03; # UTC scriptversion=2018-03-07.03; # UTC
# Copyright (C) 1996-2021 Free Software Foundation, Inc. # Copyright (C) 1996-2020 Free Software Foundation, Inc.
# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. # Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify

View file

@ -0,0 +1,10 @@
#if !defined _Noreturn && __STDC_VERSION__ < 201112
# if (3 <= __GNUC__ || (__GNUC__ == 2 && 8 <= __GNUC_MINOR__) \
|| 0x5110 <= __SUNPRO_C)
# define _Noreturn __attribute__ ((__noreturn__))
# elif 1200 <= _MSC_VER
# define _Noreturn __declspec (noreturn)
# else
# define _Noreturn
# endif
#endif

View file

@ -1,24 +1,24 @@
/* A C macro for declaring that specific arguments must not be NULL. /* A C macro for declaring that specific arguments must not be NULL.
Copyright (C) 2009-2023 Free Software Foundation, Inc. Copyright (C) 2009-2013 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2 of the License, or by the Free Software Foundation; either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details. General Public License for more details.
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */ along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools /* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
that the values passed as arguments n, ..., m must be non-NULL pointers. that the values passed as arguments n, ..., m must be non-NULL pointers.
n = 1 stands for the first argument, n = 2 for the second argument etc. */ n = 1 stands for the first argument, n = 2 for the second argument etc. */
#ifndef _GL_ARG_NONNULL #ifndef _GL_ARG_NONNULL
# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || defined __clang__ # if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3
# define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params)) # define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
# else # else
# define _GL_ARG_NONNULL(params) # define _GL_ARG_NONNULL(params)

View file

@ -1,31 +1,22 @@
/* C++ compatible function declaration macros. /* C++ compatible function declaration macros.
Copyright (C) 2010-2023 Free Software Foundation, Inc. Copyright (C) 2010-2013 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2 of the License, or by the Free Software Foundation; either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details. General Public License for more details.
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _GL_CXXDEFS_H #ifndef _GL_CXXDEFS_H
#define _GL_CXXDEFS_H #define _GL_CXXDEFS_H
/* Begin/end the GNULIB_NAMESPACE namespace. */
#if defined __cplusplus && defined GNULIB_NAMESPACE
# define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE {
# define _GL_END_NAMESPACE }
#else
# define _GL_BEGIN_NAMESPACE
# define _GL_END_NAMESPACE
#endif
/* The three most frequent use cases of these macros are: /* The three most frequent use cases of these macros are:
* For providing a substitute for a function that is missing on some * For providing a substitute for a function that is missing on some
@ -120,25 +111,14 @@
that redirects to rpl_func, if GNULIB_NAMESPACE is defined. that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
Example: Example:
_GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...)); _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
*/
Wrapping rpl_func in an object with an inline conversion operator
avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is
actually used in the program. */
#define _GL_CXXALIAS_RPL(func,rettype,parameters) \ #define _GL_CXXALIAS_RPL(func,rettype,parameters) \
_GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters) _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
#if defined __cplusplus && defined GNULIB_NAMESPACE #if defined __cplusplus && defined GNULIB_NAMESPACE
# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
namespace GNULIB_NAMESPACE \ namespace GNULIB_NAMESPACE \
{ \ { \
static const struct _gl_ ## func ## _wrapper \ rettype (*const func) parameters = ::rpl_func; \
{ \
typedef rettype (*type) parameters; \
\
inline operator type () const \
{ \
return ::rpl_func; \
} \
} func = {}; \
} \ } \
_GL_EXTERN_C int _gl_cxxalias_dummy _GL_EXTERN_C int _gl_cxxalias_dummy
#else #else
@ -146,16 +126,6 @@
_GL_EXTERN_C int _gl_cxxalias_dummy _GL_EXTERN_C int _gl_cxxalias_dummy
#endif #endif
/* _GL_CXXALIAS_MDA (func, rettype, parameters);
is to be used when func is a Microsoft deprecated alias, on native Windows.
It declares a C++ alias called GNULIB_NAMESPACE::func
that redirects to _func, if GNULIB_NAMESPACE is defined.
Example:
_GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...));
*/
#define _GL_CXXALIAS_MDA(func,rettype,parameters) \
_GL_CXXALIAS_RPL_1 (func, _##func, rettype, parameters)
/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters); /* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters); is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
except that the C function rpl_func may have a slightly different except that the C function rpl_func may have a slightly different
@ -165,15 +135,8 @@
# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
namespace GNULIB_NAMESPACE \ namespace GNULIB_NAMESPACE \
{ \ { \
static const struct _gl_ ## func ## _wrapper \ rettype (*const func) parameters = \
{ \ reinterpret_cast<rettype(*)parameters>(::rpl_func); \
typedef rettype (*type) parameters; \
\
inline operator type () const \
{ \
return reinterpret_cast<type>(::rpl_func); \
} \
} func = {}; \
} \ } \
_GL_EXTERN_C int _gl_cxxalias_dummy _GL_EXTERN_C int _gl_cxxalias_dummy
#else #else
@ -181,38 +144,25 @@
_GL_EXTERN_C int _gl_cxxalias_dummy _GL_EXTERN_C int _gl_cxxalias_dummy
#endif #endif
/* _GL_CXXALIAS_MDA_CAST (func, rettype, parameters);
is like _GL_CXXALIAS_MDA (func, rettype, parameters);
except that the C function func may have a slightly different declaration.
A cast is used to silence the "invalid conversion" error that would
otherwise occur. */
#define _GL_CXXALIAS_MDA_CAST(func,rettype,parameters) \
_GL_CXXALIAS_RPL_CAST_1 (func, _##func, rettype, parameters)
/* _GL_CXXALIAS_SYS (func, rettype, parameters); /* _GL_CXXALIAS_SYS (func, rettype, parameters);
declares a C++ alias called GNULIB_NAMESPACE::func declares a C++ alias called GNULIB_NAMESPACE::func
that redirects to the system provided function func, if GNULIB_NAMESPACE that redirects to the system provided function func, if GNULIB_NAMESPACE
is defined. is defined.
Example: Example:
_GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...)); _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
*/
Wrapping func in an object with an inline conversion operator
avoids a reference to func unless GNULIB_NAMESPACE::func is
actually used in the program. */
#if defined __cplusplus && defined GNULIB_NAMESPACE #if defined __cplusplus && defined GNULIB_NAMESPACE
# define _GL_CXXALIAS_SYS(func,rettype,parameters) \ /* If we were to write
namespace GNULIB_NAMESPACE \ rettype (*const func) parameters = ::func;
{ \ like above in _GL_CXXALIAS_RPL_1, the compiler could optimize calls
static const struct _gl_ ## func ## _wrapper \ better (remove an indirection through a 'static' pointer variable),
{ \ but then the _GL_CXXALIASWARN macro below would cause a warning not only
typedef rettype (*type) parameters; \ for uses of ::func but also for uses of GNULIB_NAMESPACE::func. */
\ # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
inline operator type () const \ namespace GNULIB_NAMESPACE \
{ \ { \
return ::func; \ static rettype (*func) parameters = ::func; \
} \ } \
} func = {}; \
} \
_GL_EXTERN_C int _gl_cxxalias_dummy _GL_EXTERN_C int _gl_cxxalias_dummy
#else #else
# define _GL_CXXALIAS_SYS(func,rettype,parameters) \ # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
@ -228,15 +178,8 @@
# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
namespace GNULIB_NAMESPACE \ namespace GNULIB_NAMESPACE \
{ \ { \
static const struct _gl_ ## func ## _wrapper \ static rettype (*func) parameters = \
{ \ reinterpret_cast<rettype(*)parameters>(::func); \
typedef rettype (*type) parameters; \
\
inline operator type () const \
{ \
return reinterpret_cast<type>(::func); \
} \
} func = {}; \
} \ } \
_GL_EXTERN_C int _gl_cxxalias_dummy _GL_EXTERN_C int _gl_cxxalias_dummy
#else #else
@ -259,15 +202,9 @@
# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
namespace GNULIB_NAMESPACE \ namespace GNULIB_NAMESPACE \
{ \ { \
static const struct _gl_ ## func ## _wrapper \ static rettype (*func) parameters = \
{ \ reinterpret_cast<rettype(*)parameters>( \
typedef rettype (*type) parameters; \ (rettype2(*)parameters2)(::func)); \
\
inline operator type () const \
{ \
return reinterpret_cast<type>((rettype2 (*) parameters2)(::func)); \
} \
} func = {}; \
} \ } \
_GL_EXTERN_C int _gl_cxxalias_dummy _GL_EXTERN_C int _gl_cxxalias_dummy
#else #else
@ -284,9 +221,9 @@
_GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE) _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
# define _GL_CXXALIASWARN_1(func,namespace) \ # define _GL_CXXALIASWARN_1(func,namespace) \
_GL_CXXALIASWARN_2 (func, namespace) _GL_CXXALIASWARN_2 (func, namespace)
/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>, /* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
we enable the warning only when not optimizing. */ we enable the warning only when not optimizing. */
# if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__) # if !__OPTIMIZE__
# define _GL_CXXALIASWARN_2(func,namespace) \ # define _GL_CXXALIASWARN_2(func,namespace) \
_GL_WARN_ON_USE (func, \ _GL_WARN_ON_USE (func, \
"The symbol ::" #func " refers to the system function. " \ "The symbol ::" #func " refers to the system function. " \
@ -312,13 +249,16 @@
GNULIB_NAMESPACE) GNULIB_NAMESPACE)
# define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \ # define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
_GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace) _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>, /* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
we enable the warning only when not optimizing. */ we enable the warning only when not optimizing. */
# if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__) # if !__OPTIMIZE__
# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
_GL_WARN_ON_USE_CXX (func, rettype, rettype, parameters_and_attributes, \ _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \
"The symbol ::" #func " refers to the system function. " \ "The symbol ::" #func " refers to the system function. " \
"Use " #namespace "::" #func " instead.") "Use " #namespace "::" #func " instead.")
# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
extern __typeof__ (func) func
# else # else
# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
_GL_EXTERN_C int _gl_cxxalias_dummy _GL_EXTERN_C int _gl_cxxalias_dummy

View file

@ -0,0 +1,109 @@
/* A C macro for emitting warnings if a function is used.
Copyright (C) 2010-2013 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* _GL_WARN_ON_USE (function, "literal string") issues a declaration
for FUNCTION which will then trigger a compiler warning containing
the text of "literal string" anywhere that function is called, if
supported by the compiler. If the compiler does not support this
feature, the macro expands to an unused extern declaration.
This macro is useful for marking a function as a potential
portability trap, with the intent that "literal string" include
instructions on the replacement function that should be used
instead. However, one of the reasons that a function is a
portability trap is if it has the wrong signature. Declaring
FUNCTION with a different signature in C is a compilation error, so
this macro must use the same type as any existing declaration so
that programs that avoid the problematic FUNCTION do not fail to
compile merely because they included a header that poisoned the
function. But this implies that _GL_WARN_ON_USE is only safe to
use if FUNCTION is known to already have a declaration. Use of
this macro implies that there must not be any other macro hiding
the declaration of FUNCTION; but undefining FUNCTION first is part
of the poisoning process anyway (although for symbols that are
provided only via a macro, the result is a compilation error rather
than a warning containing "literal string"). Also note that in
C++, it is only safe to use if FUNCTION has no overloads.
For an example, it is possible to poison 'getline' by:
- adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]],
[getline]) in configure.ac, which potentially defines
HAVE_RAW_DECL_GETLINE
- adding this code to a header that wraps the system <stdio.h>:
#undef getline
#if HAVE_RAW_DECL_GETLINE
_GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but"
"not universally present; use the gnulib module getline");
#endif
It is not possible to directly poison global variables. But it is
possible to write a wrapper accessor function, and poison that
(less common usage, like &environ, will cause a compilation error
rather than issue the nice warning, but the end result of informing
the developer about their portability problem is still achieved):
#if HAVE_RAW_DECL_ENVIRON
static char ***rpl_environ (void) { return &environ; }
_GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared");
# undef environ
# define environ (*rpl_environ ())
#endif
*/
#ifndef _GL_WARN_ON_USE
# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
/* A compiler attribute is available in gcc versions 4.3.0 and later. */
# define _GL_WARN_ON_USE(function, message) \
extern __typeof__ (function) function __attribute__ ((__warning__ (message)))
# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
/* Verify the existence of the function. */
# define _GL_WARN_ON_USE(function, message) \
extern __typeof__ (function) function
# else /* Unsupported. */
# define _GL_WARN_ON_USE(function, message) \
_GL_WARN_EXTERN_C int _gl_warn_on_use
# endif
#endif
/* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string")
is like _GL_WARN_ON_USE (function, "string"), except that the function is
declared with the given prototype, consisting of return type, parameters,
and attributes.
This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
not work in this case. */
#ifndef _GL_WARN_ON_USE_CXX
# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
extern rettype function parameters_and_attributes \
__attribute__ ((__warning__ (msg)))
# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
/* Verify the existence of the function. */
# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
extern rettype function parameters_and_attributes
# else /* Unsupported. */
# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
_GL_WARN_EXTERN_C int _gl_warn_on_use
# endif
#endif
/* _GL_WARN_EXTERN_C declaration;
performs the declaration with C linkage. */
#ifndef _GL_WARN_EXTERN_C
# if defined __cplusplus
# define _GL_WARN_EXTERN_C extern "C"
# else
# define _GL_WARN_EXTERN_C extern
# endif
#endif

View file

@ -3,7 +3,7 @@
scriptversion=2018-03-07.03; # UTC scriptversion=2018-03-07.03; # UTC
# Copyright (C) 2011-2021 Free Software Foundation, Inc. # Copyright (C) 2011-2020 Free Software Foundation, Inc.
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -105,11 +105,8 @@ trap "st=130; $do_exit" 2
trap "st=141; $do_exit" 13 trap "st=141; $do_exit" 13
trap "st=143; $do_exit" 15 trap "st=143; $do_exit" 15
# Test script is run here. We create the file first, then append to it, # Test script is run here.
# to ameliorate tests themselves also writing to the log file. Our tests "$@" >$log_file 2>&1
# don't, but others can (automake bug#35762).
: >"$log_file"
"$@" >>"$log_file" 2>&1
estatus=$? estatus=$?
if test $enable_hard_errors = no && test $estatus -eq 99; then if test $enable_hard_errors = no && test $estatus -eq 99; then
@ -131,7 +128,7 @@ esac
# know whether the test passed or failed simply by looking at the '.log' # know whether the test passed or failed simply by looking at the '.log'
# file, without the need of also peaking into the corresponding '.trs' # file, without the need of also peaking into the corresponding '.trs'
# file (automake bug#11814). # file (automake bug#11814).
echo "$res $test_name (exit status: $estatus)" >>"$log_file" echo "$res $test_name (exit status: $estatus)" >>$log_file
# Report outcome to console. # Report outcome to console.
echo "${col}${res}${std}: $test_name" echo "${col}${res}${std}: $test_name"

File diff suppressed because it is too large Load diff

View file

@ -30,7 +30,7 @@ int main(){
/* pipefd[1] is for writing to the pipe. We want the output /* pipefd[1] is for writing to the pipe. We want the output
* that used to go to the standard output (file descriptor 1) * that used to go to the standard output (file descriptor 1)
* to be written to the pipe. The following command does this, * to be written to the pipe. The following command does this,
* creating a new file descriptor 1 (the lowest available) * creating a new file descripter 1 (the lowest available)
* that writes where pipefd[1] goes. */ * that writes where pipefd[1] goes. */
dup (pipefd[1]); /* points pipefd at file descriptor */ dup (pipefd[1]); /* points pipefd at file descriptor */
/* the child isn't going to read from the pipe, so /* the child isn't going to read from the pipe, so

49198
configure vendored

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
dnl Process this file with autoconf to produce a configure script. dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.64) AC_PREREQ(2.59)
AC_INIT(monitoring-plugins,2.4.0) AC_INIT(monitoring-plugins,2.3.2)
AC_CONFIG_SRCDIR(NPTest.pm) AC_CONFIG_SRCDIR(NPTest.pm)
AC_CONFIG_FILES([gl/Makefile]) AC_CONFIG_FILES([gl/Makefile])
AC_CONFIG_AUX_DIR(build-aux) AC_CONFIG_AUX_DIR(build-aux)
@ -328,25 +328,6 @@ AS_IF([test "x$with_ldap" != "xno"], [
LIBS="$_SAVEDLIBS" LIBS="$_SAVEDLIBS"
]) ])
AC_ARG_WITH([systemd], [AS_HELP_STRING([--without-systemd], [Skips systemd support])])
dnl Check for libsystemd
AS_IF([test "x$with_systemd" != "xno"], [
_SAVEDLIBS="$LIBS"
AC_CHECK_LIB(systemd,sd_get_sessions,,,-lsystemd)
if test "$ac_cv_lib_systemd_sd_get_sessions" = "yes"; then
SYSTEMDLIBS="-lsystemd"
SYSTEMDINCLUDE=""
AC_SUBST(SYSTEMDLIBS)
AC_SUBST(SYSTEMDINCLUDE)
else
AC_MSG_WARN([Skipping systemd support])
fi
LIBS="$_SAVEDLIBS"
])
dnl Check for headers used by check_ide_smart dnl Check for headers used by check_ide_smart
case $host in case $host in
*linux*) *linux*)
@ -621,6 +602,7 @@ AC_C_CONST
AC_STRUCT_TM AC_STRUCT_TM
AC_TYPE_PID_T AC_TYPE_PID_T
AC_TYPE_SIZE_T AC_TYPE_SIZE_T
AC_TYPE_SIGNAL
AC_CACHE_CHECK([for va_copy],ac_cv_HAVE_VA_COPY,[ AC_CACHE_CHECK([for va_copy],ac_cv_HAVE_VA_COPY,[
AC_TRY_LINK([#include <stdarg.h> AC_TRY_LINK([#include <stdarg.h>
@ -644,16 +626,12 @@ AC_TRY_COMPILE([#include <sys/time.h>],
[struct timeval *tv; [struct timeval *tv;
struct timezone *tz;], struct timezone *tz;],
AC_DEFINE(HAVE_STRUCT_TIMEVAL,1,[Define if we have a timeval structure]) AC_DEFINE(HAVE_STRUCT_TIMEVAL,1,[Define if we have a timeval structure])
FOUND_STRUCT_TIMEVAL="yes") AC_TRY_COMPILE([#include <sys/time.h>],
[struct timeval *tv;
if test x"$FOUND_STRUCT_TIMEVAL" = x"yes"; then struct timezone *tz;
AC_TRY_COMPILE([#include <sys/time.h>], gettimeofday(tv, tz);],
[struct timeval *tv; AC_DEFINE(HAVE_GETTIMEOFDAY,1,[Define if gettimeofday is found]),
struct timezone *tz; AC_DEFINE(NEED_GETTIMEOFDAY,1,[Define if gettimeofday is needed])))
gettimeofday(tv, tz);],
AC_DEFINE(HAVE_GETTIMEOFDAY,1,[Define if gettimeofday is found]),
AC_DEFINE(NEED_GETTIMEOFDAY,1,[Define if gettimeofday is needed]))
fi
dnl Checks for library functions. dnl Checks for library functions.
AC_CHECK_FUNCS(memmove select socket strdup strstr strtol strtoul floor) AC_CHECK_FUNCS(memmove select socket strdup strstr strtol strtoul floor)
@ -954,7 +932,7 @@ elif ps -Ao 's comm vsz rss uid user pid ppid args' 2>/dev/null | \
then then
ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
ac_cv_ps_command="$PATH_TO_PS -Ao 's uid pid ppid vsz rss pcpu comm args'" ac_cv_ps_command="$PATH_TO_PS -Ao 's uid pid ppid vsz rss pcpu comm args'"
# There must be no space between the %s and %n due to a weird problem in sscanf where # There must be no space between the %s and %n due to a wierd problem in sscanf where
# it will return %n as longer than the line length # it will return %n as longer than the line length
ac_cv_ps_format="%s %d %d %d %d %d %f %s%n" ac_cv_ps_format="%s %d %d %d %d %d %f %s%n"
ac_cv_ps_cols=9 ac_cv_ps_cols=9
@ -1574,7 +1552,7 @@ if test -n "$PATH_TO_SUDO"
then then
AC_DEFINE_UNQUOTED(PATH_TO_SUDO,"$PATH_TO_SUDO",[path to sudo]) AC_DEFINE_UNQUOTED(PATH_TO_SUDO,"$PATH_TO_SUDO",[path to sudo])
else else
AC_MSG_WARN([Could not find sudo or equivalent]) AC_MSG_WARN([Could not find sudo or eqivalent])
fi fi
AC_PATH_PROG(PATH_TO_MAILQ,mailq) AC_PATH_PROG(PATH_TO_MAILQ,mailq)
@ -1585,7 +1563,7 @@ if test -n "$PATH_TO_MAILQ"
then then
AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_MAILQ",[path to mailq]) AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_MAILQ",[path to mailq])
else else
AC_MSG_WARN([Could not find mailq or equivalent]) AC_MSG_WARN([Could not find mailq or eqivalent])
fi fi
AC_PATH_PROG(PATH_TO_QMAIL_QSTAT,qmail-qstat) AC_PATH_PROG(PATH_TO_QMAIL_QSTAT,qmail-qstat)
@ -1596,7 +1574,7 @@ if test -n "$PATH_TO_QMAIL_QSTAT"
then then
AC_DEFINE_UNQUOTED(PATH_TO_QMAIL_QSTAT,"$PATH_TO_QMAIL_QSTAT",[path to qmail-qstat]) AC_DEFINE_UNQUOTED(PATH_TO_QMAIL_QSTAT,"$PATH_TO_QMAIL_QSTAT",[path to qmail-qstat])
else else
AC_MSG_WARN([Could not find qmail-qstat or equivalent]) AC_MSG_WARN([Could not find qmail-qstat or eqivalent])
fi fi
dnl SWAP info required is amount allocated/available and amount free dnl SWAP info required is amount allocated/available and amount free
@ -1614,13 +1592,13 @@ then
grep -E -i "^lswap +path +pri +swaplo +blocks +free +maxswap" \ grep -E -i "^lswap +path +pri +swaplo +blocks +free +maxswap" \
>/dev/null] >/dev/null]
then then
ac_cv_swap_format=[" %*d %*s %*d,%*d %*d %*d %lu %lu"] ac_cv_swap_format=[" %*d %*s %*d,%*d %*d %*d %f %f"]
ac_cv_swap_conv=2048 ac_cv_swap_conv=2048
AC_MSG_RESULT([using IRIX format swap]) AC_MSG_RESULT([using IRIX format swap])
elif [$PATH_TO_SWAP -l 2>/dev/null | grep -E -i "^path +dev +swaplo +blocks +free" >/dev/null] elif [$PATH_TO_SWAP -l 2>/dev/null | grep -E -i "^path +dev +swaplo +blocks +free" >/dev/null]
then then
ac_cv_swap_format=["%*s %*[0-9,-] %*d %lu %lu"] ac_cv_swap_format=["%*s %*[0-9,-] %*d %f %f"]
ac_cv_swap_conv=2048 ac_cv_swap_conv=2048
AC_MSG_RESULT([using Unixware format swap]) AC_MSG_RESULT([using Unixware format swap])
else else
@ -1644,7 +1622,7 @@ then
if [$PATH_TO_SWAPINFO -k 2>/dev/null | grep -E -i "^Device +1K-blocks +Used +Avail" >/dev/null] if [$PATH_TO_SWAPINFO -k 2>/dev/null | grep -E -i "^Device +1K-blocks +Used +Avail" >/dev/null]
then then
ac_cv_swap_format=["%*s %lu %*d %lu"] ac_cv_swap_format=["%*s %f %*d %f"]
ac_cv_swap_conv=1024 ac_cv_swap_conv=1024
AC_MSG_RESULT([using FreeBSD format swapinfo]) AC_MSG_RESULT([using FreeBSD format swapinfo])
fi fi
@ -1653,7 +1631,7 @@ elif [$PATH_TO_SWAPINFO -dfM 2>/dev/null | grep -E -i "^TYPE +AVAIL +USED +FREE"
then then
ac_cv_have_swap=yes ac_cv_have_swap=yes
ac_cv_swap_command="$PATH_TO_SWAPINFO -dfM" ac_cv_swap_command="$PATH_TO_SWAPINFO -dfM"
ac_cv_swap_format=["%*s %lu %*d %lu"] ac_cv_swap_format=["%*s %f %*d %f"]
ac_cv_swap_conv=1024 ac_cv_swap_conv=1024
AC_MSG_RESULT([using HP-UX format swapinfo]) AC_MSG_RESULT([using HP-UX format swapinfo])
fi fi
@ -1668,7 +1646,7 @@ if [$PATH_TO_LSPS -a 2>/dev/null | grep -E -i "^Page Space" > /dev/null]
then then
ac_cv_have_swap=yes ac_cv_have_swap=yes
ac_cv_swap_command="$PATH_TO_LSPS -a" ac_cv_swap_command="$PATH_TO_LSPS -a"
ac_cv_swap_format=["%*s %*s %*s %lu%*s %lu %*s"] ac_cv_swap_format=["%*s %*s %*s %f%*s %f %*s"]
ac_cv_swap_conv=1 ac_cv_swap_conv=1
AC_MSG_RESULT([using AIX lsps]) AC_MSG_RESULT([using AIX lsps])
fi fi
@ -1854,7 +1832,7 @@ AM_GNU_GETTEXT([external], [need-ngettext])
AM_GNU_GETTEXT_VERSION(0.15) AM_GNU_GETTEXT_VERSION(0.15)
dnl Check for Redhat spopen problem dnl Check for Redhat spopen problem
dnl Weird problem where ECHILD is returned from a wait call in error dnl Wierd problem where ECHILD is returned from a wait call in error
dnl Only appears to affect nslookup and dig calls. Only affects redhat around dnl Only appears to affect nslookup and dig calls. Only affects redhat around
dnl 2.6.9-11 (okay in 2.6.9-5). Redhat investigating root cause dnl 2.6.9-11 (okay in 2.6.9-5). Redhat investigating root cause
dnl We patch plugins/popen.c dnl We patch plugins/popen.c
@ -1923,6 +1901,7 @@ AC_OUTPUT(
plugins-scripts/utils.sh plugins-scripts/utils.sh
test.pl test.pl
pkg/solaris/pkginfo pkg/solaris/pkginfo
po/Makefile.in
) )

22
debian/.gitlab-ci.yml vendored
View file

@ -1,14 +1,14 @@
---
include: include:
- https://salsa.debian.org/salsa-ci-team/pipeline/raw/master/recipes/debian.yml - https://salsa.debian.org/salsa-ci-team/pipeline/raw/master/salsa-ci.yml
- https://salsa.debian.org/salsa-ci-team/pipeline/raw/master/pipeline-jobs.yml
variables: variables:
RELEASE: 'unstable' RELEASE: 'unstable'
SALSA_CI_DISABLE_APTLY: 0 SALSA_CI_DISABLE_APTLY: 0
SALSA_CI_DISABLE_AUTOPKGTEST: 0 SALSA_CI_DISABLE_AUTOPKGTEST: 0
SALSA_CI_DISABLE_BLHC: 1 SALSA_CI_DISABLE_BLHC: 0
SALSA_CI_DISABLE_LINTIAN: 0 SALSA_CI_DISABLE_LINTIAN: 0
SALSA_CI_DISABLE_PIUPARTS: 0 SALSA_CI_DISABLE_PIUPARTS: 0
SALSA_CI_DISABLE_DEBREBUILD: 0 SALSA_CI_DISABLE_REPROTEST: 0
SALSA_CI_DISABLE_BUILD_PACKAGE_ALL: 0 SALSA_CI_DISABLE_BUILD_PACKAGE_ALL: 0
SALSA_CI_DISABLE_BUILD_PACKAGE_ANY: 0 SALSA_CI_DISABLE_BUILD_PACKAGE_ANY: 0

23
debian/NEWS vendored
View file

@ -1,28 +1,7 @@
monitoring-plugins (2.4.0-5) unstable; urgency=medium
Priority of check_curl alternative for check_http is now higher
then check_http.deprecated, which means calling check_http is now
check_curl. You can change that by: update-alternatives --config check_http
Removed also deprecated check_ntp from package.
-- Jan Wagner <waja@cyconet.org> Thu, 2 Dec 2025 12:49:36 +0100
monitoring-plugins (2.4.0-3) unstable; urgency=medium
The check_http plugin was deprecated. Please migrate the check command
definitions over to the drop-in replacement check_curl. It should be
sufficient to replace check_http with check_curl in your command definitions.
The check_curl plugin was moved to the monitoring-plugins-basic package for
a smoother migration path. For making things easy, update-alternatives can
be used to change the check_http alternative. This can be done with the
command: update-alternatives --config check_http
-- Jan Wagner <waja@cyconet.org> Mon, 21 Apr 2025 11:00:59 +0200
monitoring-plugins (2.1.2-3) unstable; urgency=medium monitoring-plugins (2.1.2-3) unstable; urgency=medium
We switched again over to another radius library. This time radcli We switched again over to another radius library. This time radcli
to fix #822337. This makes it again necessary to migrate your radius to fix #822337. This makes it again necessary to migrate you radius
credentials from /etc/radiusclient/servers to /etc/radcli/servers credentials from /etc/radiusclient/servers to /etc/radcli/servers
in case you are using check_radius. in case you are using check_radius.
Please install the new dependencies in this case if you don't install Please install the new dependencies in this case if you don't install

226
debian/changelog vendored
View file

@ -1,231 +1,9 @@
monitoring-plugins (2.4.0-6) UNRELEASED; urgency=medium monitoring-plugins (2.3.2-2) UNRELEASED; urgency=medium
*
-- Jan Wagner <waja@cyconet.org> Wed, 03 Dec 2025 07:15:41 +0100
monitoring-plugins (2.4.0-5) unstable; urgency=medium
[ Jan Wagner ]
* [2bd6e61] d/control: Drop libsystemd0 from build-deps, pulled by
libsystemd-dev
* [dfe02ab] Adding d/p/27_check_mysql_fix_replica, Fixes reported regression
for MariaDB 10.11.14-0+deb12u2 (Closes: #1116027)
* [9a01042] Raising alternative of check_curl over check_http. check_curl is
prefered
* [20257df] d/control: Remove deprecated check_ntp
[ Bas Couwenberg ]
* [52d9fc3] Use test-build-validate-cleanup instead of test-build-twice.
* [f047b05] Use debrebuild instead of reprotest.
* [861c613] Don't use test-build-validate-cleanup, fails where pbuilder
--twice succeeds.
-- Jan Wagner <waja@cyconet.org> Tue, 02 Dec 2025 14:06:48 +0000
monitoring-plugins (2.4.0-4) unstable; urgency=medium
[ Jan Wagner ]
* [bee01b8] d/control: Remove Alexander Wirt from Uploaders
* [7236330] d/control: Adding libsystemd-dev and libsystemd0 as build-dep
(Closes: #1110265)
* [8cd52e3] Adding d/patches/25_check_users_sd_get_uids to fix user count
[ Bas Couwenberg ]
* [4770fe3] Update lintian overrides.
* [294841c] Drop Priority: optional, default since dpkg 1.22.13.
* [97009f5] Revert "Drop Priority: optional, default since dpkg 1.22.13."
[ Jan Wagner ]
* [3f438f9] Adding d/p/26_check_mysql_replica from upstream (Closes: #1116027)
-- Jan Wagner <waja@cyconet.org> Mon, 06 Oct 2025 11:29:35 +0200
monitoring-plugins (2.4.0-3) unstable; urgency=medium
* Upload to unstable
-- Jan Wagner <waja@cyconet.org> Tue, 22 Apr 2025 16:25:21 +0200
monitoring-plugins (2.4.0-3~exp1) experimental; urgency=medium
* [7e8c776] Adding d/p/24_check_http_deprecation from upstream
* [baad659] Add d/monitoring-plugins-basic.alternatives
* [6bb8580] Adjust debian/rules for check_http rename
* [ddaa81f] check_curl: move to monitoring-plugins-basic package
* [b724e41] d/NEWS: Add information about check_http deprecation
-- Jan Wagner <waja@cyconet.org> Mon, 21 Apr 2025 16:29:02 +0200
monitoring-plugins (2.4.0-2) unstable; urgency=medium
[ Bas Couwenberg ]
* [2d414bd] Bump Standards-Version to 4.7.0, no changes.
[ Jan Wagner ]
* [672d37c] Adding d/p/10_check_curl_fix_redirects from upstream
* [15760ad] Adding d/p/11_check_curl_raise_ssl_issue from upstream
* [a6b1db0] Adding d/p/12_check_curl_add_docu from upstream
* [8b17915] Adding d/p/13_check_mysql_fix_variables from upstream
* [01e11f9] Adding d/p/14_check_curl_remove_experimental_state from upstream
* [1b018b3] Adding d/p/15_check_curl_fix_regex from upstream
* [9c49b6f] Adding d/p/16_check_curl_openssl_error from upstream
* [f3e1279] Adding d/p/17_check_fping_dontfrag_random from upstream
[ Bas Couwenberg ]
* [3c5882d] Add check_curl to monitoring-plugins-standard description.
[ Jan Wagner ]
* [043d328] Adding d/p/18_check_curl_fix_TLS_notes from upstream
* [bf60013] Adding d/p/19_check_curl_cookie_handling from upstream
[ Bas Couwenberg ]
* [9cb7fae] Bump Standards-Version to 4.7.2, no changes.
* [af69fcf] Fix old FSF address in copyright file.
[ Jan Wagner ]
* [38aec8e] Adding d/p/20_check_icmp_fix_rtmin from upstream
* [e817fec] Adding d/p/21_check_http_state_regex from upstream
* [45f91e2] Adding d/p/22_check_by_ssh_missing_options from upstream
* [b6a58eb] Adding d/p/23_sslutils_fix_error_message from upstream
* [3a5f250] debian/NEWS: Fix spelling error
* [55f87b7] Changing check_httpname to the intended check_http_hostname
definition (Closes: #1099028)
* [2f5d025] Adding d/p/04_lmstat_path (Closes: #1053687)
-- Jan Wagner <waja@cyconet.org> Sun, 20 Apr 2025 21:09:27 +0200
monitoring-plugins (2.4.0-1) unstable; urgency=medium
* [600e193] New upstream version 2.4.0
(Closes: #928752)
-- Jan Wagner <waja@cyconet.org> Tue, 23 Jul 2024 20:28:15 +0000
monitoring-plugins (2.3.5-1) unstable; urgency=medium
[ Jan Wagner ]
* [a20810f] Adding d/p/36_check_smtp_adding_proxy_header from upstream
* [0250eb9] Adding d/p/37_check_smtp_Adding_SNI from upstream
* [1381a20] Remove left over d/p/31_checl_mailq_separate_submission_queue
[ Bas Couwenberg ]
* [7c86d65] Explicitly enable test-build-twice job.
[ Jan Wagner ]
* [de72f6f] New upstream version 2.3.4
* [5956793] New upstream version 2.3.5
* [f07f4db] Drop patches integrated by upstream
-- Jan Wagner <waja@cyconet.org> Wed, 18 Oct 2023 12:04:05 +0200
monitoring-plugins (2.3.3-6) unstable; urgency=medium
* [e1f9786] Adding d/p/14_check_curl_fix_SSL_with_multiple_IPs from upstream
* [534d0c8] Adding d/p/30_check_radius_radcli_1.3.1_support from upstream
* [bd72df2] Adding d/p/31_checl_mailq_separate_submission_queue from upstream
* [567890c] Adding d/p/32_check_disk_add_ignore_missing from upstream
(Closes: #516097)
* [47b7589] Adding d/p/15_check_swap_remove_includes from upstream
* [6f89be8] Adding d/p/33_check_procs_exclude-process from upstream
* [983507a] Adding d/p/34_check_curl_fix_compare_warning from upstream
* [9225592] Adding d/p/17_fix_exit_codes from upstream
* [3a0d875] Adding d/p/18_check_mysql_fix_typo from upstream
* [17688c7] Adding d/p/19_check_nwstat_fix_typo from upstream
* [e0cfe77] Adding d/p/20_chech_nt_fix_encoding from upstream
* [3da2163] Adding d/p/21_check_pgsql_extra_output from upstream
* [7cbe4b6] Adding d/p/22_check_disk_avoid_mount from upstream
* [01be8ce] d/p/series: Fix typo
* [85d9e03] Adding d/p/23_check_mysql_fix_error_handling from upstream
* [555d643] CI: Disable BLHC job
* [85a271e] Adding d/p/24_check_disk_fix_SI_units from upstream
* [02c716f] d/p/31_check_mailq_separate_submission_queue: Fix filename
-- Jan Wagner <waja@cyconet.org> Mon, 12 Jun 2023 21:46:29 +0200
monitoring-plugins (2.3.3-5) unstable; urgency=medium
* [6fb8e25] Adding d/p/14_check_curl_fix_SSL_with_multiple_IPs from upstream
* [eab1e1d] Adding d/p/15_check_swap_remove_includes from upstream
* [3ede347] Adding d/p/16_check_snmp_disable_multiplier_when_unused from upstream
-- Jan Wagner <waja@cyconet.org> Thu, 30 Mar 2023 08:51:53 +0000
monitoring-plugins (2.3.3-4) unstable; urgency=medium
* [953ee52] Adding d/p/13_check_icmp_improvements from upstream
-- Jan Wagner <waja@cyconet.org> Tue, 07 Mar 2023 13:29:35 +0000
monitoring-plugins (2.3.3-3) unstable; urgency=medium
* [15d0c56] Adding d/p/12_check_curl_improvements from upstream
-- Jan Wagner <waja@cyconet.org> Fri, 24 Feb 2023 12:55:11 +0000
monitoring-plugins (2.3.3-2) unstable; urgency=high
* [01c9312] Adding d/p/10_check_http_chunked_wo_actual_content from upstream
* [c1f3ca7] Adding d/p/11_fallback_for_gnutls from upstream
-- Jan Wagner <waja@cyconet.org> Fri, 10 Feb 2023 10:16:38 +0000
monitoring-plugins (2.3.3-1) unstable; urgency=medium
* [e7bdd1c] New upstream version 2.3.3
* [c31ba97] Drop patches applied upstream
-- Jan Wagner <waja@cyconet.org> Thu, 02 Feb 2023 09:36:44 +0000
monitoring-plugins (2.3.2-3) unstable; urgency=high
* [62a3be0] Adding d/p/31_check_http_fix_memory_alloc_error_chunk_decod from
upstream (Closes: #1029934)
-- Jan Wagner <waja@cyconet.org> Tue, 31 Jan 2023 13:13:58 +0000
monitoring-plugins (2.3.2-2) unstable; urgency=medium
[ Bas Couwenberg ] [ Bas Couwenberg ]
* [32fba01] Bump Standards-Version to 4.6.1, no changes. * [32fba01] Bump Standards-Version to 4.6.1, no changes.
[ Jan Wagner ] -- Jan Wagner <waja@cyconet.org> Tue, 01 Nov 2022 20:20:32 +0000
* [5a11a70] Adding upstream patches fixing (u)int64_t on 32-bit machines
(Closes: #1023280)
* [2a90f45] Adding github actions
* [7d0e34a] Use testing, since unstable has large transition ongoing
* [0543e43] only removing github stuff
* [1e0e230] Adding d/patches/16_check_pgsql_dbname_too_strict
(Closes: ##982847)
* [b61a8ea] Update d/patch/13_check_http_fix_superflous_crlf
* [73bd381] Adding d/p/17_check_curl_detect_ipv6
[ Bas Couwenberg ]
* [d6b03fd] Add Rules-Requires-Root to control file.
[ Jan Wagner ]
* [08ddb1e] d/control: Drop 'pkg-' from Vcs-Headers
* [76475e9] Adding d/p/18_check_icmp_help from upstream
* [f625b1e] Adding d/p/19_check_disk_fs_usage from upstream
* [f9e79de] Adding d/p/20_check_apt_unknown_escape_sequence
* [f95110e] Adding d/p/21_check_http_faster_with_large_files from upstream
* [d4c9e0b] Adding d/p/22_check_curl_faster_with_large_files from upstream
* [c662b29] Adding gitlab CI
* [95eeed8] Adding d/p/24_check_apt_usage from upstream
* [298c20a] Bump debhelper from old 12 to 13.
* [ab165de] Update standards version to 4.6.2, no changes needed.
* [f064e9b] Adding d/p/23_check_http_chunked_encoding from upstream
* [f503139] d/README.Debian: Fix typo
* [ccc552b] Adding d/p/25_spell_fixes from upstream
* [405406d] d/rules: Set DH_VERBOSE=1
* [ff160b6] Adding d/p/26_check_mailq_fix_nullmailer_regex from upstream
(Closes: #1019406)
* [e99bd7b] Adding d/p/27_check_snmp_add_multiplier
* [73742e9] Adding d/p/28_check_snmp_fix_regex_matches from upstream
* [4f70a9d] Adding d/p/29_check_log_polish from upstream
* [4f7eea1] Adding d/p/30_check_disk_clarify_usage_possibilites from upstream
-- Jan Wagner <waja@cyconet.org> Mon, 23 Jan 2023 14:40:09 +0000
monitoring-plugins (2.3.2-1) unstable; urgency=medium monitoring-plugins (2.3.2-1) unstable; urgency=medium

27
debian/control vendored
View file

@ -2,7 +2,7 @@ Source: monitoring-plugins
Section: net Section: net
Priority: optional Priority: optional
Maintainer: Debian Nagios Maintainer Group <pkg-nagios-devel@lists.alioth.debian.org> Maintainer: Debian Nagios Maintainer Group <pkg-nagios-devel@lists.alioth.debian.org>
Uploaders: Jan Wagner <waja@cyconet.org> Uploaders: Jan Wagner <waja@cyconet.org>, Alexander Wirt <formorer@debian.org>
Build-Depends: debhelper-compat (= 13), Build-Depends: debhelper-compat (= 13),
libcurl4-openssl-dev | libcurl4-nss-dev | libcurl4-gnutls-dev, libcurl4-openssl-dev | libcurl4-nss-dev | libcurl4-gnutls-dev,
libdbi-dev, libdbi-dev,
@ -13,12 +13,11 @@ Build-Depends: debhelper-compat (= 13),
libnet-snmp-perl, libnet-snmp-perl,
libpq-dev, libpq-dev,
libssl-dev, libssl-dev,
libsystemd-dev,
liburiparser-dev, liburiparser-dev,
mawk | awk, mawk | awk,
perl, perl,
procps procps
Standards-Version: 4.7.2 Standards-Version: 4.6.2
Vcs-Browser: https://salsa.debian.org/nagios-team/monitoring-plugins Vcs-Browser: https://salsa.debian.org/nagios-team/monitoring-plugins
Vcs-Git: https://salsa.debian.org/nagios-team/monitoring-plugins.git Vcs-Git: https://salsa.debian.org/nagios-team/monitoring-plugins.git
Homepage: https://www.monitoring-plugins.org Homepage: https://www.monitoring-plugins.org
@ -59,24 +58,22 @@ Depends: inetutils-ping [kfreebsd-any hurd-any],
${shlibs:Depends} ${shlibs:Depends}
Recommends: libcap2-bin [linux-any] Recommends: libcap2-bin [linux-any]
Suggests: icinga2 Suggests: icinga2
Breaks: monitoring-plugins-standard (<< 2.4.0-3~)
Replaces: monitoring-plugins-standard (<< 2.4.0-3~)
Provides: nagios-plugins-basic Provides: nagios-plugins-basic
Description: Plugins for nagios compatible monitoring systems (basic) Description: Plugins for nagios compatible monitoring systems (basic)
Plugins for nagios compatible monitoring systems like Naemon and Icinga. It Plugins for nagios compatible monitoring systems like Naemon and Icinga. It
contains the following plugins: contains the following plugins:
. .
check_apt, check_by_ssh, check_clamd, check_cluster, check_apt, check_by_ssh, check_clamd, check_cluster,
check_curl, check_dhcp, check_disk, check_dummy, check_dhcp, check_disk, check_dummy, check_file_age,
check_file_age, check_ftp, check_host, check_http, check_ftp, check_host, check_http, check_icmp,
check_icmp, check_ide_smart, check_imap, check_ircd, check_ide_smart, check_imap, check_ircd, check_jabber,
check_jabber, check_load, check_log, check_mrtg, check_load, check_log, check_mrtg, check_mrtgtraf,
check_mrtgtraf, check_nagios, check_nntp, check_nntps, check_nagios, check_nntp, check_nntps, check_nt,
check_nt, check_ntp, check_ntp_peer, check_ntp_time, check_ntp, check_ntp_peer, check_ntp_time, check_nwstat,
check_nwstat, check_overcr, check_ping, check_pop, check_overcr, check_ping, check_pop, check_procs,
check_procs, check_real, check_rta_multi, check_sensors, check_real, check_rta_multi, check_sensors, check_simap,
check_simap, check_smtp, check_spop, check_ssh, check_smtp, check_spop, check_ssh, check_ssmtp,
check_ssmtp, check_swap, check_tcp, check_time, check_udp, check_swap, check_tcp, check_time, check_udp,
check_ups, check_users check_ups, check_users
. .
This package provides a basic set of plugins with minimal external This package provides a basic set of plugins with minimal external

9
debian/copyright vendored
View file

@ -82,7 +82,9 @@ Files with different Licenses:
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, see <https://www.gnu.org/licenses/>. along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA.
gl/alloca.in.h gl/alloca.in.h
gl/as* gl/as*
@ -151,8 +153,9 @@ Files with different Licenses:
General Public License for more details. General Public License for more details.
You should have received a copy of the GNU General Public You should have received a copy of the GNU General Public
License along with this program; if not, see License along with this program; if not, write to the Free Software
<https://www.gnu.org/licenses/>. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA.
gl/reg* gl/reg*
gl/mktime.c gl/mktime.c

View file

@ -1,12 +0,0 @@
Name: check_http
Link: /usr/lib/nagios/plugins/check_http
Status: auto
Best: /usr/lib/nagios/plugins/check_http.deprecated
Value: /usr/lib/nagios/plugins/check_http.deprecated
Alternative: /usr/lib/nagios/plugins/check_http.deprecated
Priority: 50
Name: check_http
Link: /usr/lib/nagios/plugins/check_http
Alternative: /usr/lib/nagios/plugins/check_curl
Priority: 100

View file

@ -1,11 +0,0 @@
--- a/plugins-scripts/utils.pm.in
+++ b/plugins-scripts/utils.pm.in
@@ -19,7 +19,7 @@
## updated by autoconf
$PATH_TO_SUDO = "@PATH_TO_SUDO@";
$PATH_TO_RPCINFO = "@PATH_TO_RPCINFO@" ;
-$PATH_TO_LMSTAT = "@PATH_TO_LMSTAT@" ;
+$PATH_TO_LMSTAT = "/usr/local/bin/lmstat" ;
$PATH_TO_SMBCLIENT = "@PATH_TO_SMBCLIENT@" ;
$PATH_TO_MAILQ = "@PATH_TO_MAILQ@";
$PATH_TO_QMAIL_QSTAT = "@PATH_TO_QMAIL_QSTAT@";

View file

@ -1,164 +0,0 @@
From 17549189ae6864203a48a2b2488db35a9e020e0e Mon Sep 17 00:00:00 2001
From: Sven Nierlein <sven@consol.de>
Date: Mon, 29 Jul 2024 20:53:32 +0200
Subject: [PATCH] check_curl: fix relative redirects on non-standard port
Having a webserver respond with a relative redirect as for ex. in `Location: /path/to.html`
check_curl would use the wrong standard http/https port instead
of crafting the absolute url using the given scheme/hostname and port.
Adding a new test case for this for check_http and check_curl. check_http did
it correct already, so no fix necessary there.
before:
%>./check_curl -H 127.0.0.1 -p 50493 -f follow -u /redirect_rel -s redirected -vvv
**** HEADER ****
HTTP/1.1 302 Found
...
Location: /redirect2
...
* Seen redirect location /redirect2
** scheme: (null)
** host: (null)
** port: (null)
** path: /redirect2
Redirection to http://127.0.0.1:80/redirect2
fixed:
%>./check_curl -H 127.0.0.1 -p 50493 -f follow -u /redirect_rel -s redirected -vvv
**** HEADER ****
HTTP/1.1 302 Found
...
Location: /redirect2
...
* Seen redirect location /redirect2
** scheme: (null)
** host: (null)
** port: (null)
** path: /redirect2
Redirection to http://127.0.0.1:50493/redirect2
Signed-off-by: Sven Nierlein <sven@nierlein.de>
---
plugins/check_curl.c | 15 ++++++++++-----
plugins/tests/check_curl.t | 14 +++++++++++---
plugins/tests/check_http.t | 12 +++++++++++-
3 files changed, 32 insertions(+), 9 deletions(-)
diff --git a/plugins/check_curl.c b/plugins/check_curl.c
index c54be5e4f..01e2770e3 100644
--- a/plugins/check_curl.c
+++ b/plugins/check_curl.c
@@ -1285,10 +1285,12 @@ redir (curlhelp_write_curlbuf* header_buf)
}
}
- if (!uri_strcmp (uri.scheme, "https"))
- use_ssl = true;
- else
- use_ssl = false;
+ if (uri.scheme.first) {
+ if (!uri_strcmp (uri.scheme, "https"))
+ use_ssl = true;
+ else
+ use_ssl = false;
+ }
/* we do a sloppy test here only, because uriparser would have failed
* above, if the port would be invalid, we just check for MAX_PORT
@@ -1306,10 +1308,13 @@ redir (curlhelp_write_curlbuf* header_buf)
MAX_PORT, location, display_html ? "</A>" : "");
/* by RFC 7231 relative URLs in Location should be taken relative to
- * the original URL, so wy try to form a new absolute URL here
+ * the original URL, so we try to form a new absolute URL here
*/
if (!uri.scheme.first && !uri.hostText.first) {
new_host = strdup (host_name ? host_name : server_address);
+ new_port = server_port;
+ if(use_ssl)
+ uri_string (uri.scheme, "https", DEFAULT_BUFFER_SIZE);
} else {
new_host = strdup (uri_string (uri.hostText, buf, DEFAULT_BUFFER_SIZE));
}
diff --git a/plugins/tests/check_curl.t b/plugins/tests/check_curl.t
index 3c9148308..eaa9f5183 100755
--- a/plugins/tests/check_curl.t
+++ b/plugins/tests/check_curl.t
@@ -21,7 +21,7 @@ use FindBin qw($Bin);
$ENV{'LC_TIME'} = "C";
-my $common_tests = 73;
+my $common_tests = 75;
my $ssl_only_tests = 8;
# Check that all dependent modules are available
eval "use HTTP::Daemon 6.01;";
@@ -178,6 +178,11 @@ sub run_server {
$c->send_basic_header;
$c->send_crlf;
$c->send_response(HTTP::Response->new( 200, 'OK', undef, 'redirected' ));
+ } elsif ($r->url->path eq "/redirect_rel") {
+ $c->send_basic_header(302);
+ $c->send_header("Location", "/redirect2" );
+ $c->send_crlf;
+ $c->send_response('moved to /redirect2');
} elsif ($r->url->path eq "/redir_timeout") {
$c->send_redirect( "/timeout" );
} elsif ($r->url->path eq "/timeout") {
@@ -471,9 +476,12 @@ sub run_common_tests {
is( $result->return_code, 0, $cmd);
like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output );
- # These tests may block
- print "ALRM\n";
+ $cmd = "$command -f follow -u /redirect_rel -s redirected";
+ $result = NPTest->testCmd( $cmd );
+ is( $result->return_code, 0, $cmd);
+ like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output );
+ # These tests may block
# stickyport - on full urlS port is set back to 80 otherwise
$cmd = "$command -f stickyport -u /redir_external -t 5 -s redirected";
eval {
diff --git a/plugins/tests/check_http.t b/plugins/tests/check_http.t
index 6078b2745..6eaf85b29 100755
--- a/plugins/tests/check_http.t
+++ b/plugins/tests/check_http.t
@@ -13,7 +13,7 @@ use IO::Socket::INET;
$ENV{'LC_TIME'} = "C";
-my $common_tests = 71;
+my $common_tests = 73;
my $virtual_port_tests = 8;
my $ssl_only_tests = 12;
my $chunked_encoding_special_tests = 1;
@@ -199,6 +199,11 @@ sub run_server {
$c->send_basic_header;
$c->send_crlf;
$c->send_response(HTTP::Response->new( 200, 'OK', undef, 'redirected' ));
+ } elsif ($r->url->path eq "/redirect_rel") {
+ $c->send_basic_header(302);
+ $c->send_header("Location", "/redirect2" );
+ $c->send_crlf;
+ $c->send_response('moved to /redirect2');
} elsif ($r->url->path eq "/redir_timeout") {
$c->send_redirect( "/timeout" );
} elsif ($r->url->path eq "/timeout") {
@@ -515,6 +520,11 @@ sub run_common_tests {
is( $result->return_code, 0, $cmd);
like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output );
+ $cmd = "$command -f follow -u /redirect_rel -s redirected";
+ $result = NPTest->testCmd( $cmd );
+ is( $result->return_code, 0, $cmd);
+ like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output );
+
# These tests may block
print "ALRM\n";

View file

@ -1,87 +0,0 @@
From ca40cf81fb94cf57a82df938ed2aa2843691be3a Mon Sep 17 00:00:00 2001
From: Yannick Martin <yannick.martin@ovhcloud.com>
Date: Fri, 9 Aug 2024 12:14:28 +0200
Subject: [PATCH] check_curl: raise SSL issue when --continue-after-certificate
is used
This change aims to raise the worst status between the SSL check and the HTTP check.
before:
check_curl -H www.google.fr -S --continue-after-certificate --certificate 4000,4000 ; echo $?
CRITICAL - Certificate '*.google.fr' expires in 74 day(s) (Tue 22 Oct 2024 12:53:52 PM GMT +0000).
HTTP OK: HTTP/2 200 - 22807 bytes in 0.076 second response time |time=0.075516s;;;0.000000;10.000000 size=22807B;;;0;
0
after:
/usr/lib/nagios/ovh/check_curl -H www.google.fr -S --continue-after-certificate --certificate 4000,4000 ; echo $?
CRITICAL - Certificate '*.google.fr' expires in 74 day(s) (Tue 22 Oct 2024 12:53:52 PM GMT +0000).
HTTP OK: HTTP/2 200 - 22840 bytes in 0.090 second response time |time=0.090463s;;;0.000000;10.000000 size=22840B;;;0;
2
---
plugins/check_curl.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/plugins/check_curl.c b/plugins/check_curl.c
index 01e2770e3..4522e6c9f 100644
--- a/plugins/check_curl.c
+++ b/plugins/check_curl.c
@@ -468,6 +468,7 @@ int
check_http (void)
{
int result = STATE_OK;
+ int result_ssl = STATE_OK;
int page_len = 0;
int i;
char *force_host_header = NULL;
@@ -852,9 +853,9 @@ check_http (void)
/* check certificate with OpenSSL functions, curl has been built against OpenSSL
* and we actually have OpenSSL in the monitoring tools
*/
- result = np_net_ssl_check_certificate(cert, days_till_exp_warn, days_till_exp_crit);
+ result_ssl = np_net_ssl_check_certificate(cert, days_till_exp_warn, days_till_exp_crit);
if (!continue_after_check_cert) {
- return result;
+ return result_ssl;
}
#else /* USE_OPENSSL */
die (STATE_CRITICAL, "HTTP CRITICAL - Cannot retrieve certificates - OpenSSL callback used and not linked against OpenSSL\n");
@@ -898,17 +899,17 @@ check_http (void)
die (STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg);
}
BIO_free (cert_BIO);
- result = np_net_ssl_check_certificate(cert, days_till_exp_warn, days_till_exp_crit);
+ result_ssl = np_net_ssl_check_certificate(cert, days_till_exp_warn, days_till_exp_crit);
if (!continue_after_check_cert) {
- return result;
+ return result_ssl;
}
#else /* USE_OPENSSL */
/* We assume we don't have OpenSSL and np_net_ssl_check_certificate at our disposal,
* so we use the libcurl CURLINFO data
*/
- result = net_noopenssl_check_certificate(&cert_ptr, days_till_exp_warn, days_till_exp_crit);
+ result_ssl = net_noopenssl_check_certificate(&cert_ptr, days_till_exp_warn, days_till_exp_crit);
if (!continue_after_check_cert) {
- return result;
+ return result_ssl;
}
#endif /* USE_OPENSSL */
} else {
@@ -1176,7 +1177,7 @@ check_http (void)
}
/* TODO: separate _() msg and status code: die (result, "HTTP %s: %s\n", state_text(result), msg); */
- die (result, "HTTP %s: %s %d %s%s%s - %d bytes in %.3f second response time %s|%s\n%s%s",
+ die (max_state_alt(result, result_ssl), "HTTP %s: %s %d %s%s%s - %d bytes in %.3f second response time %s|%s\n%s%s",
state_text(result), string_statuscode (status_line.http_major, status_line.http_minor),
status_line.http_code, status_line.msg,
strlen(msg) > 0 ? " - " : "",
@@ -1186,7 +1187,7 @@ check_http (void)
(show_body ? body_buf.buf : ""),
(show_body ? "\n" : "") );
- return result;
+ return max_state_alt(result, result_ssl);
}
int

View file

@ -1,42 +0,0 @@
From 9cdf2aec7fa3277237c078fc9da32f40d0292299 Mon Sep 17 00:00:00 2001
From: Alvar Penning <alvar.penning@icinga.com>
Date: Fri, 16 Aug 2024 10:38:02 +0200
Subject: [PATCH] check_curl: Documentation for --certificate, --cookie-jar
From the mere help output for -C / --certificate, I was confused about
what its two integer parameters do. Unfortunately, I also missed out on
the explaining examples later. Since I like to have basic documentation
for each flag, I tried to make the arguments as short as possible.
The other fix was one hyphen too many for the --cookie-jar option.
---
plugins/check_curl.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/plugins/check_curl.c b/plugins/check_curl.c
index 4522e6c9f..e9c15e648 100644
--- a/plugins/check_curl.c
+++ b/plugins/check_curl.c
@@ -2008,8 +2008,11 @@ print_help (void)
printf (" %s\n", _("Note: SNI is not supported in libcurl before 7.18.1"));
#endif
printf (" %s\n", "-C, --certificate=INTEGER[,INTEGER]");
- printf (" %s\n", _("Minimum number of days a certificate has to be valid. Port defaults to 443"));
- printf (" %s\n", _("(when this option is used the URL is not checked by default. You can use"));
+ printf (" %s\n", _("Minimum number of days a certificate has to be valid. Port defaults to 443."));
+ printf (" %s\n", _("A STATE_WARNING is returned if the certificate has a validity less than the"));
+ printf (" %s\n", _("first agument's value. If there is a second argument and the certificate's"));
+ printf (" %s\n", _("validity is less than its value, a STATE_CRITICAL is returned."));
+ printf (" %s\n", _("(When this option is used the URL is not checked by default. You can use"));
printf (" %s\n", _(" --continue-after-certificate to override this behavior)"));
printf (" %s\n", "--continue-after-certificate");
printf (" %s\n", _("Allows the HTTP check to continue after performing the certificate check."));
@@ -2092,7 +2095,7 @@ print_help (void)
printf (" %s\n", _("Enable automatic decompression of body (CURLOPT_ACCEPT_ENCODING)."));
printf(" %s\n", "--haproxy-protocol");
printf(" %s\n", _("Send HAProxy proxy protocol v1 header (CURLOPT_HAPROXYPROTOCOL)."));
- printf (" %s\n", "---cookie-jar=FILE");
+ printf (" %s\n", "--cookie-jar=FILE");
printf (" %s\n", _("Store cookies in the cookie jar and send them out when requested."));
printf ("\n");

View file

@ -0,0 +1,66 @@
From f089d660902b726072f4e2fe619d8647d23914d3 Mon Sep 17 00:00:00 2001
From: rincewind <rincewind@vulgrim.de>
Date: Tue, 20 Apr 2021 12:15:27 +0200
Subject: [PATCH 1/2] Remove superflous CRLF in HTTP-Requests in check_http
---
plugins/check_http.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/plugins/check_http.c b/plugins/check_http.c
index ff39c5912..a606cbed0 100644
--- a/plugins/check_http.c
+++ b/plugins/check_http.c
@@ -966,8 +966,7 @@ check_http (void)
}
asprintf (&buf, "%sProxy-Connection: keep-alive\r\n", buf);
asprintf (&buf, "%sHost: %s\r\n", buf, host_name);
- /* we finished our request, send empty line with CRLF */
- asprintf (&buf, "%s%s", buf, CRLF);
+
if (verbose) printf ("%s\n", buf);
send(sd, buf, strlen (buf), 0);
buf[0]='\0';
@@ -1070,7 +1069,7 @@ check_http (void)
}
xasprintf (&buf, "%sContent-Length: %i\r\n\r\n", buf, (int)strlen (http_post_data));
- xasprintf (&buf, "%s%s%s", buf, http_post_data, CRLF);
+ xasprintf (&buf, "%s%s", buf, http_post_data);
}
else {
/* or just a newline so the server knows we're done with the request */
From 0ac75e22bb729ca3adcc355aba8d451ce3a41c4e Mon Sep 17 00:00:00 2001
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
Date: Fri, 4 Nov 2022 12:41:08 +0100
Subject: [PATCH 2/2] Readd some end of lines
---
plugins/check_http.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/plugins/check_http.c b/plugins/check_http.c
index a606cbed0..41d478163 100644
--- a/plugins/check_http.c
+++ b/plugins/check_http.c
@@ -966,7 +966,8 @@ check_http (void)
}
asprintf (&buf, "%sProxy-Connection: keep-alive\r\n", buf);
asprintf (&buf, "%sHost: %s\r\n", buf, host_name);
-
+ /* we finished our request, send empty line with CRLF */
+ asprintf (&buf, "%s%s", buf, CRLF);
if (verbose) printf ("%s\n", buf);
send(sd, buf, strlen (buf), 0);
buf[0]='\0';
@@ -1070,8 +1071,7 @@ check_http (void)
xasprintf (&buf, "%sContent-Length: %i\r\n\r\n", buf, (int)strlen (http_post_data));
xasprintf (&buf, "%s%s", buf, http_post_data);
- }
- else {
+ } else {
/* or just a newline so the server knows we're done with the request */
xasprintf (&buf, "%s%s", buf, CRLF);
}

View file

@ -1,28 +0,0 @@
diff --git a/plugins/check_mysql.c b/plugins/check_mysql.c
index 6a7daf11a..15ec04c04 100644
--- a/plugins/check_mysql.c
+++ b/plugins/check_mysql.c
@@ -59,8 +59,8 @@ bool ssl = false;
char *opt_file = NULL;
char *opt_group = NULL;
unsigned int db_port = MYSQL_PORT;
-int check_slave = 0, warn_sec = 0, crit_sec = 0;
-int ignore_auth = 0;
+bool check_slave = false;
+bool ignore_auth = false;
int verbose = 0;
static double warning_time = 0;
@@ -456,10 +456,10 @@ process_arguments (int argc, char **argv)
db_port = atoi (optarg);
break;
case 'S':
- check_slave = 1; /* check-slave */
+ check_slave = true; /* check-slave */
break;
case 'n':
- ignore_auth = 1; /* ignore-auth */
+ ignore_auth = true; /* ignore-auth */
break;
case 'w':
warning = optarg;

81
debian/patches/14_PRId64_PRIu64_1 vendored Normal file
View file

@ -0,0 +1,81 @@
From 817ac2e5dad1ce5d0e0ea96fa7f726566251b08d Mon Sep 17 00:00:00 2001
From: Andreas Baumann <202930+andreasbaumann@users.noreply.github.com>
Date: Fri, 21 Oct 2022 18:31:12 +0200
Subject: [PATCH] using PRId64 and PRIu64 instead of %ld directly (#1800)
---
plugins/utils.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/plugins/utils.c b/plugins/utils.c
index 17dd58146..f75cf03b7 100644
--- a/plugins/utils.c
+++ b/plugins/utils.c
@@ -615,27 +615,27 @@ char *perfdata_uint64 (const char *label,
char *data = NULL;
if (strpbrk (label, "'= "))
- xasprintf (&data, "'%s'=%ld%s;", label, val, uom);
+ xasprintf (&data, "'%s'=%" PRId64 "%s;", label, val, uom);
else
- xasprintf (&data, "%s=%ld%s;", label, val, uom);
+ xasprintf (&data, "%s=%" PRId64 "%s;", label, val, uom);
if (warnp)
- xasprintf (&data, "%s%lu;", data, warn);
+ xasprintf (&data, "%s%" PRIu64 ";", data, warn);
else
xasprintf (&data, "%s;", data);
if (critp)
- xasprintf (&data, "%s%lu;", data, crit);
+ xasprintf (&data, "%s%" PRIu64 ";", data, crit);
else
xasprintf (&data, "%s;", data);
if (minp)
- xasprintf (&data, "%s%lu;", data, minv);
+ xasprintf (&data, "%s%" PRIu64 ";", data, minv);
else
xasprintf (&data, "%s;", data);
if (maxp)
- xasprintf (&data, "%s%lu", data, maxv);
+ xasprintf (&data, "%s%" PRIu64, data, maxv);
return data;
}
@@ -656,27 +656,27 @@ char *perfdata_int64 (const char *label,
char *data = NULL;
if (strpbrk (label, "'= "))
- xasprintf (&data, "'%s'=%ld%s;", label, val, uom);
+ xasprintf (&data, "'%s'=%" PRId64 "%s;", label, val, uom);
else
- xasprintf (&data, "%s=%ld%s;", label, val, uom);
+ xasprintf (&data, "%s=%" PRId64 "%s;", label, val, uom);
if (warnp)
- xasprintf (&data, "%s%ld;", data, warn);
+ xasprintf (&data, "%s%" PRId64 ";", data, warn);
else
xasprintf (&data, "%s;", data);
if (critp)
- xasprintf (&data, "%s%ld;", data, crit);
+ xasprintf (&data, "%s%" PRId64 ";", data, crit);
else
xasprintf (&data, "%s;", data);
if (minp)
- xasprintf (&data, "%s%ld;", data, minv);
+ xasprintf (&data, "%s%" PRId64 ";", data, minv);
else
xasprintf (&data, "%s;", data);
if (maxp)
- xasprintf (&data, "%s%ld", data, maxv);
+ xasprintf (&data, "%s%" PRId64, data, maxv);
return data;
}

View file

@ -1,13 +0,0 @@
diff --git a/plugins/check_curl.c b/plugins/check_curl.c
index e9c15e648..e25d7a79a 100644
--- a/plugins/check_curl.c
+++ b/plugins/check_curl.c
@@ -2190,8 +2190,6 @@ print_usage (void)
printf ("%s\n", _("In the first form, make an HTTP request."));
printf ("%s\n\n", _("In the second form, connect to the server and check the TLS certificate."));
#endif
- printf ("%s\n", _("WARNING: check_curl is experimental. Please use"));
- printf ("%s\n\n", _("check_http if you need a stable version."));
}
void

25
debian/patches/15_PRId64_PRIu64_2 vendored Normal file
View file

@ -0,0 +1,25 @@
From eb2dfdd5c24b87198b66397b224d6406c468a0bc Mon Sep 17 00:00:00 2001
From: Andreas Baumann <202930+andreasbaumann@users.noreply.github.com>
Date: Thu, 27 Oct 2022 22:48:18 +0200
Subject: [PATCH] fixed two PRId64 to PRIu64 in perfdata_uint64 (#1802)
---
plugins/utils.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/plugins/utils.c b/plugins/utils.c
index f75cf03b..b4214c61 100644
--- a/plugins/utils.c
+++ b/plugins/utils.c
@@ -615,9 +615,9 @@ char *perfdata_uint64 (const char *label,
char *data = NULL;
if (strpbrk (label, "'= "))
- xasprintf (&data, "'%s'=%" PRId64 "%s;", label, val, uom);
+ xasprintf (&data, "'%s'=%" PRIu64 "%s;", label, val, uom);
else
- xasprintf (&data, "%s=%" PRId64 "%s;", label, val, uom);
+ xasprintf (&data, "%s=%" PRIu64 "%s;", label, val, uom);
if (warnp)
xasprintf (&data, "%s%" PRIu64 ";", data, warn);

View file

@ -1,82 +0,0 @@
From 46efe803cf8e7b769ca112afc158b76510b01e46 Mon Sep 17 00:00:00 2001
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
Date: Mon, 19 Aug 2024 15:23:41 +0200
Subject: [PATCH 1/3] check_curl: Fix help for state regex option
The help output of `check-curl` contained a typo,
the real option is `state-regex` and not `regex-state` as
the help suggests.
Also added the two possible options to avoid confusion.
---
plugins/check_curl.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/plugins/check_curl.c b/plugins/check_curl.c
index e9c15e648..bf46b2261 100644
--- a/plugins/check_curl.c
+++ b/plugins/check_curl.c
@@ -2061,8 +2061,8 @@ print_help (void)
printf (" %s\n", "--invert-regex");
printf (" %s\n", _("Return STATE if found, OK if not (STATE is CRITICAL, per default)"));
printf (" %s\n", _("can be changed with --state--regex)"));
- printf (" %s\n", "--regex-state=STATE");
- printf (" %s\n", _("Return STATE if regex is found, OK if not\n"));
+ printf (" %s\n", "--state-regex=STATE");
+ printf (" %s\n", _("Return STATE if regex is found, OK if not\nSTATE can be one of \"critical\",\"warning\""));
printf (" %s\n", "-a, --authorization=AUTH_PAIR");
printf (" %s\n", _("Username:password on sites with basic authentication"));
printf (" %s\n", "-b, --proxy-authorization=AUTH_PAIR");
From b6c72064a53da8b173b7406a0a535922dc0cc1b3 Mon Sep 17 00:00:00 2001
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
Date: Mon, 19 Aug 2024 15:26:52 +0200
Subject: [PATCH 2/3] check_curl: Parse state-regex option ignoring case
Previously the --state-regex option accepted only "critical" and
"warning" as values.
This commit changes the strcmp there to strcasecmp to be more tolerant
regarding the input.
---
plugins/check_curl.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/plugins/check_curl.c b/plugins/check_curl.c
index bf46b2261..38c971093 100644
--- a/plugins/check_curl.c
+++ b/plugins/check_curl.c
@@ -1775,9 +1775,9 @@ process_arguments (int argc, char **argv)
invert_regex = true;
break;
case STATE_REGEX:
- if (!strcmp (optarg, "critical"))
+ if (!strcasecmp (optarg, "critical"))
state_regex = STATE_CRITICAL;
- else if (!strcmp (optarg, "warning"))
+ else if (!strcasecmp (optarg, "warning"))
state_regex = STATE_WARNING;
else usage2 (_("Invalid state-regex option"), optarg);
break;
From af097aa3642174a2111f0bbcbc8236fff0901e17 Mon Sep 17 00:00:00 2001
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
Date: Mon, 19 Aug 2024 15:33:17 +0200
Subject: [PATCH 3/3] check_curl: change help for --state-regex again to fix
formatting
---
plugins/check_curl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/plugins/check_curl.c b/plugins/check_curl.c
index 38c971093..214ba74f9 100644
--- a/plugins/check_curl.c
+++ b/plugins/check_curl.c
@@ -2062,7 +2062,7 @@ print_help (void)
printf (" %s\n", _("Return STATE if found, OK if not (STATE is CRITICAL, per default)"));
printf (" %s\n", _("can be changed with --state--regex)"));
printf (" %s\n", "--state-regex=STATE");
- printf (" %s\n", _("Return STATE if regex is found, OK if not\nSTATE can be one of \"critical\",\"warning\""));
+ printf (" %s\n", _("Return STATE if regex is found, OK if not. STATE can be one of \"critical\",\"warning\""));
printf (" %s\n", "-a, --authorization=AUTH_PAIR");
printf (" %s\n", _("Username:password on sites with basic authentication"));
printf (" %s\n", "-b, --proxy-authorization=AUTH_PAIR");

View file

@ -1,115 +0,0 @@
From 528e92c180148703ee2cb90d7291f4edbfc270d4 Mon Sep 17 00:00:00 2001
From: Sven Nierlein <sven@consol.de>
Date: Wed, 9 Oct 2024 09:50:39 +0200
Subject: [PATCH] fix check_curl: OpenSSL SSL_read: error:0A000126:SSL
routines::unexpected eof while reading, errno 0
using check_curl on a probably embedded device responding as 'Server: GoAhead-Webs'
%> check_curl -H ... -S -vvv
> GET / HTTP/1.1
Host: ...
User-Agent: check_curl/v2.4.0 (monitoring-plugins 2.4.0, libcurl/7.76.1 OpenSSL/3.0.7 zlib/1.2.11 brotli/1.0.9 libidn2/2.3.0 libpsl/0.21.1 (+libidn2/2.3.0) libssh/0.10.4/openssl/zlib nghttp2/1.43.0)
Accept: */*
Connection: close
* Mark bundle as not supporting multiuse
* HTTP 1.0, assume close after body
< HTTP/1.0 302 Redirect
< Server: GoAhead-Webs
< Date: Tue Mar 26 17:57:16 2019
< Cache-Control: no-cache, no-store, must-revalidate,private
< Pragma: no-cache
< Expires: 0
< Content-Type: text/html
< X-Frame-Options: sameorigin
< X-XSS-Protection: 1; mode=block
< X-Content-Type-Options: nosniff
< Location: https://...
<
* OpenSSL SSL_read: error:0A000126:SSL routines::unexpected eof while reading, errno 0
* Closing connection 0
reading the discussion on https://github.com/openssl/openssl/discussions/22690 suggest to set the option SSL_OP_IGNORE_UNEXPECTED_EOF
which makes check_curl behave like check_http at this point.
Since this is a rather new flag, fencing it in ifdefs.
And since there can only be one ssl ctx function, we need to move both tasks into one function.
---
plugins/check_curl.c | 29 ++++++++++++++++++++++-------
1 file changed, 22 insertions(+), 7 deletions(-)
diff --git a/plugins/check_curl.c b/plugins/check_curl.c
index 7f45b5a79..d3bddacd2 100644
--- a/plugins/check_curl.c
+++ b/plugins/check_curl.c
@@ -214,6 +214,7 @@ char *client_privkey = NULL;
char *ca_cert = NULL;
bool verify_peer_and_host = false;
bool is_openssl_callback = false;
+bool add_sslctx_verify_fun = false;
#if defined(HAVE_SSL) && defined(USE_OPENSSL)
X509 *cert = NULL;
#endif /* defined(HAVE_SSL) && defined(USE_OPENSSL) */
@@ -299,7 +300,7 @@ main (int argc, char **argv)
int verify_callback(int preverify_ok, X509_STORE_CTX *x509_ctx)
{
- (void) preverify_ok;
+ (void) preverify_ok;
/* TODO: we get all certificates of the chain, so which ones
* should we test?
* TODO: is the last certificate always the server certificate?
@@ -324,9 +325,18 @@ int verify_callback(int preverify_ok, X509_STORE_CTX *x509_ctx)
CURLcode sslctxfun(CURL *curl, SSL_CTX *sslctx, void *parm)
{
- (void) curl; // ignore unused parameter
- (void) parm; // ignore unused parameter
- SSL_CTX_set_verify(sslctx, SSL_VERIFY_PEER, verify_callback);
+ (void) curl; // ignore unused parameter
+ (void) parm; // ignore unused parameter
+ if(add_sslctx_verify_fun) {
+ SSL_CTX_set_verify(sslctx, SSL_VERIFY_PEER, verify_callback);
+ }
+
+ // workaround for issue:
+ // OpenSSL SSL_read: error:0A000126:SSL routines::unexpected eof while reading, errno 0
+ // see discussion https://github.com/openssl/openssl/discussions/22690
+#ifdef SSL_OP_IGNORE_UNEXPECTED_EOF
+ SSL_CTX_set_options(sslctx, SSL_OP_IGNORE_UNEXPECTED_EOF);
+#endif
return CURLE_OK;
}
@@ -678,9 +688,8 @@ check_http (void)
* OpenSSL-style libraries only!) */
#ifdef USE_OPENSSL
/* libcurl and monitoring plugins built with OpenSSL, good */
- handle_curl_option_return_code (curl_easy_setopt(curl, CURLOPT_SSL_CTX_FUNCTION, sslctxfun), "CURLOPT_SSL_CTX_FUNCTION");
+ add_sslctx_verify_fun = true;
is_openssl_callback = true;
-#else /* USE_OPENSSL */
#endif /* USE_OPENSSL */
/* libcurl is built with OpenSSL, monitoring plugins, so falling
* back to manually extracting certificate information */
@@ -713,12 +722,18 @@ check_http (void)
#else /* LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 19, 1) */
/* old libcurl, our only hope is OpenSSL, otherwise we are out of luck */
if (ssl_library == CURLHELP_SSL_LIBRARY_OPENSSL || ssl_library == CURLHELP_SSL_LIBRARY_LIBRESSL)
- handle_curl_option_return_code (curl_easy_setopt(curl, CURLOPT_SSL_CTX_FUNCTION, sslctxfun), "CURLOPT_SSL_CTX_FUNCTION");
+ add_sslctx_verify_fun = true;
else
die (STATE_CRITICAL, "HTTP CRITICAL - Cannot retrieve certificates (no CURLOPT_SSL_CTX_FUNCTION, no OpenSSL library or libcurl too old and has no CURLOPT_CERTINFO)\n");
#endif /* LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 19, 1) */
}
+#if LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 10, 6) /* required for CURLOPT_SSL_CTX_FUNCTION */
+ // ssl ctx function is not available with all ssl backends
+ if (curl_easy_setopt(curl, CURLOPT_SSL_CTX_FUNCTION, NULL) != CURLE_UNKNOWN_OPTION)
+ handle_curl_option_return_code (curl_easy_setopt(curl, CURLOPT_SSL_CTX_FUNCTION, sslctxfun), "CURLOPT_SSL_CTX_FUNCTION");
+#endif
+
#endif /* LIBCURL_FEATURE_SSL */
/* set default or user-given user agent identification */

View file

@ -0,0 +1,88 @@
From 508f8e875210ec140457d58463589626a761bb2e Mon Sep 17 00:00:00 2001
From: Florian Lohoff <f@zz.de>
Date: Mon, 15 Feb 2021 15:26:33 +0100
Subject: [PATCH] Removing is_pg_dbname alltogether,using postgres API.
(Closes: #1660)
The problem is that check_pgsql validates the Database name and has different assumptions
that postgres itself.
I fail to see a reason to validate the database name here. Postgres'es API should
do this - So i would suggest a fix like this by removing is_pg_dbname alltogether.
---
plugins/check_pgsql.c | 48 ++++---------------------------------------
1 file changed, 4 insertions(+), 44 deletions(-)
diff --git a/plugins/check_pgsql.c b/plugins/check_pgsql.c
index c893386cb..c26cd439c 100644
--- a/plugins/check_pgsql.c
+++ b/plugins/check_pgsql.c
@@ -69,7 +69,6 @@ int process_arguments (int, char **);
int validate_arguments (void);
void print_usage (void);
void print_help (void);
-int is_pg_dbname (char *);
int is_pg_logname (char *);
int do_query (PGconn *, char *);
@@ -347,10 +346,10 @@ process_arguments (int argc, char **argv)
pgport = optarg;
break;
case 'd': /* database name */
- if (!is_pg_dbname (optarg)) /* checks length and valid chars */
- usage2 (_("Database name is not valid"), optarg);
- else /* we know length, and know optarg is terminated, so us strcpy */
- snprintf(dbName, NAMEDATALEN, "%s", optarg);
+ if (strlen(optarg) >= NAMEDATALEN) {
+ usage2 (_("Database name exceeds the maximum length"), optarg);
+ }
+ snprintf(dbName, NAMEDATALEN, "%s", optarg);
break;
case 'l': /* login name */
if (!is_pg_logname (optarg))
@@ -414,45 +413,6 @@ validate_arguments ()
return OK;
}
-
-/******************************************************************************
-
-@@-
-<sect3>
-<title>is_pg_dbname</title>
-
-<para>&PROTO_is_pg_dbname;</para>
-
-<para>Given a database name, this function returns TRUE if the string
-is a valid PostgreSQL database name, and returns false if it is
-not.</para>
-
-<para>Valid PostgreSQL database names are less than &NAMEDATALEN;
-characters long and consist of letters, numbers, and underscores. The
-first character cannot be a number, however.</para>
-
-</sect3>
--@@
-******************************************************************************/
-
-
-
-int
-is_pg_dbname (char *dbname)
-{
- char txt[NAMEDATALEN];
- char tmp[NAMEDATALEN];
- if (strlen (dbname) > NAMEDATALEN - 1)
- return (FALSE);
- strncpy (txt, dbname, NAMEDATALEN - 1);
- txt[NAMEDATALEN - 1] = 0;
- if (sscanf (txt, "%[_a-zA-Z]%[^_a-zA-Z0-9-]", tmp, tmp) == 1)
- return (TRUE);
- if (sscanf (txt, "%[_a-zA-Z]%[_a-zA-Z0-9-]%[^_a-zA-Z0-9-]", tmp, tmp, tmp) ==
- 2) return (TRUE);
- return (FALSE);
-}
-
/**
the tango program should eventually create an entity here based on the

134
debian/patches/17_check_curl_detect_ipv6 vendored Normal file
View file

@ -0,0 +1,134 @@
From 4a5ddd201119260028db6a4f27027d72aa9a160a Mon Sep 17 00:00:00 2001
From: Lorenz <12514511+RincewindsHat@users.noreply.github.com>
Date: Mon, 7 Nov 2022 17:48:28 +0100
Subject: [PATCH] Check curl detect ipv6 (#1809)
* If server_address is an IPv6 address surround it with brackets
* If the message is too short, we should not have an underflow
* Add simple conditional test case available if IPv6 is
---
diff --git a/plugins/check_curl.c b/plugins/check_curl.c
index a69854a80..2ad373c05 100644
--- a/plugins/check_curl.c
+++ b/plugins/check_curl.c
@@ -476,6 +476,18 @@ check_http (void)
printf ("* curl CURLOPT_RESOLVE: %s\n", dnscache);
}
+ // If server_address is an IPv6 address it must be surround by square brackets
+ struct in6_addr tmp_in_addr;
+ if (inet_pton(AF_INET6, server_address, &tmp_in_addr) == 1) {
+ char *new_server_address = malloc(strlen(server_address) + 3);
+ if (new_server_address == NULL) {
+ die(STATE_UNKNOWN, "HTTP UNKNOWN - Unable to allocate memory\n");
+ }
+ snprintf(new_server_address, strlen(server_address)+3, "[%s]", server_address);
+ free(server_address);
+ server_address = new_server_address;
+ }
+
/* compose URL: use the address we want to connect to, set Host: header later */
snprintf (url, DEFAULT_BUFFER_SIZE, "%s://%s:%d%s",
use_ssl ? "https" : "http",
@@ -999,10 +1011,12 @@ check_http (void)
result = max_state_alt(get_status(total_time, thlds), result);
/* Cut-off trailing characters */
- if(msg[strlen(msg)-2] == ',')
- msg[strlen(msg)-2] = '\0';
- else
- msg[strlen(msg)-3] = '\0';
+ if (strlen(msg) >= 2) {
+ if(msg[strlen(msg)-2] == ',')
+ msg[strlen(msg)-2] = '\0';
+ else
+ msg[strlen(msg)-3] = '\0';
+ }
/* TODO: separate _() msg and status code: die (result, "HTTP %s: %s\n", state_text(result), msg); */
die (result, "HTTP %s: %s %d %s%s%s - %d bytes in %.3f second response time %s|%s\n%s%s",
diff --git a/plugins/t/check_curl.t b/plugins/t/check_curl.t
index 693f4b25e..eae98cc1f 100644
--- a/plugins/t/check_curl.t
+++ b/plugins/t/check_curl.t
@@ -1,15 +1,22 @@
#! /usr/bin/perl -w -I ..
#
-# HyperText Transfer Protocol (HTTP) Test via check_http
+# HyperText Transfer Protocol (HTTP) Test via check_curl
#
#
use strict;
use Test::More;
use POSIX qw/mktime strftime/;
-use NPTest;
-plan tests => 57;
+use vars qw($tests $has_ipv6);
+
+BEGIN {
+ use NPTest;
+ $has_ipv6 = NPTest::has_ipv6();
+ $tests = $has_ipv6 ? 59 : 57;
+ plan tests => $tests;
+}
+
my $successOutput = '/OK.*HTTP.*second/';
@@ -18,6 +25,7 @@ my $plugin = 'check_http';
$plugin = 'check_curl' if $0 =~ m/check_curl/mx;
my $host_tcp_http = getTestParameter("NP_HOST_TCP_HTTP", "A host providing the HTTP Service (a web server)", "localhost");
+my $host_tcp_http_ipv6 = getTestParameter("NP_HOST_TCP_HTTP_IPV6", "An IPv6 address providing a HTTP Service (a web server)", "::1");
my $host_tls_http = getTestParameter("NP_HOST_TLS_HTTP", "A host providing the HTTPS Service (a tls web server)", "localhost");
my $host_tls_cert = getTestParameter("NP_HOST_TLS_CERT", "the common name of the certificate.", "localhost");
my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE", "The hostname of system not responsive to network requests", "10.0.0.1");
@@ -31,26 +39,35 @@ my $faketime = -x '/usr/bin/faketime' ? 1 : 0;
$res = NPTest->testCmd(
- "./$plugin $host_tcp_http -wt 300 -ct 600"
- );
+ "./$plugin $host_tcp_http -wt 300 -ct 600"
+ );
cmp_ok( $res->return_code, '==', 0, "Webserver $host_tcp_http responded" );
like( $res->output, $successOutput, "Output OK" );
+if ($has_ipv6) {
+ # Test for IPv6 formatting
+ $res = NPTest->testCmd(
+ "./$plugin -I $host_tcp_http_ipv6 -wt 300 -ct 600"
+ );
+ cmp_ok( $res->return_code, '==', 0, "IPv6 URL formatting is working" );
+ like( $res->output, $successOutput, "Output OK" );
+}
+
$res = NPTest->testCmd(
- "./$plugin $host_tcp_http -wt 300 -ct 600 -v -v -v -k 'bob:there' -k 'carl:frown'"
- );
+ "./$plugin $host_tcp_http -wt 300 -ct 600 -v -v -v -k 'bob:there' -k 'carl:frown'"
+ );
like( $res->output, '/bob:there\r\ncarl:frown\r\n/', "Got headers with multiple -k options" );
$res = NPTest->testCmd(
- "./$plugin $host_nonresponsive -wt 1 -ct 2 -t 3"
- );
+ "./$plugin $host_nonresponsive -wt 1 -ct 2 -t 3"
+ );
cmp_ok( $res->return_code, '==', 2, "Webserver $host_nonresponsive not responding" );
# was CRITICAL only, but both check_curl and check_http print HTTP CRITICAL (puzzle?!)
like( $res->output, "/HTTP CRITICAL - Invalid HTTP response received from host on port 80: cURL returned 28 - Connection timed out after/", "Output OK");
$res = NPTest->testCmd(
- "./$plugin $hostname_invalid -wt 1 -ct 2"
- );
+ "./$plugin $hostname_invalid -wt 1 -ct 2"
+ );
cmp_ok( $res->return_code, '==', 2, "Webserver $hostname_invalid not valid" );
# The first part of the message comes from the OS catalogue, so cannot check this.
# On Debian, it is Name or service not known, on Darwin, it is No address associated with nodename

View file

@ -1,83 +0,0 @@
From 88d991773b6d8ac416ad2931ea8debc949555c7a Mon Sep 17 00:00:00 2001
From: William <william@blackhats.net.au>
Date: Wed, 6 Nov 2024 14:00:23 +1000
Subject: [PATCH] Add dontfrag/random for fping
Support the dont fragment and randomise packet data options for check_fping
---
plugins/check_fping.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
--- a/plugins/check_fping.c
+++ b/plugins/check_fping.c
@@ -7,7 +7,7 @@
*
* Description:
*
-* This file contains the check_disk plugin
+* This file contains the check_fping plugin
*
* This plugin will use the fping command to ping the specified host for a
* fast check
@@ -60,6 +60,8 @@
int target_timeout = 0;
int packet_interval = 0;
bool verbose = false;
+bool dontfrag = false;
+bool randomize_packet_data = false;
int cpl;
int wpl;
double crta;
@@ -105,6 +107,10 @@
xasprintf(&option_string, "%s-S %s ", option_string, sourceip);
if (sourceif)
xasprintf(&option_string, "%s-I %s ", option_string, sourceif);
+ if (dontfrag)
+ xasprintf(&option_string, "%s-M ", option_string);
+ if (randomize_packet_data)
+ xasprintf(&option_string, "%s-R ", option_string);
#ifdef PATH_TO_FPING6
if (address_family != AF_INET && is_inet6_addr(server))
@@ -303,6 +309,8 @@
{"help", no_argument, 0, 'h'},
{"use-ipv4", no_argument, 0, '4'},
{"use-ipv6", no_argument, 0, '6'},
+ {"dontfrag", no_argument, 0, 'M'},
+ {"random", no_argument, 0, 'R'},
{0, 0, 0, 0}
};
@@ -320,7 +328,7 @@
}
while (1) {
- c = getopt_long (argc, argv, "+hVvaH:S:c:w:b:n:T:i:I:46", longopts, &option);
+ c = getopt_long (argc, argv, "+hVvaH:S:c:w:b:n:T:i:I:M:R:46", longopts, &option);
if (c == -1 || c == EOF || c == 1)
break;
@@ -415,6 +423,12 @@
else
usage (_("Interval must be a positive integer"));
break;
+ case 'R':
+ randomize_packet_data = true;
+ break;
+ case 'M':
+ dontfrag = true;
+ break;
}
}
@@ -506,6 +520,10 @@
printf (" %s\n", _("name or IP Address of sourceip"));
printf (" %s\n", "-I, --sourceif=IF");
printf (" %s\n", _("source interface name"));
+ printf(" %s\n", "-M, --dontfrag");
+ printf(" %s\n", _("set the Don't Fragment flag"));
+ printf(" %s\n", "-R, --random");
+ printf(" %s\n", _("random packet data (to foil link data compression)"));
printf (UT_VERBOSE);
printf ("\n");
printf (" %s\n", _("THRESHOLD is <rta>,<pl>%% where <rta> is the round trip average travel time (ms)"));

View file

@ -1,21 +0,0 @@
From 8de299308c52d083b893a87e6924405b652f1f7b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lorenz=20K=C3=A4stle?=
<12514511+RincewindsHat@users.noreply.github.com>
Date: Wed, 27 Nov 2024 14:22:02 +0100
Subject: [PATCH] check_curl: update TLS notification notes
---
plugins/check_curl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/plugins/check_curl.c
+++ b/plugins/check_curl.c
@@ -2013,7 +2013,7 @@
printf (" %s\n", _("Connect via SSL. Port defaults to 443. VERSION is optional, and prevents"));
printf (" %s\n", _("auto-negotiation (2 = SSLv2, 3 = SSLv3, 1 = TLSv1, 1.1 = TLSv1.1,"));
printf (" %s\n", _("1.2 = TLSv1.2, 1.3 = TLSv1.3). With a '+' suffix, newer versions are also accepted."));
- printf (" %s\n", _("Note: SSLv2 and SSLv3 are deprecated and are usually disabled in libcurl"));
+ printf (" %s\n", _("Note: SSLv2, SSLv3, TLSv1.0 and TLSv1.1 are deprecated and are usually disabled in libcurl"));
printf (" %s\n", "--sni");
printf (" %s\n", _("Enable SSL/TLS hostname extension support (SNI)"));
#if LIBCURL_VERSION_NUM >= 0x071801

59
debian/patches/18_check_icmp_help vendored Normal file
View file

@ -0,0 +1,59 @@
From e5db81bb29544b1be6500ad4a4dec5b4002c9962 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Aksel=20Sj=C3=B6gren?= <asjogren@itrsgroup.com>
Date: Tue, 29 Nov 2022 13:55:32 +0100
Subject: [PATCH] check_icmp: fix parsing help/version long options
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Fix parsing of the long options --help and --version. The special
handling must be done before calling getopt().
This fixes erroneous output like:
./check_icmp --version
./check_icmp: invalid option -- '-'
./check_icmp: invalid option -- 'e'
./check_icmp: invalid option -- 'r'
./check_icmp: invalid option -- '-'
./check_icmp: invalid option -- 'e'
./check_icmp: invalid option -- 'r'
Signed-off-by: Aksel Sjögren <asjogren@itrsgroup.com>
---
plugins-root/check_icmp.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
index f8f153512..1f87b75f9 100644
--- a/plugins-root/check_icmp.c
+++ b/plugins-root/check_icmp.c
@@ -451,6 +451,14 @@ main(int argc, char **argv)
packets = 5;
}
+ /* support "--help" and "--version" */
+ if(argc == 2) {
+ if(!strcmp(argv[1], "--help"))
+ strcpy(argv[1], "-h");
+ if(!strcmp(argv[1], "--version"))
+ strcpy(argv[1], "-V");
+ }
+
/* Parse protocol arguments first */
for(i = 1; i < argc; i++) {
while((arg = getopt(argc, argv, opts_str)) != EOF) {
@@ -555,14 +563,6 @@ main(int argc, char **argv)
/* Parse extra opts if any */
argv=np_extra_opts(&argc, argv, progname);
- /* support "--help" and "--version" */
- if(argc == 2) {
- if(!strcmp(argv[1], "--help"))
- strcpy(argv[1], "-h");
- if(!strcmp(argv[1], "--version"))
- strcpy(argv[1], "-V");
- }
-
argv = &argv[optind];
while(*argv) {
add_target(*argv);

View file

@ -1,46 +0,0 @@
From 191d15354ba32a483fd4f8017595c7eb82ee5650 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andre=20Kl=C3=A4rner?= <kandre@ak-online.be>
Date: Fri, 29 Nov 2024 10:34:16 +0100
Subject: [PATCH] check_curl: enable internal cookie handling
This enables us to enable curl cookie engine by specifying an empty
filename as the cookie jar file.
This works, since curl's CURLOPT_COOKIEFILE option allows passing an
empty string as filename, which it interprets as a request to enable the
cookie processing. But since CURLOPT_COOKIEJAR would now attempt to
write to a file named by an empty filename, it would break again (or at
least produce a warning in verbose output).
Overall this is allows to handle checking URLs with cookie based
sessions without persisting the cookies to disk, by using the
curl-internal redirect following.
---
plugins/check_curl.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
--- a/plugins/check_curl.c
+++ b/plugins/check_curl.c
@@ -831,8 +831,11 @@
/* cookie handling */
if (cookie_jar_file != NULL) {
- handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_COOKIEJAR, cookie_jar_file), "CURLOPT_COOKIEJAR");
+ /* enable reading cookies from a file, and if the filename is an empty string, only enable the curl cookie engine */
handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_COOKIEFILE, cookie_jar_file), "CURLOPT_COOKIEFILE");
+ /* now enable saving cookies to a file, but only if the filename is not an empty string, since writing it would fail */
+ if (*cookie_jar_file)
+ handle_curl_option_return_code(curl_easy_setopt(curl, CURLOPT_COOKIEJAR, cookie_jar_file), "CURLOPT_COOKIEJAR");
}
/* do the request */
@@ -2111,6 +2114,9 @@
printf(" %s\n", "--haproxy-protocol");
printf(" %s\n", _("Send HAProxy proxy protocol v1 header (CURLOPT_HAPROXYPROTOCOL)."));
printf (" %s\n", "--cookie-jar=FILE");
+ printf (" %s\n", _("Specify an empty string as FILE to enable curl's cookie engine without saving"));
+ printf (" %s\n", _("the cookies to disk. Only enabling the engine without saving to disk requires"));
+ printf (" %s\n", _("handling multiple requests internally to curl, so use it with --onredirect=curl"));
printf (" %s\n", _("Store cookies in the cookie jar and send them out when requested."));
printf ("\n");

46
debian/patches/19_check_disk_fs_usage vendored Normal file
View file

@ -0,0 +1,46 @@
From dd249c5d4bbce1c1250322dab8c8d0d69b0dca34 Mon Sep 17 00:00:00 2001
From: christian-2 <49752982+christian-2@users.noreply.github.com>
Date: Tue, 13 Dec 2022 23:48:36 +0100
Subject: [PATCH] check_disk: Find accessible mount path if multiple are
available (#1820)
* fixes #1819
* mount entries also have to be accessible according to get_fs_usage()
---
lib/utils_disk.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/lib/utils_disk.c b/lib/utils_disk.c
index c7c9126e4..4f16068a7 100644
--- a/lib/utils_disk.c
+++ b/lib/utils_disk.c
@@ -28,6 +28,7 @@
#include "common.h"
#include "utils_disk.h"
+#include "gl/fsusage.h"
void
np_add_name (struct name_list **list, const char *name)
@@ -127,9 +128,12 @@ np_set_best_match(struct parameter_list *desired, struct mount_entry *mount_list
size_t name_len = strlen(d->name);
size_t best_match_len = 0;
struct mount_entry *best_match = NULL;
+ struct fs_usage fsp;
/* set best match if path name exactly matches a mounted device name */
for (me = mount_list; me; me = me->me_next) {
+ if (get_fs_usage(me->me_mountdir, me->me_devname, &fsp) < 0)
+ continue; /* skip if permissions do not suffice for accessing device */
if (strcmp(me->me_devname, d->name)==0)
best_match = me;
}
@@ -137,6 +141,8 @@ np_set_best_match(struct parameter_list *desired, struct mount_entry *mount_list
/* set best match by directory name if no match was found by devname */
if (! best_match) {
for (me = mount_list; me; me = me->me_next) {
+ if (get_fs_usage(me->me_mountdir, me->me_devname, &fsp) < 0)
+ continue; /* skip if permissions do not suffice for accessing device */
size_t len = strlen (me->me_mountdir);
if ((exact == FALSE && (best_match_len <= len && len <= name_len &&
(len == 1 || strncmp (me->me_mountdir, d->name, len) == 0)))

View file

@ -0,0 +1,22 @@
From 28553e8d1cc56de12e4c9f7705a92f0e0e86d9d9 Mon Sep 17 00:00:00 2001
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
Date: Mon, 19 Dec 2022 17:15:49 +0100
Subject: [PATCH] Fix unknown escape sequence error output
---
plugins/check_apt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/plugins/check_apt.c b/plugins/check_apt.c
index d7be57505..f70fec16b 100644
--- a/plugins/check_apt.c
+++ b/plugins/check_apt.c
@@ -530,7 +530,7 @@ print_help (void)
printf (" %s\n", _("this REGEXP, the plugin will return CRITICAL status. Can be specified"));
printf (" %s\n", _("multiple times like above. Default is a regexp matching security"));
printf (" %s\n", _("upgrades for Debian and Ubuntu:"));
- printf (" \t\%s\n", SECURITY_RE);
+ printf (" \t%s\n", SECURITY_RE);
printf (" %s\n", _("Note that the package must first match the include list before its"));
printf (" %s\n", _("information is compared against the critical list."));
printf (" %s\n", "-o, --only-critical");

View file

@ -1,29 +0,0 @@
From e5f35d40556468fcdebccae847cfc19380952ca0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lorenz=20K=C3=A4stle?=
<12514511+RincewindsHat@users.noreply.github.com>
Date: Wed, 27 Nov 2024 15:29:19 +0100
Subject: [PATCH] check_icmp: set rtmin initially
---
plugins-root/check_icmp.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
--- a/plugins-root/check_icmp.c
+++ b/plugins-root/check_icmp.c
@@ -64,6 +64,7 @@
#include <netinet/ip_icmp.h>
#include <netinet/icmp6.h>
#include <arpa/inet.h>
+#include <math.h>
/** sometimes undefined system macros (quite a few, actually) **/
@@ -1051,7 +1052,7 @@
icmp_recv++;
if (tdiff > (unsigned int)host->rtmax)
host->rtmax = tdiff;
- if (tdiff < (unsigned int)host->rtmin)
+ if ((host->rtmin == INFINITY) || (tdiff < (unsigned int)host->rtmin))
host->rtmin = tdiff;
if(debug) {

View file

@ -0,0 +1,37 @@
From 763862a61cf5a7ba1a10f607022aac2434c79f57 Mon Sep 17 00:00:00 2001
From: Danijel Tasov <data@consol.de>
Date: Wed, 21 Dec 2022 14:48:11 +0100
Subject: [PATCH] make check_http faster with larger files
The current implementation becomes exponentially slower with growing
response size.
See also:
https://github.com/nagios-plugins/nagios-plugins/blob/release-2.4.2/plugins/check_http.c#L1199-L1204
---
plugins/check_http.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/plugins/check_http.c b/plugins/check_http.c
index 41d478163..1835a2d09 100644
--- a/plugins/check_http.c
+++ b/plugins/check_http.c
@@ -1095,9 +1095,14 @@ check_http (void)
*pos = ' ';
}
buffer[i] = '\0';
- xasprintf (&full_page_new, "%s%s", full_page, buffer);
- free (full_page);
+
+ if ((full_page_new = realloc(full_page, pagesize + i + 1)) == NULL)
+ die (STATE_UNKNOWN, _("HTTP UNKNOWN - Could not allocate memory for full_page\n"));
+
+ memmove(&full_page_new[pagesize], buffer, i + 1);
+
full_page = full_page_new;
+
pagesize += i;
if (no_body && document_headers_done (full_page)) {

View file

@ -1,22 +0,0 @@
From e445a386f8ad1166b05fcdfdb5b9cde4622a8632 Mon Sep 17 00:00:00 2001
From: Andreas Baumann <mail@andreasbaumann.cc>
Date: Fri, 27 Dec 2024 15:32:24 +0100
Subject: [PATCH] check_http: fix documentation for --state-regex
---
plugins/check_http.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/plugins/check_http.c b/plugins/check_http.c
index 97c0e39ad..baff682a7 100644
--- a/plugins/check_http.c
+++ b/plugins/check_http.c
@@ -1805,7 +1805,7 @@ print_help (void)
printf (" %s\n", "--invert-regex");
printf (" %s\n", _("Return STATE if found, OK if not (STATE is CRITICAL, per default)"));
printf (" %s\n", _("can be changed with --state--regex)"));
- printf (" %s\n", "--regex-state=STATE");
+ printf (" %s\n", "--state-regex=STATE");
printf (" %s\n", _("Return STATE if regex is found, OK if not\n"));
printf (" %s\n", "-a, --authorization=AUTH_PAIR");

View file

@ -1,20 +0,0 @@
From 02adcbfa896eb726c59ca647eb4cf6909c690f37 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lorenz=20K=C3=A4stle?=
<12514511+RincewindsHat@users.noreply.github.com>
Date: Mon, 24 Feb 2025 20:32:19 +0100
Subject: [PATCH] check_by_ssh: Remove warning/critical from help
---
plugins/check_by_ssh.c | 1 -
1 file changed, 1 deletion(-)
--- a/plugins/check_by_ssh.c
+++ b/plugins/check_by_ssh.c
@@ -454,7 +454,6 @@
printf (" %s\n", _("Tell ssh to use this configfile [optional]"));
printf (" %s\n","-q, --quiet");
printf (" %s\n", _("Tell ssh to suppress warning and diagnostic messages [optional]"));
- printf (UT_WARN_CRIT);
printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
printf (" %s\n","-U, --unknown-timeout");
printf (" %s\n", _("Make connection problems return UNKNOWN instead of CRITICAL"));

View file

@ -0,0 +1,36 @@
From 765b29f09bd3bc2a938260caa5f263343aafadb7 Mon Sep 17 00:00:00 2001
From: Sven Nierlein <sven@nierlein.de>
Date: Thu, 22 Dec 2022 12:51:18 +0100
Subject: [PATCH] check_curl: fix checking large bodys (#1823)
check_curl fails on large pages:
HTTP CRITICAL - Invalid HTTP response received from host on port 5080: cURL returned 23 - Failure writing output to destination
for example trying to run check_curl on the test from #1822
I guess the idea is to double the buffer size each time it is to small. But the code
exponentially grows the buffer size which works well 2-3 times, but then fails.
---
plugins/check_curl.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/plugins/check_curl.c b/plugins/check_curl.c
index 2ad373c05..55de22fd2 100644
--- a/plugins/check_curl.c
+++ b/plugins/check_curl.c
@@ -2024,9 +2024,12 @@ curlhelp_buffer_write_callback (void *buffer, size_t size, size_t nmemb, void *s
curlhelp_write_curlbuf *buf = (curlhelp_write_curlbuf *)stream;
while (buf->bufsize < buf->buflen + size * nmemb + 1) {
- buf->bufsize *= buf->bufsize * 2;
+ buf->bufsize = buf->bufsize * 2;
buf->buf = (char *)realloc (buf->buf, buf->bufsize);
- if (buf->buf == NULL) return -1;
+ if (buf->buf == NULL) {
+ fprintf(stderr, "malloc failed (%d) %s\n", errno, strerror(errno));
+ return -1;
+ }
}
memcpy (buf->buf + buf->buflen, buffer, size * nmemb);

File diff suppressed because it is too large Load diff

View file

@ -1,23 +0,0 @@
From ef3045b97eea23a4dec3197277e5ff4e5afc5c71 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andre=20Kl=C3=A4rner?= <kandre@ak-online.be>
Date: Mon, 17 Mar 2025 16:13:46 +0100
Subject: [PATCH] change error message for missing certificate
The old error message is quite similar to the openssl `failed to retrieve issuer certificate` and can mislead users to troubleshooting certificate stores.
The new message should be distinct enough to make it clear to users that this is not a problem raised by the underlying SSL implementation, but a problem inside monitoring-plugins.
---
plugins/sslutils.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/plugins/sslutils.c
+++ b/plugins/sslutils.c
@@ -208,7 +208,7 @@
time_t tm_t;
if (!certificate) {
- printf("%s\n",_("CRITICAL - Cannot retrieve server certificate."));
+ printf("%s\n",_("CRITICAL - No server certificate present to inspect."));
return STATE_CRITICAL;
}

131
debian/patches/24_check_apt_usage vendored Normal file
View file

@ -0,0 +1,131 @@
From 0899e41f5075d661153eb2c77ace1734a8f66bfa Mon Sep 17 00:00:00 2001
From: Lorenz <12514511+RincewindsHat@users.noreply.github.com>
Date: Sun, 8 Jan 2023 17:23:53 +0100
Subject: [PATCH] Check apt usage (#1793)
* Remove trailing whitespaces
* Use real booleans
* Fix comment
* Put upgrade options in the root sections
Co-authored-by: waja <waja@users.noreply.github.com>
---
plugins/check_apt.c | 40 ++++++++++++++++++++--------------------
1 file changed, 20 insertions(+), 20 deletions(-)
diff --git a/plugins/check_apt.c b/plugins/check_apt.c
index af3563a14..312909b7f 100644
--- a/plugins/check_apt.c
+++ b/plugins/check_apt.c
@@ -76,9 +76,9 @@ int cmpstringp(const void *p1, const void *p2);
/* configuration variables */
static int verbose = 0; /* -v */
-static int list = 0; /* list packages available for upgrade */
-static int do_update = 0; /* whether to call apt-get update */
-static int only_critical = 0; /* whether to warn about non-critical updates */
+static bool list = false; /* list packages available for upgrade */
+static bool do_update = false; /* whether to call apt-get update */
+static bool only_critical = false; /* whether to warn about non-critical updates */
static upgrade_type upgrade = UPGRADE; /* which type of upgrade to do */
static char *upgrade_opts = NULL; /* options to override defaults for upgrade */
static char *update_opts = NULL; /* options to override defaults for update */
@@ -119,7 +119,7 @@ int main (int argc, char **argv) {
if(sec_count > 0){
result = max_state(result, STATE_CRITICAL);
- } else if(packages_available >= packages_warning && only_critical == 0){
+ } else if(packages_available >= packages_warning && only_critical == false){
result = max_state(result, STATE_WARNING);
} else if(result > STATE_UNKNOWN){
result = STATE_UNKNOWN;
@@ -144,7 +144,7 @@ int main (int argc, char **argv) {
for(i = 0; i < sec_count; i++)
printf("%s (security)\n", secpackages_list[i]);
- if (only_critical == 0) {
+ if (only_critical == false) {
for(i = 0; i < packages_available - sec_count; i++)
printf("%s\n", packages_list[i]);
}
@@ -166,7 +166,7 @@ int process_arguments (int argc, char **argv) {
{"upgrade", optional_argument, 0, 'U'},
{"no-upgrade", no_argument, 0, 'n'},
{"dist-upgrade", optional_argument, 0, 'd'},
- {"list", no_argument, 0, 'l'},
+ {"list", no_argument, false, 'l'},
{"include", required_argument, 0, 'i'},
{"exclude", required_argument, 0, 'e'},
{"critical", required_argument, 0, 'c'},
@@ -212,14 +212,14 @@ int process_arguments (int argc, char **argv) {
upgrade=NO_UPGRADE;
break;
case 'u':
- do_update=1;
+ do_update=true;
if(optarg!=NULL){
update_opts=strdup(optarg);
if(update_opts==NULL) die(STATE_UNKNOWN, "strdup failed");
}
break;
case 'l':
- list=1;
+ list=true;
break;
case 'i':
do_include=add_to_regexp(do_include, optarg);
@@ -231,7 +231,7 @@ int process_arguments (int argc, char **argv) {
do_critical=add_to_regexp(do_critical, optarg);
break;
case 'o':
- only_critical=1;
+ only_critical=true;
break;
case INPUT_FILE_OPT:
input_filename = optarg;
@@ -371,7 +371,7 @@ int run_update(void){
struct output chld_out, chld_err;
char *cmdline;
- /* run the upgrade */
+ /* run the update */
cmdline = construct_cmdline(NO_UPGRADE, update_opts);
result = np_runcmd(cmdline, &chld_out, &chld_err, 0);
/* apt-get update changes exit status if it can't fetch packages.
@@ -501,16 +501,6 @@ print_help (void)
printf(UT_PLUG_TIMEOUT, timeout_interval);
- printf (" %s\n", "-U, --upgrade=OPTS");
- printf (" %s\n", _("[Default] Perform an upgrade. If an optional OPTS argument is provided,"));
- printf (" %s\n", _("apt-get will be run with these command line options instead of the"));
- printf (" %s", _("default "));
- printf ("(%s).\n", UPGRADE_DEFAULT_OPTS);
- printf (" %s\n", _("Note that you may be required to have root privileges if you do not use"));
- printf (" %s\n", _("the default options."));
- printf (" %s\n", "-d, --dist-upgrade=OPTS");
- printf (" %s\n", _("Perform a dist-upgrade instead of normal upgrade. Like with -U OPTS"));
- printf (" %s\n", _("can be provided to override the default options."));
printf (" %s\n", "-n, --no-upgrade");
printf (" %s\n", _("Do not run the upgrade. Probably not useful (without -u at least)."));
printf (" %s\n", "-l, --list");
@@ -547,6 +537,16 @@ print_help (void)
printf (" %s\n", _("the default options. Note: you may also need to adjust the global"));
printf (" %s\n", _("timeout (with -t) to prevent the plugin from timing out if apt-get"));
printf (" %s\n", _("upgrade is expected to take longer than the default timeout."));
+ printf (" %s\n", "-U, --upgrade=OPTS");
+ printf (" %s\n", _("Perform an upgrade. If an optional OPTS argument is provided,"));
+ printf (" %s\n", _("apt-get will be run with these command line options instead of the"));
+ printf (" %s", _("default "));
+ printf ("(%s).\n", UPGRADE_DEFAULT_OPTS);
+ printf (" %s\n", _("Note that you may be required to have root privileges if you do not use"));
+ printf (" %s\n", _("the default options, which will only run a simulation and NOT perform the upgrade"));
+ printf (" %s\n", "-d, --dist-upgrade=OPTS");
+ printf (" %s\n", _("Perform a dist-upgrade instead of normal upgrade. Like with -U OPTS"));
+ printf (" %s\n", _("can be provided to override the default options."));
printf(UT_SUPPORT);
}

View file

@ -1,30 +0,0 @@
From 14169fe5a11b94a9f9ab44336fdb5170ee98be66 Mon Sep 17 00:00:00 2001
From: Jan Wagner <waja@cyconet.org>
Date: Sat, 19 Apr 2025 14:37:46 +0200
Subject: [PATCH] check_http: Adding deprecation text
---
plugins/check_http.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/plugins/check_http.c b/plugins/check_http.c
index baff682a7..8e0c15ec9 100644
--- a/plugins/check_http.c
+++ b/plugins/check_http.c
@@ -1724,6 +1724,16 @@ print_help (void)
printf ("%s\n", _("strings and regular expressions, check connection times, and report on"));
printf ("%s\n", _("certificate expiration times."));
+ printf ("\n");
+ printf ("%s\n", _("ATTENTION!"));
+ printf ("\n");
+ printf ("%s\n", _("THIS PLUGIN IS DEPRECATED. The functionality was reimplemented by the"));
+ printf ("%s\n", _("check_curl plugin, which can be used as a drop-in replacement. You should"));
+ printf ("%s\n", _("migrate your checks over to check_curl, because check_http is going to be"));
+ printf ("%s\n", _("removed sooner than later. Just replace check_http with check_curl in your"));
+ printf ("%s\n", _("check command definitions."));
+ printf ("%s\n", _("Report issues to: https://github.com/monitoring-plugins/monitoring-plugins/issues"));
+
printf ("\n\n");
print_usage ();

View file

@ -1,28 +0,0 @@
From fb39f96ac6f72bb56d17f3e8694134dfea9186e9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lorenz=20K=C3=A4stle?=
<12514511+RincewindsHat@users.noreply.github.com>
Date: Mon, 11 Aug 2025 21:49:20 +0200
Subject: [PATCH] check_users: Use sd_get_uids instead of sd_get_session
Previously check_users in combination with systemd used
sd_get_sessions (3) to aquire the number of users, probably
with the idea that every users opens a session.
Turns out, that a user can have multiple sessions and we only really
want to know how many users there are.
This commit changes to sd_get_uids (3) to achieve that target.
---
plugins/check_users.d/users.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/plugins/check_users.c
+++ b/plugins/check_users.c
@@ -92,7 +92,7 @@
#ifdef HAVE_LIBSYSTEMD
if (sd_booted () > 0)
- users = sd_get_sessions (NULL);
+ users = sd_get_uids(NULL);
else {
#endif
#if HAVE_WTSAPI32_H

50
debian/patches/25_spell_fixes vendored Normal file
View file

@ -0,0 +1,50 @@
From dcb1a53f969da6f53d5b64a96b7988a8975bcc84 Mon Sep 17 00:00:00 2001
From: Jan Wagner <waja@cyconet.org>
Date: Tue, 17 Jan 2023 13:55:05 +0000
Subject: [PATCH] Fixing spelling errors
---
plugins/check_apt.c | 2 +-
plugins/check_curl.c | 2 +-
plugins/check_fping.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/plugins/check_apt.c b/plugins/check_apt.c
index 312909b7f..fa982ae34 100644
--- a/plugins/check_apt.c
+++ b/plugins/check_apt.c
@@ -528,7 +528,7 @@ print_help (void)
printf (" %s\n", _("of upgrades will be printed, but any non-critical upgrades will not cause"));
printf (" %s\n", _("the plugin to return WARNING status."));
printf (" %s\n", "-w, --packages-warning");
- printf (" %s\n", _("Minumum number of packages available for upgrade to return WARNING status."));
+ printf (" %s\n", _("Minimum number of packages available for upgrade to return WARNING status."));
printf (" %s\n\n", _("Default is 1 package."));
printf ("%s\n\n", _("The following options require root privileges and should be used with care:"));
diff --git a/plugins/check_curl.c b/plugins/check_curl.c
index 55de22fd2..c6593df1a 100644
--- a/plugins/check_curl.c
+++ b/plugins/check_curl.c
@@ -1680,7 +1680,7 @@ process_arguments (int argc, char **argv)
curl_http_version = CURL_HTTP_VERSION_NONE;
#endif /* LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 33, 0) */
} else {
- fprintf (stderr, "unkown http-version parameter: %s\n", optarg);
+ fprintf (stderr, "unknown http-version parameter: %s\n", optarg);
exit (STATE_WARNING);
}
break;
diff --git a/plugins/check_fping.c b/plugins/check_fping.c
index be9362ad5..db4331624 100644
--- a/plugins/check_fping.c
+++ b/plugins/check_fping.c
@@ -492,7 +492,7 @@ void print_help (void) {
printf (" %s\n", "-c, --critical=THRESHOLD");
printf (" %s\n", _("critical threshold pair"));
printf (" %s\n", "-a, --alive");
- printf (" %s\n", _("Return OK after first successfull reply"));
+ printf (" %s\n", _("Return OK after first successful reply"));
printf (" %s\n", "-b, --bytes=INTEGER");
printf (" %s (default: %d)\n", _("size of ICMP packet"),PACKET_SIZE);
printf (" %s\n", "-n, --number=INTEGER");

View file

@ -0,0 +1,28 @@
From 7ae8456e7a89faf0d9a10c0e2720910cbe0317b8 Mon Sep 17 00:00:00 2001
From: andrew bezella <abezella@archive.org>
Date: Wed, 19 Oct 2022 21:33:18 +0200
Subject: [PATCH] Fixing nullmailer regex
attached is a patch that updates the format expected in the nullmailer
mailq output. the regex is a little more flexible and less specific
than the previous version.
---
plugins-scripts/check_mailq.pl | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/plugins-scripts/check_mailq.pl b/plugins-scripts/check_mailq.pl
index 4c72332a5..27073d3cc 100755
--- a/plugins-scripts/check_mailq.pl
+++ b/plugins-scripts/check_mailq.pl
@@ -537,9 +537,9 @@
}
while (<MAILQ>) {
- #2006-06-22 16:00:00 282 bytes
+ #2022-08-25 01:30:40 502 bytes from <user@example.com>
- if (/^[1-9][0-9]*-[01][0-9]-[0-3][0-9]\s[0-2][0-9]\:[0-5][0-9]\:[0-5][0-9]\s+[0-9]+\sbytes/) {
+ if (/^\d{4}-\d{2}-\d{2}\s+\d{2}\:\d{2}\:\d{2}\s+\d+\sbytes/) {
$msg_q++ ;
}
}

View file

@ -1,188 +0,0 @@
From 4886fa3debf79aa2faac9d0180e8ddb4bb1d4aaa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lorenz=20K=C3=A4stle?=
<12514511+RincewindsHat@users.noreply.github.com>
Date: Mon, 24 Feb 2025 19:52:08 +0100
Subject: [PATCH 1/2] Add MySQL server version dectection and adaptive replica
query
---
Taken from https://github.com/monitoring-plugins/monitoring-plugins/compare/master...maintenance-2.4.0-check_mysql.patch
---
plugins/check_mysql.c | 51 +++++++++++++++++++++++++++++++++++++++++--
1 file changed, 49 insertions(+), 2 deletions(-)
diff --git a/plugins/check_mysql.c b/plugins/check_mysql.c
index 6a7daf11a..1b7403f7b 100644
--- a/plugins/check_mysql.c
+++ b/plugins/check_mysql.c
@@ -211,8 +211,55 @@ main (int argc, char **argv)
}
if(check_slave) {
- /* check the slave status */
- if (mysql_query (&mysql, "show slave status") != 0) {
+ // Detect which version we are, on older version
+ // "show slave status" should work, on newer ones
+ // "show replica status"
+ // But first we have to find out whether this is
+ // MySQL or MariaDB since the version numbering scheme
+ // is different
+ bool use_deprecated_slave_status = false;
+ const char *server_version = mysql_get_server_info(&mysql);
+ unsigned long server_verion_int = mysql_get_server_version(&mysql);
+ unsigned long major_version = server_verion_int / 10000;
+ unsigned long minor_version = (server_verion_int % 10000) / 100;
+ unsigned long patch_version = (server_verion_int % 100);
+ if (verbose) {
+ printf("Found MariaDB: %s, main version: %lu, minor version: %lu, patch version: %lu\n", server_version, major_version,
+ minor_version, patch_version);
+ }
+
+ if (strstr(server_version, "MariaDB") != NULL) {
+ // Looks like MariaDB, new commands should be available after 10.5.1
+ if (major_version < 10) {
+ use_deprecated_slave_status = true;
+ } else if (major_version == 10) {
+ if (minor_version < 5) {
+ use_deprecated_slave_status = true;
+ } else if (minor_version == 5 && patch_version < 1) {
+ use_deprecated_slave_status = true;
+ }
+ }
+ } else if (strstr(server_version, "MySQL") != NULL) {
+ // Looks like MySQL
+ if (major_version < 8) {
+ use_deprecated_slave_status = true;
+ } else if (major_version == 10 && minor_version < 4) {
+ use_deprecated_slave_status = true;
+ }
+ } else {
+ printf("Not a known sever implementation: %s\n", server_version);
+ exit(STATE_UNKNOWN);
+ }
+
+ char *replica_query = NULL;
+ if (use_deprecated_slave_status) {
+ replica_query = "show slave status";
+ } else {
+ replica_query = "show replica status";
+ }
+
+ /* check the replica status */
+ if (mysql_query(&mysql, replica_query) != 0) {
error = strdup(mysql_error(&mysql));
mysql_close (&mysql);
die (STATE_CRITICAL, _("slave query error: %s\n"), error);
From 291a704bcf738f6ceb7a1f46c69b8332b33dbd70 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lorenz=20K=C3=A4stle?=
<12514511+RincewindsHat@users.noreply.github.com>
Date: Fri, 26 Sep 2025 08:57:19 +0200
Subject: [PATCH 2/2] check_mysql: Assume MySQL server by default (in replica
check)
In the Debian Bug tracker (and then Github) a person pointed out,
that a MySQL server does not respond with a hint that is indeed the
MySQL software, but only with the version string.
Which makes sense if one assumes to be the only implementation.
This commit changes the behaviour of the Replica check to assume
that the counterpart is a MySQL server if there are not hints that
it is a MariaDB server.
---
plugins/check_mysql.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/plugins/check_mysql.c b/plugins/check_mysql.c
index 1b7403f7b..951a96f93 100644
--- a/plugins/check_mysql.c
+++ b/plugins/check_mysql.c
@@ -239,16 +239,13 @@ main (int argc, char **argv)
use_deprecated_slave_status = true;
}
}
- } else if (strstr(server_version, "MySQL") != NULL) {
- // Looks like MySQL
+ } else {
+ // Looks like MySQL (or at least not like MariaDB)
if (major_version < 8) {
use_deprecated_slave_status = true;
} else if (major_version == 10 && minor_version < 4) {
use_deprecated_slave_status = true;
}
- } else {
- printf("Not a known sever implementation: %s\n", server_version);
- exit(STATE_UNKNOWN);
}
char *replica_query = NULL;
From 392c945966d96d1dba9c68ac7a73450c2ad72d85 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lorenz=20K=C3=A4stle?= <lorenz.kaestle@netways.de>
Date: Tue, 30 Sep 2025 14:51:39 +0200
Subject: [PATCH] More renaming due to MySQL name chances
Due to MySQL changing several term in Version 8.0.22 the way to
determine the status of replicas has changed.
To adapt to these changes in a517dc614e44650a7e9204c4202feec7a40fd37f
check_mysql was modified to adapt to different versions.
Some parts were missed though which results in failures to detect
the replica status properly.
This parts should be contained in this commit.
---
Taken from https://patch-diff.githubusercontent.com/raw/monitoring-plugins/monitoring-plugins/pull/2163.patch
---
plugins/check_mysql.c | 37 ++++++++++++++++++++++++++-----------
1 file changed, 26 insertions(+), 11 deletions(-)
--- a/plugins/check_mysql.c
+++ b/plugins/check_mysql.c
@@ -300,17 +300,32 @@
num_fields = mysql_num_fields(res);
fields = mysql_fetch_fields(res);
for(i = 0; i < num_fields; i++) {
- if (strcmp(fields[i].name, "Slave_IO_Running") == 0) {
- slave_io_field = i;
- continue;
- }
- if (strcmp(fields[i].name, "Slave_SQL_Running") == 0) {
- slave_sql_field = i;
- continue;
- }
- if (strcmp(fields[i].name, "Seconds_Behind_Master") == 0) {
- seconds_behind_field = i;
- continue;
+ if (use_deprecated_slave_status) {
+ if (strcmp(fields[i].name, "Slave_IO_Running") == 0) {
+ slave_io_field = i;
+ continue;
+ }
+ if (strcmp(fields[i].name, "Slave_SQL_Running") == 0) {
+ slave_sql_field = i;
+ continue;
+ }
+ if (strcmp(fields[i].name, "Seconds_Behind_Master") == 0) {
+ seconds_behind_field = i;
+ continue;
+ }
+ } else {
+ if (strcmp(fields[i].name, "Replica_IO_Running") == 0) {
+ slave_io_field = i;
+ continue;
+ }
+ if (strcmp(fields[i].name, "Replica_SQL_Running") == 0) {
+ slave_sql_field = i;
+ continue;
+ }
+ if (strcmp(fields[i].name, "Seconds_Behind_Source") == 0) {
+ seconds_behind_field = i;
+ continue;
+ }
}
}

View file

@ -1,51 +0,0 @@
Backport of https://patch-diff.githubusercontent.com/raw/monitoring-plugins/monitoring-plugins/pull/2184.patch
--- a/plugins/check_mysql.c
+++ b/plugins/check_mysql.c
@@ -300,32 +300,20 @@
num_fields = mysql_num_fields(res);
fields = mysql_fetch_fields(res);
for(i = 0; i < num_fields; i++) {
- if (use_deprecated_slave_status) {
- if (strcmp(fields[i].name, "Slave_IO_Running") == 0) {
- slave_io_field = i;
- continue;
- }
- if (strcmp(fields[i].name, "Slave_SQL_Running") == 0) {
- slave_sql_field = i;
- continue;
- }
- if (strcmp(fields[i].name, "Seconds_Behind_Master") == 0) {
- seconds_behind_field = i;
- continue;
- }
- } else {
- if (strcmp(fields[i].name, "Replica_IO_Running") == 0) {
- slave_io_field = i;
- continue;
- }
- if (strcmp(fields[i].name, "Replica_SQL_Running") == 0) {
- slave_sql_field = i;
- continue;
- }
- if (strcmp(fields[i].name, "Seconds_Behind_Source") == 0) {
- seconds_behind_field = i;
- continue;
- }
+ if ((strcmp(fields[i].name, "Slave_IO_Running") == 0) ||
+ (strcmp(fields[i].name, "Replica_IO_Running") == 0)) {
+ slave_io_field = i;
+ continue;
+ }
+ if ((strcmp(fields[i].name, "Slave_SQL_Running") == 0) ||
+ (strcmp(fields[i].name, "Replica_SQL_Running") == 0)) {
+ slave_sql_field = i;
+ continue;
+ }
+ if ((strcmp(fields[i].name, "Seconds_Behind_Master") == 0) ||
+ (strcmp(fields[i].name, "Seconds_Behind_Source") == 0)) {
+ seconds_behind_field = i;
+ continue;
}
}

34
debian/patches/series vendored
View file

@ -1,23 +1,17 @@
02_check_icmp_links 02_check_icmp_links
03_epn 03_epn
04_lmstat_path
# commited upstream # commited upstream
10_check_curl_fix_redirects 13_check_http_fix_superflous_crlf
11_check_curl_raise_ssl_issue 14_PRId64_PRIu64_1
12_check_curl_add_docu 15_PRId64_PRIu64_2
13_check_mysql_fix_variables 16_check_pgsql_dbname_too_strict
14_check_curl_remove_experimental_state 17_check_curl_detect_ipv6
15_check_curl_fix_regex 18_check_icmp_help
16_check_curl_openssl_error 19_check_disk_fs_usage
17_check_fping_dontfrag_random 20_check_apt_unknown_escape_sequence
18_check_curl_fix_TLS_notes 21_check_http_faster_with_large_files
19_check_curl_cookie_handling 22_check_curl_faster_with_large_files
20_check_icmp_fix_rtmin 23_check_http_chunked_encoding
21_check_http_state_regex 24_check_apt_usage
22_check_by_ssh_missing_options 25_spell_fixes
23_sslutils_fix_error_message 26_check_mailq_fix_nullmailer_regex
24_check_http_deprecation
25_check_users_sd_get_uids
26_check_mysql_replica
# feature patches
27_check_mysql_fix_replica

View file

@ -6,7 +6,7 @@ define command{
# 'check_http_hostname' command definition # 'check_http_hostname' command definition
define command{ define command{
command_name check_http_hostname command_name check_httpname
command_line /usr/lib/nagios/plugins/check_http -H '$HOSTNAME$' -I '$HOSTADDRESS$' '$ARG1$' command_line /usr/lib/nagios/plugins/check_http -H '$HOSTNAME$' -I '$HOSTADDRESS$' '$ARG1$'
} }
@ -64,7 +64,7 @@ define command{
# 'check_http_hostname_4' command definition # 'check_http_hostname_4' command definition
define command{ define command{
command_name check_http_hostname_4 command_name check_httpname_4
command_line /usr/lib/nagios/plugins/check_http -H '$HOSTNAME$' -I '$HOSTADDRESS$' -4 '$ARG1$' command_line /usr/lib/nagios/plugins/check_http -H '$HOSTNAME$' -I '$HOSTADDRESS$' -4 '$ARG1$'
} }

11
debian/rules vendored
View file

@ -28,15 +28,15 @@ std_plugins:=check_breeze check_ifoperstatus check_hpjd check_ifstatus \
check_rpc check_snmp check_wave check_fping check_game \ check_rpc check_snmp check_wave check_fping check_game \
check_radius check_mysql check_mysql_query check_pgsql \ check_radius check_mysql check_mysql_query check_pgsql \
check_disk_smb check_ldap check_ldaps \ check_disk_smb check_ldap check_ldaps \
check_mailq \ check_mailq check_curl \
check_dns check_dig check_flexlm check_oracle \ check_dns check_dig check_flexlm check_oracle \
check_dbi check_dbi
common_files:=negate urlize utils.pm utils.sh common_files:=negate urlize utils.pm utils.sh
basic_plugin_cfgs:=apt dhcp disk dummy ftp http curl-http load mail news ntp ping procs \ basic_plugin_cfgs:=apt dhcp disk dummy ftp http load mail news ntp ping procs \
real ssh tcp_udp telnet users real ssh tcp_udp telnet users
std_plugin_cfgs:=breeze disk-smb dns flexlm fping games hppjd ifstatus ldap \ std_plugin_cfgs:=breeze curl-http disk-smb dns flexlm fping games hppjd ifstatus ldap \
mailq mrtg mysql netware nt pgsql radius rpc-nfs snmp mailq mrtg mysql netware nt pgsql radius rpc-nfs snmp
PATH = /bin:/sbin:/usr/bin:/usr/sbin PATH = /bin:/sbin:/usr/bin:/usr/sbin
@ -156,10 +156,6 @@ install: build
for p in ${std_plugins}; do \ for p in ${std_plugins}; do \
mv ${NP_BASIC_DIR}/${NP_LIBEXEC}/$$p ${NP_STD_DIR}/${NP_LIBEXEC}; \ mv ${NP_BASIC_DIR}/${NP_LIBEXEC}/$$p ${NP_STD_DIR}/${NP_LIBEXEC}; \
done done
# rename check_http to check_http_deprecated for making use of update-alternatives
mv ${NP_BASIC_DIR}/${NP_LIBEXEC}/check_http ${NP_BASIC_DIR}/${NP_LIBEXEC}/check_http.deprecated
# remove deprecated check_ntp
rm ${NP_BASIC_DIR}/${NP_LIBEXEC}/check_ntp
# slit out common files # slit out common files
for p in ${common_files}; do \ for p in ${common_files}; do \
mv ${NP_BASIC_DIR}/${NP_LIBEXEC}/$$p ${NP_COMMON_DIR}/${NP_LIBEXEC}; \ mv ${NP_BASIC_DIR}/${NP_LIBEXEC}/$$p ${NP_COMMON_DIR}/${NP_LIBEXEC}; \
@ -217,7 +213,6 @@ binary-arch: build install
dh_link -a dh_link -a
dh_installexamples -a dh_installexamples -a
dh_installman -a dh_installman -a
dh_installalternatives -a
dh_strip -a dh_strip -a
dh_compress -a dh_compress -a
dh_fixperms -a -X utils.pm dh_fixperms -a -X utils.pm

View file

@ -1,3 +0,0 @@
# Not supported by devscripts in trixie
older-debian-watch-file-standard 4 *

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,50 +0,0 @@
/* A C macro for declaring that a function does not return.
Copyright (C) 2011-2023 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#ifndef _Noreturn
# if (defined __cplusplus \
&& ((201103 <= __cplusplus && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) \
|| (defined _MSC_VER && 1900 <= _MSC_VER)) \
&& 0)
/* [[noreturn]] is not practically usable, because with it the syntax
extern _Noreturn void func (...);
would not be valid; such a declaration would only be valid with 'extern'
and '_Noreturn' swapped, or without the 'extern' keyword. However, some
AIX system header files and several gnulib header files use precisely
this syntax with 'extern'. */
# define _Noreturn [[noreturn]]
# elif (defined __clang__ && __clang_major__ < 16 \
&& defined _GL_WORK_AROUND_LLVM_BUG_59792)
/* Compile with -D_GL_WORK_AROUND_LLVM_BUG_59792 to work around
that rare LLVM bug, though you may get many false-alarm warnings. */
# define _Noreturn
# elif ((!defined __cplusplus || defined __clang__) \
&& (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \
|| (!defined __STRICT_ANSI__ \
&& (4 < __GNUC__ + (7 <= __GNUC_MINOR__) \
|| (defined __apple_build_version__ \
? 6000000 <= __apple_build_version__ \
: 3 < __clang_major__ + (5 <= __clang_minor__))))))
/* _Noreturn works as-is. */
# elif (2 < __GNUC__ + (8 <= __GNUC_MINOR__) || defined __clang__ \
|| 0x5110 <= __SUNPRO_C)
# define _Noreturn __attribute__ ((__noreturn__))
# elif 1200 <= (defined _MSC_VER ? _MSC_VER : 0)
# define _Noreturn __declspec (noreturn)
# else
# define _Noreturn
# endif
#endif

View file

@ -1,213 +0,0 @@
/* af_alg.c - Compute message digests from file streams and buffers.
Copyright (C) 2018-2023 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Matteo Croce <mcroce@redhat.com>, 2018. */
#include <config.h>
#include "af_alg.h"
#if USE_LINUX_CRYPTO_API
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <linux/if_alg.h>
#include <sys/stat.h>
#include <sys/sendfile.h>
#include <sys/socket.h>
#include "sys-limits.h"
#define BLOCKSIZE 32768
/* Return a newly created socket for ALG.
On error, return a negative error number. */
static int
alg_socket (char const *alg)
{
struct sockaddr_alg salg = {
.salg_family = AF_ALG,
.salg_type = "hash",
};
/* Copy alg into salg.salg_name, without calling strcpy nor strlen. */
for (size_t i = 0; (salg.salg_name[i] = alg[i]) != '\0'; i++)
if (i == sizeof salg.salg_name - 1)
/* alg is too long. */
return -EINVAL;
int cfd = socket (AF_ALG, SOCK_SEQPACKET | SOCK_CLOEXEC, 0);
if (cfd < 0)
return -EAFNOSUPPORT;
int ofd = (bind (cfd, (struct sockaddr *) &salg, sizeof salg) == 0
? accept4 (cfd, NULL, 0, SOCK_CLOEXEC)
: -1);
close (cfd);
return ofd < 0 ? -EAFNOSUPPORT : ofd;
}
int
afalg_buffer (const char *buffer, size_t len, const char *alg,
void *resblock, ssize_t hashlen)
{
/* On Linux < 4.9, the value for an empty stream is wrong (all zeroes).
See <https://patchwork.kernel.org/patch/9308641/>.
This was not fixed properly until November 2016,
see <https://patchwork.kernel.org/patch/9434741/>. */
if (len == 0)
return -EAFNOSUPPORT;
int ofd = alg_socket (alg);
if (ofd < 0)
return ofd;
int result;
for (;;)
{
ssize_t size = (len > BLOCKSIZE ? BLOCKSIZE : len);
if (send (ofd, buffer, size, MSG_MORE) != size)
{
result = -EAFNOSUPPORT;
break;
}
buffer += size;
len -= size;
if (len == 0)
{
result = read (ofd, resblock, hashlen) == hashlen ? 0 : -EAFNOSUPPORT;
break;
}
}
close (ofd);
return result;
}
int
afalg_stream (FILE *stream, const char *alg,
void *resblock, ssize_t hashlen)
{
int ofd = alg_socket (alg);
if (ofd < 0)
return ofd;
/* If STREAM's size is known and nonzero and not too large, attempt
sendfile to pipe the data. The nonzero restriction avoids issues
with /proc files that pretend to be empty, and lets the classic
read-write loop work around an empty-input bug noted below. */
int fd = fileno (stream);
int result;
struct stat st;
off_t off = ftello (stream);
if (0 <= off && fstat (fd, &st) == 0
&& (S_ISREG (st.st_mode) || S_TYPEISSHM (&st) || S_TYPEISTMO (&st))
&& off < st.st_size && st.st_size - off < SYS_BUFSIZE_MAX)
{
/* Make sure the offset of fileno (stream) reflects how many bytes
have been read from stream before this function got invoked.
Note: fflush on an input stream after ungetc does not work as expected
on some platforms. Therefore this situation is not supported here. */
if (fflush (stream))
result = -EIO;
else
{
off_t nbytes = st.st_size - off;
if (sendfile (ofd, fd, &off, nbytes) == nbytes)
{
if (read (ofd, resblock, hashlen) == hashlen)
{
/* The input buffers of stream are no longer valid. */
if (lseek (fd, off, SEEK_SET) != (off_t)-1)
result = 0;
else
/* The file position of fd has not changed. */
result = -EAFNOSUPPORT;
}
else
/* The file position of fd has not changed. */
result = -EAFNOSUPPORT;
}
else
/* The file position of fd has not changed. */
result = -EAFNOSUPPORT;
}
}
else
{
/* sendfile not possible, do a classic read-write loop. */
/* Number of bytes to seek (backwards) in case of error. */
off_t nseek = 0;
for (;;)
{
char buf[BLOCKSIZE];
/* When the stream is not seekable, start with a single-byte block,
so that we can use ungetc() in the case that send() fails. */
size_t blocksize = (nseek == 0 && off < 0 ? 1 : BLOCKSIZE);
ssize_t size = fread (buf, 1, blocksize, stream);
if (size == 0)
{
/* On Linux < 4.9, the value for an empty stream is wrong (all 0).
See <https://patchwork.kernel.org/patch/9308641/>.
This was not fixed properly until November 2016,
see <https://patchwork.kernel.org/patch/9434741/>. */
result = ferror (stream) ? -EIO : nseek == 0 ? -EAFNOSUPPORT : 0;
break;
}
nseek -= size;
if (send (ofd, buf, size, MSG_MORE) != size)
{
if (nseek == -1)
{
/* 1 byte of pushback buffer is guaranteed on stream, even
if stream is not seekable. */
ungetc ((unsigned char) buf[0], stream);
result = -EAFNOSUPPORT;
}
else if (fseeko (stream, nseek, SEEK_CUR) == 0)
/* The position of stream has been restored. */
result = -EAFNOSUPPORT;
else
result = -EIO;
break;
}
/* Don't assume that EOF is sticky. See:
<https://sourceware.org/bugzilla/show_bug.cgi?id=19476>. */
if (feof (stream))
{
result = 0;
break;
}
}
if (result == 0 && read (ofd, resblock, hashlen) != hashlen)
{
if (nseek == 0 || fseeko (stream, nseek, SEEK_CUR) == 0)
/* The position of stream has been restored. */
result = -EAFNOSUPPORT;
else
result = -EIO;
}
}
close (ofd);
return result;
}
#endif

View file

@ -1,115 +0,0 @@
/* af_alg.h - Compute message digests from file streams and buffers.
Copyright (C) 2018-2023 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Matteo Croce <mcroce@redhat.com>, 2018.
Documentation by Bruno Haible <bruno@clisp.org>, 2018. */
/* Declare specific functions for computing message digests
using the Linux kernel crypto API, if available. This kernel API gives
access to specialized crypto instructions (that would also be available
in user space) or to crypto devices (not directly available in user space).
For a more complete set of facilities that use the Linux kernel crypto API,
look at libkcapi. */
#ifndef AF_ALG_H
# define AF_ALG_H 1
# include <stdio.h>
# include <errno.h>
# ifdef __cplusplus
extern "C" {
# endif
# if USE_LINUX_CRYPTO_API
/* Compute a message digest of a memory region.
The memory region starts at BUFFER and is LEN bytes long.
ALG is the message digest algorithm; see the file /proc/crypto.
RESBLOCK points to a block of HASHLEN bytes, for the result.
HASHLEN must be the length of the message digest, in bytes, in particular:
alg | hashlen
-------+--------
md5 | 16
sha1 | 20
sha224 | 28
sha256 | 32
sha384 | 48
sha512 | 64
If successful, fill RESBLOCK and return 0.
Upon failure, return a negated error number. */
int
afalg_buffer (const char *buffer, size_t len, const char *alg,
void *resblock, ssize_t hashlen);
/* Compute a message digest of data read from STREAM.
STREAM is an open file stream. The last operation on STREAM should
not be 'ungetc', and if STREAM is also open for writing it should
have been fflushed since its last write. Read from the current
position to the end of STREAM. Handle regular files efficiently.
ALG is the message digest algorithm; see the file /proc/crypto.
RESBLOCK points to a block of HASHLEN bytes, for the result.
HASHLEN must be the length of the message digest, in bytes, in particular:
alg | hashlen
-------+--------
md5 | 16
sha1 | 20
sha224 | 28
sha256 | 32
sha384 | 48
sha512 | 64
If successful, fill RESBLOCK and return 0.
Upon failure, return a negated error number.
Unless returning 0 or -EIO, restore STREAM's file position so that
the caller can fall back on some other method. */
int
afalg_stream (FILE *stream, const char *alg,
void *resblock, ssize_t hashlen);
# else
static inline int
afalg_buffer (const char *buffer, size_t len, const char *alg,
void *resblock, ssize_t hashlen)
{
return -EAFNOSUPPORT;
}
static inline int
afalg_stream (FILE *stream, const char *alg,
void *resblock, ssize_t hashlen)
{
return -EAFNOSUPPORT;
}
# endif
# ifdef __cplusplus
}
# endif
#endif /* AF_ALG_H */

View file

@ -1,20 +1,22 @@
/* Memory allocation on the stack. /* Memory allocation on the stack.
Copyright (C) 1995, 1999, 2001-2004, 2006-2023 Free Software Foundation, Copyright (C) 1995, 1999, 2001-2004, 2006-2013 Free Software Foundation,
Inc. Inc.
This file is free software: you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify it
it under the terms of the GNU Lesser General Public License as under the terms of the GNU General Public License as published
published by the Free Software Foundation; either version 2.1 of the by the Free Software Foundation; either version 3, or (at your option)
License, or (at your option) any later version. any later version.
This file is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
GNU Lesser General Public License for more details. General Public License for more details.
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU General Public
along with this program. If not, see <https://www.gnu.org/licenses/>. */ License along with this program; if not, see
<http://www.gnu.org/licenses/>.
*/
/* Avoid using the symbol _ALLOCA_H here, as Bison assumes _ALLOCA_H /* Avoid using the symbol _ALLOCA_H here, as Bison assumes _ALLOCA_H
means there is a real alloca function. */ means there is a real alloca function. */
@ -33,16 +35,7 @@
*/ */
#ifndef alloca #ifndef alloca
/* Some version of mingw have an <alloca.h> that causes trouble when # ifdef __GNUC__
included after 'alloca' gets defined as a macro. As a workaround,
include this <alloca.h> first and define 'alloca' as a macro afterwards
if needed. */
# if defined __GNUC__ && (defined _WIN32 && ! defined __CYGWIN__) && @HAVE_ALLOCA_H@
# include_next <alloca.h>
# endif
#endif
#ifndef alloca
# if defined __GNUC__ || (__clang_major__ >= 4)
# define alloca __builtin_alloca # define alloca __builtin_alloca
# elif defined _AIX # elif defined _AIX
# define alloca __alloca # define alloca __alloca
@ -58,8 +51,6 @@ extern "C"
void *_alloca (unsigned short); void *_alloca (unsigned short);
# pragma intrinsic (_alloca) # pragma intrinsic (_alloca)
# define alloca _alloca # define alloca _alloca
# elif defined __MVS__
# include <stdlib.h>
# else # else
# include <stddef.h> # include <stddef.h>
# ifdef __cplusplus # ifdef __cplusplus

View file

@ -1,19 +1,19 @@
/* A GNU-like <arpa/inet.h>. /* A GNU-like <arpa/inet.h>.
Copyright (C) 2005-2006, 2008-2023 Free Software Foundation, Inc. Copyright (C) 2005-2006, 2008-2013 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as it under the terms of the GNU General Public License as published by
published by the Free Software Foundation; either version 2.1 of the the Free Software Foundation; either version 3, or (at your option)
License, or (at your option) any later version. any later version.
This file is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */ along with this program; if not, see <http://www.gnu.org/licenses/>. */
#ifndef _@GUARD_PREFIX@_ARPA_INET_H #ifndef _@GUARD_PREFIX@_ARPA_INET_H
@ -49,12 +49,6 @@
#ifndef _@GUARD_PREFIX@_ARPA_INET_H #ifndef _@GUARD_PREFIX@_ARPA_INET_H
#define _@GUARD_PREFIX@_ARPA_INET_H #define _@GUARD_PREFIX@_ARPA_INET_H
/* Get all possible declarations of inet_ntop() and inet_pton(). */
#if (@GNULIB_INET_NTOP@ || @GNULIB_INET_PTON@ || defined GNULIB_POSIXCHECK) \
&& @HAVE_WS2TCPIP_H@
# include <ws2tcpip.h>
#endif
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
/* The definition of _GL_ARG_NONNULL is copied here. */ /* The definition of _GL_ARG_NONNULL is copied here. */
@ -76,8 +70,8 @@
the return value is NULL and errno is set to ENOSPC. A good value the return value is NULL and errno is set to ENOSPC. A good value
for CNT is 46. for CNT is 46.
For more details, see the POSIX:2008 specification For more details, see the POSIX:2001 specification
<https://pubs.opengroup.org/onlinepubs/9699919799/functions/inet_ntop.html>. */ <http://www.opengroup.org/susv3xsh/inet_ntop.html>. */
# if @REPLACE_INET_NTOP@ # if @REPLACE_INET_NTOP@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE) # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef inet_ntop # undef inet_ntop
@ -103,9 +97,7 @@ _GL_CXXALIAS_SYS_CAST (inet_ntop, const char *,
(int af, const void *restrict src, (int af, const void *restrict src,
char *restrict dst, socklen_t cnt)); char *restrict dst, socklen_t cnt));
# endif # endif
# if __GLIBC__ >= 2
_GL_CXXALIASWARN (inet_ntop); _GL_CXXALIASWARN (inet_ntop);
# endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef inet_ntop # undef inet_ntop
# if HAVE_RAW_DECL_INET_NTOP # if HAVE_RAW_DECL_INET_NTOP
@ -134,9 +126,7 @@ _GL_FUNCDECL_SYS (inet_pton, int,
_GL_CXXALIAS_SYS (inet_pton, int, _GL_CXXALIAS_SYS (inet_pton, int,
(int af, const char *restrict src, void *restrict dst)); (int af, const char *restrict src, void *restrict dst));
# endif # endif
# if __GLIBC__ >= 2
_GL_CXXALIASWARN (inet_pton); _GL_CXXALIASWARN (inet_pton);
# endif
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef inet_pton # undef inet_pton
# if HAVE_RAW_DECL_INET_PTON # if HAVE_RAW_DECL_INET_PTON

View file

@ -1,18 +1,18 @@
/* Formatted output to strings. /* Formatted output to strings.
Copyright (C) 1999, 2002, 2006, 2009-2023 Free Software Foundation, Inc. Copyright (C) 1999, 2002, 2006, 2009-2013 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as it under the terms of the GNU General Public License as published by
published by the Free Software Foundation; either version 2.1 of the the Free Software Foundation; either version 3, or (at your option)
License, or (at your option) any later version. any later version.
This file is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU General Public License along
along with this program. If not, see <https://www.gnu.org/licenses/>. */ with this program; if not, see <http://www.gnu.org/licenses/>. */
#include <config.h> #include <config.h>

View file

@ -1,19 +1,19 @@
/* Formatted output to strings. /* Formatted output to strings.
Copyright (C) 1999, 2002, 2006-2007, 2009-2023 Free Software Foundation, Copyright (C) 1999, 2002, 2006-2007, 2009-2013 Free Software Foundation,
Inc. Inc.
This file is free software: you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as it under the terms of the GNU General Public License as published by
published by the Free Software Foundation; either version 2.1 of the the Free Software Foundation; either version 3, or (at your option)
License, or (at your option) any later version. any later version.
This file is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU General Public License along
along with this program. If not, see <https://www.gnu.org/licenses/>. */ with this program; if not, see <http://www.gnu.org/licenses/>. */
#include <config.h> #include <config.h>

View file

@ -1,27 +0,0 @@
/* Substitute for and wrapper around <assert.h>
Copyright (C) 2011-2023 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Do not guard the include, since <assert.h> is supposed to define
the assert macro each time it is included. */
#if __GNUC__ >= 3
@PRAGMA_SYSTEM_HEADER@
#endif
@PRAGMA_COLUMNS@
#@INCLUDE_NEXT@ @NEXT_ASSERT_H@
/* The definition of static_assert is copied here. */

View file

@ -1,226 +0,0 @@
/* ATTRIBUTE_* macros for using attributes in GCC and similar compilers
Copyright 2020-2023 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Paul Eggert. */
/* Provide public ATTRIBUTE_* names for the private _GL_ATTRIBUTE_*
macros used within Gnulib. */
/* These attributes can be placed in two ways:
- At the start of a declaration (i.e. even before storage-class
specifiers!); then they apply to all entities that are declared
by the declaration.
- Immediately after the name of an entity being declared by the
declaration; then they apply to that entity only. */
#ifndef _GL_ATTRIBUTE_H
#define _GL_ATTRIBUTE_H
/* This file defines two types of attributes:
* C23 standard attributes. These have macro names that do not begin with
'ATTRIBUTE_'.
* Selected GCC attributes; see:
https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html
https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html
https://gcc.gnu.org/onlinedocs/gcc/Common-Type-Attributes.html
These names begin with 'ATTRIBUTE_' to avoid name clashes. */
/* =============== Attributes for specific kinds of functions =============== */
/* Attributes for functions that should not be used. */
/* Warn if the entity is used. */
/* Applies to:
- function, variable,
- struct, union, struct/union member,
- enumeration, enumeration item,
- typedef,
in C++ also: namespace, class, template specialization. */
#define DEPRECATED _GL_ATTRIBUTE_DEPRECATED
/* If a function call is not optimized way, warn with MSG. */
/* Applies to: functions. */
#define ATTRIBUTE_WARNING(msg) _GL_ATTRIBUTE_WARNING (msg)
/* If a function call is not optimized way, report an error with MSG. */
/* Applies to: functions. */
#define ATTRIBUTE_ERROR(msg) _GL_ATTRIBUTE_ERROR (msg)
/* Attributes for memory-allocating functions. */
/* The function returns a pointer to freshly allocated memory. */
/* Applies to: functions. */
#define ATTRIBUTE_MALLOC _GL_ATTRIBUTE_MALLOC
/* ATTRIBUTE_ALLOC_SIZE ((N)) - The Nth argument of the function
is the size of the returned memory block.
ATTRIBUTE_ALLOC_SIZE ((M, N)) - Multiply the Mth and Nth arguments
to determine the size of the returned memory block. */
/* Applies to: function, pointer to function, function types. */
#define ATTRIBUTE_ALLOC_SIZE(args) _GL_ATTRIBUTE_ALLOC_SIZE (args)
/* ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
that can be freed by passing them as the Ith argument to the
function F.
ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that
can be freed via 'free'; it can be used only after declaring 'free'. */
/* Applies to: functions. Cannot be used on inline functions. */
#define ATTRIBUTE_DEALLOC(f, i) _GL_ATTRIBUTE_DEALLOC(f, i)
#define ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC_FREE
/* Attributes for variadic functions. */
/* The variadic function expects a trailing NULL argument.
ATTRIBUTE_SENTINEL () - The last argument is NULL (requires C99).
ATTRIBUTE_SENTINEL ((N)) - The (N+1)st argument from the end is NULL. */
/* Applies to: functions. */
#define ATTRIBUTE_SENTINEL(pos) _GL_ATTRIBUTE_SENTINEL (pos)
/* ================== Attributes for compiler diagnostics ================== */
/* Attributes that help the compiler diagnose programmer mistakes.
Some of them may also help for some compiler optimizations. */
/* ATTRIBUTE_FORMAT ((ARCHETYPE, STRING-INDEX, FIRST-TO-CHECK)) -
The STRING-INDEXth function argument is a format string of style
ARCHETYPE, which is one of:
printf, gnu_printf
scanf, gnu_scanf,
strftime, gnu_strftime,
strfmon,
or the same thing prefixed and suffixed with '__'.
If FIRST-TO-CHECK is not 0, arguments starting at FIRST-TO_CHECK
are suitable for the format string. */
/* Applies to: functions. */
#define ATTRIBUTE_FORMAT(spec) _GL_ATTRIBUTE_FORMAT (spec)
/* ATTRIBUTE_NONNULL ((N1, N2,...)) - Arguments N1, N2,... must not be NULL.
ATTRIBUTE_NONNULL () - All pointer arguments must not be null. */
/* Applies to: functions. */
#define ATTRIBUTE_NONNULL(args) _GL_ATTRIBUTE_NONNULL (args)
/* The function's return value is a non-NULL pointer. */
/* Applies to: functions. */
#define ATTRIBUTE_RETURNS_NONNULL _GL_ATTRIBUTE_RETURNS_NONNULL
/* Warn if the caller does not use the return value,
unless the caller uses something like ignore_value. */
/* Applies to: function, enumeration, class. */
#define NODISCARD _GL_ATTRIBUTE_NODISCARD
/* Attributes that disable false alarms when the compiler diagnoses
programmer "mistakes". */
/* Do not warn if the entity is not used. */
/* Applies to:
- function, variable,
- struct, union, struct/union member,
- enumeration, enumeration item,
- typedef,
in C++ also: class. */
#define MAYBE_UNUSED _GL_ATTRIBUTE_MAYBE_UNUSED
/* The contents of a character array is not meant to be NUL-terminated. */
/* Applies to: struct/union members and variables that are arrays of element
type '[[un]signed] char'. */
#define ATTRIBUTE_NONSTRING _GL_ATTRIBUTE_NONSTRING
/* Do not warn if control flow falls through to the immediately
following 'case' or 'default' label. */
/* Applies to: Empty statement (;), inside a 'switch' statement. */
#define FALLTHROUGH _GL_ATTRIBUTE_FALLTHROUGH
/* ================== Attributes for debugging information ================== */
/* Attributes regarding debugging information emitted by the compiler. */
/* Omit the function from stack traces when debugging. */
/* Applies to: function. */
#define ATTRIBUTE_ARTIFICIAL _GL_ATTRIBUTE_ARTIFICIAL
/* Make the entity visible to debuggers etc., even with '-fwhole-program'. */
/* Applies to: functions, variables. */
#define ATTRIBUTE_EXTERNALLY_VISIBLE _GL_ATTRIBUTE_EXTERNALLY_VISIBLE
/* ========== Attributes that mainly direct compiler optimizations ========== */
/* The function does not throw exceptions. */
/* Applies to: functions. */
#define ATTRIBUTE_NOTHROW _GL_ATTRIBUTE_NOTHROW
/* Do not inline the function. */
/* Applies to: functions. */
#define ATTRIBUTE_NOINLINE _GL_ATTRIBUTE_NOINLINE
/* Always inline the function, and report an error if the compiler
cannot inline. */
/* Applies to: function. */
#define ATTRIBUTE_ALWAYS_INLINE _GL_ATTRIBUTE_ALWAYS_INLINE
/* It is OK for a compiler to omit duplicate calls with the same arguments.
This attribute is safe for a function that neither depends on
nor affects observable state, and always returns exactly once -
e.g., does not loop forever, and does not call longjmp.
(This attribute is stricter than ATTRIBUTE_PURE.) */
/* Applies to: functions. */
#define ATTRIBUTE_CONST _GL_ATTRIBUTE_CONST
/* It is OK for a compiler to omit duplicate calls with the same
arguments if observable state is not changed between calls.
This attribute is safe for a function that does not affect
observable state, and always returns exactly once.
(This attribute is looser than ATTRIBUTE_CONST.) */
/* Applies to: functions. */
#define ATTRIBUTE_PURE _GL_ATTRIBUTE_PURE
/* The function is rarely executed. */
/* Applies to: functions. */
#define ATTRIBUTE_COLD _GL_ATTRIBUTE_COLD
/* If called from some other compilation unit, the function executes
code from that unit only by return or by exception handling,
letting the compiler optimize that unit more aggressively. */
/* Applies to: functions. */
#define ATTRIBUTE_LEAF _GL_ATTRIBUTE_LEAF
/* For struct members: The member has the smallest possible alignment.
For struct, union, class: All members have the smallest possible alignment,
minimizing the memory required. */
/* Applies to: struct members, struct, union,
in C++ also: class. */
#define ATTRIBUTE_PACKED _GL_ATTRIBUTE_PACKED
/* ================ Attributes that make invalid code valid ================ */
/* Attributes that prevent fatal compiler optimizations for code that is not
fully ISO C compliant. */
/* Pointers to the type may point to the same storage as pointers to
other types, thus disabling strict aliasing optimization. */
/* Applies to: types. */
#define ATTRIBUTE_MAY_ALIAS _GL_ATTRIBUTE_MAY_ALIAS
#endif /* _GL_ATTRIBUTE_H */

View file

@ -1,24 +1,24 @@
/* base64.c -- Encode binary data using printable characters. /* base64.c -- Encode binary data using printable characters.
Copyright (C) 1999-2001, 2004-2006, 2009-2023 Free Software Foundation, Inc. Copyright (C) 1999-2001, 2004-2006, 2009-2013 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as it under the terms of the GNU General Public License as published by
published by the Free Software Foundation; either version 2.1 of the the Free Software Foundation; either version 3, or (at your option)
License, or (at your option) any later version. any later version.
This file is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */ along with this program; if not, see <http://www.gnu.org/licenses/>. */
/* Written by Simon Josefsson. Partially adapted from GNU MailUtils /* Written by Simon Josefsson. Partially adapted from GNU MailUtils
* (mailbox/filter_trans.c, as of 2004-11-28). Improved by review * (mailbox/filter_trans.c, as of 2004-11-28). Improved by review
* from Paul Eggert, Bruno Haible, and Stepan Kasal. * from Paul Eggert, Bruno Haible, and Stepan Kasal.
* *
* See also RFC 4648 <https://www.ietf.org/rfc/rfc4648.txt>. * See also RFC 4648 <http://www.ietf.org/rfc/rfc4648.txt>.
* *
* Be careful with error checking. Here is how you would typically * Be careful with error checking. Here is how you would typically
* use these functions: * use these functions:
@ -30,7 +30,7 @@
* FAIL: memory allocation error * FAIL: memory allocation error
* OK: data in OUT/OUTLEN * OK: data in OUT/OUTLEN
* *
* idx_t outlen = base64_encode_alloc (in, inlen, &out); * size_t outlen = base64_encode_alloc (in, inlen, &out);
* if (out == NULL && outlen == 0 && inlen != 0) * if (out == NULL && outlen == 0 && inlen != 0)
* FAIL: input too long * FAIL: input too long
* if (out == NULL) * if (out == NULL)
@ -44,84 +44,51 @@
/* Get prototype. */ /* Get prototype. */
#include "base64.h" #include "base64.h"
/* Get imalloc. */ /* Get malloc. */
#include <ialloc.h> #include <stdlib.h>
#include <intprops.h>
/* Get UCHAR_MAX. */ /* Get UCHAR_MAX. */
#include <limits.h> #include <limits.h>
#include <string.h> #include <string.h>
/* Convert 'char' to 'unsigned char' without casting. */ /* C89 compliant way to cast 'char' to 'unsigned char'. */
static unsigned char static unsigned char
to_uchar (char ch) to_uchar (char ch)
{ {
return ch; return ch;
} }
static const char b64c[64] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
/* Base64 encode IN array of size INLEN into OUT array. OUT needs
to be of length >= BASE64_LENGTH(INLEN), and INLEN needs to be
a multiple of 3. */
static void
base64_encode_fast (const char *restrict in, idx_t inlen, char *restrict out)
{
while (inlen)
{
*out++ = b64c[(to_uchar (in[0]) >> 2) & 0x3f];
*out++ = b64c[((to_uchar (in[0]) << 4) + (to_uchar (in[1]) >> 4)) & 0x3f];
*out++ = b64c[((to_uchar (in[1]) << 2) + (to_uchar (in[2]) >> 6)) & 0x3f];
*out++ = b64c[to_uchar (in[2]) & 0x3f];
inlen -= 3;
in += 3;
}
}
/* Base64 encode IN array of size INLEN into OUT array of size OUTLEN. /* Base64 encode IN array of size INLEN into OUT array of size OUTLEN.
If OUTLEN is less than BASE64_LENGTH(INLEN), write as many bytes as If OUTLEN is less than BASE64_LENGTH(INLEN), write as many bytes as
possible. If OUTLEN is larger than BASE64_LENGTH(INLEN), also zero possible. If OUTLEN is larger than BASE64_LENGTH(INLEN), also zero
terminate the output buffer. */ terminate the output buffer. */
void void
base64_encode (const char *restrict in, idx_t inlen, base64_encode (const char *restrict in, size_t inlen,
char *restrict out, idx_t outlen) char *restrict out, size_t outlen)
{ {
/* Note this outlen constraint can be enforced at compile time. static const char b64str[64] =
I.E. that the output buffer is exactly large enough to hold "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
the encoded inlen bytes. The inlen constraints (of corresponding
to outlen, and being a multiple of 3) can change at runtime
at the end of input. However the common case when reading
large inputs is to have both constraints satisfied, so we depend
on both in base_encode_fast(). */
if (outlen % 4 == 0 && inlen == (outlen >> 2) * 3)
{
base64_encode_fast (in, inlen, out);
return;
}
while (inlen && outlen) while (inlen && outlen)
{ {
*out++ = b64c[(to_uchar (in[0]) >> 2) & 0x3f]; *out++ = b64str[(to_uchar (in[0]) >> 2) & 0x3f];
if (!--outlen) if (!--outlen)
break; break;
*out++ = b64c[((to_uchar (in[0]) << 4) *out++ = b64str[((to_uchar (in[0]) << 4)
+ (--inlen ? to_uchar (in[1]) >> 4 : 0)) + (--inlen ? to_uchar (in[1]) >> 4 : 0))
& 0x3f]; & 0x3f];
if (!--outlen) if (!--outlen)
break; break;
*out++ = *out++ =
(inlen (inlen
? b64c[((to_uchar (in[1]) << 2) ? b64str[((to_uchar (in[1]) << 2)
+ (--inlen ? to_uchar (in[2]) >> 6 : 0)) + (--inlen ? to_uchar (in[2]) >> 6 : 0))
& 0x3f] & 0x3f]
: '='); : '=');
if (!--outlen) if (!--outlen)
break; break;
*out++ = inlen ? b64c[to_uchar (in[2]) & 0x3f] : '='; *out++ = inlen ? b64str[to_uchar (in[2]) & 0x3f] : '=';
if (!--outlen) if (!--outlen)
break; break;
if (inlen) if (inlen)
@ -143,21 +110,30 @@ base64_encode (const char *restrict in, idx_t inlen,
memory allocation failed, OUT is set to NULL, and the return value memory allocation failed, OUT is set to NULL, and the return value
indicates length of the requested memory block, i.e., indicates length of the requested memory block, i.e.,
BASE64_LENGTH(inlen) + 1. */ BASE64_LENGTH(inlen) + 1. */
idx_t size_t
base64_encode_alloc (const char *in, idx_t inlen, char **out) base64_encode_alloc (const char *in, size_t inlen, char **out)
{ {
size_t outlen = 1 + BASE64_LENGTH (inlen);
/* Check for overflow in outlen computation. /* Check for overflow in outlen computation.
Treat negative INLEN as overflow, for better compatibility with *
pre-2021-08-27 API, which used size_t. */ * If there is no overflow, outlen >= inlen.
idx_t in_over_3 = inlen / 3 + (inlen % 3 != 0), outlen; *
if (! INT_MULTIPLY_OK (in_over_3, 4, &outlen) || inlen < 0) * If the operation (inlen + 2) overflows then it yields at most +1, so
* outlen is 0.
*
* If the multiplication overflows, we lose at least half of the
* correct value, so the result is < ((inlen + 2) / 3) * 2, which is
* less than (inlen + 2) * 0.66667, which is less than inlen as soon as
* (inlen > 4).
*/
if (inlen > outlen)
{ {
*out = NULL; *out = NULL;
return 0; return 0;
} }
outlen++;
*out = imalloc (outlen); *out = malloc (outlen);
if (!*out) if (!*out)
return outlen; return outlen;
@ -341,7 +317,7 @@ base64_decode_ctx_init (struct base64_decode_context *ctx)
static char * static char *
get_4 (struct base64_decode_context *ctx, get_4 (struct base64_decode_context *ctx,
char const *restrict *in, char const *restrict in_end, char const *restrict *in, char const *restrict in_end,
idx_t *n_non_newline) size_t *n_non_newline)
{ {
if (ctx->i == 4) if (ctx->i == 4)
ctx->i = 0; ctx->i = 0;
@ -393,8 +369,8 @@ get_4 (struct base64_decode_context *ctx,
*OUT to point to the byte after the last one written, and decrement *OUT to point to the byte after the last one written, and decrement
*OUTLEN to reflect the number of bytes remaining in *OUT. */ *OUTLEN to reflect the number of bytes remaining in *OUT. */
static bool static bool
decode_4 (char const *restrict in, idx_t inlen, decode_4 (char const *restrict in, size_t inlen,
char *restrict *outp, idx_t *outleft) char *restrict *outp, size_t *outleft)
{ {
char *out = *outp; char *out = *outp;
if (inlen < 2) if (inlen < 2)
@ -479,10 +455,10 @@ decode_4 (char const *restrict in, idx_t inlen,
bool bool
base64_decode_ctx (struct base64_decode_context *ctx, base64_decode_ctx (struct base64_decode_context *ctx,
const char *restrict in, idx_t inlen, const char *restrict in, size_t inlen,
char *restrict out, idx_t *outlen) char *restrict out, size_t *outlen)
{ {
idx_t outleft = *outlen; size_t outleft = *outlen;
bool ignore_newlines = ctx != NULL; bool ignore_newlines = ctx != NULL;
bool flush_ctx = false; bool flush_ctx = false;
unsigned int ctx_i = 0; unsigned int ctx_i = 0;
@ -496,7 +472,7 @@ base64_decode_ctx (struct base64_decode_context *ctx,
while (true) while (true)
{ {
idx_t outleft_save = outleft; size_t outleft_save = outleft;
if (ctx_i == 0 && !flush_ctx) if (ctx_i == 0 && !flush_ctx)
{ {
while (true) while (true)
@ -570,17 +546,17 @@ base64_decode_ctx (struct base64_decode_context *ctx,
undefined. */ undefined. */
bool bool
base64_decode_alloc_ctx (struct base64_decode_context *ctx, base64_decode_alloc_ctx (struct base64_decode_context *ctx,
const char *in, idx_t inlen, char **out, const char *in, size_t inlen, char **out,
idx_t *outlen) size_t *outlen)
{ {
/* This may allocate a few bytes too many, depending on input, /* This may allocate a few bytes too many, depending on input,
but it's not worth the extra CPU time to compute the exact size. but it's not worth the extra CPU time to compute the exact size.
The exact size is 3 * (inlen + (ctx ? ctx->i : 0)) / 4, minus 1 if the The exact size is 3 * (inlen + (ctx ? ctx->i : 0)) / 4, minus 1 if the
input ends with "=" and minus another 1 if the input ends with "==". input ends with "=" and minus another 1 if the input ends with "==".
Shifting before multiplying avoids the possibility of overflow. */ Dividing before multiplying avoids the possibility of overflow. */
idx_t needlen = 3 * ((inlen >> 2) + 1); size_t needlen = 3 * (inlen / 4) + 3;
*out = imalloc (needlen); *out = malloc (needlen);
if (!*out) if (!*out)
return true; return true;

View file

@ -1,25 +1,28 @@
/* base64.h -- Encode binary data using printable characters. /* base64.h -- Encode binary data using printable characters.
Copyright (C) 2004-2006, 2009-2023 Free Software Foundation, Inc. Copyright (C) 2004-2006, 2009-2013 Free Software Foundation, Inc.
Written by Simon Josefsson. Written by Simon Josefsson.
This file is free software: you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as it under the terms of the GNU General Public License as published by
published by the Free Software Foundation; either version 2.1 of the the Free Software Foundation; either version 3, or (at your option)
License, or (at your option) any later version. any later version.
This file is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */ along with this program; if not, see <http://www.gnu.org/licenses/>. */
#ifndef BASE64_H #ifndef BASE64_H
# define BASE64_H # define BASE64_H
/* Get idx_t. */ /* Get size_t. */
# include <idx.h> # include <stddef.h>
/* Get bool. */
# include <stdbool.h>
# ifdef __cplusplus # ifdef __cplusplus
extern "C" { extern "C" {
@ -31,26 +34,26 @@ extern "C" {
struct base64_decode_context struct base64_decode_context
{ {
int i; unsigned int i;
char buf[4]; char buf[4];
}; };
extern bool isbase64 (char ch) _GL_ATTRIBUTE_CONST; extern bool isbase64 (char ch) _GL_ATTRIBUTE_CONST;
extern void base64_encode (const char *restrict in, idx_t inlen, extern void base64_encode (const char *restrict in, size_t inlen,
char *restrict out, idx_t outlen); char *restrict out, size_t outlen);
extern idx_t base64_encode_alloc (const char *in, idx_t inlen, char **out); extern size_t base64_encode_alloc (const char *in, size_t inlen, char **out);
extern void base64_decode_ctx_init (struct base64_decode_context *ctx); extern void base64_decode_ctx_init (struct base64_decode_context *ctx);
extern bool base64_decode_ctx (struct base64_decode_context *ctx, extern bool base64_decode_ctx (struct base64_decode_context *ctx,
const char *restrict in, idx_t inlen, const char *restrict in, size_t inlen,
char *restrict out, idx_t *outlen); char *restrict out, size_t *outlen);
extern bool base64_decode_alloc_ctx (struct base64_decode_context *ctx, extern bool base64_decode_alloc_ctx (struct base64_decode_context *ctx,
const char *in, idx_t inlen, const char *in, size_t inlen,
char **out, idx_t *outlen); char **out, size_t *outlen);
#define base64_decode(in, inlen, out, outlen) \ #define base64_decode(in, inlen, out, outlen) \
base64_decode_ctx (NULL, in, inlen, out, outlen) base64_decode_ctx (NULL, in, inlen, out, outlen)

View file

@ -1,36 +1,37 @@
/* basename.c -- return the last element in a file name /* basename.c -- return the last element in a file name
Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2023 Free Software Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2013 Free Software
Foundation, Inc. Foundation, Inc.
This file is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as it under the terms of the GNU General Public License as published by
published by the Free Software Foundation; either version 2.1 of the the Free Software Foundation; either version 3 of the License, or
License, or (at your option) any later version. (at your option) any later version.
This file is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h> #include <config.h>
/* Specification. */ #include "dirname.h"
#include "basename-lgpl.h"
#include <string.h> #include <string.h>
#include "filename.h" /* Return the address of the last file name component of NAME. If
NAME has no relative file name components because it is a file
system root, return the empty string. */
char * char *
last_component (char const *name) last_component (char const *name)
{ {
char const *base = name + FILE_SYSTEM_PREFIX_LEN (name); char const *base = name + FILE_SYSTEM_PREFIX_LEN (name);
char const *p; char const *p;
bool last_was_slash = false; bool saw_slash = false;
while (ISSLASH (*base)) while (ISSLASH (*base))
base++; base++;
@ -38,17 +39,21 @@ last_component (char const *name)
for (p = base; *p; p++) for (p = base; *p; p++)
{ {
if (ISSLASH (*p)) if (ISSLASH (*p))
last_was_slash = true; saw_slash = true;
else if (last_was_slash) else if (saw_slash)
{ {
base = p; base = p;
last_was_slash = false; saw_slash = false;
} }
} }
return (char *) base; return (char *) base;
} }
/* Return the length of the basename NAME. Typically NAME is the
value returned by base_name or last_component. Act like strlen
(NAME), except omit all trailing slashes. */
size_t size_t
base_len (char const *name) base_len (char const *name)
{ {

View file

@ -1,78 +0,0 @@
/* Extract the last component (base name) of a file name.
Copyright (C) 1998, 2001, 2003-2006, 2009-2023 Free Software Foundation,
Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#ifndef _BASENAME_LGPL_H
#define _BASENAME_LGPL_H
#include <stddef.h>
#ifndef DOUBLE_SLASH_IS_DISTINCT_ROOT
# define DOUBLE_SLASH_IS_DISTINCT_ROOT 0
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* Return the address of the last file name component of FILENAME.
If FILENAME has some trailing slash(es), they are considered to be
part of the last component.
If FILENAME has no relative file name components because it is a file
system root, return the empty string.
Examples:
FILENAME RESULT
"foo.c" "foo.c"
"foo/bar.c" "bar.c"
"/foo/bar.c" "bar.c"
"foo/bar/" "bar/"
"foo/bar//" "bar//"
"/" ""
"//" ""
"" ""
The return value is a tail of the given FILENAME; do NOT free() it! */
/* This function was traditionally called 'basename', but we avoid this
function name because
* Various platforms have different functions in their libc.
In particular, the glibc basename(), defined in <string.h>, does
not consider trailing slashes to be part of the component:
FILENAME RESULT
"foo/bar/" ""
"foo/bar//" ""
* The 'basename' command eliminates trailing slashes and for a root
produces a non-empty result:
FILENAME RESULT
"foo/bar/" "bar"
"foo/bar//" "bar"
"/" "/"
"//" "/"
*/
extern char *last_component (char const *filename) _GL_ATTRIBUTE_PURE;
/* Return the length of the basename FILENAME.
Typically FILENAME is the value returned by base_name or last_component.
Act like strlen (FILENAME), except omit all trailing slashes. */
extern size_t base_len (char const *filename) _GL_ATTRIBUTE_PURE;
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* _BASENAME_LGPL_H */

View file

@ -1,11 +1,11 @@
/* basename.c -- return the last element in a file name /* basename.c -- return the last element in a file name
Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2023 Free Software Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2013 Free Software
Foundation, Inc. Foundation, Inc.
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation; either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
@ -14,7 +14,7 @@
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h> #include <config.h>
@ -22,43 +22,37 @@
#include <string.h> #include <string.h>
#include "xalloc.h" #include "xalloc.h"
#include "xstrndup.h"
char * char *
base_name (char const *name) base_name (char const *name)
{ {
char const *base = last_component (name); char const *base = last_component (name);
idx_t length; size_t length;
int dotslash_len;
if (*base)
{
length = base_len (base);
/* Collapse a sequence of trailing slashes into one. */ /* If there is no last component, then name is a file system root or the
length += ISSLASH (base[length]); empty string. */
if (! *base)
return xstrndup (name, base_len (name));
/* On systems with drive letters, "a/b:c" must return "./b:c" rather /* Collapse a sequence of trailing slashes into one. */
than "b:c" to avoid confusion with a drive letter. On systems length = base_len (base);
with pure POSIX semantics, this is not an issue. */ if (ISSLASH (base[length]))
dotslash_len = FILE_SYSTEM_PREFIX_LEN (base) != 0 ? 2 : 0; length++;
}
else
{
/* There is no last component, so NAME is a file system root or
the empty string. */
base = name;
length = base_len (base);
dotslash_len = 0;
}
char *p = ximalloc (dotslash_len + length + 1); /* On systems with drive letters, "a/b:c" must return "./b:c" rather
if (dotslash_len) than "b:c" to avoid confusion with a drive letter. On systems
with pure POSIX semantics, this is not an issue. */
if (FILE_SYSTEM_PREFIX_LEN (base))
{ {
char *p = xmalloc (length + 3);
p[0] = '.'; p[0] = '.';
p[1] = '/'; p[1] = '/';
memcpy (p + 2, base, length);
p[length + 2] = '\0';
return p;
} }
/* Finally, copy the basename. */ /* Finally, copy the basename. */
memcpy (p + dotslash_len, base, length); return xstrndup (base, length);
p[dotslash_len + length] = '\0';
return p;
} }

View file

@ -1,19 +1,19 @@
/* Convert unibyte character to wide character. /* Convert unibyte character to wide character.
Copyright (C) 2008, 2010-2023 Free Software Foundation, Inc. Copyright (C) 2008, 2010-2013 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2008. Written by Bruno Haible <bruno@clisp.org>, 2008.
This file is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as it under the terms of the GNU General Public License as published by
published by the Free Software Foundation; either version 2.1 of the the Free Software Foundation; either version 3 of the License, or
License, or (at your option) any later version. (at your option) any later version.
This file is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h> #include <config.h>

View file

@ -1,44 +0,0 @@
/* byteswap.h - Byte swapping
Copyright (C) 2005, 2007, 2009-2023 Free Software Foundation, Inc.
Written by Oskar Liljeblad <oskar@osk.mine.nu>, 2005.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#ifndef _GL_BYTESWAP_H
#define _GL_BYTESWAP_H
/* Given an unsigned 16-bit argument X, return the value corresponding to
X with reversed byte order. */
#define bswap_16(x) ((((x) & 0x00FF) << 8) | \
(((x) & 0xFF00) >> 8))
/* Given an unsigned 32-bit argument X, return the value corresponding to
X with reversed byte order. */
#define bswap_32(x) ((((x) & 0x000000FF) << 24) | \
(((x) & 0x0000FF00) << 8) | \
(((x) & 0x00FF0000) >> 8) | \
(((x) & 0xFF000000) >> 24))
/* Given an unsigned 64-bit argument X, return the value corresponding to
X with reversed byte order. */
#define bswap_64(x) ((((x) & 0x00000000000000FFULL) << 56) | \
(((x) & 0x000000000000FF00ULL) << 40) | \
(((x) & 0x0000000000FF0000ULL) << 24) | \
(((x) & 0x00000000FF000000ULL) << 8) | \
(((x) & 0x000000FF00000000ULL) >> 8) | \
(((x) & 0x0000FF0000000000ULL) >> 24) | \
(((x) & 0x00FF000000000000ULL) >> 40) | \
(((x) & 0xFF00000000000000ULL) >> 56))
#endif /* _GL_BYTESWAP_H */

View file

@ -1,55 +0,0 @@
/* calloc() function that is glibc compatible.
This wrapper function is required at least on Tru64 UNIX 5.1 and mingw.
Copyright (C) 2004-2007, 2009-2023 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* written by Jim Meyering and Bruno Haible */
#include <config.h>
/* Specification. */
#include <stdlib.h>
#include <errno.h>
#include "xalloc-oversized.h"
/* Call the system's calloc below. */
#undef calloc
/* Allocate and zero-fill an NxS-byte block of memory from the heap,
even if N or S is zero. */
void *
rpl_calloc (size_t n, size_t s)
{
if (n == 0 || s == 0)
n = s = 1;
if (xalloc_oversized (n, s))
{
errno = ENOMEM;
return NULL;
}
void *result = calloc (n, s);
#if !HAVE_MALLOC_POSIX
if (result == NULL)
errno = ENOMEM;
#endif
return result;
}

View file

@ -1,707 +0,0 @@
/* Copyright (C) 1992-2023 Free Software Foundation, Inc.
Copyright The GNU Toolchain Authors.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
#ifndef _SYS_CDEFS_H
#define _SYS_CDEFS_H 1
/* We are almost always included from features.h. */
#ifndef _FEATURES_H
# include <features.h>
#endif
/* The GNU libc does not support any K&R compilers or the traditional mode
of ISO C compilers anymore. Check for some of the combinations not
supported anymore. */
#if defined __GNUC__ && !defined __STDC__
# error "You need a ISO C conforming compiler to use the glibc headers"
#endif
/* Some user header file might have defined this before. */
#undef __P
#undef __PMT
/* Compilers that lack __has_attribute may object to
#if defined __has_attribute && __has_attribute (...)
even though they do not need to evaluate the right-hand side of the &&.
Similarly for __has_builtin, etc. */
#if (defined __has_attribute \
&& (!defined __clang_minor__ \
|| (defined __apple_build_version__ \
? 6000000 <= __apple_build_version__ \
: 3 < __clang_major__ + (5 <= __clang_minor__))))
# define __glibc_has_attribute(attr) __has_attribute (attr)
#else
# define __glibc_has_attribute(attr) 0
#endif
#ifdef __has_builtin
# define __glibc_has_builtin(name) __has_builtin (name)
#else
# define __glibc_has_builtin(name) 0
#endif
#ifdef __has_extension
# define __glibc_has_extension(ext) __has_extension (ext)
#else
# define __glibc_has_extension(ext) 0
#endif
#if defined __GNUC__ || defined __clang__
/* All functions, except those with callbacks or those that
synchronize memory, are leaf functions. */
# if __GNUC_PREREQ (4, 6) && !defined _LIBC
# define __LEAF , __leaf__
# define __LEAF_ATTR __attribute__ ((__leaf__))
# else
# define __LEAF
# define __LEAF_ATTR
# endif
/* GCC can always grok prototypes. For C++ programs we add throw()
to help it optimize the function calls. But this only works with
gcc 2.8.x and egcs. For gcc 3.4 and up we even mark C functions
as non-throwing using a function attribute since programs can use
the -fexceptions options for C code as well. */
# if !defined __cplusplus \
&& (__GNUC_PREREQ (3, 4) || __glibc_has_attribute (__nothrow__))
# define __THROW __attribute__ ((__nothrow__ __LEAF))
# define __THROWNL __attribute__ ((__nothrow__))
# define __NTH(fct) __attribute__ ((__nothrow__ __LEAF)) fct
# define __NTHNL(fct) __attribute__ ((__nothrow__)) fct
# else
# if defined __cplusplus && (__GNUC_PREREQ (2,8) || __clang_major >= 4)
# if __cplusplus >= 201103L
# define __THROW noexcept (true)
# else
# define __THROW throw ()
# endif
# define __THROWNL __THROW
# define __NTH(fct) __LEAF_ATTR fct __THROW
# define __NTHNL(fct) fct __THROW
# else
# define __THROW
# define __THROWNL
# define __NTH(fct) fct
# define __NTHNL(fct) fct
# endif
# endif
#else /* Not GCC or clang. */
# if (defined __cplusplus \
|| (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L))
# define __inline inline
# else
# define __inline /* No inline functions. */
# endif
# define __THROW
# define __THROWNL
# define __NTH(fct) fct
#endif /* GCC || clang. */
/* These two macros are not used in glibc anymore. They are kept here
only because some other projects expect the macros to be defined. */
#define __P(args) args
#define __PMT(args) args
/* For these things, GCC behaves the ANSI way normally,
and the non-ANSI way under -traditional. */
#define __CONCAT(x,y) x ## y
#define __STRING(x) #x
/* This is not a typedef so `const __ptr_t' does the right thing. */
#define __ptr_t void *
/* C++ needs to know that types and declarations are C, not C++. */
#ifdef __cplusplus
# define __BEGIN_DECLS extern "C" {
# define __END_DECLS }
#else
# define __BEGIN_DECLS
# define __END_DECLS
#endif
/* Fortify support. */
#define __bos(ptr) __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1)
#define __bos0(ptr) __builtin_object_size (ptr, 0)
/* Use __builtin_dynamic_object_size at _FORTIFY_SOURCE=3 when available. */
#if __USE_FORTIFY_LEVEL == 3 && (__glibc_clang_prereq (9, 0) \
|| __GNUC_PREREQ (12, 0))
# define __glibc_objsize0(__o) __builtin_dynamic_object_size (__o, 0)
# define __glibc_objsize(__o) __builtin_dynamic_object_size (__o, 1)
#else
# define __glibc_objsize0(__o) __bos0 (__o)
# define __glibc_objsize(__o) __bos (__o)
#endif
/* Compile time conditions to choose between the regular, _chk and _chk_warn
variants. These conditions should get evaluated to constant and optimized
away. */
#define __glibc_safe_len_cond(__l, __s, __osz) ((__l) <= (__osz) / (__s))
#define __glibc_unsigned_or_positive(__l) \
((__typeof (__l)) 0 < (__typeof (__l)) -1 \
|| (__builtin_constant_p (__l) && (__l) > 0))
/* Length is known to be safe at compile time if the __L * __S <= __OBJSZ
condition can be folded to a constant and if it is true, or unknown (-1) */
#define __glibc_safe_or_unknown_len(__l, __s, __osz) \
((__osz) == (__SIZE_TYPE__) -1 \
|| (__glibc_unsigned_or_positive (__l) \
&& __builtin_constant_p (__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), \
(__s), (__osz))) \
&& __glibc_safe_len_cond ((__SIZE_TYPE__) (__l), (__s), (__osz))))
/* Conversely, we know at compile time that the length is unsafe if the
__L * __S <= __OBJSZ condition can be folded to a constant and if it is
false. */
#define __glibc_unsafe_len(__l, __s, __osz) \
(__glibc_unsigned_or_positive (__l) \
&& __builtin_constant_p (__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), \
__s, __osz)) \
&& !__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), __s, __osz))
/* Fortify function f. __f_alias, __f_chk and __f_chk_warn must be
declared. */
#define __glibc_fortify(f, __l, __s, __osz, ...) \
(__glibc_safe_or_unknown_len (__l, __s, __osz) \
? __ ## f ## _alias (__VA_ARGS__) \
: (__glibc_unsafe_len (__l, __s, __osz) \
? __ ## f ## _chk_warn (__VA_ARGS__, __osz) \
: __ ## f ## _chk (__VA_ARGS__, __osz))) \
/* Fortify function f, where object size argument passed to f is the number of
elements and not total size. */
#define __glibc_fortify_n(f, __l, __s, __osz, ...) \
(__glibc_safe_or_unknown_len (__l, __s, __osz) \
? __ ## f ## _alias (__VA_ARGS__) \
: (__glibc_unsafe_len (__l, __s, __osz) \
? __ ## f ## _chk_warn (__VA_ARGS__, (__osz) / (__s)) \
: __ ## f ## _chk (__VA_ARGS__, (__osz) / (__s)))) \
#if __GNUC_PREREQ (4,3)
# define __warnattr(msg) __attribute__((__warning__ (msg)))
# define __errordecl(name, msg) \
extern void name (void) __attribute__((__error__ (msg)))
#else
# define __warnattr(msg)
# define __errordecl(name, msg) extern void name (void)
#endif
/* Support for flexible arrays.
Headers that should use flexible arrays only if they're "real"
(e.g. only if they won't affect sizeof()) should test
#if __glibc_c99_flexarr_available. */
#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L && !defined __HP_cc
# define __flexarr []
# define __glibc_c99_flexarr_available 1
#elif __GNUC_PREREQ (2,97) || defined __clang__
/* GCC 2.97 and clang support C99 flexible array members as an extension,
even when in C89 mode or compiling C++ (any version). */
# define __flexarr []
# define __glibc_c99_flexarr_available 1
#elif defined __GNUC__
/* Pre-2.97 GCC did not support C99 flexible arrays but did have
an equivalent extension with slightly different notation. */
# define __flexarr [0]
# define __glibc_c99_flexarr_available 1
#else
/* Some other non-C99 compiler. Approximate with [1]. */
# define __flexarr [1]
# define __glibc_c99_flexarr_available 0
#endif
/* __asm__ ("xyz") is used throughout the headers to rename functions
at the assembly language level. This is wrapped by the __REDIRECT
macro, in order to support compilers that can do this some other
way. When compilers don't support asm-names at all, we have to do
preprocessor tricks instead (which don't have exactly the right
semantics, but it's the best we can do).
Example:
int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); */
#if (defined __GNUC__ && __GNUC__ >= 2) || (__clang_major__ >= 4)
# define __REDIRECT(name, proto, alias) name proto __asm__ (__ASMNAME (#alias))
# ifdef __cplusplus
# define __REDIRECT_NTH(name, proto, alias) \
name proto __THROW __asm__ (__ASMNAME (#alias))
# define __REDIRECT_NTHNL(name, proto, alias) \
name proto __THROWNL __asm__ (__ASMNAME (#alias))
# else
# define __REDIRECT_NTH(name, proto, alias) \
name proto __asm__ (__ASMNAME (#alias)) __THROW
# define __REDIRECT_NTHNL(name, proto, alias) \
name proto __asm__ (__ASMNAME (#alias)) __THROWNL
# endif
# define __ASMNAME(cname) __ASMNAME2 (__USER_LABEL_PREFIX__, cname)
# define __ASMNAME2(prefix, cname) __STRING (prefix) cname
/*
#elif __SOME_OTHER_COMPILER__
# define __REDIRECT(name, proto, alias) name proto; \
_Pragma("let " #name " = " #alias)
*/
#endif
/* GCC and clang have various useful declarations that can be made with
the '__attribute__' syntax. All of the ways we use this do fine if
they are omitted for compilers that don't understand it. */
#if !(defined __GNUC__ || defined __clang__)
# define __attribute__(xyz) /* Ignore */
#endif
/* At some point during the gcc 2.96 development the `malloc' attribute
for functions was introduced. We don't want to use it unconditionally
(although this would be possible) since it generates warnings. */
#if __GNUC_PREREQ (2,96) || __glibc_has_attribute (__malloc__)
# define __attribute_malloc__ __attribute__ ((__malloc__))
#else
# define __attribute_malloc__ /* Ignore */
#endif
/* Tell the compiler which arguments to an allocation function
indicate the size of the allocation. */
#if __GNUC_PREREQ (4, 3)
# define __attribute_alloc_size__(params) \
__attribute__ ((__alloc_size__ params))
#else
# define __attribute_alloc_size__(params) /* Ignore. */
#endif
/* Tell the compiler which argument to an allocation function
indicates the alignment of the allocation. */
#if __GNUC_PREREQ (4, 9) || __glibc_has_attribute (__alloc_align__)
# define __attribute_alloc_align__(param) \
__attribute__ ((__alloc_align__ param))
#else
# define __attribute_alloc_align__(param) /* Ignore. */
#endif
/* At some point during the gcc 2.96 development the `pure' attribute
for functions was introduced. We don't want to use it unconditionally
(although this would be possible) since it generates warnings. */
#if __GNUC_PREREQ (2,96) || __glibc_has_attribute (__pure__)
# define __attribute_pure__ __attribute__ ((__pure__))
#else
# define __attribute_pure__ /* Ignore */
#endif
/* This declaration tells the compiler that the value is constant. */
#if __GNUC_PREREQ (2,5) || __glibc_has_attribute (__const__)
# define __attribute_const__ __attribute__ ((__const__))
#else
# define __attribute_const__ /* Ignore */
#endif
#if __GNUC_PREREQ (2,7) || __glibc_has_attribute (__unused__)
# define __attribute_maybe_unused__ __attribute__ ((__unused__))
#else
# define __attribute_maybe_unused__ /* Ignore */
#endif
/* At some point during the gcc 3.1 development the `used' attribute
for functions was introduced. We don't want to use it unconditionally
(although this would be possible) since it generates warnings. */
#if __GNUC_PREREQ (3,1) || __glibc_has_attribute (__used__)
# define __attribute_used__ __attribute__ ((__used__))
# define __attribute_noinline__ __attribute__ ((__noinline__))
#else
# define __attribute_used__ __attribute__ ((__unused__))
# define __attribute_noinline__ /* Ignore */
#endif
/* Since version 3.2, gcc allows marking deprecated functions. */
#if __GNUC_PREREQ (3,2) || __glibc_has_attribute (__deprecated__)
# define __attribute_deprecated__ __attribute__ ((__deprecated__))
#else
# define __attribute_deprecated__ /* Ignore */
#endif
/* Since version 4.5, gcc also allows one to specify the message printed
when a deprecated function is used. clang claims to be gcc 4.2, but
may also support this feature. */
#if __GNUC_PREREQ (4,5) \
|| __glibc_has_extension (__attribute_deprecated_with_message__)
# define __attribute_deprecated_msg__(msg) \
__attribute__ ((__deprecated__ (msg)))
#else
# define __attribute_deprecated_msg__(msg) __attribute_deprecated__
#endif
/* At some point during the gcc 2.8 development the `format_arg' attribute
for functions was introduced. We don't want to use it unconditionally
(although this would be possible) since it generates warnings.
If several `format_arg' attributes are given for the same function, in
gcc-3.0 and older, all but the last one are ignored. In newer gccs,
all designated arguments are considered. */
#if __GNUC_PREREQ (2,8) || __glibc_has_attribute (__format_arg__)
# define __attribute_format_arg__(x) __attribute__ ((__format_arg__ (x)))
#else
# define __attribute_format_arg__(x) /* Ignore */
#endif
/* At some point during the gcc 2.97 development the `strfmon' format
attribute for functions was introduced. We don't want to use it
unconditionally (although this would be possible) since it
generates warnings. */
#if __GNUC_PREREQ (2,97) || __glibc_has_attribute (__format__)
# define __attribute_format_strfmon__(a,b) \
__attribute__ ((__format__ (__strfmon__, a, b)))
#else
# define __attribute_format_strfmon__(a,b) /* Ignore */
#endif
/* The nonnull function attribute marks pointer parameters that
must not be NULL. This has the name __nonnull in glibc,
and __attribute_nonnull__ in files shared with Gnulib to avoid
collision with a different __nonnull in DragonFlyBSD 5.9. */
#ifndef __attribute_nonnull__
# if __GNUC_PREREQ (3,3) || __glibc_has_attribute (__nonnull__)
# define __attribute_nonnull__(params) __attribute__ ((__nonnull__ params))
# else
# define __attribute_nonnull__(params)
# endif
#endif
#ifndef __nonnull
# define __nonnull(params) __attribute_nonnull__ (params)
#endif
/* The returns_nonnull function attribute marks the return type of the function
as always being non-null. */
#ifndef __returns_nonnull
# if __GNUC_PREREQ (4, 9) || __glibc_has_attribute (__returns_nonnull__)
# define __returns_nonnull __attribute__ ((__returns_nonnull__))
# else
# define __returns_nonnull
# endif
#endif
/* If fortification mode, we warn about unused results of certain
function calls which can lead to problems. */
#if __GNUC_PREREQ (3,4) || __glibc_has_attribute (__warn_unused_result__)
# define __attribute_warn_unused_result__ \
__attribute__ ((__warn_unused_result__))
# if defined __USE_FORTIFY_LEVEL && __USE_FORTIFY_LEVEL > 0
# define __wur __attribute_warn_unused_result__
# endif
#else
# define __attribute_warn_unused_result__ /* empty */
#endif
#ifndef __wur
# define __wur /* Ignore */
#endif
/* Forces a function to be always inlined. */
#if __GNUC_PREREQ (3,2) || __glibc_has_attribute (__always_inline__)
/* The Linux kernel defines __always_inline in stddef.h (283d7573), and
it conflicts with this definition. Therefore undefine it first to
allow either header to be included first. */
# undef __always_inline
# define __always_inline __inline __attribute__ ((__always_inline__))
#else
# undef __always_inline
# define __always_inline __inline
#endif
/* Associate error messages with the source location of the call site rather
than with the source location inside the function. */
#if __GNUC_PREREQ (4,3) || __glibc_has_attribute (__artificial__)
# define __attribute_artificial__ __attribute__ ((__artificial__))
#else
# define __attribute_artificial__ /* Ignore */
#endif
/* GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99
inline semantics, unless -fgnu89-inline is used. Using __GNUC_STDC_INLINE__
or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions
older than 4.3 may define these macros and still not guarantee GNU inlining
semantics.
clang++ identifies itself as gcc-4.2, but has support for GNU inlining
semantics, that can be checked for by using the __GNUC_STDC_INLINE_ and
__GNUC_GNU_INLINE__ macro definitions. */
#if (!defined __cplusplus || __GNUC_PREREQ (4,3) \
|| (defined __clang__ && (defined __GNUC_STDC_INLINE__ \
|| defined __GNUC_GNU_INLINE__)))
# if defined __GNUC_STDC_INLINE__ || defined __cplusplus
# define __extern_inline extern __inline __attribute__ ((__gnu_inline__))
# define __extern_always_inline \
extern __always_inline __attribute__ ((__gnu_inline__))
# else
# define __extern_inline extern __inline
# define __extern_always_inline extern __always_inline
# endif
#endif
#ifdef __extern_always_inline
# define __fortify_function __extern_always_inline __attribute_artificial__
#endif
/* GCC 4.3 and above allow passing all anonymous arguments of an
__extern_always_inline function to some other vararg function. */
#if __GNUC_PREREQ (4,3)
# define __va_arg_pack() __builtin_va_arg_pack ()
# define __va_arg_pack_len() __builtin_va_arg_pack_len ()
#endif
/* It is possible to compile containing GCC extensions even if GCC is
run in pedantic mode if the uses are carefully marked using the
`__extension__' keyword. But this is not generally available before
version 2.8. */
#if !(__GNUC_PREREQ (2,8) || defined __clang__)
# define __extension__ /* Ignore */
#endif
/* __restrict is known in EGCS 1.2 and above, and in clang.
It works also in C++ mode (outside of arrays), but only when spelled
as '__restrict', not 'restrict'. */
#if !(__GNUC_PREREQ (2,92) || __clang_major__ >= 3)
# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
# define __restrict restrict
# else
# define __restrict /* Ignore */
# endif
#endif
/* ISO C99 also allows to declare arrays as non-overlapping. The syntax is
array_name[restrict]
GCC 3.1 and clang support this.
This syntax is not usable in C++ mode. */
#if (__GNUC_PREREQ (3,1) || __clang_major__ >= 3) && !defined __cplusplus
# define __restrict_arr __restrict
#else
# ifdef __GNUC__
# define __restrict_arr /* Not supported in old GCC. */
# else
# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
# define __restrict_arr restrict
# else
/* Some other non-C99 compiler. */
# define __restrict_arr /* Not supported. */
# endif
# endif
#endif
#if (__GNUC__ >= 3) || __glibc_has_builtin (__builtin_expect)
# define __glibc_unlikely(cond) __builtin_expect ((cond), 0)
# define __glibc_likely(cond) __builtin_expect ((cond), 1)
#else
# define __glibc_unlikely(cond) (cond)
# define __glibc_likely(cond) (cond)
#endif
#if (!defined _Noreturn \
&& (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \
&& !(__GNUC_PREREQ (4,7) \
|| (3 < __clang_major__ + (5 <= __clang_minor__))))
# if __GNUC_PREREQ (2,8)
# define _Noreturn __attribute__ ((__noreturn__))
# else
# define _Noreturn
# endif
#endif
#if __GNUC_PREREQ (8, 0)
/* Describes a char array whose address can safely be passed as the first
argument to strncpy and strncat, as the char array is not necessarily
a NUL-terminated string. */
# define __attribute_nonstring__ __attribute__ ((__nonstring__))
#else
# define __attribute_nonstring__
#endif
/* Undefine (also defined in libc-symbols.h). */
#undef __attribute_copy__
#if __GNUC_PREREQ (9, 0)
/* Copies attributes from the declaration or type referenced by
the argument. */
# define __attribute_copy__(arg) __attribute__ ((__copy__ (arg)))
#else
# define __attribute_copy__(arg)
#endif
#if (!defined _Static_assert && !defined __cplusplus \
&& (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \
&& (!(__GNUC_PREREQ (4, 6) || __clang_major__ >= 4) \
|| defined __STRICT_ANSI__))
# define _Static_assert(expr, diagnostic) \
extern int (*__Static_assert_function (void)) \
[!!sizeof (struct { int __error_if_negative: (expr) ? 2 : -1; })]
#endif
/* Gnulib avoids including these, as they don't work on non-glibc or
older glibc platforms. */
#ifndef __GNULIB_CDEFS
# include <bits/wordsize.h>
# include <bits/long-double.h>
#endif
#if __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1
# ifdef __REDIRECT
/* Alias name defined automatically. */
# define __LDBL_REDIR(name, proto) ... unused__ldbl_redir
# define __LDBL_REDIR_DECL(name) \
extern __typeof (name) name __asm (__ASMNAME ("__" #name "ieee128"));
/* Alias name defined automatically, with leading underscores. */
# define __LDBL_REDIR2_DECL(name) \
extern __typeof (__##name) __##name \
__asm (__ASMNAME ("__" #name "ieee128"));
/* Alias name defined manually. */
# define __LDBL_REDIR1(name, proto, alias) ... unused__ldbl_redir1
# define __LDBL_REDIR1_DECL(name, alias) \
extern __typeof (name) name __asm (__ASMNAME (#alias));
# define __LDBL_REDIR1_NTH(name, proto, alias) \
__REDIRECT_NTH (name, proto, alias)
# define __REDIRECT_NTH_LDBL(name, proto, alias) \
__LDBL_REDIR1_NTH (name, proto, __##alias##ieee128)
/* Unused. */
# define __REDIRECT_LDBL(name, proto, alias) ... unused__redirect_ldbl
# define __LDBL_REDIR_NTH(name, proto) ... unused__ldbl_redir_nth
# else
_Static_assert (0, "IEEE 128-bits long double requires redirection on this platform");
# endif
#elif defined __LONG_DOUBLE_MATH_OPTIONAL && defined __NO_LONG_DOUBLE_MATH
# define __LDBL_COMPAT 1
# ifdef __REDIRECT
# define __LDBL_REDIR1(name, proto, alias) __REDIRECT (name, proto, alias)
# define __LDBL_REDIR(name, proto) \
__LDBL_REDIR1 (name, proto, __nldbl_##name)
# define __LDBL_REDIR1_NTH(name, proto, alias) __REDIRECT_NTH (name, proto, alias)
# define __LDBL_REDIR_NTH(name, proto) \
__LDBL_REDIR1_NTH (name, proto, __nldbl_##name)
# define __LDBL_REDIR2_DECL(name) \
extern __typeof (__##name) __##name __asm (__ASMNAME ("__nldbl___" #name));
# define __LDBL_REDIR1_DECL(name, alias) \
extern __typeof (name) name __asm (__ASMNAME (#alias));
# define __LDBL_REDIR_DECL(name) \
extern __typeof (name) name __asm (__ASMNAME ("__nldbl_" #name));
# define __REDIRECT_LDBL(name, proto, alias) \
__LDBL_REDIR1 (name, proto, __nldbl_##alias)
# define __REDIRECT_NTH_LDBL(name, proto, alias) \
__LDBL_REDIR1_NTH (name, proto, __nldbl_##alias)
# endif
#endif
#if (!defined __LDBL_COMPAT && __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0) \
|| !defined __REDIRECT
# define __LDBL_REDIR1(name, proto, alias) name proto
# define __LDBL_REDIR(name, proto) name proto
# define __LDBL_REDIR1_NTH(name, proto, alias) name proto __THROW
# define __LDBL_REDIR_NTH(name, proto) name proto __THROW
# define __LDBL_REDIR2_DECL(name)
# define __LDBL_REDIR_DECL(name)
# ifdef __REDIRECT
# define __REDIRECT_LDBL(name, proto, alias) __REDIRECT (name, proto, alias)
# define __REDIRECT_NTH_LDBL(name, proto, alias) \
__REDIRECT_NTH (name, proto, alias)
# endif
#endif
/* __glibc_macro_warning (MESSAGE) issues warning MESSAGE. This is
intended for use in preprocessor macros.
Note: MESSAGE must be a _single_ string; concatenation of string
literals is not supported. */
#if __GNUC_PREREQ (4,8) || __glibc_clang_prereq (3,5)
# define __glibc_macro_warning1(message) _Pragma (#message)
# define __glibc_macro_warning(message) \
__glibc_macro_warning1 (GCC warning message)
#else
# define __glibc_macro_warning(msg)
#endif
/* Generic selection (ISO C11) is a C-only feature, available in GCC
since version 4.9. Previous versions do not provide generic
selection, even though they might set __STDC_VERSION__ to 201112L,
when in -std=c11 mode. Thus, we must check for !defined __GNUC__
when testing __STDC_VERSION__ for generic selection support.
On the other hand, Clang also defines __GNUC__, so a clang-specific
check is required to enable the use of generic selection. */
#if !defined __cplusplus \
&& (__GNUC_PREREQ (4, 9) \
|| __glibc_has_extension (c_generic_selections) \
|| (!defined __GNUC__ && defined __STDC_VERSION__ \
&& __STDC_VERSION__ >= 201112L))
# define __HAVE_GENERIC_SELECTION 1
#else
# define __HAVE_GENERIC_SELECTION 0
#endif
#if __GNUC_PREREQ (10, 0)
/* Designates a 1-based positional argument ref-index of pointer type
that can be used to access size-index elements of the pointed-to
array according to access mode, or at least one element when
size-index is not provided:
access (access-mode, <ref-index> [, <size-index>]) */
# define __attr_access(x) __attribute__ ((__access__ x))
/* For _FORTIFY_SOURCE == 3 we use __builtin_dynamic_object_size, which may
use the access attribute to get object sizes from function definition
arguments, so we can't use them on functions we fortify. Drop the object
size hints for such functions. */
# if __USE_FORTIFY_LEVEL == 3
# define __fortified_attr_access(a, o, s) __attribute__ ((__access__ (a, o)))
# else
# define __fortified_attr_access(a, o, s) __attr_access ((a, o, s))
# endif
# if __GNUC_PREREQ (11, 0)
# define __attr_access_none(argno) __attribute__ ((__access__ (__none__, argno)))
# else
# define __attr_access_none(argno)
# endif
#else
# define __fortified_attr_access(a, o, s)
# define __attr_access(x)
# define __attr_access_none(argno)
#endif
#if __GNUC_PREREQ (11, 0)
/* Designates dealloc as a function to call to deallocate objects
allocated by the declared function. */
# define __attr_dealloc(dealloc, argno) \
__attribute__ ((__malloc__ (dealloc, argno)))
# define __attr_dealloc_free __attr_dealloc (__builtin_free, 1)
#else
# define __attr_dealloc(dealloc, argno)
# define __attr_dealloc_free
#endif
/* Specify that a function such as setjmp or vfork may return
twice. */
#if __GNUC_PREREQ (4, 1)
# define __attribute_returns_twice__ __attribute__ ((__returns_twice__))
#else
# define __attribute_returns_twice__ /* Ignore. */
#endif
#endif /* sys/cdefs.h */

View file

@ -1,83 +0,0 @@
/* cloexec.c - set or clear the close-on-exec descriptor flag
Copyright (C) 1991, 2004-2006, 2009-2023 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* The code is taken from glibc/manual/llio.texi */
#include <config.h>
#include "cloexec.h"
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
/* Set the 'FD_CLOEXEC' flag of DESC if VALUE is true,
or clear the flag if VALUE is false.
Return 0 on success, or -1 on error with 'errno' set.
Note that on MingW, this function does NOT protect DESC from being
inherited into spawned children. Instead, either use dup_cloexec
followed by closing the original DESC, or use interfaces such as
open or pipe2 that accept flags like O_CLOEXEC to create DESC
non-inheritable in the first place. */
int
set_cloexec_flag (int desc, bool value)
{
#ifdef F_SETFD
int flags = fcntl (desc, F_GETFD, 0);
if (0 <= flags)
{
int newflags = (value ? flags | FD_CLOEXEC : flags & ~FD_CLOEXEC);
if (flags == newflags
|| fcntl (desc, F_SETFD, newflags) != -1)
return 0;
}
return -1;
#else /* !F_SETFD */
/* Use dup2 to reject invalid file descriptors; the cloexec flag
will be unaffected. */
if (desc < 0)
{
errno = EBADF;
return -1;
}
if (dup2 (desc, desc) < 0)
/* errno is EBADF here. */
return -1;
/* There is nothing we can do on this kind of platform. Punt. */
return 0;
#endif /* !F_SETFD */
}
/* Duplicates a file handle FD, while marking the copy to be closed
prior to exec or spawn. Returns -1 and sets errno if FD could not
be duplicated. */
int
dup_cloexec (int fd)
{
return fcntl (fd, F_DUPFD_CLOEXEC, 0);
}

View file

@ -1,34 +0,0 @@
/* cloexec.c - set or clear the close-on-exec descriptor flag
Copyright (C) 2004, 2009-2023 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Set the 'FD_CLOEXEC' flag of DESC if VALUE is true,
or clear the flag if VALUE is false.
Return 0 on success, or -1 on error with 'errno' set.
Note that on MingW, this function does NOT protect DESC from being
inherited into spawned children. Instead, either use dup_cloexec
followed by closing the original DESC, or use interfaces such as
open or pipe2 that accept flags like O_CLOEXEC to create DESC
non-inheritable in the first place. */
int set_cloexec_flag (int desc, bool value);
/* Duplicates a file handle FD, while marking the copy to be closed
prior to exec or spawn. Returns -1 and sets errno if FD could not
be duplicated. */
int dup_cloexec (int fd);

View file

@ -1,75 +0,0 @@
/* close replacement.
Copyright (C) 2008-2023 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
/* Specification. */
#include <unistd.h>
#include <errno.h>
#include "fd-hook.h"
#if HAVE_MSVC_INVALID_PARAMETER_HANDLER
# include "msvc-inval.h"
#endif
#undef close
#if defined _WIN32 && !defined __CYGWIN__
# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
static int
close_nothrow (int fd)
{
int result;
TRY_MSVC_INVAL
{
result = _close (fd);
}
CATCH_MSVC_INVAL
{
result = -1;
errno = EBADF;
}
DONE_MSVC_INVAL;
return result;
}
# else
# define close_nothrow _close
# endif
#else
# define close_nothrow close
#endif
/* Override close() to call into other gnulib modules. */
int
rpl_close (int fd)
{
#if WINDOWS_SOCKETS
int retval = execute_all_close_hooks (close_nothrow, fd);
#else
int retval = close_nothrow (fd);
#endif
#if REPLACE_FCHDIR
if (retval >= 0)
_gl_unregister_fd (fd);
#endif
return retval;
}

684
gl/config.charset Normal file
View file

@ -0,0 +1,684 @@
#! /bin/sh
# Output a system dependent table of character encoding aliases.
#
# Copyright (C) 2000-2004, 2006-2013 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, see <http://www.gnu.org/licenses/>.
#
# The table consists of lines of the form
# ALIAS CANONICAL
#
# ALIAS is the (system dependent) result of "nl_langinfo (CODESET)".
# ALIAS is compared in a case sensitive way.
#
# CANONICAL is the GNU canonical name for this character encoding.
# It must be an encoding supported by libiconv. Support by GNU libc is
# also desirable. CANONICAL is case insensitive. Usually an upper case
# MIME charset name is preferred.
# The current list of GNU canonical charset names is as follows.
#
# name MIME? used by which systems
# (darwin = Mac OS X, woe32 = native Windows)
#
# ASCII, ANSI_X3.4-1968 glibc solaris freebsd netbsd darwin cygwin
# ISO-8859-1 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin
# ISO-8859-2 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin
# ISO-8859-3 Y glibc solaris cygwin
# ISO-8859-4 Y osf solaris freebsd netbsd openbsd darwin
# ISO-8859-5 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin
# ISO-8859-6 Y glibc aix hpux solaris cygwin
# ISO-8859-7 Y glibc aix hpux irix osf solaris netbsd openbsd darwin cygwin
# ISO-8859-8 Y glibc aix hpux osf solaris cygwin
# ISO-8859-9 Y glibc aix hpux irix osf solaris darwin cygwin
# ISO-8859-13 glibc netbsd openbsd darwin cygwin
# ISO-8859-14 glibc cygwin
# ISO-8859-15 glibc aix osf solaris freebsd netbsd openbsd darwin cygwin
# KOI8-R Y glibc solaris freebsd netbsd openbsd darwin
# KOI8-U Y glibc freebsd netbsd openbsd darwin cygwin
# KOI8-T glibc
# CP437 dos
# CP775 dos
# CP850 aix osf dos
# CP852 dos
# CP855 dos
# CP856 aix
# CP857 dos
# CP861 dos
# CP862 dos
# CP864 dos
# CP865 dos
# CP866 freebsd netbsd openbsd darwin dos
# CP869 dos
# CP874 woe32 dos
# CP922 aix
# CP932 aix cygwin woe32 dos
# CP943 aix
# CP949 osf darwin woe32 dos
# CP950 woe32 dos
# CP1046 aix
# CP1124 aix
# CP1125 dos
# CP1129 aix
# CP1131 darwin
# CP1250 woe32
# CP1251 glibc solaris netbsd openbsd darwin cygwin woe32
# CP1252 aix woe32
# CP1253 woe32
# CP1254 woe32
# CP1255 glibc woe32
# CP1256 woe32
# CP1257 woe32
# GB2312 Y glibc aix hpux irix solaris freebsd netbsd darwin
# EUC-JP Y glibc aix hpux irix osf solaris freebsd netbsd darwin
# EUC-KR Y glibc aix hpux irix osf solaris freebsd netbsd darwin cygwin
# EUC-TW glibc aix hpux irix osf solaris netbsd
# BIG5 Y glibc aix hpux osf solaris freebsd netbsd darwin cygwin
# BIG5-HKSCS glibc solaris darwin
# GBK glibc aix osf solaris darwin cygwin woe32 dos
# GB18030 glibc solaris netbsd darwin
# SHIFT_JIS Y hpux osf solaris freebsd netbsd darwin
# JOHAB glibc solaris woe32
# TIS-620 glibc aix hpux osf solaris cygwin
# VISCII Y glibc
# TCVN5712-1 glibc
# ARMSCII-8 glibc darwin
# GEORGIAN-PS glibc cygwin
# PT154 glibc
# HP-ROMAN8 hpux
# HP-ARABIC8 hpux
# HP-GREEK8 hpux
# HP-HEBREW8 hpux
# HP-TURKISH8 hpux
# HP-KANA8 hpux
# DEC-KANJI osf
# DEC-HANYU osf
# UTF-8 Y glibc aix hpux osf solaris netbsd darwin cygwin
#
# Note: Names which are not marked as being a MIME name should not be used in
# Internet protocols for information interchange (mail, news, etc.).
#
# Note: ASCII and ANSI_X3.4-1968 are synonymous canonical names. Applications
# must understand both names and treat them as equivalent.
#
# The first argument passed to this file is the canonical host specification,
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
# or
# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
host="$1"
os=`echo "$host" | sed -e 's/^[^-]*-[^-]*-\(.*\)$/\1/'`
echo "# This file contains a table of character encoding aliases,"
echo "# suitable for operating system '${os}'."
echo "# It was automatically generated from config.charset."
# List of references, updated during installation:
echo "# Packages using this file: "
case "$os" in
linux-gnulibc1*)
# Linux libc5 doesn't have nl_langinfo(CODESET); therefore
# localcharset.c falls back to using the full locale name
# from the environment variables.
echo "C ASCII"
echo "POSIX ASCII"
for l in af af_ZA ca ca_ES da da_DK de de_AT de_BE de_CH de_DE de_LU \
en en_AU en_BW en_CA en_DK en_GB en_IE en_NZ en_US en_ZA \
en_ZW es es_AR es_BO es_CL es_CO es_DO es_EC es_ES es_GT \
es_HN es_MX es_PA es_PE es_PY es_SV es_US es_UY es_VE et \
et_EE eu eu_ES fi fi_FI fo fo_FO fr fr_BE fr_CA fr_CH fr_FR \
fr_LU ga ga_IE gl gl_ES id id_ID in in_ID is is_IS it it_CH \
it_IT kl kl_GL nl nl_BE nl_NL no no_NO pt pt_BR pt_PT sv \
sv_FI sv_SE; do
echo "$l ISO-8859-1"
echo "$l.iso-8859-1 ISO-8859-1"
echo "$l.iso-8859-15 ISO-8859-15"
echo "$l.iso-8859-15@euro ISO-8859-15"
echo "$l@euro ISO-8859-15"
echo "$l.cp-437 CP437"
echo "$l.cp-850 CP850"
echo "$l.cp-1252 CP1252"
echo "$l.cp-1252@euro CP1252"
#echo "$l.atari-st ATARI-ST" # not a commonly used encoding
echo "$l.utf-8 UTF-8"
echo "$l.utf-8@euro UTF-8"
done
for l in cs cs_CZ hr hr_HR hu hu_HU pl pl_PL ro ro_RO sk sk_SK sl \
sl_SI sr sr_CS sr_YU; do
echo "$l ISO-8859-2"
echo "$l.iso-8859-2 ISO-8859-2"
echo "$l.cp-852 CP852"
echo "$l.cp-1250 CP1250"
echo "$l.utf-8 UTF-8"
done
for l in mk mk_MK ru ru_RU; do
echo "$l ISO-8859-5"
echo "$l.iso-8859-5 ISO-8859-5"
echo "$l.koi8-r KOI8-R"
echo "$l.cp-866 CP866"
echo "$l.cp-1251 CP1251"
echo "$l.utf-8 UTF-8"
done
for l in ar ar_SA; do
echo "$l ISO-8859-6"
echo "$l.iso-8859-6 ISO-8859-6"
echo "$l.cp-864 CP864"
#echo "$l.cp-868 CP868" # not a commonly used encoding
echo "$l.cp-1256 CP1256"
echo "$l.utf-8 UTF-8"
done
for l in el el_GR gr gr_GR; do
echo "$l ISO-8859-7"
echo "$l.iso-8859-7 ISO-8859-7"
echo "$l.cp-869 CP869"
echo "$l.cp-1253 CP1253"
echo "$l.cp-1253@euro CP1253"
echo "$l.utf-8 UTF-8"
echo "$l.utf-8@euro UTF-8"
done
for l in he he_IL iw iw_IL; do
echo "$l ISO-8859-8"
echo "$l.iso-8859-8 ISO-8859-8"
echo "$l.cp-862 CP862"
echo "$l.cp-1255 CP1255"
echo "$l.utf-8 UTF-8"
done
for l in tr tr_TR; do
echo "$l ISO-8859-9"
echo "$l.iso-8859-9 ISO-8859-9"
echo "$l.cp-857 CP857"
echo "$l.cp-1254 CP1254"
echo "$l.utf-8 UTF-8"
done
for l in lt lt_LT lv lv_LV; do
#echo "$l BALTIC" # not a commonly used encoding, wrong encoding name
echo "$l ISO-8859-13"
done
for l in ru_UA uk uk_UA; do
echo "$l KOI8-U"
done
for l in zh zh_CN; do
#echo "$l GB_2312-80" # not a commonly used encoding, wrong encoding name
echo "$l GB2312"
done
for l in ja ja_JP ja_JP.EUC; do
echo "$l EUC-JP"
done
for l in ko ko_KR; do
echo "$l EUC-KR"
done
for l in th th_TH; do
echo "$l TIS-620"
done
for l in fa fa_IR; do
#echo "$l ISIRI-3342" # a broken encoding
echo "$l.utf-8 UTF-8"
done
;;
linux* | *-gnu*)
# With glibc-2.1 or newer, we don't need any canonicalization,
# because glibc has iconv and both glibc and libiconv support all
# GNU canonical names directly. Therefore, the Makefile does not
# need to install the alias file at all.
# The following applies only to glibc-2.0.x and older libcs.
echo "ISO_646.IRV:1983 ASCII"
;;
aix*)
echo "ISO8859-1 ISO-8859-1"
echo "ISO8859-2 ISO-8859-2"
echo "ISO8859-5 ISO-8859-5"
echo "ISO8859-6 ISO-8859-6"
echo "ISO8859-7 ISO-8859-7"
echo "ISO8859-8 ISO-8859-8"
echo "ISO8859-9 ISO-8859-9"
echo "ISO8859-15 ISO-8859-15"
echo "IBM-850 CP850"
echo "IBM-856 CP856"
echo "IBM-921 ISO-8859-13"
echo "IBM-922 CP922"
echo "IBM-932 CP932"
echo "IBM-943 CP943"
echo "IBM-1046 CP1046"
echo "IBM-1124 CP1124"
echo "IBM-1129 CP1129"
echo "IBM-1252 CP1252"
echo "IBM-eucCN GB2312"
echo "IBM-eucJP EUC-JP"
echo "IBM-eucKR EUC-KR"
echo "IBM-eucTW EUC-TW"
echo "big5 BIG5"
echo "GBK GBK"
echo "TIS-620 TIS-620"
echo "UTF-8 UTF-8"
;;
hpux*)
echo "iso88591 ISO-8859-1"
echo "iso88592 ISO-8859-2"
echo "iso88595 ISO-8859-5"
echo "iso88596 ISO-8859-6"
echo "iso88597 ISO-8859-7"
echo "iso88598 ISO-8859-8"
echo "iso88599 ISO-8859-9"
echo "iso885915 ISO-8859-15"
echo "roman8 HP-ROMAN8"
echo "arabic8 HP-ARABIC8"
echo "greek8 HP-GREEK8"
echo "hebrew8 HP-HEBREW8"
echo "turkish8 HP-TURKISH8"
echo "kana8 HP-KANA8"
echo "tis620 TIS-620"
echo "big5 BIG5"
echo "eucJP EUC-JP"
echo "eucKR EUC-KR"
echo "eucTW EUC-TW"
echo "hp15CN GB2312"
#echo "ccdc ?" # what is this?
echo "SJIS SHIFT_JIS"
echo "utf8 UTF-8"
;;
irix*)
echo "ISO8859-1 ISO-8859-1"
echo "ISO8859-2 ISO-8859-2"
echo "ISO8859-5 ISO-8859-5"
echo "ISO8859-7 ISO-8859-7"
echo "ISO8859-9 ISO-8859-9"
echo "eucCN GB2312"
echo "eucJP EUC-JP"
echo "eucKR EUC-KR"
echo "eucTW EUC-TW"
;;
osf*)
echo "ISO8859-1 ISO-8859-1"
echo "ISO8859-2 ISO-8859-2"
echo "ISO8859-4 ISO-8859-4"
echo "ISO8859-5 ISO-8859-5"
echo "ISO8859-7 ISO-8859-7"
echo "ISO8859-8 ISO-8859-8"
echo "ISO8859-9 ISO-8859-9"
echo "ISO8859-15 ISO-8859-15"
echo "cp850 CP850"
echo "big5 BIG5"
echo "dechanyu DEC-HANYU"
echo "dechanzi GB2312"
echo "deckanji DEC-KANJI"
echo "deckorean EUC-KR"
echo "eucJP EUC-JP"
echo "eucKR EUC-KR"
echo "eucTW EUC-TW"
echo "GBK GBK"
echo "KSC5601 CP949"
echo "sdeckanji EUC-JP"
echo "SJIS SHIFT_JIS"
echo "TACTIS TIS-620"
echo "UTF-8 UTF-8"
;;
solaris*)
echo "646 ASCII"
echo "ISO8859-1 ISO-8859-1"
echo "ISO8859-2 ISO-8859-2"
echo "ISO8859-3 ISO-8859-3"
echo "ISO8859-4 ISO-8859-4"
echo "ISO8859-5 ISO-8859-5"
echo "ISO8859-6 ISO-8859-6"
echo "ISO8859-7 ISO-8859-7"
echo "ISO8859-8 ISO-8859-8"
echo "ISO8859-9 ISO-8859-9"
echo "ISO8859-15 ISO-8859-15"
echo "koi8-r KOI8-R"
echo "ansi-1251 CP1251"
echo "BIG5 BIG5"
echo "Big5-HKSCS BIG5-HKSCS"
echo "gb2312 GB2312"
echo "GBK GBK"
echo "GB18030 GB18030"
echo "cns11643 EUC-TW"
echo "5601 EUC-KR"
echo "ko_KR.johap92 JOHAB"
echo "eucJP EUC-JP"
echo "PCK SHIFT_JIS"
echo "TIS620.2533 TIS-620"
#echo "sun_eu_greek ?" # what is this?
echo "UTF-8 UTF-8"
;;
freebsd* | os2*)
# FreeBSD 4.2 doesn't have nl_langinfo(CODESET); therefore
# localcharset.c falls back to using the full locale name
# from the environment variables.
# Likewise for OS/2. OS/2 has XFree86 just like FreeBSD. Just
# reuse FreeBSD's locale data for OS/2.
echo "C ASCII"
echo "US-ASCII ASCII"
for l in la_LN lt_LN; do
echo "$l.ASCII ASCII"
done
for l in da_DK de_AT de_CH de_DE en_AU en_CA en_GB en_US es_ES \
fi_FI fr_BE fr_CA fr_CH fr_FR is_IS it_CH it_IT la_LN \
lt_LN nl_BE nl_NL no_NO pt_PT sv_SE; do
echo "$l.ISO_8859-1 ISO-8859-1"
echo "$l.DIS_8859-15 ISO-8859-15"
done
for l in cs_CZ hr_HR hu_HU la_LN lt_LN pl_PL sl_SI; do
echo "$l.ISO_8859-2 ISO-8859-2"
done
for l in la_LN lt_LT; do
echo "$l.ISO_8859-4 ISO-8859-4"
done
for l in ru_RU ru_SU; do
echo "$l.KOI8-R KOI8-R"
echo "$l.ISO_8859-5 ISO-8859-5"
echo "$l.CP866 CP866"
done
echo "uk_UA.KOI8-U KOI8-U"
echo "zh_TW.BIG5 BIG5"
echo "zh_TW.Big5 BIG5"
echo "zh_CN.EUC GB2312"
echo "ja_JP.EUC EUC-JP"
echo "ja_JP.SJIS SHIFT_JIS"
echo "ja_JP.Shift_JIS SHIFT_JIS"
echo "ko_KR.EUC EUC-KR"
;;
netbsd*)
echo "646 ASCII"
echo "ISO8859-1 ISO-8859-1"
echo "ISO8859-2 ISO-8859-2"
echo "ISO8859-4 ISO-8859-4"
echo "ISO8859-5 ISO-8859-5"
echo "ISO8859-7 ISO-8859-7"
echo "ISO8859-13 ISO-8859-13"
echo "ISO8859-15 ISO-8859-15"
echo "eucCN GB2312"
echo "eucJP EUC-JP"
echo "eucKR EUC-KR"
echo "eucTW EUC-TW"
echo "BIG5 BIG5"
echo "SJIS SHIFT_JIS"
;;
openbsd*)
echo "646 ASCII"
echo "ISO8859-1 ISO-8859-1"
echo "ISO8859-2 ISO-8859-2"
echo "ISO8859-4 ISO-8859-4"
echo "ISO8859-5 ISO-8859-5"
echo "ISO8859-7 ISO-8859-7"
echo "ISO8859-13 ISO-8859-13"
echo "ISO8859-15 ISO-8859-15"
;;
darwin[56]*)
# Darwin 6.8 doesn't have nl_langinfo(CODESET); therefore
# localcharset.c falls back to using the full locale name
# from the environment variables.
echo "C ASCII"
for l in en_AU en_CA en_GB en_US la_LN; do
echo "$l.US-ASCII ASCII"
done
for l in da_DK de_AT de_CH de_DE en_AU en_CA en_GB en_US es_ES \
fi_FI fr_BE fr_CA fr_CH fr_FR is_IS it_CH it_IT nl_BE \
nl_NL no_NO pt_PT sv_SE; do
echo "$l ISO-8859-1"
echo "$l.ISO8859-1 ISO-8859-1"
echo "$l.ISO8859-15 ISO-8859-15"
done
for l in la_LN; do
echo "$l.ISO8859-1 ISO-8859-1"
echo "$l.ISO8859-15 ISO-8859-15"
done
for l in cs_CZ hr_HR hu_HU la_LN pl_PL sl_SI; do
echo "$l.ISO8859-2 ISO-8859-2"
done
for l in la_LN lt_LT; do
echo "$l.ISO8859-4 ISO-8859-4"
done
for l in ru_RU; do
echo "$l.KOI8-R KOI8-R"
echo "$l.ISO8859-5 ISO-8859-5"
echo "$l.CP866 CP866"
done
for l in bg_BG; do
echo "$l.CP1251 CP1251"
done
echo "uk_UA.KOI8-U KOI8-U"
echo "zh_TW.BIG5 BIG5"
echo "zh_TW.Big5 BIG5"
echo "zh_CN.EUC GB2312"
echo "ja_JP.EUC EUC-JP"
echo "ja_JP.SJIS SHIFT_JIS"
echo "ko_KR.EUC EUC-KR"
;;
darwin*)
# Darwin 7.5 has nl_langinfo(CODESET), but sometimes its value is
# useless:
# - It returns the empty string when LANG is set to a locale of the
# form ll_CC, although ll_CC/LC_CTYPE is a symlink to an UTF-8
# LC_CTYPE file.
# - The environment variables LANG, LC_CTYPE, LC_ALL are not set by
# the system; nl_langinfo(CODESET) returns "US-ASCII" in this case.
# - The documentation says:
# "... all code that calls BSD system routines should ensure
# that the const *char parameters of these routines are in UTF-8
# encoding. All BSD system functions expect their string
# parameters to be in UTF-8 encoding and nothing else."
# It also says
# "An additional caveat is that string parameters for files,
# paths, and other file-system entities must be in canonical
# UTF-8. In a canonical UTF-8 Unicode string, all decomposable
# characters are decomposed ..."
# but this is not true: You can pass non-decomposed UTF-8 strings
# to file system functions, and it is the OS which will convert
# them to decomposed UTF-8 before accessing the file system.
# - The Apple Terminal application displays UTF-8 by default.
# - However, other applications are free to use different encodings:
# - xterm uses ISO-8859-1 by default.
# - TextEdit uses MacRoman by default.
# We prefer UTF-8 over decomposed UTF-8-MAC because one should
# minimize the use of decomposed Unicode. Unfortunately, through the
# Darwin file system, decomposed UTF-8 strings are leaked into user
# space nevertheless.
# Then there are also the locales with encodings other than US-ASCII
# and UTF-8. These locales can be occasionally useful to users (e.g.
# when grepping through ISO-8859-1 encoded text files), when all their
# file names are in US-ASCII.
echo "ISO8859-1 ISO-8859-1"
echo "ISO8859-2 ISO-8859-2"
echo "ISO8859-4 ISO-8859-4"
echo "ISO8859-5 ISO-8859-5"
echo "ISO8859-7 ISO-8859-7"
echo "ISO8859-9 ISO-8859-9"
echo "ISO8859-13 ISO-8859-13"
echo "ISO8859-15 ISO-8859-15"
echo "KOI8-R KOI8-R"
echo "KOI8-U KOI8-U"
echo "CP866 CP866"
echo "CP949 CP949"
echo "CP1131 CP1131"
echo "CP1251 CP1251"
echo "eucCN GB2312"
echo "GB2312 GB2312"
echo "eucJP EUC-JP"
echo "eucKR EUC-KR"
echo "Big5 BIG5"
echo "Big5HKSCS BIG5-HKSCS"
echo "GBK GBK"
echo "GB18030 GB18030"
echo "SJIS SHIFT_JIS"
echo "ARMSCII-8 ARMSCII-8"
echo "PT154 PT154"
#echo "ISCII-DEV ?"
echo "* UTF-8"
;;
beos* | haiku*)
# BeOS and Haiku have a single locale, and it has UTF-8 encoding.
echo "* UTF-8"
;;
msdosdjgpp*)
# DJGPP 2.03 doesn't have nl_langinfo(CODESET); therefore
# localcharset.c falls back to using the full locale name
# from the environment variables.
echo "#"
echo "# The encodings given here may not all be correct."
echo "# If you find that the encoding given for your language and"
echo "# country is not the one your DOS machine actually uses, just"
echo "# correct it in this file, and send a mail to"
echo "# Juan Manuel Guerrero <juan.guerrero@gmx.de>"
echo "# and Bruno Haible <bruno@clisp.org>."
echo "#"
echo "C ASCII"
# ISO-8859-1 languages
echo "ca CP850"
echo "ca_ES CP850"
echo "da CP865" # not CP850 ??
echo "da_DK CP865" # not CP850 ??
echo "de CP850"
echo "de_AT CP850"
echo "de_CH CP850"
echo "de_DE CP850"
echo "en CP850"
echo "en_AU CP850" # not CP437 ??
echo "en_CA CP850"
echo "en_GB CP850"
echo "en_NZ CP437"
echo "en_US CP437"
echo "en_ZA CP850" # not CP437 ??
echo "es CP850"
echo "es_AR CP850"
echo "es_BO CP850"
echo "es_CL CP850"
echo "es_CO CP850"
echo "es_CR CP850"
echo "es_CU CP850"
echo "es_DO CP850"
echo "es_EC CP850"
echo "es_ES CP850"
echo "es_GT CP850"
echo "es_HN CP850"
echo "es_MX CP850"
echo "es_NI CP850"
echo "es_PA CP850"
echo "es_PY CP850"
echo "es_PE CP850"
echo "es_SV CP850"
echo "es_UY CP850"
echo "es_VE CP850"
echo "et CP850"
echo "et_EE CP850"
echo "eu CP850"
echo "eu_ES CP850"
echo "fi CP850"
echo "fi_FI CP850"
echo "fr CP850"
echo "fr_BE CP850"
echo "fr_CA CP850"
echo "fr_CH CP850"
echo "fr_FR CP850"
echo "ga CP850"
echo "ga_IE CP850"
echo "gd CP850"
echo "gd_GB CP850"
echo "gl CP850"
echo "gl_ES CP850"
echo "id CP850" # not CP437 ??
echo "id_ID CP850" # not CP437 ??
echo "is CP861" # not CP850 ??
echo "is_IS CP861" # not CP850 ??
echo "it CP850"
echo "it_CH CP850"
echo "it_IT CP850"
echo "lt CP775"
echo "lt_LT CP775"
echo "lv CP775"
echo "lv_LV CP775"
echo "nb CP865" # not CP850 ??
echo "nb_NO CP865" # not CP850 ??
echo "nl CP850"
echo "nl_BE CP850"
echo "nl_NL CP850"
echo "nn CP865" # not CP850 ??
echo "nn_NO CP865" # not CP850 ??
echo "no CP865" # not CP850 ??
echo "no_NO CP865" # not CP850 ??
echo "pt CP850"
echo "pt_BR CP850"
echo "pt_PT CP850"
echo "sv CP850"
echo "sv_SE CP850"
# ISO-8859-2 languages
echo "cs CP852"
echo "cs_CZ CP852"
echo "hr CP852"
echo "hr_HR CP852"
echo "hu CP852"
echo "hu_HU CP852"
echo "pl CP852"
echo "pl_PL CP852"
echo "ro CP852"
echo "ro_RO CP852"
echo "sk CP852"
echo "sk_SK CP852"
echo "sl CP852"
echo "sl_SI CP852"
echo "sq CP852"
echo "sq_AL CP852"
echo "sr CP852" # CP852 or CP866 or CP855 ??
echo "sr_CS CP852" # CP852 or CP866 or CP855 ??
echo "sr_YU CP852" # CP852 or CP866 or CP855 ??
# ISO-8859-3 languages
echo "mt CP850"
echo "mt_MT CP850"
# ISO-8859-5 languages
echo "be CP866"
echo "be_BE CP866"
echo "bg CP866" # not CP855 ??
echo "bg_BG CP866" # not CP855 ??
echo "mk CP866" # not CP855 ??
echo "mk_MK CP866" # not CP855 ??
echo "ru CP866"
echo "ru_RU CP866"
echo "uk CP1125"
echo "uk_UA CP1125"
# ISO-8859-6 languages
echo "ar CP864"
echo "ar_AE CP864"
echo "ar_DZ CP864"
echo "ar_EG CP864"
echo "ar_IQ CP864"
echo "ar_IR CP864"
echo "ar_JO CP864"
echo "ar_KW CP864"
echo "ar_MA CP864"
echo "ar_OM CP864"
echo "ar_QA CP864"
echo "ar_SA CP864"
echo "ar_SY CP864"
# ISO-8859-7 languages
echo "el CP869"
echo "el_GR CP869"
# ISO-8859-8 languages
echo "he CP862"
echo "he_IL CP862"
# ISO-8859-9 languages
echo "tr CP857"
echo "tr_TR CP857"
# Japanese
echo "ja CP932"
echo "ja_JP CP932"
# Chinese
echo "zh_CN GBK"
echo "zh_TW CP950" # not CP938 ??
# Korean
echo "kr CP949" # not CP934 ??
echo "kr_KR CP949" # not CP934 ??
# Thai
echo "th CP874"
echo "th_TH CP874"
# Other
echo "eo CP850"
echo "eo_EO CP850"
;;
esac

View file

@ -1,20 +1,20 @@
/* dirname.c -- return all but the last element in a file name /* dirname.c -- return all but the last element in a file name
Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2023 Free Software Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2013 Free Software
Foundation, Inc. Foundation, Inc.
This file is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as it under the terms of the GNU General Public License as published by
published by the Free Software Foundation; either version 2.1 of the the Free Software Foundation; either version 3 of the License, or
License, or (at your option) any later version. (at your option) any later version.
This file is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h> #include <config.h>

View file

@ -1,11 +1,11 @@
/* dirname.c -- return all but the last element in a file name /* dirname.c -- return all but the last element in a file name
Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2023 Free Software Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2013 Free Software
Foundation, Inc. Foundation, Inc.
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation; either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
@ -14,7 +14,7 @@
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h> #include <config.h>

View file

@ -1,53 +1,46 @@
/* Take file names apart into directory and base names. /* Take file names apart into directory and base names.
Copyright (C) 1998, 2001, 2003-2006, 2009-2023 Free Software Foundation, Copyright (C) 1998, 2001, 2003-2006, 2009-2013 Free Software Foundation,
Inc. Inc.
This file is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as it under the terms of the GNU General Public License as published by
published by the Free Software Foundation; either version 2.1 of the the Free Software Foundation; either version 3 of the License, or
License, or (at your option) any later version. (at your option) any later version.
This file is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef DIRNAME_H_ #ifndef DIRNAME_H_
# define DIRNAME_H_ 1 # define DIRNAME_H_ 1
# include <stdlib.h> # include <stdbool.h>
# include "filename.h" # include <stddef.h>
# include "basename-lgpl.h" # include "dosname.h"
# ifndef DIRECTORY_SEPARATOR # ifndef DIRECTORY_SEPARATOR
# define DIRECTORY_SEPARATOR '/' # define DIRECTORY_SEPARATOR '/'
# endif # endif
#ifdef __cplusplus # ifndef DOUBLE_SLASH_IS_DISTINCT_ROOT
extern "C" { # define DOUBLE_SLASH_IS_DISTINCT_ROOT 0
#endif
# if GNULIB_DIRNAME
char *base_name (char const *file)
_GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
_GL_ATTRIBUTE_RETURNS_NONNULL;
char *dir_name (char const *file)
_GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
_GL_ATTRIBUTE_RETURNS_NONNULL;
# endif # endif
char *mdir_name (char const *file) # if GNULIB_DIRNAME
_GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE; char *base_name (char const *file);
char *dir_name (char const *file);
# endif
char *mdir_name (char const *file);
size_t base_len (char const *file) _GL_ATTRIBUTE_PURE;
size_t dir_len (char const *file) _GL_ATTRIBUTE_PURE; size_t dir_len (char const *file) _GL_ATTRIBUTE_PURE;
char *last_component (char const *file) _GL_ATTRIBUTE_PURE;
bool strip_trailing_slashes (char *file); bool strip_trailing_slashes (char *file);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* not DIRNAME_H_ */ #endif /* not DIRNAME_H_ */

53
gl/dosname.h Normal file
View file

@ -0,0 +1,53 @@
/* File names on MS-DOS/Windows systems.
Copyright (C) 2000-2001, 2004-2006, 2009-2013 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
From Paul Eggert and Jim Meyering. */
#ifndef _DOSNAME_H
#define _DOSNAME_H
#if (defined _WIN32 || defined __WIN32__ || \
defined __MSDOS__ || defined __CYGWIN__ || \
defined __EMX__ || defined __DJGPP__)
/* This internal macro assumes ASCII, but all hosts that support drive
letters use ASCII. */
# define _IS_DRIVE_LETTER(C) (((unsigned int) (C) | ('a' - 'A')) - 'a' \
<= 'z' - 'a')
# define FILE_SYSTEM_PREFIX_LEN(Filename) \
(_IS_DRIVE_LETTER ((Filename)[0]) && (Filename)[1] == ':' ? 2 : 0)
# ifndef __CYGWIN__
# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 1
# endif
# define ISSLASH(C) ((C) == '/' || (C) == '\\')
#else
# define FILE_SYSTEM_PREFIX_LEN(Filename) 0
# define ISSLASH(C) ((C) == '/')
#endif
#ifndef FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 0
#endif
#if FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
# define IS_ABSOLUTE_FILE_NAME(F) ISSLASH ((F)[FILE_SYSTEM_PREFIX_LEN (F)])
# else
# define IS_ABSOLUTE_FILE_NAME(F) \
(ISSLASH ((F)[0]) || FILE_SYSTEM_PREFIX_LEN (F) != 0)
#endif
#define IS_RELATIVE_FILE_NAME(F) (! IS_ABSOLUTE_FILE_NAME (F))
#endif /* DOSNAME_H_ */

Some files were not shown because too many files have changed in this diff Show more