add password/bare options

This commit is contained in:
Love Hornquist Astrand
2009-11-21 23:53:26 -08:00
parent 0510f7e0cd
commit 368536bc08
3 changed files with 27 additions and 7 deletions

View File

@@ -3,6 +3,8 @@
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
* Portions Copyright (c) 2009 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -157,15 +159,9 @@ init(struct init_options *opt, int argc, char **argv)
krb5_principal princ;
const char *realm = argv[i];
/* Create `krbtgt/REALM' */
ret = krb5_make_principal(context, &princ, realm,
KRB5_TGS_NAME, realm, NULL);
if(ret)
return 0;
if (opt->realm_max_ticket_life_string == NULL) {
max_life = 0;
if(edit_deltat ("Realm max ticket life", &max_life, NULL, 0)) {
krb5_free_principal(context, princ);
return 0;
}
}
@@ -173,13 +169,22 @@ init(struct init_options *opt, int argc, char **argv)
max_rlife = 0;
if(edit_deltat("Realm max renewable ticket life", &max_rlife,
NULL, 0)) {
krb5_free_principal(context, princ);
return 0;
}
}
/* Create `krbtgt/REALM' */
ret = krb5_make_principal(context, &princ, realm,
KRB5_TGS_NAME, realm, NULL);
if(ret)
return 0;
create_random_entry(princ, max_life, max_rlife, 0);
krb5_free_principal(context, princ);
if (opt->bare_flag)
continue;
/* Create `kadmin/changepw' */
krb5_make_principal(context, &princ, realm,
"kadmin", "changepw", NULL);

View File

@@ -54,6 +54,11 @@ command = {
type = "flag"
help = "just convert keyfile to new format"
}
option = {
long = "random-password"
type = "flag"
help = "use a random password (and print the password to stdout)"
}
option = {
long = "master-key-fd"
type = "integer"
@@ -89,6 +94,11 @@ command = {
type = "string"
help = "realm max renewable lifetime"
}
option = {
long = "bare"
type = "flag"
help = "only create krbtgt for realm"
}
argument = "realm..."
min_args = "1"
help = "Initializes the default principals for a realm. Creates the database\nif necessary. Local (-l) mode only."

View File

@@ -3,6 +3,8 @@
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
* Portions Copyright (c) 2009 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -93,6 +95,9 @@ stash(struct stash_options *opt, int argc, char **argv)
}
buf[n] = '\0';
buf[strcspn(buf, "\r\n")] = '\0';
} else if (opt->random_password_flag) {
random_password (buf, sizeof(buf));
printf("Using random master stash password: %s\n", buf);
} else {
if(UI_UTIL_read_pw_string(buf, sizeof(buf), "Master key: ", 1)) {
hdb_free_master_key(context, mkey);