Commit Graph

517 Commits

Author SHA1 Message Date
Guillem Jover
4cc43915f2 Move procfs based implementation into a new closefrom_procfs() function 2015-09-23 07:59:34 +02:00
Guillem Jover
34df142665 Refactor file descriptor closure into a new closefrom_close() 2015-09-23 07:59:34 +02:00
Guillem Jover
3881c4fc68 Update closefrom() function
Import from sudo. Adapt the build system to detect the required features.
2015-09-23 07:59:34 +02:00
Guillem Jover
3a3d87d730 test: Add closefrom() unit test 2015-09-23 07:59:34 +02:00
Guillem Jover
d62f7d8fac test: Add test case for fpurge(NULL) 2015-09-23 07:59:34 +02:00
Guillem Jover
cfb4d462a9 test: Move and activate fpurge() test case from module to a dedicated file 2015-09-23 07:59:34 +02:00
Guillem Jover
205827a2dd build: Centralize testsuite LDADD setting in a single variable 2015-09-23 07:59:34 +02:00
Guillem Jover
c7e01e9884 Sync queue(3) from FreeBSD
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=85147
2015-09-23 07:59:34 +02:00
Guillem Jover
3267114483 Add __offsetof, __rangeof and __containerof to sys/cdefs.h
Import and adapt from FreeBSD.
2015-09-23 07:59:27 +02:00
Guillem Jover
0e4e3ab269 Add __DECONST, __DEVOLATILE and __DEQUALIFY macros to sys/cdefs.h
Import from FreeBSD.
2015-09-23 07:59:24 +02:00
Guillem Jover
a6fe103c1b Add new man page for reallocarray(3)
Import man page from OpenBSD.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=85622
2015-09-23 07:14:24 +02:00
Guillem Jover
02b55488c5 Use stdint integer types instead of BSD legacy ones 2015-09-23 07:14:21 +02:00
Callum Davies
6378351169 Fix arc4random() and arc4random_stir() prototypes
These two functions accept no arguments.  The prototypes should reflect
this.  This change lets the compiler warn about certain (admittedly
silly) mistakes.

Signed-off-by: Guillem Jover <guillem@hadrons.org>
2014-08-12 12:18:13 +02:00
Guillem Jover
e390651b64 Release libbsd 0.7.0 2014-07-29 03:19:15 +02:00
Guillem Jover
e8d3d04177 build: Remove hard requirement for GNU .init_array section support
In case the support is not available, just stop building the
libbsd-ctor.a library, which is a nice to have thing, but should not
have been a hard requirement from the start. This should allow to
build libbsd on non-glibc based systems using another libc.
2014-07-20 02:09:20 +02:00
Benjamin Baier
faa005cb32 Add reallocarray() function from OpenBSD
Signed-off-by: Guillem Jover <guillem@hadrons.org>
2014-07-17 05:13:05 +02:00
Guillem Jover
36aca8c06e Add stringlist module from NetBSD 2014-07-17 05:11:00 +02:00
Guillem Jover
e8f9300355 Add getbsize() function
Import code from DragonFlyBSD and man page from FreeBSD.
2014-07-15 10:57:42 +02:00
Christian Svensson
a88bb8380d Add OpenRISC support to nlist()
Signed-off-by: Guillem Jover <guillem@hadrons.org>
2014-03-06 22:11:27 +01:00
Guillem Jover
8d16c3df67 Add timeconv module from FreeBSD
Inline license information from FreeBSD root dir COPYRIGHT file.
2013-10-21 05:48:30 +02:00
Guillem Jover
f41fdcf186 Add funopen() function
This is a wrapper over the glibc fopencookie() function.

We diverge from the FreeBSD, OpenBSD and DragonFlyBSD declarations,
because seekfn() there wrongly uses fpos_t, assuming it's an integral
type, and any code using that on a system where fpos_t is a struct
(such as GNU-based systems or NetBSD) will fail to build. In which case,
as the code has to be modified anyway, we might just as well use the
correct declaration.
2013-10-21 05:35:44 +02:00
Guillem Jover
86cbff385a Handle glibc partial header inclusions
The glibc headers use selective inclusions through the __need_NAME
mechanism to avoid circular dependencies.

The problem is that if we are being overlaid, and have been requested
a partial inclusion, when we pass control to the system header, then
we might miss definitions needed by our own header, resulting in build
failures.

Workaround that by catching current partial requests, and skip the
current inclusion.
2013-10-21 05:35:17 +02:00
Guillem Jover
ee04e8de14 build: Set subdir-objects automake option
Bump automake minimal version to 1.9.
2013-10-21 05:33:08 +02:00
Guillem Jover
61b2dbb8f5 Fix dehumanize_number() to correctly detect overflows
Do not allow numbers greated than INT64_MAX and smaller than INT64_MIN.
Clarify the positive sign value by prefixing it with an explicit +.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=66909
2013-10-21 05:29:37 +02:00
Guillem Jover
119417462e Release libbsd 0.6.0 2013-07-14 13:34:07 +02:00
Guillem Jover
948bcf1db8 Warn when setproctitle() gets called before initialization
Try to give a helpful message in case the program is not initializing
the setproctitle() machinery.
2013-07-14 13:34:07 +02:00
Guillem Jover
c5b9590287 Move setproctitle() automatic initialization to its own library
The automatic initialization cannot be part of the main shared library,
because there is no thread-safe way to change the environ global
variable. This is not a problem if the initializaion happens just at
program load time, but becomes one if the shared library is directly or
indirectly dlopen()ed during the execution of the program, which could
have either kept references to the old environ or could change it in
some other thread. This has been observed for example on systems using
Samba NSS modules.

To avoid any other possible fallout, the constructor is split into a
new static library that needs to be linked explicitly into programs
using setproctitle(). As an additional safety measure the pkg-config
linker flags will mark the program as not allowing to be dlopen()ed
so that we avoid the problem described above.

Reported-by: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=66679
2013-07-14 13:32:11 +02:00
Guillem Jover
3077d2fffc build: Move version ABI from Makefile to configure.ac
It's easier to find there, and the value can be reused in case we have
to provide another shared library.
2013-07-14 10:27:25 +02:00
Guillem Jover
1bf0a55579 Release libbsd 0.5.2 2013-06-08 18:26:04 +02:00
Guillem Jover
ad613d9d09 Create a shallow copy of environ before replacing it in setproctitle()
Because clearenv() or setenv() might free the environ array of pointers,
we should make sure to copy it so that we can access it later on when
doing the deep copy via setenv().

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=65470
2013-06-08 18:26:04 +02:00
Guillem Jover
e084ce3fa7 Specify setproctitle_stub() signature manually if typeof is missing
Do not stop exporting the function in the version node even if typeof
is not available, as that would break ABI.
2013-06-08 18:09:36 +02:00
Guillem Jover
50e4c55afd Try to check if setproctitle() constructor got passed arguments 2013-06-08 18:09:36 +02:00
Guillem Jover
6faea4d2a0 Force setproctitle() into .init_array section
The GNU .init_array support is an extension over the standard System V
ABI .init_array support, which passes the main() arguments to the init
function.

This support comes in three parts. First the dynamic linker (from glibc)
needs to support it. Then function pointers need to be placed in the
section, for example by using __attribute__((constructor)), that the
compiler (gcc or clang for example) might place in section .ctors and
the linker (from binutils) will move to .init_array on the output
object, or by placing them directly into .init_array by the compiler
when compiling. If this does not happen and the function pointers end
up in .ctors, then they will not get passed the main() arguments, which
we do really need in this case.

But this relies on recent binutils or gcc having native .init_array
support, and not having it disabled through --disable-initfini-array.

To guarantee we get the correct behaviour, let's just place the function
pointer in the .init_array section directly, so we only require a recent
enough glibc.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=65029
2013-06-08 18:09:29 +02:00
Guillem Jover
367e036537 test: Try setting and getting an environment variable after setproctitle() 2013-06-08 18:08:58 +02:00
Guillem Jover
dc8b09783f build: Ignore automake 1.13+ test suite generated files 2013-05-30 04:09:25 +02:00
Guillem Jover
4663364783 Release libbsd 0.5.1 2013-05-27 06:52:05 +02:00
Guillem Jover
df5aebd7e1 test: Mark a literal integer as long long
This fixes build failures on 32-bit architectures.
2013-05-27 06:51:15 +02:00
Guillem Jover
9587882316 Release libbsd 0.5.0 2013-05-27 05:40:06 +02:00
Guillem Jover
01f146c28e build: Handle the ChangeLog as a distributed-only file
The ChangeLog file is distributed, and cannot be regenerated outside
of the git repository, so do not remove it in DISTCLEANFILES, and move
the generation code into dist-hook, which also avoids unnecessary
computation during normal builds.
2013-05-27 05:39:44 +02:00
Guillem Jover
509841b533 build: Use AM_V_at for mkdir 2013-05-27 04:05:17 +02:00
Guillem Jover
06f0585c48 build: Compress the distribution tarball with xz instead of gzip 2013-05-27 04:05:17 +02:00
Guillem Jover
7c4caa679a Fix comparison between signed and unsigned integer compiler warnings 2013-05-27 04:05:17 +02:00
Guillem Jover
30349f8922 Update radixsort module from NetBSD
Merge some interesting changes.
2013-05-27 04:05:17 +02:00
Guillem Jover
96a2dae352 Update setmode module from NetBSD
Merge some interesting changes.
2013-05-27 04:05:17 +02:00
Casper Dik
a4812cdf24 Fix getpeereid() compilation on Solaris
The code in getpeereid() is unlikely to compile as ucred_t is an opaque
struct (ucred_t * works but ucred_t does not). Either you need to give
a pointer initialized to NULL and getpeerucred() allocates a new ucred
or you call it with an allocated ucred as in this patch.

Signed-off-by: Guillem Jover <guillem@hadrons.org>
2013-05-27 04:05:17 +02:00
Guillem Jover
d3a09e1cf4 Switch dehumanize_number() to use expand_number()
The function is a duplicate of expand_number(), but covering less
prefixes and with a slightly different function signature.

Spotted-by: Peter da Silva <resuna@gmail.com>
2013-05-27 04:03:14 +02:00
Guillem Jover
330b569fe3 test: Add new humanize unit test 2013-05-27 03:41:48 +02:00
Guillem Jover
8c26c40ad2 test: Add setproctitle() unit test 2013-05-27 03:24:23 +02:00
Guillem Jover
e9933255d4 Make setproctitle() available in 0.2 and 0.5 version nodes
Make the 0.5 version the default, so that code wanting the actual
implemented version can get a proper versioned depdendency. For code
linked against the old version, make it available as an alias.
2013-05-27 03:24:22 +02:00
Guillem Jover
c984dacd65 Implement sendmail semantics for setproctitle()
Prefix the title with "progname: ", and skip it if the format string
starts with '-' (which gets skipped on output too).
2013-05-27 03:24:20 +02:00