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 1449367

Summary: Locked screen prompts for user password and not smartcard pin
Product: Red Hat Enterprise Linux 7 Reporter: Roshni <rpattath>
Component: openscAssignee: Jakub Jelen <jjelen>
Status: CLOSED WORKSFORME QA Contact: Release Test Team <release-test-team-automation>
Severity: unspecified Docs Contact:
Priority: high    
Version: 7.4CC: rpattath
Target Milestone: rcKeywords: Regression, TestBlocker
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-05-10 14:54:52 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:

Description Roshni 2017-05-09 19:39:48 UTC
Description of problem:
Locked screen prompts for user password and not smartcard pin

Version-Release number of selected component (if applicable):
opensc-0.16.0-4.20170227git777e2a3.el7.x86_64

How reproducible:
always

Steps to Reproduce:
1. Login using smartcard pin using CAC card
2. Lock the screen and move the mouse
3. Smartcard is still inserted

Actual results:
Prompt for user password

Expected results:


Additional info:
[lastday2001428082@dhcp129-77 ~]$ /usr/libexec/gnome-settings-daemon -r --debug |& grep smartcard
** (gnome-settings-daemon:8432): DEBUG: Loading plugin: /usr/lib64/gnome-settings-daemon-3.0/smartcard.gnome-settings-plugin
** (gnome-settings-daemon:8432): DEBUG: GnomeSettingsPluginInfo: name='Smartcard' file='/usr/lib64/gnome-settings-daemon-3.0/smartcard.gnome-settings-plugin' location='smartcard'
** (gnome-settings-daemon:8432): DEBUG: Loading /usr/lib64/gnome-settings-daemon-3.0/libsmartcard.so
(gnome-settings-daemon:8432): smartcard-plugin-DEBUG: GsdSmartcard initializing
(gnome-settings-daemon:8432): smartcard-plugin-DEBUG: GsdSmartcardManagerError: Registering dbus error org.gnome.SettingsDaemon.Smartcard.Manager.Error.Generic
(gnome-settings-daemon:8432): smartcard-plugin-DEBUG: GsdSmartcardManagerError: Registering dbus error org.gnome.SettingsDaemon.Smartcard.Manager.Error.WithNss
(gnome-settings-daemon:8432): smartcard-plugin-DEBUG: GsdSmartcardManagerError: Registering dbus error org.gnome.SettingsDaemon.Smartcard.Manager.Error.LoadingDriver
(gnome-settings-daemon:8432): smartcard-plugin-DEBUG: GsdSmartcardManagerError: Registering dbus error org.gnome.SettingsDaemon.Smartcard.Manager.Error.WatchingForEvents
(gnome-settings-daemon:8432): smartcard-plugin-DEBUG: GsdSmartcardManagerError: Registering dbus error org.gnome.SettingsDaemon.Smartcard.Manager.Error.ReportingEvents
(gnome-settings-daemon:8432): smartcard-plugin-DEBUG: GsdSmartcardManagerError: Registering dbus error org.gnome.SettingsDaemon.Smartcard.Manager.Error.FindingSmartcard
(gnome-settings-daemon:8432): smartcard-plugin-DEBUG: Activating gsd_smartcard plugin
** (gnome-settings-daemon:8432): DEBUG: GnomeSettingsManager: emitting plugin-activated smartcard
** (gnome-settings-daemon:8432): DEBUG: Plugin smartcard: active
(gnome-settings-daemon:8432): smartcard-plugin-DEBUG: attempting to load NSS database '/etc/pki/nssdb'
(gnome-settings-daemon:8432): smartcard-plugin-DEBUG: NSS database '/etc/pki/nssdb' loaded
(gnome-settings-daemon:8432): smartcard-plugin-DEBUG: taking name org.gnome.SettingsDaemon.Smartcard on session bus
(gnome-settings-daemon:8432): smartcard-plugin-DEBUG: Getting list of suitable drivers
(gnome-settings-daemon:8432): smartcard-plugin-DEBUG: Activating driver 'opensc module'
(gnome-settings-daemon:8432): smartcard-plugin-DEBUG: watching for smartcard events
(gnome-settings-daemon:8432): smartcard-plugin-DEBUG: Detected smartcard insertion event in slot 0
(gnome-settings-daemon:8432): smartcard-plugin-DEBUG: ===============================
(gnome-settings-daemon:8432): smartcard-plugin-DEBUG:  Token 'PIV Card Holder pin (PIV_II)'
(gnome-settings-daemon:8432): smartcard-plugin-DEBUG:  Inserted: yes
(gnome-settings-daemon:8432): smartcard-plugin-DEBUG:  Previously used to login: no
(gnome-settings-daemon:8432): smartcard-plugin-DEBUG: ===============================



[lastday2001428082@dhcp129-77 ~]$ env
XDG_VTNR=1
SSH_AGENT_PID=3057
XDG_SESSION_ID=1
HOSTNAME=dhcp129-77.rdu.redhat.com
IMSETTINGS_INTEGRATE_DESKTOP=yes
TERM=xterm-256color
SHELL=/bin/bash
XDG_MENU_PREFIX=gnome-
VTE_VERSION=4601
HISTSIZE=1000
GJS_DEBUG_OUTPUT=stderr
WINDOWID=35651590
GJS_DEBUG_TOPICS=JS ERROR;JS LOG
IMSETTINGS_MODULE=none
USER=lastday2001428082
LS_COLORS=rs=0:di=38;5;27:ln=38;5;51:mh=44;38;5;15:pi=40;38;5;11:so=38;5;13:do=38;5;5:bd=48;5;232;38;5;11:cd=48;5;232;38;5;3:or=48;5;232;38;5;9:mi=05;48;5;232;38;5;15:su=48;5;196;38;5;15:sg=48;5;11;38;5;16:ca=48;5;196;38;5;226:tw=48;5;10;38;5;16:ow=48;5;10;38;5;21:st=48;5;21;38;5;15:ex=38;5;34:*.tar=38;5;9:*.tgz=38;5;9:*.arc=38;5;9:*.arj=38;5;9:*.taz=38;5;9:*.lha=38;5;9:*.lz4=38;5;9:*.lzh=38;5;9:*.lzma=38;5;9:*.tlz=38;5;9:*.txz=38;5;9:*.tzo=38;5;9:*.t7z=38;5;9:*.zip=38;5;9:*.z=38;5;9:*.Z=38;5;9:*.dz=38;5;9:*.gz=38;5;9:*.lrz=38;5;9:*.lz=38;5;9:*.lzo=38;5;9:*.xz=38;5;9:*.bz2=38;5;9:*.bz=38;5;9:*.tbz=38;5;9:*.tbz2=38;5;9:*.tz=38;5;9:*.deb=38;5;9:*.rpm=38;5;9:*.jar=38;5;9:*.war=38;5;9:*.ear=38;5;9:*.sar=38;5;9:*.rar=38;5;9:*.alz=38;5;9:*.ace=38;5;9:*.zoo=38;5;9:*.cpio=38;5;9:*.7z=38;5;9:*.rz=38;5;9:*.cab=38;5;9:*.jpg=38;5;13:*.jpeg=38;5;13:*.gif=38;5;13:*.bmp=38;5;13:*.pbm=38;5;13:*.pgm=38;5;13:*.ppm=38;5;13:*.tga=38;5;13:*.xbm=38;5;13:*.xpm=38;5;13:*.tif=38;5;13:*.tiff=38;5;13:*.png=38;5;13:*.svg=38;5;13:*.svgz=38;5;13:*.mng=38;5;13:*.pcx=38;5;13:*.mov=38;5;13:*.mpg=38;5;13:*.mpeg=38;5;13:*.m2v=38;5;13:*.mkv=38;5;13:*.webm=38;5;13:*.ogm=38;5;13:*.mp4=38;5;13:*.m4v=38;5;13:*.mp4v=38;5;13:*.vob=38;5;13:*.qt=38;5;13:*.nuv=38;5;13:*.wmv=38;5;13:*.asf=38;5;13:*.rm=38;5;13:*.rmvb=38;5;13:*.flc=38;5;13:*.avi=38;5;13:*.fli=38;5;13:*.flv=38;5;13:*.gl=38;5;13:*.dl=38;5;13:*.xcf=38;5;13:*.xwd=38;5;13:*.yuv=38;5;13:*.cgm=38;5;13:*.emf=38;5;13:*.axv=38;5;13:*.anx=38;5;13:*.ogv=38;5;13:*.ogx=38;5;13:*.aac=38;5;45:*.au=38;5;45:*.flac=38;5;45:*.mid=38;5;45:*.midi=38;5;45:*.mka=38;5;45:*.mp3=38;5;45:*.mpc=38;5;45:*.ogg=38;5;45:*.ra=38;5;45:*.wav=38;5;45:*.axa=38;5;45:*.oga=38;5;45:*.spx=38;5;45:*.xspf=38;5;45:
PKCS11_LOGIN_CERT_ISSUER=CN=DOD JITC CA-31,OU=PKI,OU=DoD,O=U.S. Government,C=US
SSH_AUTH_SOCK=/run/user/1005/keyring/ssh
SESSION_MANAGER=local/unix:@/tmp/.ICE-unix/2878,unix/unix:/tmp/.ICE-unix/2878
USERNAME=lastday2001428082
PKCS11_LOGIN_CERT_SERIAL=03:87:C9
GNOME_SHELL_SESSION_MODE=classic
PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/home/lastday2001428082/.local/bin:/home/lastday2001428082/bin
MAIL=/var/spool/mail/lastday2001428082
DESKTOP_SESSION=gnome-classic
QT_IM_MODULE=xim
QT_QPA_PLATFORMTHEME=qgnomeplatform
XDG_SESSION_TYPE=x11
PWD=/home/lastday2001428082
XMODIFIERS=@im=none
LANG=en_US.UTF-8
GDM_LANG=en_US.UTF-8
GDMSESSION=gnome-classic
HISTCONTROL=ignoredups
HOME=/home/lastday2001428082
SHLVL=2
XDG_SEAT=seat0
PKCS11_LOGIN_TOKEN_NAME=LAST.DAY.2001428082
GNOME_DESKTOP_SESSION_ID=this-is-deprecated
XDG_SESSION_DESKTOP=gnome-classic
LOGNAME=lastday2001428082
XDG_DATA_DIRS=/home/lastday2001428082/.local/share/flatpak/exports/share/:/var/lib/flatpak/exports/share/:/usr/local/share/:/usr/share/
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-768maLPLXf,guid=b6f868319c965b111f80b0935911e0e7
LESSOPEN=||/usr/bin/lesspipe.sh %s
WINDOWPATH=1
DISPLAY=:0
XDG_RUNTIME_DIR=/run/user/1005
XDG_CURRENT_DESKTOP=GNOME-Classic:GNOME
COLORTERM=truecolor
XAUTHORITY=/run/gdm/auth-for-lastday2001428082-LTRLgV/database
_=/usr/bin/env

Comment 3 Jakub Jelen 2017-05-10 07:18:37 UTC
How does the debug log look like for coolkey (how it should look correctly), which I suppose is still working?

I suppose it is saying "Previously used to login yes" instead of "no" now. It would mean that the following condition [1] evaluates to false for some reason.

    token_name = PK11_GetTokenName (card_slot);
    if (g_strcmp0 (g_getenv ("PKCS11_LOGIN_TOKEN_NAME"), token_name) == 0)

The environment variable "PKCS11_LOGIN_TOKEN_NAME" is set to "LAST.DAY.2001428082" (from the env above) by pam_pkcs11 and from PK11_GetTokenName(), which should be the same.

Are you sure both pam_pkcs11 and gnome-settings-daemon are using the same NSS DB and the same pkcs11 library? Your log confirms this in gnome-settings, but not about the pam_pkcs11 (and the name looks more like from coolkey).

The same token with using the different driver shows different label, which is mostly the case here:

$ pkcs11-tool -T --module /usr/lib64/pkcs11/libcoolkeypk11.so 
Available slots:
Slot 0 (0x1): OMNIKEY AG CardMan 3121 00 00
  token label        : Test E. Cardholder IV
$ pkcs11-tool -T --module /usr/lib64/pkcs11/opensc-pkcs11.so
Available slots:
Slot 0 (0x0): OMNIKEY AG CardMan 3121 00 00
  token label        : PIV Card Holder pin (PIV_II)

In ideal case, we should make OpenSC to use similar token names as coolkey is using. I will try to find out with upstream why OpenSC is using these names.

Until that I believe this is misconfiguration of pam_pkcs11, which is still using coolkey and therefore the environment variables do not match. Can you verify that?


[1] https://github.com/GNOME/gnome-settings-daemon/blob/5b3ac1cbf6b0bea98732f4610e340e50b69994ea/plugins/smartcard/gsd-smartcard-service.c#L497
[2] https://github.com/OpenSC/pam_pkcs11/blob/8a3e8c667ed615ca2608c04414de69fdae5b6787/src/common/pkcs11_lib.c#L708

Comment 4 Jakub Jelen 2017-05-10 08:09:04 UTC
The PKCS#11 specification (pkcs-11v2-30b-d6.pdf) is very vague about the meaning of the label field in the CK_TOKEN_INFO structure:

> application-defined label, assigned during token
initialization. Must be padded with the blank character
(‘ ‘). Should not be null-terminated.

The coolkey is obviously setting the full cardholder name to this field:

    memcpy(label, personName, MIN(personLen, maxSize));

but OpenSC is using PIN label for some reason in combination with pkcs15-emulated label (one for a driver)

    p15card->tokeninfo->label = strdup("PIV_II");

We can probably push similar change to OpenSC, but I don't think this should be a blocker for RHEL7.4 release unless it will prevent the above use case with Gnome.

Comment 5 Roshni 2017-05-10 14:54:52 UTC
With the following changes to pam_pkcs11.conf I do not see this issue

use_pkcs11_module = opensc;

The following already existed when the issue was seen

pkcs11_module opensc {
                module = "opensc-pkcs11.so";
                description = "OpenSC PKCS#11 module";
                # Slot-number to use. One for the first, two for the second and so
                # on. The default value is zero which means to use the first slot
                # with an available token.
                slot_num = 0;
                nss_dir = /etc/pki/nssdb;

                # Path to the directory where the CA certificates are stored. The
                # directory must contain an openssl hash-link to each certificate.
                # The default value is /etc/pam_pkcs11/cacerts.
                ca_dir = "/etc/pam_pkcs11/cacerts";

                # Path to the directory where the CRLs are stored. The directory
                # must contain an openssl hash-link to each CRL. The default value
                # is /etc/pam_pkcs11/crls.
                crl_dir = "/etc/pam_pkcs11/crls";

                # Sets the Certificate Policy, (see above)
                cert_policy = ca, signature;
        }

Closing the bug and opened a new bug for the label issue https://bugzilla.redhat.com/show_bug.cgi?id=1449740