Add alias support to seinfo -t

This commit is contained in:
Dan Walsh 2013-03-28 13:32:30 -04:00
parent 87688b7eb6
commit 87ef079e2e
2 changed files with 88 additions and 1 deletions

82
0015-aliases.patch Normal file
View File

@ -0,0 +1,82 @@
diff -up setools-3.3.7/libapol/src/policy-query.c~ setools-3.3.7/libapol/src/policy-query.c
diff -up setools-3.3.7/libqpol/include/qpol/type_query.h~ setools-3.3.7/libqpol/include/qpol/type_query.h
diff -up setools-3.3.7/libqpol/tests/iterators-tests.c~ setools-3.3.7/libqpol/tests/iterators-tests.c
diff -up setools-3.3.7/secmds/seinfo.c~ setools-3.3.7/secmds/seinfo.c
--- setools-3.3.7/secmds/seinfo.c~ 2013-03-25 11:30:23.161633059 -0400
+++ setools-3.3.7/secmds/seinfo.c 2013-03-28 13:08:07.281751011 -0400
@@ -46,6 +46,7 @@
#include <string.h>
#include <assert.h>
#include <getopt.h>
+#include <selinux/selinux.h>
#define COPYRIGHT_INFO "Copyright (C) 2003-2007 Tresys Technology, LLC"
@@ -54,6 +55,7 @@
static char *policy_file = NULL;
+static void print_type_aliases(FILE * fp, const qpol_type_t * type_datum, const apol_policy_t * policydb);
static void print_type_attrs(FILE * fp, const qpol_type_t * type_datum, const apol_policy_t * policydb, const int expand);
static void print_attr_types(FILE * fp, const qpol_type_t * type_datum, const apol_policy_t * policydb, const int expand);
static void print_user_roles(FILE * fp, const qpol_user_t * user_datum, const apol_policy_t * policydb, const int expand);
@@ -511,6 +513,7 @@ static int print_types(FILE * fp, const
if (qpol_policy_get_type_by_name(q, name, &type_datum))
goto cleanup;
print_type_attrs(fp, type_datum, policydb, expand);
+ print_type_aliases(fp, type_datum, policydb);
} else {
if (qpol_policy_get_type_iter(q, &iter))
goto cleanup;
@@ -1897,6 +1900,51 @@ int main(int argc, char **argv)
}
/**
+ * Prints the alias of a type.
+ *
+ * @param fp Reference to a file to which to print type information
+ * @param type_datum Reference to sepol type_datum
+ * @param policydb Reference to a policy
+ * attributes
+ */
+static void print_type_aliases(FILE * fp, const qpol_type_t * type_datum, const apol_policy_t * policydb)
+{
+ qpol_iterator_t *iter = NULL;
+ size_t alias_size;
+ unsigned char isattr, isalias;
+ const char *type_name = NULL;
+ const char *alias_name;
+ qpol_policy_t *q = apol_policy_get_qpol(policydb);
+
+ if (qpol_type_get_name(q, type_datum, &type_name))
+ goto cleanup;
+ if (qpol_type_get_isattr(q, type_datum, &isattr))
+ goto cleanup;
+ if (qpol_type_get_isalias(q, type_datum, &isalias))
+ goto cleanup;
+
+ if (isalias) {
+ fprintf(fp, " TypeName %s\n", type_name);
+ }
+ if (qpol_type_get_alias_iter(q, type_datum, &iter))
+ goto cleanup;
+ if (qpol_iterator_get_size(iter, &alias_size))
+ goto cleanup;
+ if (alias_size > 0) {
+ fprintf(fp, " Aliases\n");
+ for (; !qpol_iterator_end(iter); qpol_iterator_next(iter)) {
+ if (qpol_iterator_get_item(iter, (void **)&alias_name))
+ goto cleanup;
+ fprintf(fp, " %s\n", alias_name);
+ }
+ }
+
+ cleanup:
+ qpol_iterator_destroy(&iter);
+ return;
+}
+
+/**
* Prints a textual representation of a type, and possibly
* all of that type's attributes.
*

View File

@ -3,7 +3,7 @@
Name: setools
Version: %{setools_maj_ver}.%{setools_min_ver}
Release: 36%{?dist}
Release: 37%{?dist}
License: GPLv2
URL: http://oss.tresys.com/projects/setools
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
@ -24,6 +24,7 @@ Patch11: 0011-setools-noship.patch
Patch12: 0012-seaudit.patch
Patch13: 0013-swig.patch
Patch14: 0014-boolsub.patch
Patch15: 0015-aliases.patch
Summary: Policy analysis tools for SELinux
Group: System Environment/Base
@ -163,6 +164,7 @@ This package includes the following graphical tools:
%patch12 -p 1 -b .seaudit
%patch13 -p 1 -b .swig
%patch14 -p 2 -b .boolsub
%patch15 -p 1 -b .aliases
%ifarch sparc sparcv9 sparc64 s390 s390x
for file in `find . -name Makefile.am`; do
sed -i -e 's:-fpic:-fPIC:' $file;
@ -279,6 +281,9 @@ rm -rf ${RPM_BUILD_ROOT}
%postun libs-tcl -p /sbin/ldconfig
%changelog
* Thu Mar 28 2013 Dan Walsh <dwalsh@redhat.com> - 3.3.7-37
- Add alias support to seinfo -t
* Fri Mar 15 2013 Dan Walsh <dwalsh@redhat.com> - 3.3.7-36
- Drop support for python bindings