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

Commit 94b0f376 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "ueventd: relabel block devices nodes when processing subsequent add events"

parents 3abd0323 24a3cbfa
Loading
Loading
Loading
Loading
+15 −6
Original line number Diff line number Diff line
@@ -244,7 +244,11 @@ static void make_device(const char *path,

    mode = get_device_perm(path, links, &uid, &gid) | (block ? S_IFBLK : S_IFCHR);

    selabel_lookup_best_match(sehandle, &secontext, path, links, mode);
    if (selabel_lookup_best_match(sehandle, &secontext, path, links, mode)) {
        ERROR("Device '%s' not created; cannot find SELinux label (%s)\n",
                path, strerror(errno));
        return;
    }
    setfscreatecon(secontext);

    dev = makedev(major, minor);
@@ -254,15 +258,20 @@ static void make_device(const char *path,
     * racy. Fixing the gid race at least fixed the issue with system_server
     * opening dynamic input devices under the AID_INPUT gid. */
    setegid(gid);
    mknod(path, mode, dev);
    /* If the node already exists update its SELinux label to handle cases when
     * it was created with the wrong context during coldboot procedure. */
    if (mknod(path, mode, dev) && (errno == EEXIST)) {
        if (lsetfilecon(path, secontext)) {
            ERROR("Cannot set '%s' SELinux label on '%s' device (%s)\n",
                    secontext, path, strerror(errno));
        }
    }
    chown(path, uid, -1);
    setegid(AID_ROOT);

    if (secontext) {
    freecon(secontext);
    setfscreatecon(NULL);
}
}

static void add_platform_device(const char *path)
{