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

Signed-off-by: Mike Lockwood <lockwood@android.com>
diff --git a/logwrapper/logwrapper.c b/logwrapper/logwrapper.c
index c7a2534..1989e0f 100644
--- a/logwrapper/logwrapper.c
+++ b/logwrapper/logwrapper.c
@@ -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 @@
     } 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);
     }