mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-25 11:47:38 +00:00
Call freecon() when fgetfilecon() succeeds
This commit is contained in:
parent
f42a87b51a
commit
dfe1f2c108
@ -18,10 +18,11 @@ static void restore_syscon(int dirfd) {
|
|||||||
DIR *dir;
|
DIR *dir;
|
||||||
char *con;
|
char *con;
|
||||||
|
|
||||||
fgetfilecon(dirfd, &con);
|
if (fgetfilecon(dirfd, &con) >= 0) {
|
||||||
if (strlen(con) == 0 || strcmp(con, UNLABEL_CON) == 0)
|
if (strlen(con) == 0 || strcmp(con, UNLABEL_CON) == 0)
|
||||||
fsetfilecon(dirfd, SYSTEM_CON);
|
fsetfilecon(dirfd, SYSTEM_CON);
|
||||||
freecon(con);
|
freecon(con);
|
||||||
|
}
|
||||||
|
|
||||||
dir = xfdopendir(dirfd);
|
dir = xfdopendir(dirfd);
|
||||||
while ((entry = xreaddir(dir))) {
|
while ((entry = xreaddir(dir))) {
|
||||||
@ -29,10 +30,11 @@ static void restore_syscon(int dirfd) {
|
|||||||
if (entry->d_type == DT_DIR) {
|
if (entry->d_type == DT_DIR) {
|
||||||
restore_syscon(fd);
|
restore_syscon(fd);
|
||||||
} else if (entry->d_type == DT_REG) {
|
} else if (entry->d_type == DT_REG) {
|
||||||
fgetfilecon(fd, &con);
|
if (fgetfilecon(fd, &con) >= 0) {
|
||||||
if (con[0] == '\0' || strcmp(con, UNLABEL_CON) == 0)
|
if (con[0] == '\0' || strcmp(con, UNLABEL_CON) == 0)
|
||||||
fsetfilecon(fd, SYSTEM_CON);
|
fsetfilecon(fd, SYSTEM_CON);
|
||||||
freecon(con);
|
freecon(con);
|
||||||
|
}
|
||||||
} else if (entry->d_type == DT_LNK) {
|
} else if (entry->d_type == DT_LNK) {
|
||||||
getfilecon_at(dirfd, entry->d_name, &con);
|
getfilecon_at(dirfd, entry->d_name, &con);
|
||||||
if (con[0] == '\0' || strcmp(con, UNLABEL_CON) == 0)
|
if (con[0] == '\0' || strcmp(con, UNLABEL_CON) == 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user