Commit b4ebe0be authored by Milan Broz's avatar Milan Broz

Add verbose log level and move unlocking keyslot messages there.

git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@238 36d66b0a-2a48-0410-832c-cd162a569da5
parent 231ab016
2010-05-27 Milan Broz <mbroz@redhat.com>
* Fix luksFormat/luksOpen reading passphrase from stdin and "-" keyfile.
* Add verbose log level and move unlocking message there.
2010-05-23 Milan Broz <mbroz@redhat.com>
* Fix luksClose operation for stacked DM devices.
......
......@@ -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)
......
......@@ -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),
......
......@@ -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;
}
......
......@@ -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;
......
......@@ -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,
......
......@@ -138,23 +138,27 @@ static int yesDialog(char *msg)
}
static void cmdLineLog(int level, char *msg) {
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;
}
switch(level) {
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)
......
......@@ -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 */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment