Skip to content
Snippets Groups Projects
Select Git revision
  • 9bfc1be04bc511785568c95b4fae0b20d840c243
  • buster default protected
  • bullseye
  • master protected
4 results

0020-Only-update-attributes-given-on-the-command-line.patch

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    0020-Only-update-attributes-given-on-the-command-line.patch 4.59 KiB
    From 32d8f994120cbb9b5b8b4bb1f7e80798bf82da20 Mon Sep 17 00:00:00 2001
    From: Sumit Bose <sbose@redhat.com>
    Date: Fri, 1 Jun 2018 21:26:47 +0200
    Subject: [PATCH 20/30] Only update attributes given on the command line
    
    When updating attributes of the LDAP computer object we only want to
    update attributes which are related to options given on the command
    line. Otherwise a simple call of 'adcli update' to check if the machine
    account password needs an update might unexpectedly reset other
    attributes as well.
    
    Related to https://bugzilla.redhat.com/show_bug.cgi?id=1547013
               https://bugzilla.redhat.com/show_bug.cgi?id=1545568
               https://bugzilla.redhat.com/show_bug.cgi?id=1538730
    ---
     library/adenroll.c | 35 ++++++++++++++++++++++++++++++-----
     1 file changed, 30 insertions(+), 5 deletions(-)
    
    diff --git a/library/adenroll.c b/library/adenroll.c
    index eca3c37..ee845ef 100644
    --- a/library/adenroll.c
    +++ b/library/adenroll.c
    @@ -99,8 +99,11 @@ struct _adcli_enroll {
     	int user_princpal_generate;
     
     	char *os_name;
    +	int os_name_explicit;
     	char *os_version;
    +	int os_version_explicit;
     	char *os_service_pack;
    +	int os_service_pack_explicit;
     
     	krb5_kvno kvno;
     	char *keytab_name;
    @@ -113,6 +116,7 @@ struct _adcli_enroll {
     	int computer_password_lifetime_explicit;
     	char *samba_data_tool;
     	bool trusted_for_delegation;
    +	int trusted_for_delegation_explicit;
     };
     
     static adcli_result
    @@ -1212,7 +1216,11 @@ update_computer_account (adcli_enroll *enroll)
     	ldap = adcli_conn_get_ldap_connection (enroll->conn);
     	return_if_fail (ldap != NULL);
     
    -	{
    +	/* Only update attributes which are explicitly given on the command
    +	 * line. Otherwise 'adcli update' must be always called with the same
    +	 * set of options to make sure existing attributes are not deleted or
    +	 * overwritten with different values. */
    +	if (enroll->host_fqdn_explicit) {
     		char *vals_dNSHostName[] = { enroll->host_fqdn, NULL };
     		LDAPMod dNSHostName = { LDAP_MOD_REPLACE, "dNSHostName", { vals_dNSHostName, } };
     		LDAPMod *mods[] = { &dNSHostName, NULL };
    @@ -1220,7 +1228,7 @@ update_computer_account (adcli_enroll *enroll)
     		res |= update_computer_attribute (enroll, ldap, mods);
     	}
     
    -	if (res == ADCLI_SUCCESS) {
    +	if (res == ADCLI_SUCCESS && enroll->trusted_for_delegation_explicit) {
     		char *vals_userAccountControl[] = { NULL , NULL };
     		LDAPMod userAccountControl = { LDAP_MOD_REPLACE, "userAccountControl", { vals_userAccountControl, } };
     		LDAPMod *mods[] = { &userAccountControl, NULL };
    @@ -1240,12 +1248,25 @@ update_computer_account (adcli_enroll *enroll)
     		LDAPMod operatingSystemVersion = { LDAP_MOD_REPLACE, "operatingSystemVersion", { vals_operatingSystemVersion, } };
     		char *vals_operatingSystemServicePack[] = { enroll->os_service_pack, NULL };
     		LDAPMod operatingSystemServicePack = { LDAP_MOD_REPLACE, "operatingSystemServicePack", { vals_operatingSystemServicePack, } };
    -		LDAPMod *mods[] = { &operatingSystem, &operatingSystemVersion, &operatingSystemServicePack, NULL };
    +		LDAPMod *mods[] = { NULL, NULL, NULL, NULL };