RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1846882 - No longer able to delete computer from AD using adcli
Summary: No longer able to delete computer from AD using adcli
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: adcli
Version: 8.2
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: 8.0
Assignee: Sumit Bose
QA Contact: sssd-qe
URL:
Whiteboard: sync-to-jira
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-06-15 08:02 UTC by Sumit Bose
Modified: 2020-11-04 02:11 UTC (History)
2 users (show)

Fixed In Version: adcli-0.8.2-6.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-11-04 02:07:53 UTC
Type: Bug
Target Upstream Version:
Embargoed:
pm-rhel: mirror+


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2020:4578 0 None None None 2020-11-04 02:08:00 UTC

Description Sumit Bose 2020-06-15 08:02:35 UTC
This bug was initially created as a copy of Bug #1840752

I am copying this bug because: 
Issues fixed in RHEL-7 should be fixed in RHEL-8 as well to avoid regression.


adcli-0.8.1-13.el7.x86_64


Description of problem:

In our AD environment we've been using the following command to delete computer objects without issue.

$ adcli delete-computer --verbose --domain=ad.gatech.edu --login-ccache=FILE:/path/to/krb5cc HOST
 ! Couldn't enumerate keytab: (null): Permission denied
adcli: couldn't lookup domain info from keytab: Couldn't enumerate keytab: (null): Permission denied


When it was working the command would continue. Here is an example. I don't know what should be considered private so I just replaced the stuff specific to us with placeholders. The host I ran this command on was "math30192".


$ adcli delete-computer --verbose --domain=ad.gatech.edu --login-ccache=FILE:/path/to/krb5cc math-thisistest.math.gatech.edu
 ! Couldn't enumerate keytab: (null): Permission denied
 * Using domain name: ad.gatech.edu
 * Calculated computer account name from fqdn: MATH30192
 * Calculated domain realm from name: AD.GATECH.EDU
 * Discovering domain controllers: _ldap._tcp.ad.gatech.edu
 * Sending netlogon pings to domain controller: cldap://SOME_IP
 * Sending netlogon pings to domain controller: ldap://SOME_IP
 * Sending netlogon pings to domain controller: cldap://SOME_IP
 * Sending netlogon pings to domain controller: ldap://SOME_IP
 * Sending netlogon pings to domain controller: cldap://SOME_IP
 ! Couldn't perform discovery search: Can't contact LDAP server
 ! Couldn't perform discovery search: Can't contact LDAP server
 * Received NetLogon info from: SOME_AD_SERVER
 * Wrote out krb5.conf snippet to /tmp/adcli-krb5-I1U1w4/krb5.d/adcli-krb5-conf-uTTwzH
 * Looked up short domain name: AD
 * Looked up domain SID: SOME_SID
 * Using fully qualified name: math30192.math.gatech.edu
 * Using domain name: ad.gatech.edu
 * Using computer account name: MATH30192
 * Using domain realm: ad.gatech.edu
 * Using fully qualified name: math-thisistest.math.gatech.edu
 * Truncated computer account name from fqdn: MATH-THISISTEST
 * Computer account for MATH-THISISTEST$ does not exist
 ! No computer account for MATH-THISISTEST$ exists
adcli: deleting math-thisistest.math.gatech.edu in ad.gatech.edu domain failed: No computer account for MATH-THISISTEST$ exists


The most recent version of adcli (adcli-0.8.1-13.el7.x86_64) breaks this workflow. After some debugging of the source RPMs I've narrowed it down to the following patch files:


In both -9 and -13:
0001-delete-use-keytab-data-to-determine-realm-and-NetBIO.patch
0001-tools-remove-errx-from-computer-commands.patch

Only in -13:
0001-Fix-for-issues-found-by-Coverity.patch


The first patch attempts to do something and if it fails prints an error message. The second patch extends this to exiting the program if there is an error.

The third patch "fixes" the function that's called in the first patch (load_host_keytab called by adcli_enroll_load) so that it returns "res" rather than "ADCLI_SUCCESS" at the end. This is great and all, but it breaks the program. As we now exit when this fails, even though it doesn't need to "succeed" for the delete command to work properly.

Comment 1 Sumit Bose 2020-06-15 13:20:01 UTC
upstream:
 - 40d3be22f6e518e4354aa7c3d0278291fcbed32f

Comment 4 shridhar 2020-08-03 13:06:05 UTC
Tested with following details:


::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::   Test description
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

PURPOSE of /CoreOS/adcli/Regression/bz1840752-No-longer-able-to-delete-computer-from-AD-using-adcli
Description: Test for BZ#1840752 (no longer able to delete computer from AD using adcli
Author: Shridhar Gadekar <sgadekar>
Bug summary: no longer able to delete computer from AD using adcli
Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=1840752


::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::   Setup
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: [ 09:03:57 ] :: [   LOG    ] :: Package adcli is present
:: [ 09:03:57 ] :: [   LOG    ] :: Package versions:
:: [ 09:03:57 ] :: [   LOG    ] ::   adcli-0.8.2-6.el8.x86_64
:: [ 09:03:57 ] :: [   PASS   ] :: Creating tmp directory (Expected 0, got 0)
:: [ 09:03:57 ] :: [   PASS   ] :: Command 'pushd /tmp/tmp.51MzqdKmw7' (Expected 0, got 0)
:: [ 09:03:57 ] :: [   INFO   ] :: rlImport: Found 'realmd/basic', version '1.0-59' in /mnt/tests
:: [ 09:03:57 ] :: [   INFO   ] :: rlImport: Will try to import realmd/basic from /mnt/tests/CoreOS/realmd/Library/basic/lib.sh
:: [ 09:03:58 ] :: [   PASS   ] :: Command 'rlImport realmd/basic' (Expected 0, got 0)
:: [ 09:03:59 ] :: [   INFO   ] :: using '/var/tmp/beakerlib-7937001/backup' as backup destination
:: [ 09:03:59 ] :: [   PASS   ] :: Command 'rlFileBackup --clean /etc/resolv.conf /etc/krb5.keytab' (Expected 0, got 0)
:: [ 09:04:05 ] :: [   PASS   ] :: Command 'chronyd -q 'server 10.37.152.14 iburst' 'maxdistance 16'' (Expected 0, got 0)
:: [ 09:04:05 ] :: [   PASS   ] :: Command 'hostnamectl set-hostname ci-vm-10-0-138-.ad.baseos.qe' (Expected 0, got 0)
:: [ 09:04:07 ] :: [   PASS   ] :: Command 'ldapsearch -x -LLL -H ldap://10.37.152.14 -D 'Amy-admin.qe' -w 'Pass2012!' -b CN=ci-vm-10-0-138-,CN=Computers,dc=ad,dc=baseos,dc=qe -s sub '*'' (Expected 0-255, got 0)
:: [ 09:04:07 ] :: [   LOG    ] :: It should be safe to join this machine to AD
:: [ 09:04:07 ] :: [   PASS   ] :: Command 'ldapsearch -x -LLL -H ldap://10.37.152.14 -D 'Amy-admin.qe' -w 'Pass2012!' -b CN=ci-vm-10-0-138-,CN=Computers,dc=ad,dc=baseos,dc=qe -s sub '*'' (Expected 0-255, got 0)
:: [ 09:04:07 ] :: [ WARNING  ] :: It looks like the machine already has a record in AD. It was probably not properly cleaned by other test.
:: [ 09:04:07 ] :: [   PASS   ] :: Command 'echo nameserver\ 10.37.152.14 > /etc/resolv.conf' (Expected 0, got 0)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::   Duration: 11s
::   Assertions: 9 good, 0 bad
::   RESULT: PASS (Setup)


::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::   adcli join
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: [ 09:04:16 ] :: [   PASS   ] :: Join computer to AD (Expected 0, got 0)
:: [ 09:04:20 ] :: [   PASS   ] :: Command 'su local_user -c 'echo -n Pass2012! | adcli delete-computer --verbose --domain ad.baseos.qe --login-user Amy-admin --stdin-password'' (Expected 0, got 0)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::   Duration: 12s
::   Assertions: 2 good, 0 bad
::   RESULT: PASS (adcli join)


::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::   Cleanup
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: [ 09:04:20 ] :: [   LOG    ] :: Clean up
:: [ 09:04:20 ] :: [   PASS   ] :: klist -kte (Expected 0, got 0)
:: [ 09:04:20 ] :: [   PASS   ] :: Command 'kdestroy -A' (Expected 0, got 0)
:: [ 09:04:20 ] :: [   PASS   ] :: Command 'rm -f /etc/krb5.keytab' (Expected 0, got 0)
:: [ 09:04:21 ] :: [   PASS   ] :: rm -f rlRun_LOG (Expected 0, got 0)
:: [ 09:04:21 ] :: [   LOG    ] :: Computer was removed from AD domain
:: [ 09:04:21 ] :: [   PASS   ] :: Command 'hostnamectl set-hostname ci-vm-10-0-138-52.hosted.upshift.rdu2.redhat.com' (Expected 0, got 0)
:: [ 09:04:22 ] :: [   PASS   ] :: Command 'rlFileRestore' (Expected 0, got 0)
:: [ 09:04:22 ] :: [   PASS   ] :: Command 'popd' (Expected 0, got 0)
:: [ 09:04:22 ] :: [   PASS   ] :: Removing tmp directory (Expected 0, got 0)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::   Duration: 2s
::   Assertions: 8 good, 0 bad
::   RESULT: PASS (Cleanup)


::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::   /CoreOS/adcli/Regression/bz1840752-No-longer-able-to-delete-computer-from-AD-using-adcli
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: [ 09:04:22 ] :: [   LOG    ] :: File '/var/tmp/beakerlib-7937001/journal.xml' stored here: /var/tmp/BEAKERLIB_7937001_STORED_journal.xml
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::   Duration: 25s
::   Phases: 3 good, 0 bad
::   OVERALL RESULT: PASS (/CoreOS/adcli/Regression/bz1840752-No-longer-able-to-delete-computer-from-AD-using-adcli)

Script done, file is /tmp/1minutetip.TESTOUT.LOG
Shared connection to 10.0.138.52 closed.
[ INFO  ] AVC check: OK
[ INFO  ] What to do next?
 

marking verified.

Comment 7 errata-xmlrpc 2020-11-04 02:07:53 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (adcli bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2020:4578


Note You need to log in before you can comment on or make changes to this bug.