zkey: Add batch-mode option to zkey-cryptsetup tool

When re-enciphering or setting LUKS2 volume keys using zkey-cryptsetup,
allow to specify the --batch-mode|-q option to suppress confirmation
questions.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Ingo Franzki
2019-03-19 11:04:37 +01:00
committed by Jan Höppner
parent 11bfa1d3c8
commit e693173eef
2 changed files with 28 additions and 0 deletions

View File

@@ -102,6 +102,7 @@ behave in the same way as with \fBcryptsetup\fP.
.IR bytes ]
.RB [ \-\-tries | \-T
.IR number ]
.RB [ \-\-batch\-mode | \-q ]
.RB [ \-\-verbose | \-V ]
.RB [ \-\-debug | \-D ]
.PP
@@ -261,6 +262,7 @@ behave in the same way as with \fBcryptsetup\fP.
.IR bytes ]
.RB [ \-\-tries | \-T
.IR number ]
.RB [ \-\-batch\-mode | \-q ]
.RB [ \-\-verbose | \-V ]
.RB [ \-\-debug | \-D ]
.PP
@@ -347,6 +349,9 @@ has been set (made active). When completing the staged re-enciphering, the
(unbound) key slot containing the re-enciphered secure volume key becomes
the active key slot and, optionally, all key slots containing the old secure
volume key are removed.
.TP
.BR \-q ", " \-\-batch\-mode
Suppresses all confirmation questions. Use with care!
.
.
.
@@ -355,6 +360,9 @@ volume key are removed.
.BR \-m ", " \-\-master\-key\-file\~\fIfile\-name\fP
Specifies the name of a file containing the secure AES key that is set as the
new volume key.
.TP
.BR \-q ", " \-\-batch\-mode
Suppresses all confirmation questions. Use with care!
.
.
.

View File

@@ -98,6 +98,7 @@ static struct zkey_cryptsetup_globals {
bool inplace;
bool staged;
char *master_key_file;
bool batch_mode;
bool debug;
bool verbose;
void *lib_csulcca;
@@ -181,6 +182,11 @@ static struct util_opt opt_vec[] = {
.command = COMMAND_REENCIPHER,
},
OPT_PASSPHRASE_ENTRY(COMMAND_REENCIPHER),
{
.option = {"batch-mode", 0, NULL, 'q'},
.desc = "Suppresses all confirmation questions. Use with care!",
.command = COMMAND_REENCIPHER,
},
/***********************************************************/
{
.flags = UTIL_OPT_FLAG_SECTION,
@@ -209,6 +215,11 @@ static struct util_opt opt_vec[] = {
.command = COMMAND_SETKEY,
},
OPT_PASSPHRASE_ENTRY(COMMAND_SETKEY),
{
.option = {"batch-mode", 0, NULL, 'q'},
.desc = "Suppresses all confirmation questions. Use with care!",
.command = COMMAND_SETKEY,
},
/***********************************************************/
{
.flags = UTIL_OPT_FLAG_SECTION,
@@ -1173,6 +1184,12 @@ static bool prompt_for_yes(void)
{
char str[20];
if (g.batch_mode) {
printf("(yes implied because '--batch-mode' | '-q' option is "
"specified)\n");
return true;
}
if (fgets(str, sizeof(str), stdin) == NULL)
return false;
@@ -2236,6 +2253,9 @@ int main(int argc, char *argv[])
case 'm':
g.master_key_file = optarg;
break;
case 'q':
g.batch_mode = true;
break;
case 'D':
g.debug = true;
g.verbose = true;