Home | History | Annotate | Download | only in tests
      1 /*
      2  * Author: Joshua Brindle <jbrindle (at) tresys.com>
      3  *         Chad Sellers <csellers (at) tresys.com>
      4  *
      5  * Copyright (C) 2006 Tresys Technology, LLC
      6  *
      7  *  This library is free software; you can redistribute it and/or
      8  *  modify it under the terms of the GNU Lesser General Public
      9  *  License as published by the Free Software Foundation; either
     10  *  version 2.1 of the License, or (at your option) any later version.
     11  *
     12  *  This library is distributed in the hope that it will be useful,
     13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
     14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     15  *  Lesser General Public License for more details.
     16  *
     17  *  You should have received a copy of the GNU Lesser General Public
     18  *  License along with this library; if not, write to the Free Software
     19  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
     20  */
     21 
     22 #ifndef __COMMON_H__
     23 #define __COMMON_H__
     24 
     25 #include <sepol/policydb/policydb.h>
     26 #include <sepol/policydb/conditional.h>
     27 
     28 /* helper functions */
     29 
     30 /* Load a source policy into p. policydb_init will called within this function.
     31  *
     32  * Example: test_load_policy(p, POLICY_BASE, 1, "foo", "base.conf") will load the
     33  *  policy "policies/foo/mls/base.conf" into p.
     34  *
     35  * Arguments:
     36  *  p            policydb_t into which the policy will be read. This should be
     37  *                malloc'd but not passed to policydb_init.
     38  *  policy_type  Type of policy expected - POLICY_BASE or POLICY_MOD.
     39  *  mls          Boolean value indicating whether an mls policy is expected.
     40  *  test_name    Name of the test which will be the name of the directory in
     41  *                which the policies are stored.
     42  *  policy_name  Name of the policy in the directory.
     43  *
     44  * Returns:
     45  *  0            success
     46  * -1            error - the policydb will be destroyed but not freed.
     47  */
     48 extern int test_load_policy(policydb_t * p, int policy_type, int mls, const char *test_name, const char *policy_name);
     49 
     50 /* Find an avrule_decl_t by a unique symbol. If the symbol is declared in more
     51  * than one decl an error is returned.
     52  *
     53  * Returns:
     54  *  decl      success
     55  *  NULL      error (including more than one declaration)
     56  */
     57 extern avrule_decl_t *test_find_decl_by_sym(policydb_t * p, int symtab, char *sym);
     58 
     59 #endif
     60