src/setproctitle.c


Log

Author Commit Date CI Message
Guillem Jover 04a8fb24 2021-03-02T00:48:02 Add missing prototypes to functions Warned-by: gcc
Guillem Jover 890699a7 2019-08-06T18:51:45 build: Abstract symbol versioning via new libbsd_symver_* macros This makes it more obvious what they are doing. It will make it easier to make these directives more portable, as they are really ELF specific.
Guillem Jover 574c7a13 2018-06-18T00:36:44 Protect C language extensions with two leading and trailing underscores This should make their usage safer against user macros.
Guillem Jover 2a8514d8 2017-07-17T00:57:07 Fix handling of non-contiguous argv + envp in setproctitle() The two arrays might not reference contiguous memory, and assuming they are does break at least now on GNU/Hurd, which contains an unmapped memory block between the memory used by the two arrays. Just check that each element is strictly after the previous one, so that we know there are no unmapped memory blocks inbetween.
Guillem Jover ed84bec5 2016-02-10T10:38:51 Switch URLs from http or git to https
Guillem Jover 948bcf1d 2013-07-13T02:11:20 Warn when setproctitle() gets called before initialization Try to give a helpful message in case the program is not initializing the setproctitle() machinery.
Guillem Jover c5b95902 2013-07-11T12:25:54 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
Guillem Jover ad613d9d 2013-06-07T07:11:50 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
Guillem Jover e084ce3f 2013-06-07T04:46:29 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.
Guillem Jover 50e4c55a 2013-06-08T17:55:19 Try to check if setproctitle() constructor got passed arguments
Guillem Jover 6faea4d2 2013-05-29T02:23:56 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
Guillem Jover e9933255 2013-05-25T17:11:53 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.
Guillem Jover c984dacd 2012-11-27T14:24:13 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).
Guillem Jover 35785f8d 2012-11-25T21:10:53 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.
William Ahern 2a0260d0 2012-11-28T11:09:02 Add a setproctitle() implementation Taken from libnostd. Signed-off-by: Guillem Jover <guillem@hadrons.org>
Guillem Jover e7f39760 2012-03-23T10:31:42 Add email address to my name
Guillem Jover b891772a 2011-05-29T02:49:14 Remove blank lines at EOF
Guillem Jover 3fed78e5 2010-01-10T00:37:03 Replace setproctitle dummy macro with a function stub This way we can replace it later on with a real implementation so that applications can immediately benefit from it w/o the need to recompile them.