add option -H --hex to the add command
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@14793 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
25
admin/add.c
25
admin/add.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1997-2004 Kungliga Tekniska H<>gskolan
|
* Copyright (c) 1997-2005 Kungliga Tekniska H<>gskolan
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
* (Royal Institute of Technology, Stockholm, Sweden).
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@@ -101,7 +101,28 @@ kt_add(struct add_options *opt, int argc, char **argv)
|
|||||||
opt->password_string = buf;
|
opt->password_string = buf;
|
||||||
}
|
}
|
||||||
if(opt->password_string) {
|
if(opt->password_string) {
|
||||||
if (!opt->salt_flag) {
|
if (opt->hex_flag) {
|
||||||
|
size_t len;
|
||||||
|
void *data;
|
||||||
|
|
||||||
|
len = (strlen(opt->password_string) + 1) / 2;
|
||||||
|
|
||||||
|
data = malloc(len);
|
||||||
|
if (data == NULL) {
|
||||||
|
krb5_warn(context, ENOMEM, "malloc");
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hex_decode(opt->password_string, data, len) != len) {
|
||||||
|
free(data);
|
||||||
|
krb5_warn(context, ENOMEM, "hex decode failed");
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = krb5_keyblock_init(context, enctype,
|
||||||
|
data, len, &entry.keyblock);
|
||||||
|
free(data);
|
||||||
|
} else if (!opt->salt_flag) {
|
||||||
krb5_salt salt;
|
krb5_salt salt;
|
||||||
krb5_data pw;
|
krb5_data pw;
|
||||||
|
|
||||||
|
@@ -75,6 +75,12 @@ command = {
|
|||||||
type = "flag"
|
type = "flag"
|
||||||
help = "generate random key"
|
help = "generate random key"
|
||||||
}
|
}
|
||||||
|
option = {
|
||||||
|
long = "hex"
|
||||||
|
short = "H"
|
||||||
|
type = "flag"
|
||||||
|
help = "password is a hexadecimal string"
|
||||||
|
}
|
||||||
function = "kt_add"
|
function = "kt_add"
|
||||||
help = "Adds a key to a keytab."
|
help = "Adds a key to a keytab."
|
||||||
max_args = "0"
|
max_args = "0"
|
||||||
|
Reference in New Issue
Block a user