aliases
I believe that we need a minor change in the policy language to deal with aliases.
The current setup requires that all aliases be specified on the type declaration line. One significant problem with this is that if a type is declared by a macro there is no way to add aliases to it. Because of this we have at various times had aliases specified in macros when they weren't needed for 95% of the cases.
I believe that a declaration of the form is necessary:
typealias foo_t aliases { bar_t baz_t };
That would mean that I could do:
var_run_domain(foo)
typealias foo_var_run_t alias var_run_foo_t;
Instead of having the current alias in the var_run_domain() macro. Of course it's no big deal for the var_run_domain() macro (and I'll remove the alias from my tree because it's been there too long anyway). But there are other situations which are more difficult to manage (such as renaming netscape to mozilla).
Signature · 10 lines
http://www.coker.com.au/selinux/ My NSA Security Enhanced Linux packages http://www.coker.com.au/bonnie++/ Bonnie++ hard drive benchmark http://www.coker.com.au/postal/ Postal SMTP/POP benchmark http://www.coker.com.au/~russell/ My home page -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 14 lines · Russell Coker
I believe that we need a minor change in the policy language to deal with aliases.
The current setup requires that all aliases be specified on the type declaration line. One significant problem with this is that if a type is declared by a macro there is no way to add aliases to it. Because of this we have at various times had aliases specified in macros when they weren't needed for 95% of the cases.
I believe that a declaration of the form is necessary:
typealiasfoo_taliases {bar_tbaz_t};That would mean that I could do:
Quoted 8 lines
var_run_domain(foo)
typealiasfoo_var_run_taliasvar_run_foo_t;Instead of having the current alias in the
var_run_domain()macro. Of course it's no big deal for thevar_run_domain()macro (and I'll remove the alias from my tree because it's been there too long anyway). But there are other situations which are more difficult to manage (such as renaming netscape to mozilla).
Aside from preserving old type names for compatibility, type aliases seem to have little use, and significant potential for confusion.
Signature · 8 lines
Stephen Smalley <[email protected]> National Security Agency -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 14 lines · Russell Coker
I believe that we need a minor change in the policy language to deal with aliases.
The current setup requires that all aliases be specified on the type declaration line. One significant problem with this is that if a type is declared by a macro there is no way to add aliases to it. Because of this we have at various times had aliases specified in macros when they weren't needed for 95% of the cases.
I believe that a declaration of the form is necessary:
typealiasfoo_taliases {bar_tbaz_t};That would mean that I could do:
Quoted 8 lines
var_run_domain(foo)
typealiasfoo_var_run_taliasvar_run_foo_t;Instead of having the current alias in the
var_run_domain()macro. Of course it's no big deal for thevar_run_domain()macro (and I'll remove the alias from my tree because it's been there too long anyway). But there are other situations which are more difficult to manage (such as renaming netscape to mozilla).
A simple patch for checkpolicy that adds such typealias declarations is attached. However, note that this patch only supports typealias declarations _after_ the base type declaration has been processed; removing this ordering dependency would require reworking checkpolicy further, as it currently collects all of the type declarations (including alias and attribute information) in a single pass.
Signature · 2 lines
Stephen Smalley <[email protected]> National Security Agency
Index: checkpolicy/policy_parse.y
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/checkpolicy/policy_parse.y,v retrieving revision 1.11
policy_parse.y +61 -0
@@ -42,6 +42,7 @@ static int define_common_base(void); static int define_av_base(void); static int define_attrib(void); +static int define_typealias(void); static int define_type(int alias); static int define_compute_type(int which); static int define_te_avtab(int which);
@@ -82,6 +83,7 @@ %token SID %token ROLE %token ROLES +%token TYPEALIAS %token TYPE %token TYPES %token ALIAS
@@ -240,6 +242,7 @@ ; te_decl : attribute_def | type_def + | typealias_def | transition_def | te_avtab_def ;
@@ -251,6 +254,9 @@ | TYPE identifier opt_attr_list ';' {if (define_type(0)) return -1;} ; +typealias_def : TYPEALIAS identifier alias_def + {if (define_typealias()) return -1;} + ; opt_attr_list : ',' id_comma_list | ;
@@ -1479,6 +1485,61 @@ return 0; } +static int define_typealias(void) +{ + char *id; + type_datum_t *t, *aliasdatum;; + int ret; + + + if (pass == 2) { + while ((id = queue_remove(id_queue))) + free(id); + return 0; + } + + id = (char *) queue_remove(id_queue); + if (!id) { + yyerror("no type name for typealias definition?"); + return -1; + } + + t = hashtab_search(policydbp->p_types.table, id); + if (!t || t->isattr) { + sprintf(errormsg, "unknown type %s", id); + yyerror(errormsg); + free(id); + return -1; + } + + while ((id = queue_remove(id_queue))) { + aliasdatum = (type_datum_t *) malloc(sizeof(type_datum_t)); + if (!aliasdatum) { + yyerror("out of memory"); + return -1; + } + memset(aliasdatum, 0, sizeof(type_datum_t)); + aliasdatum->value = t->value; + + ret = hashtab_insert(policydbp->p_types.table, + (hashtab_key_t) id, (hashtab_datum_t) aliasdatum); + + if (ret == HASHTAB_PRESENT) { + sprintf(errormsg, "name conflict for type alias %s", id); + yyerror(errormsg); + free(aliasdatum); + free(id); + return -1; + } + if (ret == HASHTAB_OVERFLOW) { + yyerror("hash table overflow"); + free(aliasdatum); + free(id); + return -1; + } + } + return 0; +} static int define_type(int alias) {
Index: checkpolicy/policy_scan.l
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/checkpolicy/policy_scan.l,v retrieving revision 1.3
policy_scan.l +2 -0
@@ -46,6 +46,8 @@ roles { return(ROLES); } TYPES | types { return(TYPES); } +TYPEALIAS | +typealias { return(TYPEALIAS); } TYPE | type { return(TYPE); } ALIAS |