All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ivan Gyurdiev <ivg2@cornell.edu>
To: SELinux List <SELinux@tycho.nsa.gov>
Cc: Stephen Smalley <sds@tycho.nsa.gov>
Subject: [SEMANAGE][SEPOL] Minor cleanups
Date: Wed, 08 Feb 2006 03:24:33 -0500	[thread overview]
Message-ID: <43E9AAC1.804@cornell.edu> (raw)

[-- Attachment #1: Type: text/plain, Size: 250 bytes --]

This is left over after my other patches are applied...
- port and interface list traversals are confusing because of unneded 
variable
- increase verbosity in some error messages
- semanage: don't shadow type_str the function to keep gcc happy






[-- Attachment #2: libsemanage.sepol.cleanups.diff --]
[-- Type: text/x-patch, Size: 3834 bytes --]

diff -Naurp --exclude-from excludes old/libsemanage/src/fcontexts_file.c new/libsemanage/src/fcontexts_file.c
--- old/libsemanage/src/fcontexts_file.c	2006-02-08 03:13:23.000000000 -0500
+++ new/libsemanage/src/fcontexts_file.c	2006-02-04 02:05:59.000000000 -0500
@@ -52,7 +52,7 @@ static int fcontext_print(
 	const char* expr = semanage_fcontext_get_expr(fcontext);
 	int type = semanage_fcontext_get_type(fcontext);
 	const char* print_str = type_str(type);
-	const char* type_str = semanage_fcontext_get_type_str(type);
+	const char* tstr = semanage_fcontext_get_type_str(type);
 	semanage_context_t* con = semanage_fcontext_get_con(fcontext);
 
 	if (fprintf(str, "%s %s ", expr, print_str) < 0)
@@ -73,7 +73,7 @@ static int fcontext_print(
 
 	err:
 	ERR(handle, "could not print file context for "
-		"%s (%s) to stream", expr, type_str);
+		"%s (%s) to stream", expr, tstr);
 	free(con_str);
 	return STATUS_ERR;
 }
diff -Naurp --exclude-from excludes old/libsepol/src/interfaces.c new/libsepol/src/interfaces.c
--- old/libsepol/src/interfaces.c	2006-02-08 03:13:24.000000000 -0500
+++ new/libsepol/src/interfaces.c	2006-02-03 19:34:08.000000000 -0500
@@ -248,11 +248,11 @@ int sepol_iface_iterate(
 	void* arg) {
 
 	const policydb_t *policydb = &p->p;
-	ocontext_t *c, *l, *head;
+	ocontext_t *c, *head;
 	sepol_iface_t* iface = NULL;
 
 	head = policydb->ocontexts[OCON_NETIF];
-	for (l = NULL, c = head; c; l = c, c = c->next) {
+	for (c = head; c; c = c->next) {
 		int status;
 
 		if (iface_to_record(handle, policydb, c, &iface) < 0)
diff -Naurp --exclude-from excludes old/libsepol/src/ports.c new/libsepol/src/ports.c
--- old/libsepol/src/ports.c	2006-02-08 03:13:24.000000000 -0500
+++ new/libsepol/src/ports.c	2006-02-03 20:25:06.000000000 -0500
@@ -51,19 +51,23 @@ static int port_from_record(
 	context_struct_t* tmp_con = NULL;
 	int tmp_proto;
 
+	int low = sepol_port_get_low(data);
+	int high = sepol_port_get_high(data);
+	int proto = sepol_port_get_proto(data);
+
 	tmp_port = (ocontext_t *) calloc(1, sizeof(ocontext_t));
 	if (!tmp_port) 
 		goto omem;
 	
 	/* Process protocol */
-	tmp_proto = sepol2ipproto(handle, sepol_port_get_proto(data));
+	tmp_proto = sepol2ipproto(handle, proto);
 	if (tmp_proto < 0)
 		goto err;
 	tmp_port->u.port.protocol = tmp_proto;
 
 	/* Port range */
-	tmp_port->u.port.low_port = sepol_port_get_low(data);
-	tmp_port->u.port.high_port = sepol_port_get_high(data);
+	tmp_port->u.port.low_port = low;
+	tmp_port->u.port.high_port = high;
 	if (tmp_port->u.port.low_port > tmp_port->u.port.high_port) {
 		ERR(handle, "low port %d exceeds high port %d",
 			tmp_port->u.port.low_port, 
@@ -93,7 +97,8 @@ static int port_from_record(
         }
 	context_destroy(tmp_con);
 	free(tmp_con);
-	ERR(handle, "error creating port structure");
+	ERR(handle, "could not create port structure for range %u:%u (%s)",
+		low, high, sepol_port_get_proto_str(proto));
 	return STATUS_ERR;
 }
 
@@ -207,7 +212,7 @@ int sepol_port_query(
 	sepol_port_t** response) {
 
 	const policydb_t *policydb = &p->p;
-	ocontext_t *c, *l, *head;
+	ocontext_t *c, *head;
 
 	int low, high, proto;
 	const char* proto_str;
@@ -218,7 +223,7 @@ int sepol_port_query(
 		goto err;
 
 	head = policydb->ocontexts[OCON_PORT];
-	for (l = NULL, c = head; c; l = c, c = c->next) {
+	for (c = head; c; c = c->next) {
 		int proto2 = c->u.port.protocol;
 		int low2 = c->u.port.low_port;
 		int high2 = c->u.port.high_port;
@@ -309,11 +314,11 @@ int sepol_port_iterate(
 	void* arg) {
 
 	const policydb_t *policydb = &p->p;
-	ocontext_t *c, *l, *head;
+	ocontext_t *c, *head;
 	sepol_port_t* port = NULL;	
 
 	head = policydb->ocontexts[OCON_PORT];
-	for (l = NULL, c = head; c; l = c, c = c->next) {
+	for (c = head; c; c = c->next) {
 		int status;
 
 		if (port_to_record(handle, policydb, c, &port) < 0)

             reply	other threads:[~2006-02-08  8:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-08  8:24 Ivan Gyurdiev [this message]
2006-02-14 19:02 ` [SEMANAGE][SEPOL] Minor cleanups Stephen Smalley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=43E9AAC1.804@cornell.edu \
    --to=ivg2@cornell.edu \
    --cc=SELinux@tycho.nsa.gov \
    --cc=sds@tycho.nsa.gov \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.