Merge \"ueventd: only relabel devices if there\'s a delta\"
am: 95428817d6
Change-Id: I610cc91cd0e3d9ce679b4c98e142bada0593d1a8
This commit is contained in:
commit
807fa4bd5c
1 changed files with 15 additions and 1 deletions
|
|
@ -257,11 +257,25 @@ static void make_device(const char *path,
|
||||||
/* If the node already exists update its SELinux label to handle cases when
|
/* If the node already exists update its SELinux label to handle cases when
|
||||||
* it was created with the wrong context during coldboot procedure. */
|
* it was created with the wrong context during coldboot procedure. */
|
||||||
if (mknod(path, mode, dev) && (errno == EEXIST)) {
|
if (mknod(path, mode, dev) && (errno == EEXIST)) {
|
||||||
if (lsetfilecon(path, secontext)) {
|
|
||||||
|
char* fcon = nullptr;
|
||||||
|
int rc = lgetfilecon(path, &fcon);
|
||||||
|
if (rc < 0) {
|
||||||
|
ERROR("Cannot get SELinux label on '%s' device (%s)\n",
|
||||||
|
path, strerror(errno));
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool different = strcmp(fcon, secontext) != 0;
|
||||||
|
freecon(fcon);
|
||||||
|
|
||||||
|
if (different && lsetfilecon(path, secontext)) {
|
||||||
ERROR("Cannot set '%s' SELinux label on '%s' device (%s)\n",
|
ERROR("Cannot set '%s' SELinux label on '%s' device (%s)\n",
|
||||||
secontext, path, strerror(errno));
|
secontext, path, strerror(errno));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
chown(path, uid, -1);
|
chown(path, uid, -1);
|
||||||
setegid(AID_ROOT);
|
setegid(AID_ROOT);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue