ktutil: Add import command and other improvements

- Add an import command that imports JSON as output by
   `ktutil list --json --keys`.

   This is enables one to filter/edit keytabs with jq!

 - Add a `merge` alias for the `copy` command, since that's effectively
   what it does.

 - Add a `--copy-duplicates` option to the `copy`/`merge` command.

 - Add a `--no-create` option to the `get` command.

 - Add a `--no-change-keys` option to the `get` command.

 - Make `add` complain if it can't finish writing to the keytab.
This commit is contained in:
Nicolas Williams
2022-10-01 17:57:54 -05:00
parent 69dc89b39a
commit ceec364ed4
5 changed files with 290 additions and 31 deletions

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004 Kungliga Tekniska Högskolan
* Copyright (c) 2004-2022 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@ -151,11 +151,17 @@ command = {
}
command = {
name = "copy"
name = "merge"
function = "kt_copy"
option = {
long = "copy-duplicates"
type = "flag"
help = "copy entries for the same principal and kvno, but different keys"
}
argument = "source destination"
min_args = "2"
max_args = "2"
help = "Copies one keytab to another."
help = "Merges one keytab into another."
}
command = {
name = "get"
@ -166,6 +172,16 @@ command = {
help = "admin principal"
argument = "principal"
}
option = {
long = "create"
type = "-flag"
help = "do not create the principal"
}
option = {
long = "change-keys"
type = "-flag"
help = "do not change the principal's keys"
}
option = {
long = "enctypes"
short = "e"
@ -214,6 +230,14 @@ command = {
argument = "principal..."
help = "Change keys for specified principals, and add them to the keytab."
}
command = {
name = "import"
function = "kt_import"
help = "Imports a keytab from JSON output of ktutil list --json --keys."
min_args = "0"
max_args = "1"
argument = "JSON-FILE"
}
command = {
name = "list"
option = {