Blame SOURCES/0002-setools-should-exit-with-an-error-status-if-it-gets-.patch

25bb7d
From 667fe9187c203ffcba855e821dff11c8f71ef000 Mon Sep 17 00:00:00 2001
25bb7d
From: Dan Walsh <dwalsh@redhat.com>
25bb7d
Date: Tue, 20 Sep 2011 15:39:51 -0400
25bb7d
Subject: [PATCH 2/6] setools-should-exit-with-an-error-status-if-it-gets-an
25bb7d
 error
25bb7d
25bb7d
---
25bb7d
 secmds/seinfo.c |   51 +++++++++++++++++++++++++++------------------------
25bb7d
 1 files changed, 27 insertions(+), 24 deletions(-)
25bb7d
25bb7d
diff --git a/secmds/seinfo.c b/secmds/seinfo.c
25bb7d
index fdf23e9..3088f88 100644
25bb7d
--- a/secmds/seinfo.c
25bb7d
+++ b/secmds/seinfo.c
25bb7d
@@ -827,7 +827,7 @@ static int print_sens(FILE * fp, const char *name, int expand, const apol_policy
25bb7d
  */
25bb7d
 static int print_cats(FILE * fp, const char *name, int expand, const apol_policy_t * policydb)
25bb7d
 {
25bb7d
-	int retval = 0;
25bb7d
+	int retval = -1;
25bb7d
 	apol_cat_query_t *query = NULL;
25bb7d
 	apol_vector_t *v = NULL;
25bb7d
 	const qpol_cat_t *cat_datum = NULL;
25bb7d
@@ -911,9 +911,10 @@ static int print_fsuse(FILE * fp, const char *type, const apol_policy_t * policy
25bb7d
 		fprintf(fp, "   %s\n", tmp);
25bb7d
 		free(tmp);
25bb7d
 	}
25bb7d
-	if (type && !apol_vector_get_size(v))
25bb7d
+	if (type && !apol_vector_get_size(v)) {
25bb7d
 		ERR(policydb, "No fs_use statement for filesystem of type %s.", type);
25bb7d
-
25bb7d
+		goto cleanup;
25bb7d
+	}
25bb7d
 	retval = 0;
25bb7d
       cleanup:
25bb7d
 	apol_fs_use_query_destroy(&query);
25bb7d
@@ -949,7 +950,6 @@ static int print_genfscon(FILE * fp, const char *type, const apol_policy_t * pol
25bb7d
 		ERR(policydb, "%s", strerror(ENOMEM));
25bb7d
 		goto cleanup;
25bb7d
 	}
25bb7d
-
25bb7d
 	if (apol_genfscon_query_set_filesystem(policydb, query, type))
25bb7d
 		goto cleanup;
25bb7d
 	if (apol_genfscon_get_by_query(policydb, query, &v))
25bb7d
@@ -967,8 +967,10 @@ static int print_genfscon(FILE * fp, const char *type, const apol_policy_t * pol
25bb7d
 		free(tmp);
25bb7d
 	}
25bb7d
 
25bb7d
-	if (type && !apol_vector_get_size(v))
25bb7d
+	if (type && !apol_vector_get_size(v)) {
25bb7d
 		ERR(policydb, "No genfscon statement for filesystem of type %s.", type);
25bb7d
+		goto cleanup;
25bb7d
+	}
25bb7d
 
25bb7d
 	retval = 0;
25bb7d
       cleanup:
25bb7d
@@ -1646,6 +1648,7 @@ cleanup:	// close and destroy iterators etc.
25bb7d
 
25bb7d
 int main(int argc, char **argv)
25bb7d
 {
25bb7d
+	int rc = 0;
25bb7d
 	int classes, types, attribs, roles, users, all, expand, stats, rt, optc, isids, bools, sens, cats, fsuse, genfs, netif,
25bb7d
 		node, port, permissives, polcaps, constrain, linebreaks;
25bb7d
 	apol_policy_t *policydb = NULL;
25bb7d
@@ -1851,46 +1854,46 @@ int main(int argc, char **argv)
25bb7d
 
25bb7d
 	/* display requested info */
25bb7d
 	if (stats || all)
25bb7d
-		print_stats(stdout, policydb);
25bb7d
+		rc = print_stats(stdout, policydb);
25bb7d
 	if (classes || all)
25bb7d
-		print_classes(stdout, class_name, expand, policydb);
25bb7d
+		rc = print_classes(stdout, class_name, expand, policydb);
25bb7d
 	if (types || all)
25bb7d
-		print_types(stdout, type_name, expand, policydb);
25bb7d
+		rc = print_types(stdout, type_name, expand, policydb);
25bb7d
 	if (attribs || all)
25bb7d
-		print_attribs(stdout, attrib_name, expand, policydb);
25bb7d
+		rc = print_attribs(stdout, attrib_name, expand, policydb);
25bb7d
 	if (roles || all)
25bb7d
-		print_roles(stdout, role_name, expand, policydb);
25bb7d
+		rc = print_roles(stdout, role_name, expand, policydb);
25bb7d
 	if (users || all)
25bb7d
-		print_users(stdout, user_name, expand, policydb);
25bb7d
+		rc = print_users(stdout, user_name, expand, policydb);
25bb7d
 	if (bools || all)
25bb7d
-		print_booleans(stdout, bool_name, expand, policydb);
25bb7d
+		rc = print_booleans(stdout, bool_name, expand, policydb);
25bb7d
 	if (sens || all)
25bb7d
-		print_sens(stdout, sens_name, expand, policydb);
25bb7d
+		rc = print_sens(stdout, sens_name, expand, policydb);
25bb7d
 	if (cats || all)
25bb7d
-		print_cats(stdout, cat_name, expand, policydb);
25bb7d
+		rc = print_cats(stdout, cat_name, expand, policydb);
25bb7d
 	if (fsuse || all)
25bb7d
-		print_fsuse(stdout, fsuse_type, policydb);
25bb7d
+		rc = print_fsuse(stdout, fsuse_type, policydb);
25bb7d
 	if (genfs || all)
25bb7d
-		print_genfscon(stdout, genfs_type, policydb);
25bb7d
+		rc = print_genfscon(stdout, genfs_type, policydb);
25bb7d
 	if (netif || all)
25bb7d
-		print_netifcon(stdout, netif_name, policydb);
25bb7d
+		rc = print_netifcon(stdout, netif_name, policydb);
25bb7d
 	if (node || all)
25bb7d
-		print_nodecon(stdout, node_addr, policydb);
25bb7d
+		rc = print_nodecon(stdout, node_addr, policydb);
25bb7d
 	if (port || all)
25bb7d
-		print_portcon(stdout, port_num, protocol, policydb);
25bb7d
+		rc = print_portcon(stdout, port_num, protocol, policydb);
25bb7d
 	if (isids || all)
25bb7d
-		print_isids(stdout, isid_name, expand, policydb);
25bb7d
+		rc = print_isids(stdout, isid_name, expand, policydb);
25bb7d
 	if (permissives || all)
25bb7d
-		print_permissives(stdout, permissive_name, expand, policydb);
25bb7d
+		rc = print_permissives(stdout, permissive_name, expand, policydb);
25bb7d
 	if (polcaps || all)
25bb7d
-		print_polcaps(stdout, polcap_name, expand, policydb);
25bb7d
+		rc = print_polcaps(stdout, polcap_name, expand, policydb);
25bb7d
 	if (constrain || all)
25bb7d
-		print_constraints(stdout, expand, policydb, linebreaks);
25bb7d
+		rc = print_constraints(stdout, expand, policydb, linebreaks);
25bb7d
 
25bb7d
 	apol_policy_destroy(&policydb);
25bb7d
 	apol_policy_path_destroy(&pol_path);
25bb7d
 	free(policy_file);
25bb7d
-	exit(0);
25bb7d
+	exit(rc);
25bb7d
 }
25bb7d
 
25bb7d
 /**
25bb7d
-- 
25bb7d
1.7.6.2
25bb7d