logwrapper: switch from root to user/group "log" after forking child.

Signed-off-by: Mike Lockwood <lockwood@android.com>
This commit is contained in:
Mike Lockwood 2008-11-01 15:35:28 -04:00
parent 3088ff8d39
commit 011a60c9ec

View file

@ -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);
}