From dfbbe9af3de8ee94d02b17b338d6601431ee12e3 Mon Sep 17 00:00:00 2001 From: Jarkko Sakkinen Date: Thu, 20 Oct 2011 13:31:27 +0300 Subject: [PATCH] smackctl: code cleanup --- tests/smackctl.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/smackctl.c b/tests/smackctl.c index b6b7f48..394d079 100644 --- a/tests/smackctl.c +++ b/tests/smackctl.c @@ -35,8 +35,8 @@ #define SMACKFS_MAGIC 0x43415d53 -static int start(void); -static int stop(void); +static int apply(void); +static int clear(void); static int status(void); static int is_smackfs_mounted(void); static int apply_rules(const char *path, int flags); @@ -50,14 +50,11 @@ int main(int argc, char **argv) return 1; } - if (!strcmp(argv[1], "start")) { - if (start()) + if (!strcmp(argv[1], "apply")) { + if (apply()) return 1; - } else if (!strcmp(argv[1], "restart")) { - if (stop() || start()) - return 1; - } else if (!strcmp(argv[1], "stop")) { - if (stop()) + } else if (!strcmp(argv[1], "clear")) { + if (clear()) return 1; } else if (!strcmp(argv[1], "status")) { if (status()) @@ -70,7 +67,7 @@ int main(int argc, char **argv) return 0; } -static int start(void) +static int apply(void) { struct stat sbuf; @@ -79,6 +76,9 @@ static int start(void) return -1; } + if (apply_rules("/smack/load", SMACK_RULE_SET_APPLY_CLEAR)) + return -1; + if (stat("/etc/smack/accesses", &sbuf) && errno != ENOENT) { perror("stat"); return -1; @@ -88,7 +88,7 @@ static int start(void) return 0; } -static int stop(void) +static int clear(void) { if (is_smackfs_mounted() != 1) { fprintf(stderr, "ERROR: SmackFS is not mounted.\n"); -- 2.7.4