Commit graph

17 commits

Author SHA1 Message Date
Rom Lemarchand
6ad53df633 liblogwrap: use POLLHUP flag to check when a child dies
Replace the old signal handling mechanism with a check of POLLHUP
to check when the child has died.

See http://b/8333626

Change-Id: Ic9909b6660b1c3d1ed3015568b1a1ee1c25afe20
2013-03-20 16:26:22 -07:00
Rom Lemarchand
74a7b91cbe liblogwrap: lock android_fork_execvp
Add a lock around android_fork_execvp to ensure no two threads can
execute it at the same time.

This is to help with http://b/8333626

Change-Id: I75d087a74b58f5b8e878675b301200f54d976fb2
2013-03-14 21:31:07 -07:00
Rom Lemarchand
451dd85fb2 liblogwrap: replace loops with calls to TEMP_FAILURE_RETRY
Makes the code slightly more readable and avoids boilerplate.

Change-Id: I023d9a1e1de729deaec97c62a5ca7983b6918f94
2013-03-12 08:55:38 -07:00
JP Abgrall
a689d13a19 logwrap lib: make logwrapper less verbose when told to not log
We don't care about exit codes if logwrap output is not requested.

Change-Id: Ibae5fe53527554a1fe865c2058deb0a128a9dde2
2013-02-13 16:31:58 -08:00
Rom Lemarchand
2f34c5033e logwrap: Change semantics of NULL status in android_fork_execvp
When passing a NULL status to android_fork_execvp the return
status will now be the return value of the child if it exited
properly, otherwise a non-0 value will be returned.

Change-Id: I13309c61b37b6b3f9d5507f7d6484e7b6baaf8d0
2013-02-08 09:37:52 -08:00
Rom Lemarchand
2a46bfa6b9 logwrapper: rename logwrap() to android_fork_execvp()
Also change the quiet flag to a logwrap flag (inverses the meaning of
the boolean).

Change-Id: I76047a7b460f4c28d52f26bfe3f65889d96047f8
2013-01-30 12:26:05 -08:00
Rom Lemarchand
f5200c0750 logwrap: add quiet flag to logwrap()
Add a quiet flag to the logwrap function that prevents messages from
getting logged.

Change-Id: Ic56c011fb608babae32b03900b955833a6bdd070
2013-01-28 16:14:20 -08:00
Rom Lemarchand
2c3b2e12c1 Merge "logwrap: Replace sigprocmask with pthread_sigmask" 2013-01-29 00:13:25 +00:00
Rom Lemarchand
665118f502 Merge "logwrap: wait for child process when receiving SIGINT or SIGQUIT" 2013-01-29 00:12:11 +00:00
Rom Lemarchand
ed179d2f98 logwrap: Replace sigprocmask with pthread_sigmask
sigprocmask has undefined behavior when called from a thread.
Replacing with pthread_sigmask to ensure correct behavior if
logwrap() gets called from a thread.

Change-Id: I77b6959d345eac8d7b90039ed8144ead8c19a00c
2013-01-29 00:05:24 +00:00
Rom Lemarchand
75c289aab9 logwrap: wait for child process when receiving SIGINT or SIGQUIT
- Wait for the child to exit before propagating SIGINT and SIGQUIT
to the parent
- Add ignore_int_quit argument to logwrap() that gives the caller the
option to ignore SIGINT and SIGQUIT while logwrap is running

Change-Id: If5c96cf23094917211310f00aa6aed515f110f5b
2013-01-29 00:04:50 +00:00
Rom Lemarchand
99e1966400 logwrap: ensure child exits with _exit
Always exit the child process with _exit() rather than exit() to ensure none
of the parent's atexit functions get called if the child needs to exit before
calling exec.

Change-Id: I6a75111ef1bb3468c114c98743565471cf82c9dd
2013-01-28 15:44:24 -08:00
Rom Lemarchand
cfb5ec3c28 logwrap: remove unnecessary call to setuid/setgid
Android allows all users to write to log.
The setuid/setgid call is unneeded and could cause unintended
side effects when called from daemons or programs that need
to run as root.

Change-Id: I3bdb26eaa4363ef037615e45a1a5cb1ceb4088f3
2013-01-28 13:12:37 -08:00
Rom Lemarchand
611f5b4b93 logwrap: fix off by 1 argument error
Fix off by 1 argument parsing error in liblogwrap.

Change-Id: I79832ae338a71c445f9f616d780c577826874386
2013-01-28 13:11:32 -08:00
Rom Lemarchand
0cc2cab6af logwrapper: switch to signal handlers for SIGCHLD
Switch to a signal handler to monitor SIGCHLD.
Also, clean up the exit path and log a warning when the
previous SIGCHLD sigaction is not default or ignore.

Change-Id: I7ef7daabee18d80e9e82fba3943cf1d03b504ae3
2013-01-28 13:08:04 -08:00
Rom Lemarchand
b58a822955 logwrapper: prevent logwrap from hanging when child dies
Sometimes the read on the PTY can wait indefinitely if the child
dies. By using a poll statement that monitors both the output
of the child and its state we prevent this from happening.

Change-Id: I51d5556c66f039bca673145ca72db262977e1689
2013-01-14 11:11:58 -08:00
Rom Lemarchand
113bd47d61 logwrapper: split into liblogwrap and the executable itself
Abstracting the functionality of logwrapper into a library and making
use of it for the logwrapper executable.

Change-Id: I2bcf722413f3a8454c6f52137dec86c4477fb8b5
2013-01-11 13:58:29 -08:00