logwrapper: switch from root to user/group "log" after forking child.
Signed-off-by: Mike Lockwood <lockwood@android.com>
This commit is contained in:
parent
3088ff8d39
commit
011a60c9ec
1 changed files with 7 additions and 0 deletions
|
@ -22,6 +22,7 @@
|
|||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "private/android_filesystem_config.h"
|
||||
#include "cutils/log.h"
|
||||
|
||||
void fatal(const char *msg) {
|
||||
|
@ -119,6 +120,12 @@ int main(int argc, char* argv[]) {
|
|||
} else {
|
||||
close(*child_write);
|
||||
|
||||
// switch user and group to "log"
|
||||
// this may fail if we are not root,
|
||||
// but in that case switching user/group is unnecessary
|
||||
setgid(AID_LOG);
|
||||
setuid(AID_LOG);
|
||||
|
||||
parent(argv[1], *parent_read);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue