No need to calculate the hash value of file_contexts
The file_contexts' hash value is no longer used. So remove it. Test: compile Change-Id: I6f2c59a712377bef698fd87ebf38cc4dfbf9ee0c Signed-off-by: liwugang <liwugang@xiaomi.com>
This commit is contained in:
parent
8c158034dd
commit
84cf5d7a34
1 changed files with 0 additions and 74 deletions
|
@ -72,76 +72,6 @@ static char const * const seapp_contexts_odm[] = {
|
|||
"/odm_seapp_contexts"
|
||||
};
|
||||
|
||||
uint8_t fc_digest[FC_DIGEST_SIZE];
|
||||
|
||||
static bool compute_file_contexts_hash(uint8_t c_digest[], const struct selinux_opt *opts, unsigned nopts)
|
||||
{
|
||||
int fd = -1;
|
||||
void *map = MAP_FAILED;
|
||||
bool ret = false;
|
||||
uint8_t *fc_data = NULL;
|
||||
size_t total_size = 0;
|
||||
struct stat sb;
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < nopts; i++) {
|
||||
fd = open(opts[i].value, O_CLOEXEC | O_RDONLY);
|
||||
if (fd < 0) {
|
||||
selinux_log(SELINUX_ERROR, "SELinux: Could not open %s: %s\n",
|
||||
opts[i].value, strerror(errno));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (fstat(fd, &sb) < 0) {
|
||||
selinux_log(SELINUX_ERROR, "SELinux: Could not stat %s: %s\n",
|
||||
opts[i].value, strerror(errno));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (sb.st_size == 0) {
|
||||
selinux_log(SELINUX_WARNING, "SELinux: Skipping %s: empty file\n",
|
||||
opts[i].value);
|
||||
goto nextfile;
|
||||
}
|
||||
|
||||
map = mmap(NULL, sb.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
|
||||
if (map == MAP_FAILED) {
|
||||
selinux_log(SELINUX_ERROR, "SELinux: Could not map %s: %s\n",
|
||||
opts[i].value, strerror(errno));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
fc_data = realloc(fc_data, total_size + sb.st_size);
|
||||
if (!fc_data) {
|
||||
selinux_log(SELINUX_ERROR, "SELinux: Count not re-alloc for %s: %s\n",
|
||||
opts[i].value, strerror(errno));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
memcpy(fc_data + total_size, map, sb.st_size);
|
||||
total_size += sb.st_size;
|
||||
|
||||
/* reset everything for next file */
|
||||
munmap(map, sb.st_size);
|
||||
nextfile:
|
||||
close(fd);
|
||||
map = MAP_FAILED;
|
||||
fd = -1;
|
||||
}
|
||||
|
||||
SHA1(fc_data, total_size, c_digest);
|
||||
ret = true;
|
||||
|
||||
cleanup:
|
||||
if (map != MAP_FAILED)
|
||||
munmap(map, sb.st_size);
|
||||
if (fd >= 0)
|
||||
close(fd);
|
||||
free(fc_data);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static struct selabel_handle* selinux_android_file_context(const struct selinux_opt *opts,
|
||||
unsigned nopts)
|
||||
{
|
||||
|
@ -158,10 +88,6 @@ static struct selabel_handle* selinux_android_file_context(const struct selinux_
|
|||
__FUNCTION__, strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
if (!compute_file_contexts_hash(fc_digest, opts, nopts)) {
|
||||
selabel_close(sehandle);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
selinux_log(SELINUX_INFO, "SELinux: Loaded file_contexts\n");
|
||||
|
||||
|
|
Loading…
Reference in a new issue