diff options
Diffstat (limited to 'src/libpts/plugins/imv_attestation/attest.c')
-rw-r--r-- | src/libpts/plugins/imv_attestation/attest.c | 53 |
1 files changed, 44 insertions, 9 deletions
diff --git a/src/libpts/plugins/imv_attestation/attest.c b/src/libpts/plugins/imv_attestation/attest.c index 1cdacaeeb..4d25df3f4 100644 --- a/src/libpts/plugins/imv_attestation/attest.c +++ b/src/libpts/plugins/imv_attestation/attest.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011-2012 Andreas Steffen + * Copyright (C) 2011-2013 Andreas Steffen * HSR Hochschule fuer Technik Rapperswil * * This program is free software; you can redistribute it and/or modify it @@ -20,6 +20,7 @@ #include <string.h> #include <errno.h> #include <syslog.h> +#include <libgen.h> #include <library.h> #include <utils/debug.h> @@ -81,6 +82,7 @@ static void attest_dbg(debug_t group, level_t level, char *fmt, ...) */ attest_db_t *attest; + /** * atexit handler to close db on shutdown */ @@ -100,11 +102,13 @@ static void do_args(int argc, char *argv[]) OP_KEYS, OP_COMPONENTS, OP_DEVICES, + OP_DIRECTORIES, OP_FILES, OP_HASHES, OP_MEASUREMENTS, OP_PACKAGES, OP_PRODUCTS, + OP_SESSIONS, OP_ADD, OP_DEL, } op = OP_UNDEF; @@ -120,15 +124,19 @@ static void do_args(int argc, char *argv[]) { "help", no_argument, NULL, 'h' }, { "components", no_argument, NULL, 'c' }, { "devices", no_argument, NULL, 'e' }, + { "directories", no_argument, NULL, 'd' }, + { "dirs", no_argument, NULL, 'd' }, { "files", no_argument, NULL, 'f' }, { "keys", no_argument, NULL, 'k' }, { "packages", no_argument, NULL, 'g' }, { "products", no_argument, NULL, 'p' }, { "hashes", no_argument, NULL, 'H' }, { "measurements", no_argument, NULL, 'm' }, + { "sessions", no_argument, NULL, 's' }, { "add", no_argument, NULL, 'a' }, - { "delete", no_argument, NULL, 'd' }, - { "del", no_argument, NULL, 'd' }, + { "delete", no_argument, NULL, 'r' }, + { "del", no_argument, NULL, 'r' }, + { "remove", no_argument, NULL, 'r' }, { "aik", required_argument, NULL, 'A' }, { "blacklist", no_argument, NULL, 'B' }, { "component", required_argument, NULL, 'C' }, @@ -171,6 +179,9 @@ static void do_args(int argc, char *argv[]) case 'c': op = OP_COMPONENTS; continue; + case 'd': + op = OP_DIRECTORIES; + continue; case 'e': op = OP_DEVICES; continue; @@ -192,10 +203,13 @@ static void do_args(int argc, char *argv[]) case 'm': op = OP_MEASUREMENTS; continue; + case 's': + op = OP_SESSIONS; + continue; case 'a': op = OP_ADD; continue; - case 'd': + case 'r': op = OP_DEL; continue; case 'A': @@ -236,7 +250,7 @@ static void do_args(int argc, char *argv[]) continue; } case 'B': - attest->set_security(attest, OS_PACKAGE_STATE_BLACKLIST); + attest->set_package_state(attest, OS_PACKAGE_STATE_BLACKLIST); continue; case 'C': if (!attest->set_component(attest, optarg, op == OP_ADD)) @@ -251,11 +265,26 @@ static void do_args(int argc, char *argv[]) } continue; case 'F': - if (!attest->set_file(attest, optarg, op == OP_ADD)) + { + char *path = strdup(optarg); + char *dir = dirname(path); + char *file = basename(optarg); + + if (*dir != '.') + { + if (!attest->set_directory(attest, dir, op == OP_ADD)) + { + free(path); + exit(EXIT_FAILURE); + } + } + free(path); + if (!attest->set_file(attest, file, op == OP_ADD)) { exit(EXIT_FAILURE); } continue; + } case 'G': if (!attest->set_package(attest, optarg, op == OP_ADD)) { @@ -301,7 +330,7 @@ static void do_args(int argc, char *argv[]) } continue; case 'Y': - attest->set_security(attest, OS_PACKAGE_STATE_SECURITY); + attest->set_package_state(attest, OS_PACKAGE_STATE_SECURITY); continue; case '1': attest->set_algo(attest, PTS_MEAS_ALGO_SHA1); @@ -372,6 +401,9 @@ static void do_args(int argc, char *argv[]) case OP_DEVICES: attest->list_devices(attest); break; + case OP_DIRECTORIES: + attest->list_directories(attest); + break; case OP_FILES: attest->list_files(attest); break; @@ -381,6 +413,9 @@ static void do_args(int argc, char *argv[]) case OP_MEASUREMENTS: attest->list_measurements(attest); break; + case OP_SESSIONS: + attest->list_sessions(attest); + break; case OP_ADD: attest->add(attest); break; @@ -408,7 +443,7 @@ int main(int argc, char *argv[]) { exit(SS_RC_LIBSTRONGSWAN_INTEGRITY); } - if (!lib->plugins->load(lib->plugins, NULL, + if (!lib->plugins->load(lib->plugins, lib->settings->get_str(lib->settings, "attest.load", PLUGINS))) { exit(SS_RC_INITIALIZATION_FAILED); @@ -426,7 +461,7 @@ int main(int argc, char *argv[]) exit(SS_RC_INITIALIZATION_FAILED); } atexit(cleanup); - libimcv_init(); + libimcv_init(FALSE); libpts_init(); do_args(argc, argv); |