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

Commit 781c8e6c authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge changes Id0fe51d0,Ie3b3907b am: e0461422 am: 2720b7f9 am: ab49f6a4 am: de43d539

Original change: https://android-review.googlesource.com/c/platform/system/core/+/1927607

Change-Id: I0efe03f0c4749e71288be6f090521eb368be600e
parents 75a505a1 de43d539
Loading
Loading
Loading
Loading
+21 −3
Original line number Diff line number Diff line
@@ -19,7 +19,9 @@
#include <errno.h>
#include <unistd.h>

#include <algorithm>
#include <string>
#include <vector>

#include <android-base/stringprintf.h>

@@ -45,9 +47,25 @@ static std::string GetUdevProblem() {
        return "";
    }

    // getgroups(2) indicates that the GNU group_member(3) may not check the egid so we check it
    // additionally just to be sure.
    if (group_member(plugdev_group->gr_gid) || getegid() == plugdev_group->gr_gid) {
    int ngroups = getgroups(0, nullptr);
    if (ngroups < 0) {
        perror("failed to get groups list size");
        return "";
    }

    std::vector<gid_t> groups(ngroups);
    ngroups = getgroups(groups.size(), groups.data());
    if (ngroups < 0) {
        perror("failed to get groups list");
        return "";
    }

    groups.resize(ngroups);

    // getgroups(2) indicates that the egid may not be included so we check it additionally just
    // to be sure.
    if (std::find(groups.begin(), groups.end(), plugdev_group->gr_gid) != groups.end() ||
        getegid() == plugdev_group->gr_gid) {
        // The user is in plugdev so the problem is likely with the udev rules.
        return "missing udev rules? user is in the plugdev group";
    }
+1 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@
#include <linux/types.h>
#include <stdint.h>
#include <sys/sysmacros.h>
#include <sys/types.h>
#include <unistd.h>

#include <chrono>