diff options
author | Yuli Khodorkovskiy <ykhodo@gmail.com> | 2018-03-29 17:16:42 -0700 |
---|---|---|
committer | William Roberts <william.c.roberts@intel.com> | 2018-04-04 11:09:11 -0500 |
commit | 3e47c239ec207565242ce3980ce8cab9b912e585 (patch) | |
tree | b760ffb16af4532c7ecf132f858a0b63341b2747 | |
parent | 814631d3aebaa041073a42c677c1ed62ce7830d5 (diff) | |
download | android_external_selinux-3e47c239ec207565242ce3980ce8cab9b912e585.tar.gz android_external_selinux-3e47c239ec207565242ce3980ce8cab9b912e585.tar.bz2 android_external_selinux-3e47c239ec207565242ce3980ce8cab9b912e585.zip |
libselinux: echo line number of bad label in selabel_fini()
Keep track of line numbers for each file context in
selabel_handle. If an error occurs in selabel_fini(), the
line number of an invalid file context is echoed to the user.
Signed-off-by: Yuli Khodorkovskiy <ykhodo@gmail.com>
-rw-r--r-- | libselinux/src/label.c | 2 | ||||
-rw-r--r-- | libselinux/src/label_file.h | 1 | ||||
-rw-r--r-- | libselinux/src/label_internal.h | 1 |
3 files changed, 3 insertions, 1 deletions
diff --git a/libselinux/src/label.c b/libselinux/src/label.c index c510edc1..591815a7 100644 --- a/libselinux/src/label.c +++ b/libselinux/src/label.c @@ -142,7 +142,7 @@ static int selabel_fini(struct selabel_handle *rec, struct selabel_lookup_rec *lr, int translating) { - if (compat_validate(lr, rec->spec_file, 0)) + if (compat_validate(lr, rec->spec_file, lr->lineno)) return -1; if (translating && !lr->ctx_trans && diff --git a/libselinux/src/label_file.h b/libselinux/src/label_file.h index 9e52a3c4..3f9ce53b 100644 --- a/libselinux/src/label_file.h +++ b/libselinux/src/label_file.h @@ -472,6 +472,7 @@ static inline int process_line(struct selabel_handle *rec, spec_arr[nspec].mode = 0; spec_arr[nspec].lr.ctx_raw = context; + spec_arr[nspec].lr.lineno = lineno; /* * bump data->nspecs to cause closef() to cover it in its free diff --git a/libselinux/src/label_internal.h b/libselinux/src/label_internal.h index 75451858..b0d05882 100644 --- a/libselinux/src/label_internal.h +++ b/libselinux/src/label_internal.h @@ -73,6 +73,7 @@ struct selabel_lookup_rec { char * ctx_raw; char * ctx_trans; int validated; + unsigned lineno; }; struct selabel_handle { |