Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
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 2100916

Summary: ipa user login with otp fails with error 'Preauthentication failed while getting initial credentials '
Product: Red Hat Enterprise Linux 8 Reporter: Sudhir Menon <sumenon>
Component: libvertoAssignee: Julien Rische <jrische>
Status: CLOSED ERRATA QA Contact: anuja <amore>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 8.7CC: frenaud, mpolovka, rcritten, tscherf
Target Milestone: rcKeywords: Regression, Triaged
Target Release: ---Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libverto-0.3.2-2.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-11-08 10:54:21 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Deadline: 2022-07-11   

Description Sudhir Menon 2022-06-24 16:55:09 UTC
Description of problem: ipa user authentication with otp fails with error ''Preauthentication failed while getting initial credentials'

Version-Release number of selected component (if applicable):
ipa-server-4.9.10-1.module+el8.7.0+15691+2b2c1dd5.x86_64
sssd-common-2.7.0-2.el8.x86_64
package krb5kdc is not installed
389-ds-base-1.4.3.30-3.module+el8.7.0+15600+347cafc6.x86_64
openssl-1.1.1k-6.el8_5.x86_64
httpd-2.4.37-47.module+el8.6.0+15654+427eba2e.2.x86_64


How reproducible:
Always

Steps to Reproduce:
1. [root@server ~]# kinit admin
2. [root@server ~]# ipa user-mod --user-auth-type=otp testuser0001
  User authentication types: otp
  Account disabled: False
  Password: True
  Member of groups: ipausers
  Kerberos keys available: True
3. [root@server ~]# ipa otptoken-add --type=totp --no-qrcode --owner=testuser0001
------------------
Added OTP token ""
------------------
  Unique ID: 0acd59f9-5766-4a35-862b-c5695847cc78
  Type: TOTP
  Owner: testuser0001
  Key: 49IEWD9cWQNceG2Ls5jelJnXg9FW9TCgl+3ajGI3S4jtCHU=
  Algorithm: sha1
  Digits: 6
  Clock offset: 0
  Clock interval: 30
  URI: otpauth://totp/testuser0001:0acd59f9-5766-4a35-862b-c5695847cc78?issuer=testuser0001%40TESTRELM.TEST&secret=4PJAIWB7LRMQGXDYNWF3HGG6SSM5PA6RK32TBIEX5XNIYYRXJOEO2CDV&digits=6&algorithm=SHA1&period=30

Actual results:
1. Authentication fails with error.
13273] 1656089128.019514: Received error from KDC: -1765328360/Preauthentication failed
[13273] 1656089128.019515: Decoding FAST response
kinit: Preauthentication failed while getting initial credentials

2. krb5kdc.log file displays the below error, even when the directory is present on the system.

Jun 24 08:19:26 server.testrelm.test krb5kdc[9303](Error): preauth pkinit failed to initialize: PKINIT initialization failed: Cannot read certificate file '/var/kerberos/krb5kdc/kdc.crt': No such file or directory

[root@server ~]# ls -lZ  /var/kerberos/krb5kdc/
total 20
-rw-r--r--. 1 root root unconfined_u:object_r:krb5kdc_conf_t:s0 1643 Jun 24 08:26 cacert.pem
-rw-------. 1 root root system_u:object_r:krb5kdc_conf_t:s0       22 Apr 29 05:14 kadm5.acl
-rw-------. 1 root root system_u:object_r:krb5kdc_conf_t:s0     1038 Jun 24 08:19 kdc.conf
-rw-r--r--. 1 root root system_u:object_r:krb5kdc_conf_t:s0     1866 Jun 24 08:26 kdc.crt
-rw-------. 1 root root system_u:object_r:krb5kdc_conf_t:s0     1704 Jun 24 08:26 kdc.key

3. No AVCs are seen on the system.
[root@server ~]# ausearch -m AVC
<no matches>

Expected results:
ipa user with otp login should work.

Additional info: attaching the system logs for reference.

Comment 4 Florence Blanc-Renaud 2022-06-24 19:02:17 UTC
The journal shows an error in ipa-otpd with "Unable to initialize event loop". The issue seems related to the version of libverto available in RHEL 8.7. 

The new ipa package (4.9.10) is initializing libverto with an additional flag: VERTO_EV_TYPE_CHILD [1].
On RHEL 8.7, libverto (0.3.0) is using libverto-libevent, while on RHEL 9.1 (where the issue doesn't happen), libverto (0.3.2) is using libverto-libev.

The spec file for RHEL 8.7 does not even compile libev [2]:

%if !0%{?rhel}
%package        libev
Summary:        libev module for %{name}
Requires:       %{name}%{?_isa} = %{version}-%{release}
Provides:       %{name}-module-base = %{version}-%{release}


I tried to do a scratch build of libverto 0.3.2 and installation of libverto + libverto-libev on RHEL 8.7 and it seems to fix the issue.

Moving the bugzilla to libverto for futher analysis. A possible fix would be to rebase libverto to 0.3.2 in RHEL 8.7 and add a dependency on libverto-libev.


[1] https://pagure.io/freeipa/blob/61a64aef6dd0b884d968e72546b4adbd265f8404/f/daemons/ipa-otpd/main.c#_245-246
[2] http://pkgs.devel.redhat.com/cgit/rpms/libverto/tree/libverto.spec?h=rhel-8.7.0#n107

Comment 6 Rob Crittenden 2022-06-24 19:09:28 UTC
Interesting. I didn't get the event error on my test install and updating libverto doesn't fix it.

The BIND is failing in ipa-otpd.

Jun 24 14:31:29 ipa.example.test ipa-otpd[12977]: tuser: request received
Jun 24 14:31:29 ipa.example.test ipa-otpd[12977]: tuser: user query start
Jun 24 14:31:29 ipa.example.test ipa-otpd[12977]: tuser: user query end: uid=tuser,cn=users,cn=accounts,dc=example,dc=test
Jun 24 14:31:29 ipa.example.test ipa-otpd[12977]: tuser: bind start: uid=tuser,cn=users,cn=accounts,dc=example,dc=test
Jun 24 14:31:29 ipa.example.test ipa-otpd[12977]: tuser: bind end: Invalid credentials
Jun 24 14:31:29 ipa.example.test ipa-otpd[12977]: tuser: response sent: Access-Reject

389-ds access log confirms

[24/Jun/2022:14:31:29.673490666 -0400] conn=47 op=6 BIND dn="uid=tuser,cn=users,cn=accounts,dc=example,dc=test" method=128 version=3
[24/Jun/2022:14:31:29.673841183 -0400] conn=47 op=6 RESULT err=49 tag=97 nentries=0 wtime=0.000033733 optime=0.000358440 etime=0.000389191

FWIW: the KDC certificate issue is a red herring. It must show up during bootstrap.

Comment 7 Rob Crittenden 2022-06-24 19:15:22 UTC
Never mind, I had removed otp from my test user's auth.

I've confirmed that with the scratch build Flo did authentication works.

Comment 8 Julien Rische 2022-06-30 08:25:05 UTC
The last version of ipa-otpd loads a libverto context with the VERTO_EV_TYPE_CHILD flag[1]. However, it is not supported by libverto-libevent[2]. It would require an upgrade to libverto-libev[3], which is provider in libverto 0.3.2 release.

[1] https://pagure.io/freeipa/blob/master/f/daemons/ipa-otpd/main.c#_246
[2] https://github.com/latchset/libverto/blob/0.3.2/src/verto-libevent.c#L146
[3] https://github.com/latchset/libverto/blob/0.3.2/src/verto-libev.c#L153

Comment 9 Michal Polovka 2022-07-11 12:43:53 UTC
Pre-verified using the automation from src/otp/test_0001_otp_master_tests.py::TestOTPfunction::test_otp_0001 and package libverto-0.3.2-2.el8.x86_64

Passed 	src/otp/test_0001_otp_master_tests.py::TestOTPfunction::test_otp_0001

Full log is an attachment of this BZ. Marking as pre-verified - tested.

Comment 15 Michal Polovka 2022-07-27 12:39:55 UTC
Verified using automation from src/otp/test_0001_otp_master_tests.py::TestOTPfunction::test_otp_0001 on RHEL8.7 machine.

Passed 	src/otp/test_0001_otp_master_tests.py::TestOTPfunction::test_otp_0001

Complete test run log is an attachment of this BZ. Marking as verified.

Comment 18 errata-xmlrpc 2022-11-08 10:54:21 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 (libverto 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-2022:7776