Jeremy A. Mowery jmowery@tresys.com
Jason Tang jtang@tresys.com
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Definition in file isid_query.h.
#include <stddef.h>
#include <stdint.h>
#include <qpol/iterator.h>
#include <qpol/policy.h>
Go to the source code of this file.
Typedefs | |
| typedef qpol_isid | qpol_isid_t |
Functions | |
| int | qpol_policy_get_isid_by_name (const qpol_policy_t *policy, const char *name, const qpol_isid_t **ocon) |
| Get an initial SID statement by name. | |
| int | qpol_policy_get_isid_iter (const qpol_policy_t *policy, qpol_iterator_t **iter) |
| Get an iterator for the initial SID statements in a policy. | |
| int | qpol_isid_get_name (const qpol_policy_t *policy, const qpol_isid_t *ocon, const char **name) |
| Get the name from an initial SID statement. | |
| int | qpol_isid_get_context (const qpol_policy_t *policy, const qpol_isid_t *ocon, const qpol_context_t **context) |
| Get the context from an initial SID statement. | |
|
|
Definition at line 39 of file isid_query.h. Referenced by apol_isid_get_by_query(), find_assoc_types_run(), find_netif_types_run(), find_node_types_run(), find_port_types_run(), in_isid_ctx(), print_isids(), and qpol_policy_get_isid_by_name(). |
|
||||||||||||||||
|
Get an initial SID statement by name.
Definition at line 37 of file isid_query.c. References ERR, qpol_policy::p, qpol_isid_t, and qpol_policy_t. Referenced by find_assoc_types_run(), find_netif_types_run(), find_node_types_run(), and find_port_types_run(). 00038 {
00039 ocontext_t *tmp = NULL;
00040 policydb_t *db = NULL;
00041
00042 if (ocon != NULL)
00043 *ocon = NULL;
00044
00045 if (policy == NULL || name == NULL || ocon == NULL) {
00046 ERR(policy, "%s", strerror(EINVAL));
00047 errno = EINVAL;
00048 return STATUS_ERR;
00049 }
00050
00051 db = &policy->p->p;
00052 for (tmp = db->ocontexts[OCON_ISID]; tmp; tmp = tmp->next) {
00053 if (!strcmp(name, tmp->u.name))
00054 break;
00055 }
00056
00057 *ocon = (qpol_isid_t *) tmp;
00058
00059 if (*ocon == NULL) {
00060 ERR(policy, "could not find initial SID statement for %s", name);
00061 errno = ENOENT;
00062 return STATUS_ERR;
00063 }
00064
00065 return STATUS_SUCCESS;
00066 }
|
|
||||||||||||
|
Get an iterator for the initial SID statements in a policy.
Definition at line 68 of file isid_query.c. References ocon_state::cur, ERR, ocon_state::head, ocon_state_end(), ocon_state_get_cur(), ocon_state_next(), ocon_state_size(), ocon_state_t, qpol_policy::p, qpol_iterator_create(), qpol_iterator_t, and qpol_policy_t. Referenced by apol_isid_get_by_query(), in_isid_ctx(), and print_stats(). 00069 {
00070 policydb_t *db = NULL;
00071 ocon_state_t *os = NULL;
00072 int error = 0;
00073
00074 if (iter != NULL)
00075 *iter = NULL;
00076
00077 if (policy == NULL || iter == NULL) {
00078 ERR(policy, "%s", strerror(EINVAL));
00079 errno = EINVAL;
00080 return STATUS_ERR;
00081 }
00082
00083 db = &policy->p->p;
00084
00085 os = calloc(1, sizeof(ocon_state_t));
00086 if (os == NULL) {
00087 error = errno;
00088 ERR(policy, "%s", strerror(ENOMEM));
00089 errno = error;
00090 return STATUS_ERR;
00091 }
00092
00093 os->head = os->cur = db->ocontexts[OCON_ISID];
00094
00095 if (qpol_iterator_create(policy, (void *)os, ocon_state_get_cur,
00096 ocon_state_next, ocon_state_end, ocon_state_size, free, iter)) {
00097 free(os);
00098 return STATUS_ERR;
00099 }
00100 return STATUS_SUCCESS;
00101 }
|
|
||||||||||||||||
|
Get the name from an initial SID statement.
Definition at line 103 of file isid_query.c. References ERR, and qpol_policy_t. Referenced by apol_isid_get_by_query(), and print_isids(). 00104 {
00105 ocontext_t *internal_ocon = NULL;
00106
00107 if (name != NULL)
00108 *name = NULL;
00109
00110 if (policy == NULL || ocon == NULL || name == NULL) {
00111 ERR(policy, "%s", strerror(EINVAL));
00112 errno = EINVAL;
00113 return STATUS_ERR;
00114 }
00115
00116 internal_ocon = (ocontext_t *) ocon;
00117 *name = internal_ocon->u.name;
00118
00119 return STATUS_SUCCESS;
00120 }
|
|
||||||||||||||||
|
Get the context from an initial SID statement.
Definition at line 122 of file isid_query.c. References ERR, qpol_context_t, and qpol_policy_t. Referenced by apol_isid_get_by_query(), find_assoc_types_run(), find_netif_types_run(), find_node_types_run(), find_port_types_run(), in_isid_ctx(), and print_isids(). 00123 {
00124 ocontext_t *internal_ocon = NULL;
00125
00126 if (context != NULL)
00127 *context = NULL;
00128
00129 if (policy == NULL || ocon == NULL || context == NULL) {
00130 ERR(policy, "%s", strerror(EINVAL));
00131 errno = EINVAL;
00132 return STATUS_ERR;
00133 }
00134
00135 internal_ocon = (ocontext_t *) ocon;
00136 *context = (qpol_context_t *) & (internal_ocon->context[0]);
00137
00138 return STATUS_SUCCESS;
00139 }
|