Commit Graph

61 Commits

Author SHA1 Message Date
Simon Ruderich
f78c0377c1 Prevent crash in execve() if env is NULL 2018-02-01 21:40:02 +01:00
Simon Ruderich
545c6af1da Update copyright year 2018-02-01 21:10:46 +01:00
Simon Ruderich
8a65b4486f update copyright year 2015-08-28 12:25:36 +02:00
Simon Ruderich
3676d3f21f vfork(): fix incorrect comment 2014-11-15 18:35:05 +01:00
Simon Ruderich
733e149c1a fix typos in comments 2014-06-22 18:24:49 +02:00
Simon Ruderich
b6d1dc09b6 handle_recursive: fix race condition if threads are used
Requires thread-local storage.

Another solution would be a mutex, but this is slower and more
complicated and might cause issues with some programs.
2014-04-08 14:38:01 +02:00
Simon Ruderich
f54cd101d7 Update copyright year. 2014-01-01 16:41:01 +01:00
Simon Ruderich
39d313d1d4 Fix error_at_line() not always exiting if status != 0.
Also add tests.
2014-01-01 16:37:48 +01:00
Simon Ruderich
73a6c78e7b Remove unnecessary check in handle_*_pre().
init_pre_post_string() sets both pre_string and post_string, so checking
only one suffices.
2013-09-15 00:10:45 +02:00
Simon Ruderich
2241f5278e Handle recursive calls of handle_*_{pre,post}() functions. 2013-07-01 03:23:50 +02:00
Simon Ruderich
d49cd5d92a Also hook un-macroed putc when it's a macro.
The macro might define it to something else, but the non-macro version
is also used in some cases, e.g. in gcc 4.8's collect2 on Debian with
eglibc 2.17-7.
2013-06-30 22:14:33 +02:00
Simon Ruderich
afa1ef98fe Restore environment for execvpe() if the exec fails. 2013-06-29 23:24:04 +02:00
Simon Ruderich
2fc66e15eb Improve checks for invalid file descriptors.
Just in case a real dup*() or fcntl() doesn't return -1 on error, but
something like -2.
2013-06-21 23:03:12 +02:00
Simon Ruderich
0d7f306898 Overwrite tracked file descriptors when exporting COLORED_STDERR_FDS.
If the list of tracked file descriptors is modified to contain unwanted
values (e.g. when a parent process closes or redirects stderr), this
makes it possible to set the tracked file descriptors back to a given
list.

This problem occurred with startx which somehow closes or redirects
stderr. As COLORED_STDERR_FDS was set in the shell running startx, this
disabled coloring stderr for all processes started in the X11 session.

This is no longer an issue. As COLORED_STDERR_FDS is set in the shell
configuration file, it automatically sets the list to the correct value
when a shell is opened in the terminal emulator once X11 is running.
2013-06-21 23:03:12 +02:00
Simon Ruderich
045ca46e79 Hook __swbuf() on FreeBSD.
Coloring works fine now on FreeBSD (with some minor issues). Tests still
fail though.
2013-06-20 23:33:27 +02:00
Simon Ruderich
f3c734eb7d configure.ac: Check if __overflow() is available. 2013-06-20 22:14:42 +02:00
Simon Ruderich
b0c02291be Hook __overflow() correctly.
It takes a FILE * and must be hooked with HOOK_FILE*().
2013-06-20 22:13:04 +02:00
Simon Ruderich
4eb55ac071 {fwrite,fputs,fputc}_unlocked() are not in POSIX.
Define fwrite_unlocked(), fputs_unlocked() and fputc_unlocked() only if
they are available on the system.
2013-06-20 20:56:51 +02:00
Simon Ruderich
cfad8a624c Update documentation. 2013-06-18 00:07:03 +02:00
Simon Ruderich
a63fef43c2 Add missing #include <sys/stat.h>. 2013-06-17 23:26:00 +02:00
Simon Ruderich
941370dda9 Hook BSD err(), errx(), warn(), warnx(), etc. functions.
err(), errx(), warn(), warnx(), verr(), verrx(), vwarn(), vwarnx() are
hooked.
2013-06-15 02:39:52 +02:00
Simon Ruderich
1068648718 Minor documentation update. 2013-06-15 02:21:27 +02:00
Simon Ruderich
217e8c8bc5 Define real_*() static variables with macros. 2013-06-15 00:54:46 +02:00
Simon Ruderich
3d46e3ab9b Add missing const and document where it can't be used. 2013-06-13 22:13:16 +02:00
Simon Ruderich
e5a94fa847 Remove unnecessary calls to update_environment() in exec*(). 2013-06-13 21:50:51 +02:00
Simon Ruderich
6d6ad4423a Add assert()s. 2013-06-13 21:33:27 +02:00
Simon Ruderich
37cb5686de Handle invalid arguments to close()/fclose() better. 2013-06-13 21:19:15 +02:00
Simon Ruderich
7adfbfd2cf Fix hook for putc_unlocked() with glibc.
putc_unlocked() is a macro which expands to __overflow() in some cases.
2013-06-13 12:59:12 +02:00
Simon Ruderich
779ba750f7 Fix compilation with clang. 2013-06-10 21:27:12 +02:00
Simon Ruderich
237251ae9c Hook execvpe(), a GNU extension. 2013-06-10 17:10:44 +02:00
Simon Ruderich
55e8d0d38a coloredstderr.c: Fix parameter name in execvp(). 2013-06-10 16:58:27 +02:00
Simon Ruderich
7c2d726cd4 coloredstderr.c: Fix indentation. 2013-06-10 16:55:25 +02:00
Simon Ruderich
357a499884 configure.ac: Add --enable-warnings.
Enables warning() messages without the overhead of all debug output.
2013-06-10 16:18:35 +02:00
Simon Ruderich
b75b0ec399 Rename __noinline/__always_inline to prevent clash with headers.
With this change noinline can be used in ldpreload.h.
2013-06-10 14:55:13 +02:00
Simon Ruderich
428e15bf68 Prevent inlining of handle_*_pre/post() functions. 2013-06-10 14:05:51 +02:00
Simon Ruderich
f3bda26e82 Don't mark init_pre_post_string() as inline. 2013-06-10 14:05:51 +02:00
Simon Ruderich
86352712fd Fix save/restore of errno for isatty(). 2013-06-10 14:05:51 +02:00
Simon Ruderich
048bd6f9e7 Use likely()/unlikely() macros to improve branch prediction. 2013-06-10 14:05:51 +02:00
Simon Ruderich
9862b8c8f1 Inline check_handle_fd() into hook macros.
It's very small and prologue/epilogue have a lot of overhead.
2013-06-10 14:05:51 +02:00
Simon Ruderich
dfd317650f Remove errno save/restore where not necessary. 2013-06-10 14:05:45 +02:00
Simon Ruderich
fe3f7d4c63 handle_*_pre(),handle_*_post(): Remove unused action parameter. 2013-06-10 04:53:30 +02:00
Simon Ruderich
bcd5f79080 Remove unused hook puts_unlocked().
This function doesn't exist (yet).
2013-06-07 02:06:57 +02:00
Simon Ruderich
06f483dbee Fix a few strict compiler warnings. 2013-06-07 02:01:23 +02:00
Simon Ruderich
31a1fdf921 Use char const * instead of const char *.
char const * is more consistent with char * const.
2013-06-07 01:56:02 +02:00
Simon Ruderich
c2097785e7 Use static list of descriptors to reduce mallocs.
Only if file descriptors with a value > 255 occur, the list
implementation is used.
2013-06-07 01:27:58 +02:00
Simon Ruderich
51377106d1 Rename tracked_fds_* tracked_fds_list_*. 2013-06-06 20:44:10 +02:00
Simon Ruderich
7f9856c5da Hook error() and error_at_line() if available.
They are used by some GNU programs to display error messages.
2013-06-05 23:57:05 +02:00
Simon Ruderich
b140cc0a82 coloredstderr.c: Use #include <config.h>.
This ensures that config.h from the build directory is preferred over a
possible file of the same name in the source directory.
2013-06-05 18:11:33 +02:00
Simon Ruderich
4d10935aee check_handle_fd(): Reduce calls to isatty(). 2013-06-05 03:33:08 +02:00
Simon Ruderich
7ea72c40db Hook execve() and the other exec*() functions.
Prevents programs from removing our environment variables during the
exec.

Also reduces unnecessary calls to update_environment() by calling it
only once before the exec.
2013-06-05 01:40:56 +02:00