|
From: <ssm...@us...> - 2007-04-24 20:19:27
|
Revision: 2370
http://svn.sourceforge.net/selinux/?rev=2370&view=rev
Author: ssmalley
Date: 2007-04-24 13:19:26 -0700 (Tue, 24 Apr 2007)
Log Message:
-----------
Author: Stephen Smalley
Email: sd...@ty...
Subject: libsemanage: some optimizations
Date: Thu, 19 Apr 2007 14:27:28 -0400
>From the earlier discussion of why setsebool was doing so much work even when
only setting active booleans, I experimented with the two optimizations below.
I have since concluded that setsebool should not use semanage at all for non-persistent
boolean changes (see next patch), but I still think these may be helpful in reducing
extraneous work there.
Two optimizations for libsemanage:
- do not set all booleans upon commit, only those whose values have changed,
- only install the sandbox upon commit if something was rebuilt
Modified Paths:
--------------
trunk/libsemanage/src/booleans_activedb.c
trunk/libsemanage/src/direct_api.c
Modified: trunk/libsemanage/src/booleans_activedb.c
===================================================================
--- trunk/libsemanage/src/booleans_activedb.c 2007-04-24 20:16:42 UTC (rev 2369)
+++ trunk/libsemanage/src/booleans_activedb.c 2007-04-24 20:19:26 UTC (rev 2370)
@@ -92,8 +92,10 @@
{
SELboolean *blist = NULL;
+ const char *name;
unsigned int bcount = 0;
unsigned int i;
+ int curvalue, newvalue;
/* Allocate a sufficiently large array */
blist = malloc(sizeof(SELboolean) * count);
@@ -102,11 +104,18 @@
/* Populate array */
for (i = 0; i < count; i++) {
- blist[i].name = strdup(semanage_bool_get_name(booleans[i]));
+ name = semanage_bool_get_name(booleans[i]);
+ if (!name)
+ goto omem;
+ newvalue = semanage_bool_get_value(booleans[i]);
+ curvalue = security_get_boolean_active(name);
+ if (newvalue == curvalue)
+ continue;
+ blist[bcount].name = strdup(name);
+ if (blist[bcount].name == NULL)
+ goto omem;
+ blist[bcount].value = newvalue;
bcount++;
- if (blist[i].name == NULL)
- goto omem;
- blist[i].value = semanage_bool_get_value(booleans[i]);
}
/* Commit */
Modified: trunk/libsemanage/src/direct_api.c
===================================================================
--- trunk/libsemanage/src/direct_api.c 2007-04-24 20:16:42 UTC (rev 2369)
+++ trunk/libsemanage/src/direct_api.c 2007-04-24 20:19:26 UTC (rev 2370)
@@ -699,7 +699,9 @@
if (retval < 0)
goto cleanup;
- retval = semanage_install_sandbox(sh);
+ if (sh->do_rebuild || modified) {
+ retval = semanage_install_sandbox(sh);
+ }
cleanup:
for (i = 0; mod_filenames != NULL && i < num_modfiles; i++) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|