* [SEMANAGE][SEPOL] Minor cleanups
@ 2006-02-08 8:24 Ivan Gyurdiev
2006-02-14 19:02 ` Stephen Smalley
0 siblings, 1 reply; 2+ messages in thread
From: Ivan Gyurdiev @ 2006-02-08 8:24 UTC (permalink / raw)
To: SELinux List; +Cc: Stephen Smalley
[-- 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)
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [SEMANAGE][SEPOL] Minor cleanups
2006-02-08 8:24 [SEMANAGE][SEPOL] Minor cleanups Ivan Gyurdiev
@ 2006-02-14 19:02 ` Stephen Smalley
0 siblings, 0 replies; 2+ messages in thread
From: Stephen Smalley @ 2006-02-14 19:02 UTC (permalink / raw)
To: Ivan Gyurdiev; +Cc: SELinux List
On Wed, 2006-02-08 at 03:24 -0500, Ivan Gyurdiev wrote:
> 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
Merged.
--
Stephen Smalley
National Security Agency
--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-02-14 19:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-08 8:24 [SEMANAGE][SEPOL] Minor cleanups Ivan Gyurdiev
2006-02-14 19:02 ` Stephen Smalley
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.