From fc66861c0d4ffd7b4b09f619da83e2726e56a41a Mon Sep 17 00:00:00 2001 From: Andrea Luzzardi Date: Mon, 9 Oct 2006 18:54:33 +0000 Subject: [PATCH] Removed enforce_otp and try_otp, use "one_time_pad" instead. Renamed otp_directory to pad_directory --- src/conf.c | 32 ++++++++++++++------------------ src/conf.h | 7 +++---- src/conf.xml | 9 ++++----- src/device.c | 10 +++++----- src/otp.c | 10 +++++----- 5 files changed, 31 insertions(+), 37 deletions(-) diff --git a/src/conf.c b/src/conf.c index 575a77f..fa8220c 100644 --- a/src/conf.c +++ b/src/conf.c @@ -28,20 +28,18 @@ static void pusb_conf_options_get_from(t_pusb_options *opts, { pusb_xpath_get_string_from(doc, from, "option[@name='hostname']", opts->hostname, sizeof(opts->hostname)); - pusb_xpath_get_string_from(doc, from, "option[@name='system_otp_directory']", - opts->system_otp_directory, - sizeof(opts->system_otp_directory)); - pusb_xpath_get_string_from(doc, from, "option[@name='device_otp_directory']", - opts->device_otp_directory, - sizeof(opts->device_otp_directory)); + pusb_xpath_get_string_from(doc, from, "option[@name='system_pad_directory']", + opts->system_pad_directory, + sizeof(opts->system_pad_directory)); + pusb_xpath_get_string_from(doc, from, "option[@name='device_pad_directory']", + opts->device_pad_directory, + sizeof(opts->device_pad_directory)); pusb_xpath_get_bool_from(doc, from, "option[@name='debug']", &(opts->debug)); pusb_xpath_get_bool_from(doc, from, "option[@name='enable']", &(opts->enable)); - pusb_xpath_get_bool_from(doc, from, "option[@name='try_otp']", - &(opts->try_otp)); - pusb_xpath_get_bool_from(doc, from, "option[@name='enforce_otp']", - &(opts->enforce_otp)); + pusb_xpath_get_bool_from(doc, from, "option[@name='one_time_pad']", + &(opts->one_time_pad)); pusb_xpath_get_int_from(doc, from, "option[@name='probe_timeout']", &(opts->probe_timeout)); } @@ -128,12 +126,11 @@ int pusb_conf_init(t_pusb_options *opts) log_error("gethostname: %s\n", strerror(errno)); return (0); } - strcpy(opts->system_otp_directory, "./"); - strcpy(opts->device_otp_directory, ".auth"); + strcpy(opts->system_pad_directory, "./"); + strcpy(opts->device_pad_directory, ".auth"); opts->probe_timeout = 10; opts->enable = 1; - opts->try_otp = 1; - opts->enforce_otp = 0; + opts->one_time_pad = 1; opts->debug = 0; return (1); } @@ -143,12 +140,11 @@ static void pusb_conf_dump(t_pusb_options *opts) log_debug("Configuration dump:\n"); log_debug("enable\t\t\t: %s\n", opts->enable ? "true" : "false"); log_debug("debug\t\t\t: %s\n", opts->debug ? "true" : "false"); - log_debug("try_otp\t\t\t: %s\n", opts->try_otp ? "true" : "false"); - log_debug("enforce_otp\t\t: %s\n", opts->enforce_otp ? "true" : "false"); + log_debug("one_time_pad\t\t: %s\n", opts->one_time_pad ? "true" : "false"); log_debug("probe_timeout\t\t: %d\n", opts->probe_timeout); log_debug("hostname\t\t\t: %s\n", opts->hostname); - log_debug("system_otp_directory\t: %s\n", opts->system_otp_directory); - log_debug("device_otp_directory\t: %s\n", opts->device_otp_directory); + log_debug("system_pad_directory\t: %s\n", opts->system_pad_directory); + log_debug("device_pad_directory\t: %s\n", opts->device_pad_directory); } diff --git a/src/conf.h b/src/conf.h index b805e68..552fbd8 100644 --- a/src/conf.h +++ b/src/conf.h @@ -35,12 +35,11 @@ typedef struct pusb_options { int probe_timeout; int enable; - int try_otp; - int enforce_otp; + int one_time_pad; int debug; char hostname[32]; - char system_otp_directory[128]; - char device_otp_directory[32]; + char system_pad_directory[128]; + char device_pad_directory[32]; t_pusb_device device; } t_pusb_options; diff --git a/src/conf.xml b/src/conf.xml index 2073046..6b91dfb 100644 --- a/src/conf.xml +++ b/src/conf.xml @@ -1,12 +1,11 @@ - - + - + @@ -22,11 +21,11 @@ foobar + foobar - diff --git a/src/device.c b/src/device.c index d00c41f..b8910db 100644 --- a/src/device.c +++ b/src/device.c @@ -70,15 +70,15 @@ int pusb_device_check(t_pusb_options *opts) return (0); } - if (!opts->try_otp && !opts->enforce_otp) + if (opts->one_time_pad) { - log_debug("One time pad is disabled, no more verifications to do.\n"); - retval = 1; + log_info("Performing one time pad verification...\n"); + retval = pusb_otp_check(opts, ctx); } else { - log_info("Performing one time pad verification...\n"); - retval = pusb_otp_check(opts, ctx); + log_debug("One time pad is disabled, no more verifications to do.\n"); + retval = 1; } pusb_hal_dbus_disconnect(dbus); diff --git a/src/otp.c b/src/otp.c index 0b78f1f..bc14a78 100644 --- a/src/otp.c +++ b/src/otp.c @@ -39,7 +39,7 @@ static FILE *pusb_otp_open_device(t_pusb_options *opts, mnt_point = (char *)libhal_volume_get_mount_point(volume); if (!mnt_point) return (NULL); - path_size = strlen(mnt_point) + 1 + strlen(opts->device_otp_directory) + \ + path_size = strlen(mnt_point) + 1 + strlen(opts->device_pad_directory) + \ 1 + strlen(opts->hostname) + strlen(".otp") + 1; if (!(path = malloc(path_size))) { @@ -48,7 +48,7 @@ static FILE *pusb_otp_open_device(t_pusb_options *opts, } memset(path, 0x00, path_size); snprintf(path, path_size, "%s/%s/%s.otp", mnt_point, - opts->device_otp_directory, opts->hostname); + opts->device_pad_directory, opts->hostname); f = fopen(path, mode); free(path); if (!f) @@ -65,7 +65,7 @@ static FILE *pusb_otp_open_system(t_pusb_options *opts, const char *mode) char *path; size_t path_size; - path_size = strlen(opts->system_otp_directory) + 1 + + path_size = strlen(opts->system_pad_directory) + 1 + strlen(opts->device.serial) + strlen(".otp") + 1; if (!(path = malloc(path_size))) { @@ -73,7 +73,7 @@ static FILE *pusb_otp_open_system(t_pusb_options *opts, const char *mode) return (NULL); } memset(path, 0x00, path_size); - snprintf(path, path_size, "%s/%s.otp", opts->system_otp_directory, + snprintf(path, path_size, "%s/%s.otp", opts->system_pad_directory, opts->device.serial); f = fopen(path, mode); free(path); @@ -153,7 +153,7 @@ int pusb_otp_check(t_pusb_options *opts, LibHalContext *ctx) volume = pusb_volume_get(opts, ctx); if (!volume) - return (!opts->enforce_otp); + return (0); retval = pusb_otp_compare(opts, volume); if (retval) {