Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 011a60c9 authored by Mike Lockwood's avatar Mike Lockwood
Browse files

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

parent 3088ff8d
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -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);
    }