diff options
author | Stef Walter <stefw@gnome.org> | 2012-08-31 17:58:11 +0200 |
---|---|---|
committer | Stef Walter <stefw@gnome.org> | 2012-08-31 17:58:11 +0200 |
commit | 57c1cd21720235b3913dd496020353014f125532 (patch) | |
tree | 44d97a21064fba374771b2dfb436d670ead77d5a /tools | |
parent | a71048282117d3e0fc6192c3f04a4fa1087f7e5b (diff) |
Add --one-time-password to the 'preset' command
* Instead of using the default computer account password specify
a preset password to use.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/adcli.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/tools/adcli.c b/tools/adcli.c index 6ccfdd1..f508298 100644 --- a/tools/adcli.c +++ b/tools/adcli.c @@ -145,6 +145,7 @@ typedef enum { opt_ldap_url, opt_no_password, opt_stdin_password, + opt_one_time_password, } Option; static char @@ -228,6 +229,11 @@ usage_option (Option opt, description = "Read a password from stdin if neccessary. Reads\n" "until EOF and includes new lines."; break; + case opt_one_time_password: + description = "A password to use for the preset computer\n" + "accounts. If not specified this will default to\n" + "the default reset password for the account"; + break; case opt_verbose: description = "Show verbose progress and failure messages."; break; @@ -399,6 +405,9 @@ parse_option (Option opt, stdin_password = 1; } return; + case opt_one_time_password: + adcli_enroll_set_computer_password (enroll, optarg); + return; case opt_verbose: adcli_conn_set_message_func (conn, message_func, NULL, NULL); return; @@ -468,6 +477,13 @@ adcli_join (int argc, if (argc != 0) usage (EUSAGE, "join", long_options, NULL); + res = adcli_conn_connect (conn); + if (res != ADCLI_SUCCESS) { + errx (1, "couldn't connect to %s domain: %s", + adcli_conn_get_domain_name (conn), + adcli_conn_get_last_error (conn)); + } + res = adcli_enroll_join (enroll, flags); if (res != ADCLI_SUCCESS) { errx (1, "enroll in %s domain failed: %s", @@ -493,6 +509,7 @@ adcli_preset (int argc, char *generated = NULL; char *options; adcli_enroll_flags flags; + int reset_password = 1; int opt; int i; @@ -505,6 +522,7 @@ adcli_preset (int argc, { "no-password", no_argument, 0, opt_no_password }, { "stdin-password", no_argument, 0, opt_stdin_password }, { "prompt-password", no_argument, 0, opt_prompt_password }, + { "one-time-password", required_argument, 0, opt_one_time_password }, { "computer-ou", required_argument, NULL, opt_computer_ou }, { "ldap-url", required_argument, NULL, opt_ldap_url }, { "service-name", required_argument, NULL, opt_service_name }, @@ -545,6 +563,7 @@ adcli_preset (int argc, usage (EUSAGE, "preset", long_options, "host.example.com ..."); adcli_conn_set_allowed_login_types (conn, ADCLI_LOGIN_USER_ACCOUNT); + reset_password = (adcli_enroll_get_computer_password (enroll) == NULL); res = adcli_conn_connect (conn); if (res != ADCLI_SUCCESS) { @@ -562,7 +581,8 @@ adcli_preset (int argc, adcli_enroll_set_host_fqdn (enroll, NULL); } - adcli_enroll_reset_computer_password (enroll); + if (reset_password) + adcli_enroll_reset_computer_password (enroll); res = adcli_enroll_join (enroll, flags); if (res != ADCLI_SUCCESS) { |