Commit Graph

627 Commits

Author SHA1 Message Date
Guillem Jover
fe16f3863e test: Use open_memstream() only if available
On Solaris this function is not yet available.
2023-04-17 04:12:42 +02:00
Guillem Jover
7c652a94ea 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.
2023-04-17 04:12:42 +02:00
Guillem Jover
ed2eb31da9 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.
2023-04-17 04:12:42 +02:00
Guillem Jover
0f8bcdfd92 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.
2023-04-17 04:12:42 +02:00
Guillem Jover
07192b31e3 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
2023-04-17 04:12:32 +02:00
Guillem Jover
ca3db5e134 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.
2023-03-29 09:35:27 +02:00
Guillem Jover
ff46386fcb man: Add HISTORY section to arc4random(3bsd) 2023-03-29 02:49:28 +02:00
Guillem Jover
4c6da577a1 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
2023-03-29 02:48:53 +02:00
Guillem Jover
830dd88a98 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.
2023-03-29 02:48:20 +02:00
Guillem Jover
257800a03c build: Add support for sanitizer compiler flags 2023-03-29 02:48:20 +02:00
Guillem Jover
536a7d42fd 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.
2023-03-29 02:47:18 +02:00
Guillem Jover
7ed5de0158 test: Import explicit_bzero() sanitizer support changes from OpenBSD 2023-03-29 02:38:26 +02:00
Guillem Jover
05a802a2c1 test: Fix memory leaks in fpurge test
Warned-by: gcc -fsanitize=leak
2023-03-21 04:13:32 +01:00
Guillem Jover
5962e03c2d 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.
2023-03-03 01:35:31 +01:00
Guillem Jover
59a21c7fb8 man: Update STANDARDS and HISTORY sections
Include BSD versions when functions were introduced. Add mention
whether these are BSD extensions.
2023-02-20 00:29:01 +01:00
Callum Farmer
7b4ebd6521 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>
2023-02-17 22:29:26 +01:00
Guillem Jover
0dfbe7699e build: Switch to debian:latest Docker image
This should always point to the latest Debian stable images.
2023-02-17 22:29:26 +01:00
Guillem Jover
dec783dce5 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.
2023-02-13 00:42:02 +01:00
Guillem Jover
fe21244b05 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.
2023-02-13 00:39:54 +01:00
Khem Raj
ec88b7bbbc 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>
2022-12-17 18:22:26 +01:00
Guilherme Janczak
23377191e8 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
3fed78e5b0 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>
2022-12-13 03:49:29 +01:00
Florian Weimer
5dea9da38d 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>
2022-12-13 03:49:29 +01:00
Guillem Jover
b9bf42ddc3 build: Enable -Wall for automake
This will make sure to warn about bogus or deprecated constructs.
2022-12-13 03:49:03 +01:00
Guillem Jover
e57c07875c build: Add missing AM_PROG_AR macro call to configure.ac
Warned-by: autoreconf
2022-12-13 03:48:51 +01:00
Guillem Jover
80f1927dcd 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.
2022-12-13 03:48:31 +01:00
Guillem Jover
b7a8bc22c9 build: Require automake 1.11
This is a rather old release (from 2009), that provides AM_SILENT_RULES.
2022-12-13 03:10:28 +01:00
Guillem Jover
e50896286c 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>
2022-11-24 23:23:33 +01:00
Guillem Jover
00b538ffa3 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.
2022-11-23 23:44:09 +01:00
Guillem Jover
5cfa39e5cd 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.
2022-11-23 23:42:49 +01:00
Guillem Jover
084911ce87 Release libbsd 0.11.7 2022-10-06 04:07:52 +02:00
Guillem Jover
3538d38fe7 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.
2022-10-06 03:59:33 +02:00
Guillem Jover
03fccd1505 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>
2022-10-05 12:31:49 +02:00
Callum Farmer
6b6e686b23 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>
2022-10-05 12:31:49 +02:00
Callum Farmer
da1f45ac71 include: explicit_bzero() requires _DEFAULT_SOURCE
Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
Signed-off-by: Guillem Jover <guillem@hadrons.org>
2022-10-05 12:15:36 +02:00
Guillem Jover
2f9eddc277 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.
2022-10-05 12:12:34 +02:00
Guillem Jover
28298ac037 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.
2022-10-05 01:36:28 +02:00
Guillem Jover
ef981f930b doc: Add missing empty line to separate README sections 2022-10-04 04:29:37 +02:00
Guillem Jover
6928d7895e doc: Refer to the main git repository as primary 2022-10-04 04:29:37 +02:00
Guillem Jover
d5865759f8 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>
2022-10-04 04:29:37 +02:00
Guillem Jover
be327c6ebe 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.
2022-10-04 04:29:07 +02:00
Guillem Jover
a14612d968 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
2022-08-23 23:51:05 +02:00
Guillem Jover
f4baceb82c man: Rewrite gerprogname(3bsd) from scratch
This gets rid of one of the last man pages with a BSD-4-clause license.
2022-08-03 11:39:31 +02:00
Guillem Jover
f35c545847 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.
2022-08-03 11:39:31 +02:00
Guillem Jover
b466b14afb man: Document that some arc4random(3) functions are now in glibc 2.36 2022-08-03 11:39:31 +02:00
Guillem Jover
1f6a48b209 Sync arc4random(3) implementation from OpenBSD
Closes: #12
2022-08-03 11:39:31 +02:00
Fabrice Fontaine
873639ebb5 Fix ELF support for big endian SH
Fix the following build failure with big endian SH (e.g. sh4aeb):

  ,---
  In file included from nlist.c:44:
  nlist.c: In function '__elf_is_okay__':
  local-elf.h:223:25: error: 'ELFDATA2LMSB' undeclared (first use in this function); did you mean 'ELFDATA2LSB'?
    223 | #define ELF_TARG_DATA   ELFDATA2LMSB
        |                         ^~~~~~~~~~~~
  `---

Fixes: http://autobuild.buildroot.org/results/2980fb79c208454195d77383f1ece9afbd7f981b
Closes: !19
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Signed-off-by: Guillem Jover <guillem@hadrons.org>
2022-06-08 11:51:55 +02:00
Guillem Jover
c9c78fdfd0 man: Use -compact also for alternative functions in libbsd(7)
The other function lists use the compact mode, let's be uniform about
this.
2022-06-08 11:50:47 +02:00
Guillem Jover
5f21307570 getentropy: Fix function cast for getauxval()
Fix also the Hurd implementation, missed in the original fix.

Extends: commit 72a82ee262
Warned-by: gcc
2022-06-08 11:49:16 +02:00
Guillem Jover
84acf21568 Release libbsd 0.11.6 2022-03-30 23:09:35 +02:00
WANG Xuerui
15200ec7ac Add LoongArch support to nlist()
Closes: !13
Signed-off-by: WANG Xuerui <git@xen0n.name>
Signed-off-by: Guillem Jover <guillem@hadrons.org>
2022-03-30 23:03:56 +02:00