struct cipso_mapping *last;
};
-static int apply_rules_file(int fd, int clear);
static int apply_rules_cb(const char *fpath, const struct stat *sb, int typeflag, struct FTW *ftwbuf);
-
static int apply_cipso_file(const char *path);
static int apply_cipso_cb(const char *fpath, const struct stat *sb, int typeflag, struct FTW *ftwbuf);
static struct cipso *cipso_new(const char *path);
static void cipso_free(struct cipso *cipso);
static int cipso_apply(struct cipso *cipso);
-
int is_smackfs_mounted(void)
{
struct statfs sfs;
return 0;
}
-static int apply_rules_file(int fd, int clear)
+int apply_rules_file(int fd, int clear)
{
struct smack_accesses *rules = NULL;
int ret = 0;
int is_smackfs_mounted(void);
int apply_rules(const char *path, int clear);
int apply_cipso(const char *path);
+int apply_rules_file(int fd, int clear);
#endif // COMMON_H
*
* Authors:
* Brian McGillion <brian.mcgillion@intel.com>
+ * Jarkko Sakkinen <jarkko.sakkinen@intel.com>
*/
#include "common.h"
int clear = 0;
int c;
+ if (is_smackfs_mounted() != 1) {
+ fprintf(stderr, "SmackFS is not mounted.\n");
+ exit(1);
+ }
+
while ((c = getopt(argc, argv, "c")) != -1) {
switch (c) {
case 'c':
}
}
- if (optind == argc)
- usage(argv[0]);
-
- if (is_smackfs_mounted() != 1) {
- fprintf(stderr, "SmackFS is not mounted.\n");
- exit(1);
- }
-
- if (apply_rules(argv[optind], clear)) {
- perror("apply_rules");
- exit(1);
+ if (optind == argc) {
+ if (apply_rules_file(STDIN_FILENO, clear)) {
+ perror("apply_rules_file");
+ exit(1);
+ }
+ } else {
+ if (apply_rules(argv[optind], clear)) {
+ perror("apply_rules");
+ exit(1);
+ }
}
exit(0);