Commit Graph
100 Commits
Author SHA1 Message Date
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 d78910e363 tests/Makefile.am: Remove unnecessary *_SOURCES variables.
They are only required if more than one source file (or one with a
different name) is used.
2013-06-20 22:02:30 +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 1fb32dbd84 tests: Remove test_symbols.sh.
It's useless as different systems provide/require different symbols.
Will be replaced by a better test.
2013-06-20 20:46:06 +02:00
Simon Ruderich cfad8a624c Update documentation. 2013-06-18 00:07:03 +02:00
Simon Ruderich 85699d0263 tests/example.c: Use errno = ENOMEM.
The output from errno = 0 is less portable.
2013-06-17 23:28:07 +02:00
Simon Ruderich a63fef43c2 Add missing #include <sys/stat.h>. 2013-06-17 23:26:00 +02:00
Simon Ruderich 50a495887f README: setuid binaries are not supported. 2013-06-15 16:53:47 +02:00
Simon Ruderich 34b3b93136 tests/example_error.c: Fix typo in function name. 2013-06-15 03:41:06 +02:00
Simon Ruderich a58d1a9017 Mark hooked functions as visibility(("protected")). 2013-06-15 03:36:50 +02:00
Simon Ruderich ca12529c8f hookmacros.h: Reduce duplication in macros.
Also preparation to add attributes to function declarations.
2013-06-15 03:23:53 +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 0a909cac79 Use locally defined functions in hooks where possible.
Don't create a hook and call the "real" function when it's enough to
call an existing hook for this function.
2013-06-15 01:58:36 +02:00
Simon Ruderich 217e8c8bc5 Define real_*() static variables with macros. 2013-06-15 00:54:46 +02:00
Simon Ruderich 9507e0f60d configure.ac: Fix Vim's syntax coloring issue with `..'. 2013-06-14 21:24:53 +02:00
Simon Ruderich 6ae629bef0 tests/Makefile.am: Enable parallel and colored test runs.
Necessary for automake < 1.13.
2013-06-14 21:24:53 +02:00
Simon Ruderich 18d52b3b5a Install libcoloredstderr.so read-only.
Prevents accidental truncates of libcoloredstderr.so with `cp` which
crash all programs which have loaded it.
2013-06-14 13:40:06 +02:00
Simon Ruderich dcaadb5f7c README: Explain how to modify pre/post variables. 2013-06-14 12:44:34 +02:00
Simon Ruderich 04334418fc README: Add first part of installation instructions. 2013-06-14 11:07:40 +02:00
Simon Ruderich 208757de88 .gitignore: Ignore generated test files.
Forgotten in d8be625da9 and
59375c2b79.
2013-06-13 22:43:43 +02:00
Simon Ruderich d5b84811d2 tests/lib.sh: Fix tests for dash. 2013-06-13 22:35:42 +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 3d46e3ab9b Add missing const and document where it can't be used. 2013-06-13 22:13:16 +02:00
Simon Ruderich 3c2b4bf9f6 tests/lib.sh: Minor cleanup. 2013-06-13 22:11:15 +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 e5a94fa847 Remove unnecessary calls to update_environment() in exec*(). 2013-06-13 21:50:51 +02:00
Simon Ruderich 1e02760898 constants.h: Fix indentation. 2013-06-13 21:45:19 +02:00
Simon Ruderich 7eb1667d41 ldpreload.h: Add missing unlikely() in DLSYM_FUNCTION(). 2013-06-13 21:44:55 +02:00
Simon Ruderich 0ad5e4db04 hookmacros.h: Remove duplication in _HOOK_PRE_FD_/_HOOK_PRE_FILE. 2013-06-13 21:44:55 +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 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 d8be625da9 tests/test_symbols.sh: Add. 2013-06-13 02:32:27 +02:00
Simon Ruderich 5e8be10581 tests/Makefile.am: Sort dist_check_DATA. 2013-06-13 02:29:55 +02:00
Simon Ruderich e954d0fdfd configure.ac: fcntl.h is required. 2013-06-13 02:25:58 +02:00
Simon Ruderich 52b4e91146 hookmacros.h: Minor style fix. 2013-06-13 01:27:45 +02:00
Simon Ruderich 04ac66863a tests: Split run.sh in multiple test files.
Allows parallel test runs and simplifies optional tests.
2013-06-13 01:26:25 +02:00
Simon Ruderich 05aefe25ba tests: Rename example-* to example_* for consistency. 2013-06-13 01:05:06 +02:00
Simon Ruderich 8a58e07a5b tests: Fix tests when running under coloredstderr. 2013-06-10 22:49:58 +02:00
Simon Ruderich b24bd8dc43 README: Add. 2013-06-10 22:33:59 +02:00
Simon Ruderich 9af3c2c727 Add another debug() print to init_from_environment(). 2013-06-10 22:25:31 +02:00
Simon Ruderich 779ba750f7 Fix compilation with clang. 2013-06-10 21:27:12 +02:00
Simon Ruderich 9434382c9e m4/ax_c___attribute__.m4: Add.
Forgotten in 0a2617527c. Used in
configure.ac.
2013-06-10 17:17:21 +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 732d4d636d configure.ac: Abort if a required function wasn't found. 2013-06-10 16:54:42 +02:00
Simon Ruderich db7cd10c74 configure.ac: strdup() is no longer used, dup2() is optional. 2013-06-10 16:54:11 +02:00
Simon Ruderich d4f585e078 configure.ac: Minor style fix. 2013-06-10 16:22:09 +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 afca2864dc tests: Fix warnings about unused parameters. 2013-06-10 15:22:17 +02:00
Simon Ruderich 2f1aa1cdd3 Only run vfork() tests if it's available. 2013-06-10 15:16:21 +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 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 0a2617527c Inline fast part of tracked_fds_find(). 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 c7f6f13de0 configure.ac: Compile with -Wall -Wextra -Wconversion. 2013-06-10 14:05:50 +02:00
Simon Ruderich 3773b830ba ldpreload.h: Split macro into function and macro. 2013-06-10 14:05:50 +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 30876b212c constants.h: Use "\033" instead of the non-standard "\e". 2013-06-09 16:26:36 +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 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 5c8b5233fb tests: Run tests under valgrind if it's available. 2013-06-07 01:17:42 +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 5af5f0faa2 debug.h: Minor code style fix. 2013-06-06 20:13:04 +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 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 374b11a314 tests: Also run tests in subshell with LD_PRELOAD set. 2013-06-05 01:06:10 +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 b22a078b8d configure.ac: Don't require special versions of malloc/realloc. 2013-06-03 22:35:51 +02:00
Simon Ruderich dbafded223 configure.ac: Reorder macros to follow convention. 2013-06-03 22:18:16 +02:00
Simon Ruderich 7c5d6fce3a Only hook vfork() if it's available. 2013-06-03 21:59:57 +02:00
Simon Ruderich 66fb589680 debug.h: Handle overflow in debug(). 2013-06-03 04:32:12 +02:00
Simon Ruderich 686bf50bcd trackfds.h: Handle overflow in update_environment(). 2013-06-03 04:28:43 +02:00
Simon Ruderich 7108005fff tests: Use <STDERR< and >STDERR> as markers.
Increases contrast to "stderr" output string.
2013-06-02 23:41:31 +02:00
Simon Ruderich e091b977de tests: Use bash to get consistent test results. 2013-06-02 23:39:14 +02:00
Simon Ruderich e362a42f56 COPYING: Add, GPL 3. 2013-06-02 18:40:39 +02:00
Simon Ruderich 1c5441c26a Hook vfork() and replace it with fork(). 2013-06-02 18:25:49 +02:00
Simon Ruderich 66140e14e4 hookmacros.h: Be more careful to restore the errno.
check_handle_fd() or handle_fd_pre() might also modify it.
2013-06-01 22:47:23 +02:00
Simon Ruderich 73870d5ed5 hookmacros.h: Reduce duplication in HOOK_VOID1(). 2013-06-01 22:44:22 +02:00
Simon Ruderich ad50ad9c54 Hook perror(3). 2013-06-01 22:08:45 +02:00