summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@open.eurogiciel.org>2014-10-03 17:08:03 +0200
committerJosé Bollo <jose.bollo@open.eurogiciel.org>2014-10-03 17:08:03 +0200
commit1d272c2d0305c8c625b48f3339db1f6ff60b146c (patch)
tree9d3f0fed81b41929f127996c6a4ffeb6b54faa49
parent6af979ffe246fcc3c5286893f364a4691094beca (diff)
downloadrpm-1d272c2d0305c8c625b48f3339db1f6ff60b146c.tar.gz
rpm-1d272c2d0305c8c625b48f3339db1f6ff60b146c.tar.bz2
rpm-1d272c2d0305c8c625b48f3339db1f6ff60b146c.zip
MSM: Avoid creating empty access rule files
The msm plugin creates one access rule file in SMACK_RULES_PATH=/etc/smack/accesses.d for each RPM installed. Since Tizen 3, the guideline for packages is simplified and the new guideline states that manifest files have to be as simple as: <manifest> <request> <domain name="_"/> </request> </manifest> It means that most access rule files are empty. Thus, this patch removes the file if it is empty because without any penality, it improves: - the start time of the system - the administration of the system The start time is improved because at start, all the files in /etc/smack/accesses.d are read and loaded to the kernel. As empty files are just removed, no time is spend to seek it, open it, read it, close it, apply empty rule. The administration is also improved because only meaning access rule files are retains, avoid to have to sort what is meaning and what is not. Change-Id: I7b40f2b291f0c1dbcb2f033f62191c651430e3c8 Signed-off-by: José Bollo <jose.bollo@open.eurogiciel.org>
-rw-r--r--plugins/msmxattr.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/plugins/msmxattr.c b/plugins/msmxattr.c
index e1f0008ef..0cd675245 100644
--- a/plugins/msmxattr.c
+++ b/plugins/msmxattr.c
@@ -989,6 +989,7 @@ package_x *msmCreatePackage(const char *name, sw_source_x *sw_source, provide_x
int msmSetupSmackRules(struct smack_accesses *smack_accesses, const char* package_name, int flag, int SmackEnabled)
{
int ret = 0;
+ int empty = 0;
char * buffer = calloc(strlen(SMACK_RULES_PATH) + strlen(package_name) + 1, sizeof(char));
if (!buffer) return -1;
strncpy(buffer, SMACK_RULES_PATH, strlen(SMACK_RULES_PATH));
@@ -1035,10 +1036,13 @@ int msmSetupSmackRules(struct smack_accesses *smack_accesses, const char* packag
ret = smack_accesses_save(smack_accesses, fileno(fd));
rpmlog(RPMLOG_DEBUG, "ret in installation %d\n", ret);
if (!ret) {
+ empty = !ftell(fd);
if (SmackEnabled == 1)
ret = smack_accesses_apply(smack_accesses);
}
fclose(fd);
+ if (empty)
+ unlink(buffer); /* status not checked because it dont care */
}
free(buffer);
if (ret)