Commit Graph

492 Commits

Author SHA1 Message Date
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
Guillem Jover
35785f8dd1 Modify setproctitle() to conform to project coding style
Use local getprogname()/setprogname() instead of reimplementing them
locally. Use clearenv() if available, not just on glibc. Use bool
instead of _Bool. Use paranthesis on sizeof. Fold the SPT_MIN macro
into spt_min(). Make spt_init() static. Avoid unnecessary gotos.
2013-05-27 03:20:17 +02:00
William Ahern
2a0260d08c Add a setproctitle() implementation
Taken from libnostd.

Signed-off-by: Guillem Jover <guillem@hadrons.org>
2013-05-27 02:49:29 +02:00
Guillem Jover
f8d52ead5e Add x32 support to nlist() 2013-05-27 02:49:29 +02:00
Guillem Jover
cf683a275a Add arm64 (aka aarch64) to nlist() 2013-05-27 02:49:28 +02:00
Guillem Jover
7196b4dcca test: Add new fgetln() and fgetwln() unit test 2013-05-27 02:49:28 +02:00
Guillem Jover
a97ce513e0 Add new fgetwln() function
Man page taken from FreeBSD.
2013-05-27 02:49:28 +02:00
Strake
ee0489eb2b Add new fparseln() function
Taken from NetBSD.

[guillem@hadrons.org:
 - Import from NetBSD instead of FreeBSD to get a 3-clause BSD license,
   instead of a 4-clause one.
 - Define compatibility macros.
 - Change library from libc to libbsd and header in man page.
 - Add copyright information to COPYING.
 - Add symbol to map file. ]

Signed-off-by: Guillem Jover <guillem@hadrons.org>
2013-05-27 02:47:32 +02:00
Guillem Jover
cb7bc0d85e Add file buffer pool support to fgetln()
This avoids buffer overwrites during concurrent or intermixed calls to
fgetln() when using more than one different stream (currently 32), which
the original interface supports natively by using an internal buffer
from the FILE structure. Although this workaround is rudimentary, it
should cover most of the theoretically problematic cases.
2013-05-27 02:12:51 +02:00
Guillem Jover
1be0bdb2c9 Add new strnstr() function
Taken from FreeBSD.
2013-05-27 02:12:43 +02:00
Guillem Jover
ff0d700df0 Add new wcslcat() and wcslcpy() functions
Taken from FreeBSD.
2013-05-27 02:11:59 +02:00
Guillem Jover
3862764872 Coalesce identical BSD-2-clause licenses 2013-05-21 04:13:55 +02:00
Guillem Jover
918a4dba4a Release libbsd 0.4.2 2012-06-27 09:15:15 +02:00
Guillem Jover
444bd1fbb8 man: Use minus signs and hyphens consistently
Any string that can be copy & pasted into a terminal, for example,
needs to correctly use minus signs (escaped dashes), instead of the
default hyphen.
2012-06-27 09:13:39 +02:00
Guillem Jover
1d69ae1cd5 man: Recode flopen(3) to UTF-8
Spotted-by: Eric Smith <eric@brouhaha.com>
2012-06-04 05:47:26 +02:00
Guillem Jover
14524b545d build: Set default compiler variables from configure
This centralizes the setting so there's no duplication anymore,
makes sure the user supplied variables are never overridden, and
are only set when using gcc.

Reported-by: Samuli Suominen <ssuominen@gentoo.org>
2012-06-03 07:46:00 +02:00
Guillem Jover
c21d788fea Release libbsd 0.4.1 2012-06-01 08:28:00 +02:00
Guillem Jover
fdcae57707 build: Set runtimelibdir to libdir
This makes sure the install-exec-hook under src works as expected even
when no runtimelibdir was specified, otherwise the symlinks end up
pointing to non-existing targets.

Reported-by: Ryan Mullen <rmmullen@gmail.com>
2012-06-01 08:27:33 +02:00
Guillem Jover
e9e4a60d7e build: Use MKDIR_P variable instead of literal «mkdir -p» 2012-06-01 08:15:00 +02:00
Guillem Jover
309c82a016 Release libbsd 0.4.0 2012-05-29 07:33:16 +02:00
Guillem Jover
cd67cb1417 Use implicit <md5.h> from overlay instead explicit <bsd/md5.h>
This was assuming an installed <bsd/md5.h> on the system, due to the
build system not including -Iinclude/ anymore.

Regression introduced in commit 901ed630fc.
2012-05-29 07:31:06 +02:00
Guillem Jover
1b5b1cd52a Move mdX.3 man page to section 3bsd
This makes sure there will be no collisions on systems where a mdX.3
provided by a third party is already present.
2012-05-29 04:51:45 +02:00
Guillem Jover
ddefaae330 Do not quote man page titles 2012-05-29 04:51:45 +02:00
Guillem Jover
e7f3976088 Add email address to my name 2012-05-29 04:51:45 +02:00
Guillem Jover
e59ac2c96c Clarify that the 4-clause BSD licenses are only for man pages 2012-05-29 04:51:45 +02:00
Guillem Jover
7cfa7e4304 Add new man page for tree(3)
Taken from FreeBSD.
2012-05-29 04:51:34 +02:00