int clear(void) { int fd; int ret; const char * smack_mnt; char path[PATH_MAX]; smack_mnt = smack_smackfs_path(); if (!smack_mnt) { errno = EFAULT; return -1; } if (is_smackfs_mounted() != 1) return -1; snprintf(path, sizeof path, "%s/load2", smack_mnt); fd = open(path, O_RDONLY); if (fd < 0) return -1; ret = apply_rules_file(fd, 1); close(fd); return ret; }
static int status(void) { int ret = is_smackfs_mounted(); switch (ret) { case 1: printf("SmackFS is mounted.\n"); return 0; case 0: printf("SmackFS is not mounted.\n"); return 0; default: return -1; } }
static int apply_all(void) { if (is_smackfs_mounted() != 1) { fprintf(stderr, "ERROR: SmackFS is not mounted.\n"); return -1; } if (clear()) return -1; if (apply_rules(ACCESSES_D_PATH, 0)) perror("apply_rules"); if (apply_cipso(CIPSO_D_PATH)) perror("apply_cipso"); return 0; }