diff options
author | Stephen Smalley <sds@tycho.nsa.gov> | 2014-03-05 16:06:42 -0500 |
---|---|---|
committer | Brian Carlstrom <bdc@google.com> | 2014-03-11 18:40:06 -0700 |
commit | a5e505cde0ecb7842195d762087a6ee9bed4e2cc (patch) | |
tree | 4e30a455c14745528cd05b42537a82f9d994236b | |
parent | 968aed00ed981987cf96dcfd7640e6dcde5c03a0 (diff) | |
download | checkpolicy-a5e505cde0ecb7842195d762087a6ee9bed4e2cc.tar.gz |
Report source file and line information for neverallow failures.
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
(cherry picked from commit 6c07e1e9cf7e7b15cca1766a6c4eb7a702e0c52e)
Change-Id: Idc1df0765f802e561fc26959f6a2ec781aafa03e
-rw-r--r-- | policy_define.c | 14 | ||||
-rw-r--r-- | policy_scan.l | 2 |
2 files changed, 16 insertions, 0 deletions
diff --git a/policy_define.c b/policy_define.c index e9ed4b4..4d2d136 100644 --- a/policy_define.c +++ b/policy_define.c @@ -60,6 +60,7 @@ int mlspol = 0; extern unsigned long policydb_lineno; extern unsigned long source_lineno; extern unsigned int policydb_errors; +extern char source_file[PATH_MAX]; extern int yywarn(char *msg); extern int yyerror(char *msg); @@ -1526,6 +1527,12 @@ int define_compute_type_helper(int which, avrule_t ** rule) avrule_init(avrule); avrule->specified = which; avrule->line = policydb_lineno; + avrule->source_line = source_lineno; + avrule->source_filename = strdup(source_file); + if (!avrule->source_filename) { + yyerror("out of memory"); + return -1; + } while ((id = queue_remove(id_queue))) { if (set_types(&avrule->stypes, id, &add, 0)) @@ -1739,6 +1746,13 @@ int define_te_avtab_helper(int which, avrule_t ** rule) avrule_init(avrule); avrule->specified = which; avrule->line = policydb_lineno; + avrule->source_line = source_lineno; + avrule->source_filename = strdup(source_file); + if (!avrule->source_filename) { + yyerror("out of memory"); + return -1; + } + while ((id = queue_remove(id_queue))) { if (set_types diff --git a/policy_scan.l b/policy_scan.l index ab046cc..454bb84 100644 --- a/policy_scan.l +++ b/policy_scan.l @@ -308,4 +308,6 @@ void set_source_file(const char *name) source_lineno = 1; strncpy(source_file, name, sizeof(source_file)-1); source_file[sizeof(source_file)-1] = '\0'; + if (strlen(source_file) && source_file[strlen(source_file)-1] == '"') + source_file[strlen(source_file)-1] = '\0'; } |