From 011a60c9ecc5a375431d3c34a70050892e28810f Mon Sep 17 00:00:00 2001 From: Mike Lockwood Date: Sat, 1 Nov 2008 15:35:28 -0400 Subject: [PATCH] logwrapper: switch from root to user/group "log" after forking child. Signed-off-by: Mike Lockwood --- logwrapper/logwrapper.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/logwrapper/logwrapper.c b/logwrapper/logwrapper.c index c7a253460..1989e0f2a 100644 --- a/logwrapper/logwrapper.c +++ b/logwrapper/logwrapper.c @@ -22,6 +22,7 @@ #include #include +#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); }