snprintf(path, sizeof path, "%s/load2", smack_mnt);
fd = open(path, O_RDONLY);
- if (fd < 0)
+ if (fd < 0) {
+ fprintf(stderr, "open() failed for '%s' : %s\n", path, strerror(errno));
return -1;
+ }
ret = apply_rules_file(fd, 1);
close(fd);
int fd;
int ret;
- errno = 0;
- if (stat(path, &sbuf))
+ if (stat(path, &sbuf)) {
+ fprintf(stderr, "stat() failed for '%s' : %s\n", path, strerror(errno));
return -1;
+ }
if (S_ISDIR(sbuf.st_mode))
return nftw(path, apply_rules_cb, 1, FTW_PHYS|FTW_ACTIONRETVAL);
fd = open(path, O_RDONLY);
- if (fd < 0)
+ if (fd < 0) {
+ fprintf(stderr, "open() failed for '%s' : %s\n", path, strerror(errno));
return -1;
+ }
ret = apply_rules_file(fd, clear);
+ if (ret)
+ fprintf(stderr, "Applying rules failed for '%s'.\n", path);
close(fd);
return ret;
}
int fd;
int ret;
- errno = 0;
- if (stat(path, &sbuf))
+ if (stat(path, &sbuf)) {
+ fprintf(stderr, "stat() failed for '%s' : %s\n", path, strerror(errno));
return -1;
+ }
if (S_ISDIR(sbuf.st_mode))
return nftw(path, apply_cipso_cb, 1, FTW_PHYS|FTW_ACTIONRETVAL);
fd = open(path, O_RDONLY);
- if (fd < 0)
+ if (fd < 0) {
+ fprintf(stderr, "open() failed for '%s' : %s\n", path, strerror(errno));
return -1;
+ }
ret = apply_cipso_file(fd);
+ if (ret)
+ fprintf(stderr, "Applying rules failed for '%s'.\n", path);
close(fd);
return ret;
}
return FTW_STOP;
fd = open(fpath, O_RDONLY);
- if (fd < 0)
+ if (fd < 0) {
+ fprintf(stderr, "open() failed for '%s' : %s\n", fpath, strerror(errno));
return -1;
+ }
ret = apply_rules_file(fd, 0) ? FTW_STOP : FTW_CONTINUE;
+ if (ret == FTW_STOP)
+ fprintf(stderr, "Applying rules failed for '%s'.\n", fpath);
close(fd);
return ret;
}
return FTW_STOP;
fd = open(fpath, O_RDONLY);
- if (fd < 0)
+ if (fd < 0) {
+ fprintf(stderr, "open() failed for '%s' : %s\n", fpath, strerror(errno));
return -1;
+ }
ret = apply_cipso_file(fd) ? FTW_STOP : FTW_CONTINUE;
+ if (ret == FTW_STOP)
+ fprintf(stderr, "Applying rules failed for '%s'.\n", fpath);
close(fd);
return ret;
}
#include "common.h"
#include <sys/smack.h>
+#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
return -1;
if (apply_rules(ACCESSES_D_PATH, 0))
- perror("apply_rules");
+ return -1;
if (apply_cipso(CIPSO_D_PATH))
- perror("apply_cipso");
+ return -1;
return 0;
}
const char *tmp = smack_smackfs_path();
if (argc < 2) {
fprintf(stderr, "Usage: %s <action>\n", argv[0]);
- return 1;
+ exit(1);
}
if (!strcmp(argv[1], "apply")) {
if (apply_all())
- return 1;
+ exit(1);
} else if (!strcmp(argv[1], "clear")) {
if (clear())
- return 1;
+ exit(1);
} else if (!strcmp(argv[1], "status")) {
if (smack_smackfs_path())
printf("SmackFS is mounted to %s.\n",
smack_smackfs_path());
else
printf("SmackFS is not mounted.\n");
- return 0;
+ exit(0);
}
fprintf(stderr, "Uknown action: %s\n", argv[1]);
- return 1;
+ exit(1);
}