|
|
69a8fd |
From a78116ba0e608050f391223bad3834d48c9adf1b Mon Sep 17 00:00:00 2001
|
|
|
69a8fd |
From: Sumit Bose <sbose@redhat.com>
|
|
|
69a8fd |
Date: Wed, 2 Jun 2021 17:24:07 +0200
|
|
|
69a8fd |
Subject: [PATCH 2/2] Add dont-expire-password option
|
|
|
69a8fd |
|
|
|
69a8fd |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1769644
|
|
|
69a8fd |
---
|
|
|
69a8fd |
doc/adcli.xml | 28 ++++++++++++++++++++++++++++
|
|
|
69a8fd |
library/adenroll.c | 44 +++++++++++++++++++++++++++++++++++++++++++-
|
|
|
69a8fd |
library/adenroll.h | 4 ++++
|
|
|
69a8fd |
tools/computer.c | 12 ++++++++++++
|
|
|
69a8fd |
4 files changed, 87 insertions(+), 1 deletion(-)
|
|
|
69a8fd |
|
|
|
69a8fd |
diff --git a/doc/adcli.xml b/doc/adcli.xml
|
|
|
69a8fd |
index 8ec48d4..1ed5d3f 100644
|
|
|
69a8fd |
--- a/doc/adcli.xml
|
|
|
69a8fd |
+++ b/doc/adcli.xml
|
|
|
69a8fd |
@@ -347,6 +347,20 @@ Password for Administrator:
|
|
|
69a8fd |
not allow that Kerberos tickets can be forwarded to the
|
|
|
69a8fd |
host.</para></listitem>
|
|
|
69a8fd |
</varlistentry>
|
|
|
69a8fd |
+ <varlistentry>
|
|
|
69a8fd |
+ <term><option>--dont-expire-password=<parameter>yes|no|true|false</parameter></option></term>
|
|
|
69a8fd |
+ <listitem><para>Set or unset the DONT_EXPIRE_PASSWORD
|
|
|
69a8fd |
+ flag in the userAccountControl attribute to indicate if
|
|
|
69a8fd |
+ the machine account password should expire or not. By
|
|
|
69a8fd |
+ default adcli will set this flag while joining the
|
|
|
69a8fd |
+ domain which corresponds to the default behavior of
|
|
|
69a8fd |
+ Windows clients.</para>
|
|
|
69a8fd |
+ <para>Please note that if the password will expire
|
|
|
69a8fd |
+ (--dont-expire-password=false) a renewal mechanism has
|
|
|
69a8fd |
+ to be enabled on the client to not loose the
|
|
|
69a8fd |
+ connectivity to AD if the password expires.</para>
|
|
|
69a8fd |
+ </listitem>
|
|
|
69a8fd |
+ </varlistentry>
|
|
|
69a8fd |
<varlistentry>
|
|
|
69a8fd |
<term><option>--add-service-principal=<parameter>service/hostname</parameter></option></term>
|
|
|
69a8fd |
<listitem><para>Add a service principal name. In
|
|
|
69a8fd |
@@ -491,6 +505,20 @@ $ adcli update --login-ccache=/tmp/krbcc_123
|
|
|
69a8fd |
not allow that Kerberos tickets can be forwarded to the
|
|
|
69a8fd |
host.</para></listitem>
|
|
|
69a8fd |
</varlistentry>
|
|
|
69a8fd |
+ <varlistentry>
|
|
|
69a8fd |
+ <term><option>--dont-expire-password=<parameter>yes|no|true|false</parameter></option></term>
|
|
|
69a8fd |
+ <listitem><para>Set or unset the DONT_EXPIRE_PASSWORD
|
|
|
69a8fd |
+ flag in the userAccountControl attribute to indicate if
|
|
|
69a8fd |
+ the machine account password should expire or not. By
|
|
|
69a8fd |
+ default adcli will set this flag while joining the
|
|
|
69a8fd |
+ domain which corresponds to the default behavior of
|
|
|
69a8fd |
+ Windows clients.</para>
|
|
|
69a8fd |
+ <para>Please note that if the password will expire
|
|
|
69a8fd |
+ (--dont-expire-password=false) a renewal mechanism has
|
|
|
69a8fd |
+ to be enabled on the client to not loose the
|
|
|
69a8fd |
+ connectivity to AD if the password expires.</para>
|
|
|
69a8fd |
+ </listitem>
|
|
|
69a8fd |
+ </varlistentry>
|
|
|
69a8fd |
<varlistentry>
|
|
|
69a8fd |
<term><option>--account-disable=<parameter>yes|no|true|false</parameter></option></term>
|
|
|
69a8fd |
<listitem><para>Set or unset the ACCOUNTDISABLE
|
|
|
69a8fd |
diff --git a/library/adenroll.c b/library/adenroll.c
|
|
|
69a8fd |
index 0f3e8b9..7653f89 100644
|
|
|
69a8fd |
--- a/library/adenroll.c
|
|
|
69a8fd |
+++ b/library/adenroll.c
|
|
|
69a8fd |
@@ -153,6 +153,8 @@ struct _adcli_enroll {
|
|
|
69a8fd |
char *samba_data_tool;
|
|
|
69a8fd |
bool trusted_for_delegation;
|
|
|
69a8fd |
int trusted_for_delegation_explicit;
|
|
|
69a8fd |
+ bool dont_expire_password;
|
|
|
69a8fd |
+ int dont_expire_password_explicit;
|
|
|
69a8fd |
bool account_disable;
|
|
|
69a8fd |
int account_disable_explicit;
|
|
|
69a8fd |
char *description;
|
|
|
69a8fd |
@@ -832,6 +834,8 @@ create_computer_account (adcli_enroll *enroll,
|
|
|
69a8fd |
int ret;
|
|
|
69a8fd |
size_t c;
|
|
|
69a8fd |
size_t m;
|
|
|
69a8fd |
+ uint32_t uac = UAC_WORKSTATION_TRUST_ACCOUNT | UAC_DONT_EXPIRE_PASSWORD ;
|
|
|
69a8fd |
+ char *uac_str = NULL;
|
|
|
69a8fd |
|
|
|
69a8fd |
LDAPMod *all_mods[] = {
|
|
|
69a8fd |
&objectClass,
|
|
|
69a8fd |
@@ -852,11 +856,21 @@ create_computer_account (adcli_enroll *enroll,
|
|
|
69a8fd |
LDAPMod *mods[mods_count];
|
|
|
69a8fd |
|
|
|
69a8fd |
if (adcli_enroll_get_trusted_for_delegation (enroll)) {
|
|
|
69a8fd |
- vals_userAccountControl[0] = "593920"; /* WORKSTATION_TRUST_ACCOUNT | DONT_EXPIRE_PASSWD | TRUSTED_FOR_DELEGATION */
|
|
|
69a8fd |
+ uac |= UAC_TRUSTED_FOR_DELEGATION;
|
|
|
69a8fd |
}
|
|
|
69a8fd |
|
|
|
69a8fd |
+ if (!adcli_enroll_get_dont_expire_password (enroll)) {
|
|
|
69a8fd |
+ uac &= ~(UAC_DONT_EXPIRE_PASSWORD);
|
|
|
69a8fd |
+ }
|
|
|
69a8fd |
+
|
|
|
69a8fd |
+ if (asprintf (&uac_str, "%d", uac) < 0) {
|
|
|
69a8fd |
+ return_val_if_reached (ADCLI_ERR_UNEXPECTED);
|
|
|
69a8fd |
+ }
|
|
|
69a8fd |
+ vals_userAccountControl[0] = uac_str;
|
|
|
69a8fd |
+
|
|
|
69a8fd |
ret = calculate_enctypes (enroll, &val;;
|
|
|
69a8fd |
if (ret != ADCLI_SUCCESS) {
|
|
|
69a8fd |
+ free (uac_str);
|
|
|
69a8fd |
return ret;
|
|
|
69a8fd |
}
|
|
|
69a8fd |
vals_supportedEncryptionTypes[0] = val;
|
|
|
69a8fd |
@@ -871,6 +885,7 @@ create_computer_account (adcli_enroll *enroll,
|
|
|
69a8fd |
mods[m] = NULL;
|
|
|
69a8fd |
|
|
|
69a8fd |
ret = ldap_add_ext_s (ldap, enroll->computer_dn, mods, NULL, NULL);
|
|
|
69a8fd |
+ free (uac_str);
|
|
|
69a8fd |
free (val);
|
|
|
69a8fd |
|
|
|
69a8fd |
/*
|
|
|
69a8fd |
@@ -1577,6 +1592,14 @@ static char *get_user_account_control (adcli_enroll *enroll)
|
|
|
69a8fd |
}
|
|
|
69a8fd |
}
|
|
|
69a8fd |
|
|
|
69a8fd |
+ if (enroll->dont_expire_password_explicit) {
|
|
|
69a8fd |
+ if (adcli_enroll_get_dont_expire_password (enroll)) {
|
|
|
69a8fd |
+ uac |= UAC_DONT_EXPIRE_PASSWORD;
|
|
|
69a8fd |
+ } else {
|
|
|
69a8fd |
+ uac &= ~(UAC_DONT_EXPIRE_PASSWORD);
|
|
|
69a8fd |
+ }
|
|
|
69a8fd |
+ }
|
|
|
69a8fd |
+
|
|
|
69a8fd |
if (enroll->account_disable_explicit) {
|
|
|
69a8fd |
if (adcli_enroll_get_account_disable (enroll)) {
|
|
|
69a8fd |
uac |= UAC_ACCOUNTDISABLE;
|
|
|
69a8fd |
@@ -1627,6 +1650,7 @@ update_computer_account (adcli_enroll *enroll)
|
|
|
69a8fd |
free (value);
|
|
|
69a8fd |
|
|
|
69a8fd |
if (res == ADCLI_SUCCESS && (enroll->trusted_for_delegation_explicit ||
|
|
|
69a8fd |
+ enroll->dont_expire_password_explicit ||
|
|
|
69a8fd |
enroll->account_disable_explicit)) {
|
|
|
69a8fd |
char *vals_userAccountControl[] = { NULL , NULL };
|
|
|
69a8fd |
LDAPMod userAccountControl = { LDAP_MOD_REPLACE, "userAccountControl", { vals_userAccountControl, } };
|
|
|
69a8fd |
@@ -3208,6 +3232,24 @@ adcli_enroll_set_trusted_for_delegation (adcli_enroll *enroll,
|
|
|
69a8fd |
enroll->trusted_for_delegation_explicit = 1;
|
|
|
69a8fd |
}
|
|
|
69a8fd |
|
|
|
69a8fd |
+bool
|
|
|
69a8fd |
+adcli_enroll_get_dont_expire_password (adcli_enroll *enroll)
|
|
|
69a8fd |
+{
|
|
|
69a8fd |
+ return_val_if_fail (enroll != NULL, false);
|
|
|
69a8fd |
+
|
|
|
69a8fd |
+ return enroll->dont_expire_password;
|
|
|
69a8fd |
+}
|
|
|
69a8fd |
+
|
|
|
69a8fd |
+void
|
|
|
69a8fd |
+adcli_enroll_set_dont_expire_password (adcli_enroll *enroll,
|
|
|
69a8fd |
+ bool value)
|
|
|
69a8fd |
+{
|
|
|
69a8fd |
+ return_if_fail (enroll != NULL);
|
|
|
69a8fd |
+
|
|
|
69a8fd |
+ enroll->dont_expire_password = value;
|
|
|
69a8fd |
+ enroll->dont_expire_password_explicit = 1;
|
|
|
69a8fd |
+}
|
|
|
69a8fd |
+
|
|
|
69a8fd |
bool
|
|
|
69a8fd |
adcli_enroll_get_account_disable (adcli_enroll *enroll)
|
|
|
69a8fd |
{
|
|
|
69a8fd |
diff --git a/library/adenroll.h b/library/adenroll.h
|
|
|
69a8fd |
index 8b1c1c7..34dc683 100644
|
|
|
69a8fd |
--- a/library/adenroll.h
|
|
|
69a8fd |
+++ b/library/adenroll.h
|
|
|
69a8fd |
@@ -126,6 +126,10 @@ bool adcli_enroll_get_trusted_for_delegation (adcli_enroll *enroll
|
|
|
69a8fd |
void adcli_enroll_set_trusted_for_delegation (adcli_enroll *enroll,
|
|
|
69a8fd |
bool value);
|
|
|
69a8fd |
|
|
|
69a8fd |
+bool adcli_enroll_get_dont_expire_password (adcli_enroll *enroll);
|
|
|
69a8fd |
+void adcli_enroll_set_dont_expire_password (adcli_enroll *enroll,
|
|
|
69a8fd |
+ bool value);
|
|
|
69a8fd |
+
|
|
|
69a8fd |
bool adcli_enroll_get_account_disable (adcli_enroll *enroll);
|
|
|
69a8fd |
void adcli_enroll_set_account_disable (adcli_enroll *enroll,
|
|
|
69a8fd |
bool value);
|
|
|
69a8fd |
diff --git a/tools/computer.c b/tools/computer.c
|
|
|
69a8fd |
index 6e309d9..16a1983 100644
|
|
|
69a8fd |
--- a/tools/computer.c
|
|
|
69a8fd |
+++ b/tools/computer.c
|
|
|
69a8fd |
@@ -110,6 +110,7 @@ typedef enum {
|
|
|
69a8fd |
opt_add_samba_data,
|
|
|
69a8fd |
opt_samba_data_tool,
|
|
|
69a8fd |
opt_trusted_for_delegation,
|
|
|
69a8fd |
+ opt_dont_expire_password,
|
|
|
69a8fd |
opt_add_service_principal,
|
|
|
69a8fd |
opt_remove_service_principal,
|
|
|
69a8fd |
opt_description,
|
|
|
69a8fd |
@@ -144,6 +145,8 @@ static adcli_tool_desc common_usages[] = {
|
|
|
69a8fd |
{ opt_computer_password_lifetime, "lifetime of the host accounts password in days", },
|
|
|
69a8fd |
{ opt_trusted_for_delegation, "set/unset the TRUSTED_FOR_DELEGATION flag\n"
|
|
|
69a8fd |
"in the userAccountControl attribute", },
|
|
|
69a8fd |
+ { opt_dont_expire_password, "set/unset the DONT_EXPIRE_PASSWORD flag\n"
|
|
|
69a8fd |
+ "in the userAccountControl attribute", },
|
|
|
69a8fd |
{ opt_account_disable, "set/unset the ACCOUNTDISABLE flag\n"
|
|
|
69a8fd |
"in the userAccountControl attribute", },
|
|
|
69a8fd |
{ opt_add_service_principal, "add the given service principal to the account\n" },
|
|
|
69a8fd |
@@ -307,6 +310,13 @@ parse_option (Option opt,
|
|
|
69a8fd |
adcli_enroll_set_trusted_for_delegation (enroll, false);
|
|
|
69a8fd |
}
|
|
|
69a8fd |
return ADCLI_SUCCESS;
|
|
|
69a8fd |
+ case opt_dont_expire_password:
|
|
|
69a8fd |
+ if (strcasecmp (optarg, "true") == 0 || strcasecmp (optarg, "yes") == 0) {
|
|
|
69a8fd |
+ adcli_enroll_set_dont_expire_password (enroll, true);
|
|
|
69a8fd |
+ } else {
|
|
|
69a8fd |
+ adcli_enroll_set_dont_expire_password (enroll, false);
|
|
|
69a8fd |
+ }
|
|
|
69a8fd |
+ return ADCLI_SUCCESS;
|
|
|
69a8fd |
case opt_account_disable:
|
|
|
69a8fd |
if (strcasecmp (optarg, "true") == 0 || strcasecmp (optarg, "yes") == 0) {
|
|
|
69a8fd |
adcli_enroll_set_account_disable (enroll, true);
|
|
|
69a8fd |
@@ -393,6 +403,7 @@ adcli_tool_computer_join (adcli_conn *conn,
|
|
|
69a8fd |
{ "description", optional_argument, NULL, opt_description },
|
|
|
69a8fd |
{ "user-principal", optional_argument, NULL, opt_user_principal },
|
|
|
69a8fd |
{ "trusted-for-delegation", required_argument, NULL, opt_trusted_for_delegation },
|
|
|
69a8fd |
+ { "dont-expire-password", required_argument, NULL, opt_dont_expire_password },
|
|
|
69a8fd |
{ "add-service-principal", required_argument, NULL, opt_add_service_principal },
|
|
|
69a8fd |
{ "show-details", no_argument, NULL, opt_show_details },
|
|
|
69a8fd |
{ "show-password", no_argument, NULL, opt_show_password },
|
|
|
69a8fd |
@@ -516,6 +527,7 @@ adcli_tool_computer_update (adcli_conn *conn,
|
|
|
69a8fd |
{ "user-principal", optional_argument, NULL, opt_user_principal },
|
|
|
69a8fd |
{ "computer-password-lifetime", optional_argument, NULL, opt_computer_password_lifetime },
|
|
|
69a8fd |
{ "trusted-for-delegation", required_argument, NULL, opt_trusted_for_delegation },
|
|
|
69a8fd |
+ { "dont-expire-password", required_argument, NULL, opt_dont_expire_password },
|
|
|
69a8fd |
{ "account-disable", required_argument, NULL, opt_account_disable },
|
|
|
69a8fd |
{ "add-service-principal", required_argument, NULL, opt_add_service_principal },
|
|
|
69a8fd |
{ "remove-service-principal", required_argument, NULL, opt_remove_service_principal },
|
|
|
69a8fd |
--
|
|
|
69a8fd |
2.31.1
|
|
|
69a8fd |
|