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

Commit 3e467f3e authored by Nick Kralevich's avatar Nick Kralevich Committed by Android (Google) Code Review
Browse files

Merge "check the return value of setuid and friends"

parents d49b4ef5 2268718e
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -243,13 +243,22 @@ void service_start(struct service *svc, const char *dynamic_args)

    /* as requested, set our gid, supplemental gids, and uid */
        if (svc->gid) {
            setgid(svc->gid);
            if (setgid(svc->gid) != 0) {
                ERROR("setgid failed: %s\n", strerror(errno));
                _exit(127);
            }
        }
        if (svc->nr_supp_gids) {
            setgroups(svc->nr_supp_gids, svc->supp_gids);
            if (setgroups(svc->nr_supp_gids, svc->supp_gids) != 0) {
                ERROR("setgroups failed: %s\n", strerror(errno));
                _exit(127);
            }
        }
        if (svc->uid) {
            setuid(svc->uid);
            if (setuid(svc->uid) != 0) {
                ERROR("setuid failed: %s\n", strerror(errno));
                _exit(127);
            }
        }

        if (!dynamic_args) {