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

Commit b4de2f99 authored by Nick Kralevich's avatar Nick Kralevich Committed by Android Git Automerger
Browse files

am 05f0382b: When dropping privileges, check return values.

Merge commit '05f0382b' into gingerbread-plus-aosp

* commit '05f0382b':
  When dropping privileges, check return values.
parents 4fd76ba2 05f0382b
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -218,8 +218,18 @@ int main(int argc, char *argv[]) {

    /* switch to non-root user and group */
    gid_t groups[] = { AID_LOG, AID_SDCARD_RW, AID_MOUNT };
    setgroups(sizeof(groups)/sizeof(groups[0]), groups);
    setuid(AID_SHELL);
    if (setgroups(sizeof(groups)/sizeof(groups[0]), groups) != 0) {
        LOGE("Unable to setgroups, aborting: %s\n", strerror(errno));
        return -1;
    }
    if (setgid(AID_SHELL) != 0) {
        LOGE("Unable to setgid, aborting: %s\n", strerror(errno));
        return -1;
    }
    if (setuid(AID_SHELL) != 0) {
        LOGE("Unable to setuid, aborting: %s\n", strerror(errno));
        return -1;
    }

    char path[PATH_MAX], tmp_path[PATH_MAX];
    pid_t gzip_pid = -1;