]> git.ipfire.org Git - thirdparty/libbsd.git/log
thirdparty/libbsd.git
17 months agobuild: Refactor function checks into a new libbsd-funcs.m4 file
Guillem Jover [Tue, 20 Feb 2024 03:40:32 +0000 (04:40 +0100)] 
build: Refactor function checks into a new libbsd-funcs.m4 file

These are complex enough to clutter the main configure.ac. Move them
into their own file.

17 months agobuild: Remove space before shell redirection
Guillem Jover [Tue, 20 Feb 2024 02:57:37 +0000 (03:57 +0100)] 
build: Remove space before shell redirection

This makes it more clear what the redirection applies to.

17 months agobuild: Add support for silent rules for the libbsd.map generation
Guillem Jover [Sun, 18 Feb 2024 19:40:24 +0000 (20:40 +0100)] 
build: Add support for silent rules for the libbsd.map generation

The new rule was introduced w/o silent rule support.

Fixes: commit 19e06407eb365a2bedc9bdd29a83c1e1803e3f92
17 months agoSplit errc family of functions from err ones
Guillem Jover [Sat, 17 Feb 2024 04:25:01 +0000 (05:25 +0100)] 
Split errc family of functions from err ones

On most systems the err family of functions is already present, but are
missing the errc family of functions, which are also present on some
other systems. Splitting them into separate files will make it easer to
conditionally include one or the other.

17 months agoSync strtoi()/strtou() implementations from NetBSD
Guillem Jover [Sat, 17 Feb 2024 02:07:58 +0000 (03:07 +0100)] 
Sync strtoi()/strtou() implementations from NetBSD

These contain the fixes to the error handling logic.

In NetBSD the manual page for strtou.3 is generated from the strtoi.3
manual page applying some substitutions, the problem is that the
cross-references are then lost. We will still keep them separate.

Reported-by: Alejandro Colomar <alx@kernel.org>
17 months agobuild: Swap symbol and alias arguments order in macros creating aliases
Guillem Jover [Wed, 14 Feb 2024 02:39:16 +0000 (03:39 +0100)] 
build: Swap symbol and alias arguments order in macros creating aliases

The current order is rather confusing, pass the real symbol first
and the alias we want to create next.

17 months agobuild: Generate the map file from the configured ABI
Guillem Jover [Sun, 11 Feb 2024 18:35:05 +0000 (19:35 +0100)] 
build: Generate the map file from the configured ABI

Some linkers require the map file definitions to contain only symbols
that are present on the linked object, either in the map file or in the
sym file we generate from the map file.

This is preparatory work to be able to conditionally include symbols
in the man and sym files depending on the ABI definitions.

17 months agobuild: Make name_from_id man pages conditional instead of id_from_name
Guillem Jover [Sun, 11 Feb 2024 23:06:56 +0000 (00:06 +0100)] 
build: Make name_from_id man pages conditional instead of id_from_name

The code is only making the name_from_id function conditional, and
assumes id_from_name are always to be included, so we need to match
the logic for the man page inclusion.

18 months agoman: Mention that funopen() can be made available on musl
Guillem Jover [Mon, 8 Jan 2024 22:57:45 +0000 (23:57 +0100)] 
man: Mention that funopen() can be made available on musl

As musl got fopencookie() implemented in 1.1.19, the funopen() function
can also be provided there. Note this in the documentation.

18 months agoman: Fix manual page references
Guillem Jover [Mon, 8 Jan 2024 22:40:31 +0000 (23:40 +0100)] 
man: Fix manual page references

When referring to another manual page and their section number, we need
to use Xr instead of Fn, otherwise the section number is interpreted as
a function argument. For functions provided by libbsd itself we should
be using the 3bsd section instead of 3.

18 months agoman: Add closefrom(), strlcpy() and strlcat() as superseded functions
Guillem Jover [Mon, 8 Jan 2024 22:39:19 +0000 (23:39 +0100)] 
man: Add closefrom(), strlcpy() and strlcat() as superseded functions

These were missing from the list of functions provided by some libc
implementation.

18 months agodoc: Use macOS to refer to the operating system
Guillem Jover [Mon, 8 Jan 2024 22:37:43 +0000 (23:37 +0100)] 
doc: Use macOS to refer to the operating system

This is the correct spelling, instead of capitalizing it.

18 months agoRelease libbsd 0.11.8 0.11.8
Guillem Jover [Mon, 8 Jan 2024 01:16:12 +0000 (02:16 +0100)] 
Release libbsd 0.11.8

18 months agotest: Close all descriptors before initializing them for closefrom()
Guillem Jover [Mon, 8 Jan 2024 00:58:54 +0000 (01:58 +0100)] 
test: Close all descriptors before initializing them for closefrom()

On macOS, closefrom() only sets the close-on-exec flag, so we cannot
check whether all file descriptors were closed, which means that if
on entry our file descriptor table was filled after the 4th file
descriptor, then we might fail the assertions for the flags for odd
file descriptors which we expect to be closed.

This can easily happen when running the test suite in parallel mode
with «make -j8 check» for example.

Closes: #23
18 months agobuild: Check out-of-tree builds in CI
Guillem Jover [Fri, 27 Oct 2023 22:52:31 +0000 (00:52 +0200)] 
build: Check out-of-tree builds in CI

Make sure the out-of-tree builds do not regress.

18 months agoAdjust strlcpy() and strlcat() per glibc adoption
Guillem Jover [Sun, 7 Jan 2024 16:43:12 +0000 (17:43 +0100)] 
Adjust strlcpy() and strlcat() per glibc adoption

These functions were added in glibc 2.38, in anticipation of POSIX
adopting them too.

Closes: #26
18 months agoDo not add a pointer to the NULL constant
Guillem Jover [Tue, 14 Nov 2023 18:15:11 +0000 (19:15 +0100)] 
Do not add a pointer to the NULL constant

Warned-by: cppcheck (nullPointerArithmetic)
18 months agoDo not confuse code analyzers with out-of-bounds array access look alike
Guillem Jover [Tue, 14 Nov 2023 18:09:25 +0000 (19:09 +0100)] 
Do not confuse code analyzers with out-of-bounds array access look alike

The code is only getting the address, but we might be performing an
addressing that is out-of-bounds. Avoid it and use the address form
instead.

Warned-by: cppcheck (objectIndex)
18 months agotest: Fix short-lived memory leak
Guillem Jover [Tue, 14 Nov 2023 18:08:15 +0000 (19:08 +0100)] 
test: Fix short-lived memory leak

Warned-by: cppcheck
21 months agobuild: Add a coverage regex to the CI job
Guillem Jover [Fri, 27 Oct 2023 22:47:26 +0000 (00:47 +0200)] 
build: Add a coverage regex to the CI job

This is needed so that gitlab can know where to extract the coverage
percentage from in the output, to be able to track and report it.

21 months agoman: Use VARIANTS instead of ALTERNATIVES in libbsd(7)
Guillem Jover [Mon, 9 Oct 2023 23:53:32 +0000 (01:53 +0200)] 
man: Use VARIANTS instead of ALTERNATIVES in libbsd(7)

Using alternatives seems confusing in this context.

21 months agoman: Markup function references with Xr instead of Fn
Guillem Jover [Mon, 9 Oct 2023 23:52:37 +0000 (01:52 +0200)] 
man: Markup function references with Xr instead of Fn

These references had man page sections in them, so using Fn meant that
these appeared as function arguments.

22 months agobuild: Add missing dash to macro title bar
Guillem Jover [Tue, 5 Sep 2023 01:02:44 +0000 (03:02 +0200)] 
build: Add missing dash to macro title bar

22 months agopwcache: Do not declare uidtb and gidtb when not used
Guillem Jover [Thu, 27 Jul 2023 11:57:51 +0000 (13:57 +0200)] 
pwcache: Do not declare uidtb and gidtb when not used

When the system provides implementations for user_from_uid() or
group_from_gid() we are not using these variables, so better not declare
them.

Fixes: commit 21d12b02112097f0c195dceb1892c95b7b957b36
22 months agofgetln: Include <stdio.h> after <sys/*>
Guillem Jover [Thu, 27 Jul 2023 11:39:00 +0000 (13:39 +0200)] 
fgetln: Include <stdio.h> after <sys/*>

The <sys/*> headers tend to define things that might be used by other
headers, so while they should be self-contained, it is better to simply
include them first.

22 months agobuild: Refactor GNU .init_array support check into a new m4 function
Guillem Jover [Fri, 26 May 2023 21:55:40 +0000 (23:55 +0200)] 
build: Refactor GNU .init_array support check into a new m4 function

2 years agobuild: Refactor linker script detection into a new m4 function
Guillem Jover [Fri, 26 May 2023 21:50:10 +0000 (23:50 +0200)] 
build: Refactor linker script detection into a new m4 function

2 years agobuild: Do not provide prototypes for arc4random() on Solaris
Guillem Jover [Thu, 27 Jul 2023 11:51:36 +0000 (13:51 +0200)] 
build: Do not provide prototypes for arc4random() on Solaris

These functions are provided by the system.

2 years agobuild: Do not build the progname module if it is not needed
Guillem Jover [Sat, 22 Apr 2023 18:47:20 +0000 (20:47 +0200)] 
build: Do not build the progname module if it is not needed

This was made conditional, but the code part was accidentally left
untouched due to having ported it locally to use __progname, which
caused build failures on the stock repo.

Fixes: commit 046621d7967e7a0f08ae988bcf7e4cd1b6cf204c
2 years agobuild: Sort entries alphabetically
Guillem Jover [Sun, 23 Apr 2023 00:04:47 +0000 (02:04 +0200)] 
build: Sort entries alphabetically

2 years agobuild: Conditionalize wcslcpy() and wcslcat() functions on macOS
Guillem Jover [Sun, 23 Apr 2023 00:05:04 +0000 (02:05 +0200)] 
build: Conditionalize wcslcpy() and wcslcat() functions on macOS

These functions are provided by the system libc.

2 years agobuild: Conditionalize only id-from-name functions not the entire pwcache
Guillem Jover [Sun, 23 Apr 2023 00:00:10 +0000 (02:00 +0200)] 
build: Conditionalize only id-from-name functions not the entire pwcache

On macOS the name-from-id functions are present, but not the
id-from-name ones, so we want to provide those instead of suppressing
the entire file.

2 years agobuild: Conditionalize getprogname()/setprogname on macOS
Guillem Jover [Sat, 22 Apr 2023 20:47:10 +0000 (22:47 +0200)] 
build: Conditionalize getprogname()/setprogname on macOS

These functions are provided by the system libc, so there is no need for
us to provide them.

2 years agoprogname: Include <procinfo.h> if available
Guillem Jover [Sat, 22 Apr 2023 18:23:08 +0000 (20:23 +0200)] 
progname: Include <procinfo.h> if available

We need this header on AIX. Missed transplanting the code from the AIX
porting system.

Fixes: commit 9fa06763a1afe0946a3a20e5bbdba72885cbade5
2 years agobuild: Check whether we need libperfstat on AIX
Guillem Jover [Tue, 18 Apr 2023 01:56:16 +0000 (03:56 +0200)] 
build: Check whether we need libperfstat on AIX

The getentropy() implementation makes use of this library on AIX.

2 years agobuild: Annotate droppable functions for musl on next SOVERSION bump
Guillem Jover [Tue, 18 Apr 2023 01:59:17 +0000 (03:59 +0200)] 
build: Annotate droppable functions for musl on next SOVERSION bump

These are already provided by the musl libc, and can thus be dropped on
the next SOVERSION bump.

2 years agobuild: Conditionalize bsd_getopt() on macOS
Guillem Jover [Tue, 18 Apr 2023 01:58:24 +0000 (03:58 +0200)] 
build: Conditionalize bsd_getopt() on macOS

The system library provides a getopt() with BSD semantics.

2 years agoMove the version script comments before the symbols
Guillem Jover [Mon, 17 Apr 2023 22:47:12 +0000 (00:47 +0200)] 
Move the version script comments before the symbols

When generating the .sym export file from the .map file, we are not
stripping these comments that are part of the same line as the symbol,
which causes ld(1) implementations to error out. Moving them before
the symbols avoids the need to strip them, as we are only keeping
actual symbol lines.

2 years agoPort getprogname() to AIX
Guillem Jover [Mon, 17 Apr 2023 22:44:49 +0000 (00:44 +0200)] 
Port getprogname() to AIX

Get the program name from the COMM field from the proc filesystem.

We could use instead the information from the psinfo binary file under
/proc, but that seems to have a shorter string limit.

2 years agoMake getprogname() porting mandatory
Guillem Jover [Mon, 17 Apr 2023 21:59:03 +0000 (23:59 +0200)] 
Make getprogname() porting mandatory

Although the function is documented as possibly returning NULL if it
cannot find a known source of information, we should still at least
attempt to port it to any supported system, and otherwise explicitly
mark it as not implementable for such systems if that was to be the
case.

2 years agotest: Do not use /dev/null as compiler output file
Guillem Jover [Mon, 17 Apr 2023 21:59:19 +0000 (23:59 +0200)] 
test: Do not use /dev/null as compiler output file

Some ld(1) implementations, such as the one on AIX, do not support using
/dev/null as the output filename for the compiled object.

Use an actual filename that we will then clean up.

2 years agobuild: Add generated *.sym files to .gitignore
Guillem Jover [Mon, 17 Apr 2023 22:49:09 +0000 (00:49 +0200)] 
build: Add generated *.sym files to .gitignore

2 years agobuild: On macOS do not build functions provided by the system
Guillem Jover [Tue, 4 Apr 2023 21:59:05 +0000 (23:59 +0200)] 
build: On macOS do not build functions provided by the system

We have never built before on macOS, so we can exclude all the functions
that are currently provided in the system.

Closes: #1
Closes: !3
2 years agobuild: Select whether to include funopen() in the build system
Guillem Jover [Thu, 6 Apr 2023 21:05:27 +0000 (23:05 +0200)] 
build: Select whether to include funopen() in the build system

This makes sure we include it when expected, alongside the man pages,
and the test cases, and do not accidentally break the ABI if the system
starts providing such interface.

2 years agobuild: Move Windows OS detection to the OS features section
Guillem Jover [Fri, 7 Apr 2023 21:43:55 +0000 (23:43 +0200)] 
build: Move Windows OS detection to the OS features section

This was placed here to make use of the same AS_CASE, but it does not
really fit with the section. Move it to the more appropriate place, and
detangle the AS_CASE.

2 years agobuild: Remove __MUSL__ definition from configure
Guillem Jover [Fri, 7 Apr 2023 21:40:22 +0000 (23:40 +0200)] 
build: Remove __MUSL__ definition from configure

We stopped relying on this macro when we turned the funopen() cpp error
into a warning in commit e50896286cc5718898194edb73fa7262ad9a22db.

2 years agobuild: Add a new libbsd_strong_alias() macro and switch users to it
Guillem Jover [Sun, 2 Apr 2023 20:33:25 +0000 (22:33 +0200)] 
build: Add a new libbsd_strong_alias() macro and switch users to it

We had several cases of code needing a strong alias, so we switch those
to use the new macro. This covers systems that support the alias
attribute and others such as macOS where we need to use assembler
directives to add the alias as the attribute is not supported.

2 years agobuild: Only emit link warnings for ELF objects
Guillem Jover [Sun, 2 Apr 2023 20:32:11 +0000 (22:32 +0200)] 
build: Only emit link warnings for ELF objects

2 years agobuild: Use an export symbols file if there is no version script support
Guillem Jover [Mon, 10 Apr 2023 22:24:13 +0000 (00:24 +0200)] 
build: Use an export symbols file if there is no version script support

We generate the symbol list from the version script to avoid repeating
ourselves and potentially getting the lists out-of-sync.

2 years agobuild: Add -no-undefined libtool flag
Guillem Jover [Tue, 11 Apr 2023 01:03:54 +0000 (03:03 +0200)] 
build: Add -no-undefined libtool flag

We have no need for undefined symbols, so we can let the shared
library build even on systems without support for undefined symbols.

2 years agobuild: Do not override the default DEPENDENCIES for libbsd
Guillem Jover [Tue, 11 Apr 2023 01:02:30 +0000 (03:02 +0200)] 
build: Do not override the default DEPENDENCIES for libbsd

Extend it instead via EXTRA_*_DEPENDENCIES, to make sure that we
preserve the builtin library dependencies generated from LIBADD.

2 years agoOnly use <stdio_ext.h> if present
Guillem Jover [Sat, 1 Apr 2023 10:46:49 +0000 (12:46 +0200)] 
Only use <stdio_ext.h> if present

2 years agoDefine _NSIG if it is not defined by the system
Guillem Jover [Sat, 1 Apr 2023 10:45:04 +0000 (12:45 +0200)] 
Define _NSIG if it is not defined by the system

At least on macOS this macro is not defined.

2 years agoDeclare environ if the system does not do so
Guillem Jover [Sat, 1 Apr 2023 10:41:42 +0000 (12:41 +0200)] 
Declare environ if the system does not do so

The environ variable is supposed to be defined by the code using it, but
on glibc-based systems it will get defined if we request it, by including
<unistd.h> and defining _GNU_SOURCE.

2 years agoUse lockf() when flock() is not available
Guillem Jover [Mon, 10 Apr 2023 21:10:40 +0000 (23:10 +0200)] 
Use lockf() when flock() is not available

On Solaris flock() is not available, and we should use instead lockf()
or fcntl().

2 years agotest: Use open_memstream() only if available
Guillem Jover [Mon, 10 Apr 2023 21:11:33 +0000 (23:11 +0200)] 
test: Use open_memstream() only if available

On Solaris this function is not yet available.

2 years agotest: Do not hardcode root:root user and group names
Guillem Jover [Mon, 10 Apr 2023 18:57:14 +0000 (20:57 +0200)] 
test: Do not hardcode root:root user and group names

On some systems the root group is named wheel, and there is no root
group.

2 years agotest: Fix closefrom() test on macOS
Guillem Jover [Sat, 1 Apr 2023 00:46:22 +0000 (02:46 +0200)] 
test: Fix closefrom() test on macOS

On macOS we do not close the file descriptors, and instead mark them all
as close-on-exec. So checking whether they are not valid does not work.

2 years agotest: Fix closefrom() test to handle open file descriptor limits
Guillem Jover [Sat, 1 Apr 2023 00:48:47 +0000 (02:48 +0200)] 
test: Fix closefrom() test to handle open file descriptor limits

If the system has configured a lower limit (either soft or hard) on the
number of open file descriptors, the test will fail. Make sure to check
whether we have exceeded that limit and adapt the max number of file
descriptors appropriately.

2 years agotest: Disable blank_stack_side_effects() on non-Hurd systems
Guillem Jover [Tue, 4 Apr 2023 22:01:42 +0000 (00:01 +0200)] 
test: Disable blank_stack_side_effects() on non-Hurd systems

This code was added to cope with Hurd specific behavior, but it is
causing flakiness on containers on some Linux systems. Only enable
it where it is currently needed to try to get stability back on CI
systems.

Closes: #14
2 years agobuild: Do not enable ASAN for musl CI pipelines
Guillem Jover [Wed, 29 Mar 2023 07:35:27 +0000 (09:35 +0200)] 
build: Do not enable ASAN for musl CI pipelines

musl-libc does not currently support ASAN, so enabling it makes
configure fail to detect libmd as it cannot link to it anymore.

2 years agoman: Add HISTORY section to arc4random(3bsd)
Guillem Jover [Wed, 29 Mar 2023 00:32:37 +0000 (02:32 +0200)] 
man: Add HISTORY section to arc4random(3bsd)

2 years agoman: Switch arc4random(3bsd) man page from OpenBSD to NetBSD
Guillem Jover [Wed, 29 Mar 2023 00:28:52 +0000 (02:28 +0200)] 
man: Switch arc4random(3bsd) man page from OpenBSD to NetBSD

This gets rid of the last BSD-4-clause licensed file in the project.

The man page will probably need to be adapted to the current
implementation, but that can be done piecemeal afterwards.

Closes: #7
2 years agodoc: Remove written-by attribution
Guillem Jover [Tue, 14 Mar 2023 00:58:40 +0000 (01:58 +0100)] 
doc: Remove written-by attribution

While attribution is important, it is not relevant when tracking the
copyright holders for the work. And in any case it still stays in the
relevant source file.

2 years agobuild: Add support for sanitizer compiler flags
Guillem Jover [Sat, 20 Feb 2021 21:23:40 +0000 (22:23 +0100)] 
build: Add support for sanitizer compiler flags

2 years agotest: Exempt blank_stack_side_effects() from sanitizer checks
Guillem Jover [Tue, 21 Mar 2023 03:11:03 +0000 (04:11 +0100)] 
test: Exempt blank_stack_side_effects() from sanitizer checks

This will mean we cannot use sanitizer support on the Hurd, for which
this function was added to fix the test. But the sanitizer suppression
function attribute is not having any effect, so this is better than
nothing.

2 years agotest: Import explicit_bzero() sanitizer support changes from OpenBSD
Guillem Jover [Tue, 21 Mar 2023 03:10:33 +0000 (04:10 +0100)] 
test: Import explicit_bzero() sanitizer support changes from OpenBSD

2 years agotest: Fix memory leaks in fpurge test
Guillem Jover [Tue, 14 Mar 2023 02:05:58 +0000 (03:05 +0100)] 
test: Fix memory leaks in fpurge test

Warned-by: gcc -fsanitize=leak
2 years agoman: Fix BSD and glibc versions
Guillem Jover [Fri, 3 Mar 2023 00:27:31 +0000 (01:27 +0100)] 
man: Fix BSD and glibc versions

The versions used in the BSD macros are unknown, so they emit warnings,
extend or reduce them to use the two digit form. Correct the glibc
version when closefrom(3) got introduced.

2 years agoman: Update STANDARDS and HISTORY sections
Guillem Jover [Sun, 19 Feb 2023 23:11:10 +0000 (00:11 +0100)] 
man: Update STANDARDS and HISTORY sections

Include BSD versions when functions were introduced. Add mention
whether these are BSD extensions.

2 years agoinclude: Adjust closefrom() per glibc adoption
Callum Farmer [Thu, 16 Feb 2023 21:26:05 +0000 (21:26 +0000)] 
include: Adjust closefrom() per glibc adoption

Added in glibc 2.34
https://sourceware.org/git/?p=glibc.git;a=commit;h=607449506f197cc9514408908f41f22537a47a8c

Signed-off-by: Guillem Jover <guillem@hadrons.org>
2 years agobuild: Switch to debian:latest Docker image
Guillem Jover [Fri, 17 Feb 2023 21:28:45 +0000 (22:28 +0100)] 
build: Switch to debian:latest Docker image

This should always point to the latest Debian stable images.

2 years agobuild: Fix version script linker support detection
Guillem Jover [Sun, 12 Feb 2023 22:55:09 +0000 (23:55 +0100)] 
build: Fix version script linker support detection

When the linker uses --no-undefined-version either specified by the user
or as the default behavior (such as with newer clang >= 16 releases),
a missing symbol definition will cause a linker error if that symbol is
listed in the version script.

2 years agoinclude: Use __has_builtin to detect __builtin_offsetof support
Guillem Jover [Tue, 20 Dec 2022 21:47:02 +0000 (22:47 +0100)] 
include: Use __has_builtin to detect __builtin_offsetof support

The __has_builtin operator is more specific and is supported by GCC
and Clang, while __is_identifier() is less specific and only supported
by Clang, so we should prefer the former whenever it is available, and
only fallback to use the latter when the former is missing and the
latter.

2 years agofunopen: Replace off64_t with off_t in funopen_seek()
Khem Raj [Thu, 15 Dec 2022 17:02:22 +0000 (09:02 -0800)] 
funopen: Replace off64_t with off_t in funopen_seek()

AC_SYS_LARGEFILE in configure.ac is setting needed defines to make
64bit off_t on relevant platforms.

Fixes build on musl:

| src/funopen.c:68:28: error: unknown type name 'off64_t'; did you mean 'off_t'?
| funopen_seek(void *cookie, off64_t *offset, int whence)
|                            ^~~~~~~
|                            off_t

Closes: !24
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Guillem Jover <guillem@hadrons.org>
2 years agoman: Prune unneeded <sys/types.h> include in setproctitle(3)
Guilherme Janczak [Wed, 7 Dec 2022 04:06:37 +0000 (04:06 +0000)] 
man: Prune unneeded <sys/types.h> include in setproctitle(3)

FreeBSD first declared the function in unistd.h in 2000:
https://cgit.freebsd.org/src/commit/include/unistd.h?id=9feac5c21886
No other #include line was needed to use the function, but the man page
unnecessarily instructed users to include sys/types.h until 2022-11-29:
https://cgit.freebsd.org/src/commit/?id=5b6f0a5012e9bc37dcb32b57b41e2443a46da620

libbsd first declared the function in unistd.h in 2010 with commit
3fed78e5b08f78256e533788b4bcd6502b0949d7 and inherited the bug from
FreeBSD's man page.

No need to do anything for backwards compat.

Signed-off-by: Guillem Jover <guillem@hadrons.org>
2 years agobuild: Improve C99 compatibility of __progname configure check
Florian Weimer [Tue, 13 Dec 2022 02:37:06 +0000 (03:37 +0100)] 
build: Improve C99 compatibility of __progname configure check

The check uses printf, so it needs to include <stdio.h> for
compilers which do not support implicit function declarations.
(They were removed from C99.)

Closes: !23
Signed-off-by: Guillem Jover <guillem@hadrons.org>
2 years agobuild: Enable -Wall for automake
Guillem Jover [Tue, 13 Dec 2022 02:35:05 +0000 (03:35 +0100)] 
build: Enable -Wall for automake

This will make sure to warn about bogus or deprecated constructs.

2 years agobuild: Add missing AM_PROG_AR macro call to configure.ac
Guillem Jover [Tue, 13 Dec 2022 02:34:37 +0000 (03:34 +0100)] 
build: Add missing AM_PROG_AR macro call to configure.ac

Warned-by: autoreconf
2 years agobuild: Fix configure.ac indentation
Guillem Jover [Tue, 13 Dec 2022 02:31:38 +0000 (03:31 +0100)] 
build: Fix configure.ac indentation

Use the same style as the newly added code, which should make the code
more readable, and produce more conforming C output.

2 years agobuild: Require automake 1.11
Guillem Jover [Tue, 13 Dec 2022 02:10:28 +0000 (03:10 +0100)] 
build: Require automake 1.11

This is a rather old release (from 2009), that provides AM_SILENT_RULES.

2 years agobuild: Do not require funopen() to be ported
Guillem Jover [Wed, 23 Nov 2022 22:31:54 +0000 (23:31 +0100)] 
build: Do not require funopen() to be ported

This function cannot be easily and (more importantly) correctly ported
without cooperation from the libc stdio layer. We already document that
users should be prepared to have the function not available on some
platforms and that they should ideally switch their code to other
more portable and better interfaces.

Instead of making the build fail, and requiring porters to add
exceptions for something that most probably cannot be ported correctly
anyway, simply print a warning and let it build. This will not be a
regression because on those systems libbsd would have never been built
before.

Prompted-by: Jens Finkhaeuser <jens@finkhaeuser.de>
2 years agobuild: Terminate lists in variables with «# EOL»
Guillem Jover [Wed, 23 Nov 2022 22:28:34 +0000 (23:28 +0100)] 
build: Terminate lists in variables with «# EOL»

This means we can add a trailing «\» to every element, so that they
can be removed without requiring modification of other lines, and can
be easily sorted.

Replace the old usage of $(nil) which could possibly end up with junk
added if such variable is ever defined, in the environment.

2 years agobuild: Use «yes» instead of «true» for AC_CHECK_FUNCS cache value
Guillem Jover [Wed, 23 Nov 2022 22:42:49 +0000 (23:42 +0100)] 
build: Use «yes» instead of «true» for AC_CHECK_FUNCS cache value

This autoconf macro sets the ac_cv_func_ cached variable to «yes» not
«true» so we were checking for an impossible condition.

2 years agoRelease libbsd 0.11.7 0.11.7
Guillem Jover [Thu, 6 Oct 2022 02:07:52 +0000 (04:07 +0200)] 
Release libbsd 0.11.7

2 years agoman: Discourage using the library in non-overlay mode
Guillem Jover [Thu, 6 Oct 2022 01:59:33 +0000 (03:59 +0200)] 
man: Discourage using the library in non-overlay mode

This makes code using it non-portable, and requires the namespeced
headers from libbsd, instead of any generic system headers. It also
requires more code changes than the overlay mode.

2 years agoinclude: Adjust reallocarray() per glibc adoption
Guillem Jover [Wed, 5 Oct 2022 10:08:31 +0000 (12:08 +0200)] 
include: Adjust reallocarray() per glibc adoption

On glibc 2.29 reallocarray() was moved to _DEFAULT_SOURCE.

Closes: !20
Based-on-patch-by: Callum Farmer <gmbr3@opensuse.org>
Signed-off-by: Guillem Jover <guillem@hadrons.org>
2 years agoinclude: Adjust arc4random() per glibc adoption
Callum Farmer [Wed, 5 Oct 2022 10:08:31 +0000 (12:08 +0200)] 
include: Adjust arc4random() per glibc adoption

Some arc4random functions were added in glibc 2.36.

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
Signed-off-by: Guillem Jover <guillem@hadrons.org>
2 years agoinclude: explicit_bzero() requires _DEFAULT_SOURCE
Callum Farmer [Mon, 3 Oct 2022 15:09:18 +0000 (16:09 +0100)] 
include: explicit_bzero() requires _DEFAULT_SOURCE

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
Signed-off-by: Guillem Jover <guillem@hadrons.org>
2 years agoinclude: Simplify glibc version dependent macro handling
Guillem Jover [Wed, 5 Oct 2022 00:05:46 +0000 (02:05 +0200)] 
include: Simplify glibc version dependent macro handling

We test once whether __GLIBC__ is not defined, so we do not need to test
whether it is on the OR branch afterwards. We decouple the glibc version
restriction check from the _*_SOURCE variable, as that contains an
implicit opposite version check.

2 years agodoc: Switch references from pkg-config to pkgconf
Guillem Jover [Tue, 4 Oct 2022 23:35:08 +0000 (01:35 +0200)] 
doc: Switch references from pkg-config to pkgconf

The former used to be the reference implementation, but it has been
stagnant to the point of not showing much signs of life. Switch to
the currently active and more complete implementation for references.

2 years agodoc: Add missing empty line to separate README sections
Guillem Jover [Tue, 4 Oct 2022 02:28:05 +0000 (04:28 +0200)] 
doc: Add missing empty line to separate README sections

2 years agodoc: Refer to the main git repository as primary
Guillem Jover [Tue, 4 Oct 2022 02:27:44 +0000 (04:27 +0200)] 
doc: Refer to the main git repository as primary

2 years agotest: Fix explicit_bzero() test on the Hurd
Guillem Jover [Wed, 24 Aug 2022 22:52:43 +0000 (00:52 +0200)] 
test: Fix explicit_bzero() test on the Hurd

On the Hurd a small read(3) might end up (indirectly) copying the data
on the stack, which we will end up finding even when we have cleared
the buffer.

To avoid these side effects, we add a new function, that we force not
to be inlined, so that we can reuse the same stack space, that will
blank any possible stack side effects. This should be portable
regardless of stack growing up or down.

Diagnosis-by: Samuel Thibault <sthibault@debian.org>
2 years agofgetwln: Add comment about lack of getwline(3) for recommendation
Guillem Jover [Tue, 23 Aug 2022 23:58:58 +0000 (01:58 +0200)] 
fgetwln: Add comment about lack of getwline(3) for recommendation

Ideally we'd recommend getwline(3), but unfortunately even though it
was part of the ISO/IEC TR 24731-2:2010 draft, it did not make it into
C11 and is not widely implemented.

2 years agosetmode: Dot not use saveset after free
Guillem Jover [Tue, 23 Aug 2022 21:49:34 +0000 (23:49 +0200)] 
setmode: Dot not use saveset after free

While we are only doing a pointer difference and not dereferencing it,
it's easier and more correct to do the pointer difference before passing
it to reallocarray().

Warned-by: gcc
3 years agoman: Rewrite gerprogname(3bsd) from scratch
Guillem Jover [Wed, 3 Aug 2022 01:05:52 +0000 (03:05 +0200)] 
man: Rewrite gerprogname(3bsd) from scratch

This gets rid of one of the last man pages with a BSD-4-clause license.

3 years agoman: Lowercase man page title
Guillem Jover [Wed, 3 Aug 2022 00:21:16 +0000 (02:21 +0200)] 
man: Lowercase man page title

While using fully uppercase man page titles has been the usual
convention for a very long time, it is rather ugly and something that
some other projects are switching away from.

3 years agoman: Document that some arc4random(3) functions are now in glibc 2.36
Guillem Jover [Tue, 2 Aug 2022 23:23:09 +0000 (01:23 +0200)] 
man: Document that some arc4random(3) functions are now in glibc 2.36

3 years agoSync arc4random(3) implementation from OpenBSD
Guillem Jover [Wed, 3 Aug 2022 00:03:05 +0000 (02:03 +0200)] 
Sync arc4random(3) implementation from OpenBSD

Closes: #12