Skip to content

Commit 52ef1d1

Browse files
authored
Simplify matching selinux context of child zygote (#8845)
1 parent f14e3a8 commit 52ef1d1

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

native/src/core/deny/utils.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <base.hpp>
1111
#include <sqlite.hpp>
1212
#include <core.hpp>
13+
#include <selinux.hpp>
1314

1415
#include "deny.hpp"
1516

@@ -108,12 +109,11 @@ static bool proc_name_match(int pid, string_view name) {
108109

109110
bool proc_context_match(int pid, string_view context) {
110111
char buf[PATH_MAX];
111-
sprintf(buf, "/proc/%d/attr/current", pid);
112-
if (auto fp = open_file(buf, "re")) {
113-
fgets(buf, sizeof(buf), fp.get());
114-
if (str_starts(buf, context)) {
115-
return true;
116-
}
112+
char con[1024];
113+
114+
sprintf(buf, "/proc/%d", pid);
115+
if (lgetfilecon(buf, { con, sizeof(con) }) >= 0) {
116+
return str_starts(con, context);
117117
}
118118
return false;
119119
}

0 commit comments

Comments
 (0)