aboutsummaryrefslogtreecommitdiffstats
path: root/libselinux/src/label_android_property.c
diff options
context:
space:
mode:
authorRichard Haines <richard_c_haines@btinternet.com>2015-09-30 16:29:20 +0100
committerStephen Smalley <sds@tycho.nsa.gov>2015-10-13 17:13:24 -0400
commite40bbea95f555fe9708cbbc39895bd67a8ac6c48 (patch)
tree04c5edad51f2f00845887003700c7ec79927379d /libselinux/src/label_android_property.c
parentc9c1f273708777c8923268cf61798ed0dc2ffded (diff)
downloadandroid_external_selinux-e40bbea95f555fe9708cbbc39895bd67a8ac6c48.tar.gz
android_external_selinux-e40bbea95f555fe9708cbbc39895bd67a8ac6c48.tar.bz2
android_external_selinux-e40bbea95f555fe9708cbbc39895bd67a8ac6c48.zip
libselinux: Add selabel_digest function
selabel_digest(3) if enabled by the SELABEL_OPT_DIGEST option during selabel_open(3) will return an SHA1 digest of the spec files, plus a list of the specfiles used to calculate the digest. There is a test utility supplied that will demonstrate the functionality. The use case for selabel_digest(3) is to implement an selinux_restorecon function based on the Android version that writes a hash of the file_contexts files to an extended attribute to enhance performance (see external/libselinux/src/android.c selinux_android_restorecon()). Signed-off-by: Richard Haines <richard_c_haines@btinternet.com>
Diffstat (limited to 'libselinux/src/label_android_property.c')
-rw-r--r--libselinux/src/label_android_property.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/libselinux/src/label_android_property.c b/libselinux/src/label_android_property.c
index af06c4a6..b8fab790 100644
--- a/libselinux/src/label_android_property.c
+++ b/libselinux/src/label_android_property.c
@@ -199,7 +199,12 @@ static int init(struct selabel_handle *rec, const struct selinux_opt *opts,
qsort(data->spec_arr, data->nspec, sizeof(struct spec), cmp);
- status = 0;
+ status = digest_add_specfile(rec->digest, fp, NULL, sb.st_size, path);
+ if (status)
+ goto finish;
+
+ status = digest_gen_hash(rec->digest);
+
finish:
fclose(fp);
return status;