diff --git a/ChangeLog b/ChangeLog index c427afeb..9101f943 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,6 @@ 2010-05-27 Milan Broz * Fix luksFormat/luksOpen reading passphrase from stdin and "-" keyfile. + * Add verbose log level and move unlocking message there. 2010-05-23 Milan Broz * Fix luksClose operation for stacked DM devices. diff --git a/lib/internal.h b/lib/internal.h index 3fe96e36..7b31cf8b 100644 --- a/lib/internal.h +++ b/lib/internal.h @@ -110,6 +110,7 @@ int parse_into_name_and_mode(const char *nameAndMode, char *name, char *mode); void logger(struct crypt_device *cd, int class, const char *file, int line, const char *format, ...); #define log_dbg(x...) logger(NULL, CRYPT_LOG_DEBUG, __FILE__, __LINE__, x) #define log_std(c, x...) logger(c, CRYPT_LOG_NORMAL, __FILE__, __LINE__, x) +#define log_verbose(c, x...) logger(c, CRYPT_LOG_VERBOSE, __FILE__, __LINE__, x) #define log_err(c, x...) do { \ logger(c, CRYPT_LOG_ERROR, __FILE__, __LINE__, x); \ set_error(x); } while(0) diff --git a/lib/libcryptsetup.h b/lib/libcryptsetup.h index 561d79c9..c2cf5fb4 100644 --- a/lib/libcryptsetup.h +++ b/lib/libcryptsetup.h @@ -42,6 +42,7 @@ int crypt_init_by_name(struct crypt_device **cd, const char *name); */ #define CRYPT_LOG_NORMAL 0 #define CRYPT_LOG_ERROR 1 +#define CRYPT_LOG_VERBOSE 2 #define CRYPT_LOG_DEBUG -1 /* always on stdout */ void crypt_set_log_callback(struct crypt_device *cd, void (*log)(int level, const char *msg, void *usrptr), diff --git a/lib/setup.c b/lib/setup.c index fc6525c8..45690b83 100644 --- a/lib/setup.c +++ b/lib/setup.c @@ -220,7 +220,7 @@ static int verify_other_keyslot(struct crypt_device *cd, if (openedIndex < 0) return -EPERM; - log_std(cd, _("Key slot %d verified.\n"), openedIndex); + log_verbose(cd, _("Key slot %d verified.\n"), openedIndex); return 0; } diff --git a/luks/keymanage.c b/luks/keymanage.c index 44cffe48..9b8ba0c5 100644 --- a/luks/keymanage.c +++ b/luks/keymanage.c @@ -620,7 +620,7 @@ int LUKS_verify_master_key(const struct luks_phdr *hdr, } /* Try to open a particular key slot */ -int LUKS_open_key(const char *device, +static int LUKS_open_key(const char *device, unsigned int keyIndex, const char *password, size_t passwordLen, @@ -670,7 +670,7 @@ int LUKS_open_key(const char *device, r = LUKS_verify_master_key(hdr, mk); if (r >= 0) - log_std(ctx, _("Key slot %d unlocked.\n"), keyIndex); + log_verbose(ctx, _("Key slot %d unlocked.\n"), keyIndex); out: free(AfKey); return r; diff --git a/luks/luks.h b/luks/luks.h index 9cc663d8..e9e3909f 100644 --- a/luks/luks.h +++ b/luks/luks.h @@ -137,15 +137,6 @@ int LUKS_set_key( uint64_t *PBKDF2_per_sec, struct crypt_device *ctx); -int LUKS_open_key( - const char *device, - unsigned int keyIndex, - const char *password, - size_t passwordLen, - struct luks_phdr *hdr, - struct luks_masterkey *mk, - struct crypt_device *ctx); - int LUKS_open_key_with_hdr( const char *device, int keyIndex, diff --git a/src/cryptsetup.c b/src/cryptsetup.c index 98c1ca80..87ef6ff4 100644 --- a/src/cryptsetup.c +++ b/src/cryptsetup.c @@ -138,23 +138,27 @@ static int yesDialog(char *msg) } static void cmdLineLog(int level, char *msg) { - switch(level) { + switch(level) { - case CRYPT_LOG_NORMAL: - fputs(msg, stdout); - break; - case CRYPT_LOG_ERROR: - fputs(msg, stderr); - break; - default: - fprintf(stderr, "Internal error on logging class for msg: %s", msg); - break; - } + case CRYPT_LOG_NORMAL: + fputs(msg, stdout); + break; + case CRYPT_LOG_VERBOSE: + if (opt_verbose) + fputs(msg, stdout); + break; + case CRYPT_LOG_ERROR: + fputs(msg, stderr); + break; + default: + fprintf(stderr, "Internal error on logging class for msg: %s", msg); + break; + } } static struct interface_callbacks cmd_icb = { - .yesDialog = yesDialog, - .log = cmdLineLog, + .yesDialog = yesDialog, + .log = cmdLineLog, }; static void _log(int level, const char *msg, void *usrptr) diff --git a/src/cryptsetup.h b/src/cryptsetup.h index a6ed1fdb..6b4ec0b9 100644 --- a/src/cryptsetup.h +++ b/src/cryptsetup.h @@ -13,6 +13,7 @@ #define log_dbg(x...) clogger(NULL, CRYPT_LOG_DEBUG, __FILE__, __LINE__, x) #define log_std(x...) clogger(NULL, CRYPT_LOG_NORMAL, __FILE__, __LINE__, x) +#define log_verbose(x...) clogger(NULL, CRYPT_LOG_VERBOSE, __FILE__, __LINE__, x) #define log_err(x...) clogger(NULL, CRYPT_LOG_ERROR, __FILE__, __LINE__, x) #endif /* CRYPTSETUP_H */