Commit Graph

36 Commits

Author SHA1 Message Date
Simon Ruderich
f54cd101d7 Update copyright year. 2014-01-01 16:41:01 +01:00
Simon Ruderich
ac9101941e Add likely() to tracked_fds_find(). 2013-09-15 00:15:50 +02:00
Simon Ruderich
291a143267 Remove unnecessary if in init_from_environment(). 2013-07-21 14:25:54 +02:00
Simon Ruderich
b950cdb792 Add COLORED_STDERR_IGNORED_BINARIES to exclude binaries. 2013-07-07 13:33:44 +02:00
Simon Ruderich
9ff0ffbd28 Add missing assert() to init_from_environment(). 2013-07-07 12:54:59 +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
ba2283bd37 Remove invalid assert() in tracked_fds_find(). 2013-06-20 23:17:03 +02:00
Simon Ruderich
1d1b6d7769 Remove duplicate code in init_from_environment(). 2013-06-13 22:15:49 +02:00
Simon Ruderich
45d25526c0 Minor documentation updates. 2013-06-13 22:15:09 +02:00
Simon Ruderich
59375c2b79 Fix possible memory overwrite in init_from_environment().
It was possible for a user to overwrite memory at a relative location
with 1 by passing a negative file descriptor.
2013-06-13 22:08:08 +02:00
Simon Ruderich
f30dbbd26d Add more error checks. 2013-06-13 21:56:50 +02:00
Simon Ruderich
d171e6bbec trackfds.h: Add missing inline for consistency. 2013-06-13 21:34:29 +02:00
Simon Ruderich
6d6ad4423a Add assert()s. 2013-06-13 21:33:27 +02:00
Simon Ruderich
9af3c2c727 Add another debug() print to init_from_environment(). 2013-06-10 22:25:31 +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
488159627f Prevent inlining for more functions.
Clang is inlining quite aggressively.
2013-06-10 14:11:04 +02:00
Simon Ruderich
0a2617527c Inline fast part of tracked_fds_find(). 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
7691b7aa1a trackfds.h: Remove incorrect debug output. 2013-06-07 01:59:27 +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
7337375e05 Add warning() and use it in DEBUG mode. 2013-06-07 00:58:16 +02:00
Simon Ruderich
51377106d1 Rename tracked_fds_* tracked_fds_list_*. 2013-06-06 20:44:10 +02:00
Simon Ruderich
feff94de6b trackfds.h: Remove unnecessary strdup(). 2013-06-05 03:16:59 +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
Simon Ruderich
a9db9083b6 Minor documentation updates. 2013-06-05 01:07:47 +02:00
Simon Ruderich
76742316e8 trackfds.h: Fix realloc() in update_environment(). 2013-06-05 00:57:26 +02:00
Simon Ruderich
d475e5ec89 Improve debug output. 2013-06-05 00:53:55 +02:00
Simon Ruderich
df4c9eab97 trackfds.h: Fix invalid write if tracked_fds_count is 0.
Also fixes missing initialization of env array.
2013-06-04 03:34:19 +02:00
Simon Ruderich
686bf50bcd trackfds.h: Handle overflow in update_environment(). 2013-06-03 04:28:43 +02:00
Simon Ruderich
96710bc3fa Add ENV_NAME_FORCE_WRITE to force writes to non-tty devices. 2013-06-01 21:13:23 +02:00
Simon Ruderich
7d4d8e0784 Fix initialization if ENV_NAME_FDS was not set.
If ENV_NAME_FDS is not set then init_from_environment() was called for
each hooked function, instead of just once.
2013-06-01 18:27:56 +02:00
Simon Ruderich
b9b86029be Display PID in tracked_fds_debug(). 2013-05-31 18:40:49 +02:00
Simon Ruderich
8772530a2e trackfds.h: Add missing void to function definition. 2013-05-31 18:39:47 +02:00
Simon Ruderich
abc3d7889f Initial commit. 2013-05-31 18:19:12 +02:00