From 1d272c2d0305c8c625b48f3339db1f6ff60b146c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Bollo?= Date: Fri, 3 Oct 2014 17:08:03 +0200 Subject: [PATCH] MSM: Avoid creating empty access rule files MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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: 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 --- plugins/msmxattr.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/msmxattr.c b/plugins/msmxattr.c index e1f0008..0cd6752 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) -- 2.7.4