Add sepolicyFilePaths() to RuntimeInfo.
Test: adb shell vintf
Bug: 28656227
Change-Id: If8c28eff7a057fafda88384c92498f0f21121b97
diff --git a/RuntimeInfo-target.cpp b/RuntimeInfo-target.cpp
index e073562..3b094c9 100644
--- a/RuntimeInfo-target.cpp
+++ b/RuntimeInfo-target.cpp
@@ -23,6 +23,7 @@
#include "CompatibilityMatrix.h"
#include "parse_string.h"
+#include <dirent.h>
#include <errno.h>
#include <sys/utsname.h>
#include <unistd.h>
@@ -187,12 +188,33 @@
return OK;
}
+static const std::string gSepolicyFilesDir{"/vendor/etc/selinux/"};
+
// Grab sepolicy file paths.
status_t RuntimeInfoFetcher::fetchSepolicyFiles() {
- mRuntimeInfo->mSepolicyFilePaths = {
- // TODO(b/36456394) need a list of sepolicy files
- };
- return OK;
+ mRuntimeInfo->mSepolicyFilePaths.clear();
+ DIR *dir = opendir(gSepolicyFilesDir.c_str());
+ if (dir == NULL) {
+ LOG(ERROR) << "Could not open directory \""
+ << gSepolicyFilesDir << "\"";
+ return -errno;
+ }
+ struct dirent *e;
+ status_t status = OK;
+ errno = 0;
+ while ((e = readdir(dir))) {
+ if (e->d_type == DT_REG || e->d_type == DT_LNK) {
+ mRuntimeInfo->mSepolicyFilePaths.push_back(
+ gSepolicyFilesDir + e->d_name);
+ }
+ }
+ if (errno != 0) {
+ LOG(ERROR) << "Could not read directory \""
+ << gSepolicyFilesDir << "\"";
+ status = -errno;
+ }
+ (void)closedir(dir);
+ return status;
}
status_t RuntimeInfoFetcher::fetchAvb() {