Skip to content

p11_child benchmark : OpenSC caching #8743

@mvogt1

Description

@mvogt1

I just found out that p11_child does benefit from the caching mechanism by OpenSC.

The difference is significant 9 secs vs 0.9 secs ! ( factor 10 )

# CACHE: DISABLED
$ cat /etc/opensc.conf | grep use_file_caching
        use_file_caching = no;
$ time pkcs11-tool --list-objects
real    0m8.982s
user    0m0.030s
sys     0m0.033s

# CACHE: ENABLED
$ cat /etc/opensc.conf | grep use_file_caching
        use_file_caching = public;          <---- default
$ time pkcs11-tool --list-objects
real    0m0.963s
user    0m0.017s
sys     0m0.011s

I'm using a wrapper to benchmark p11_child:

$ cat /usr/libexec/sssd/p11_child
#!/usr/bin/bash

LOG="/tmp/p11_child.log"
#export XDG_CACHE_HOME="/var/tmp/xdg-cache/root_p11/"
#mkdir -p $XDG_CACHE_HOME

id >> $LOG
env >> $LOG
echo "HOME: $HOME" >>$LOG

{ time  /usr/libexec/sssd/p11_child.bin "$@" ; } 2>>$LOG

When testing p11_child:

$pamtester -v gdm-smartcard <mylogin> authenticate
$ tail -f /tmp/p11_child.log 
real    0m8.820s
user    0m0.008s
sys     0m0.012s


This take 8.8 secs for p11_child, and thus not using caching (0.8 secs)

I'm missing an option in /etc/sssd.conf, for example:

p11_child_xdg_cache_home=/var/cache/p11_child

which sets the environment variable XDG_CACHE_HOME before calling pkcs11-opensc.so.
In the example wrapper above I would then get the 0.8 secs.

Note:

Setting a global cache dir according to man opensc.conf :

$ cat  /etc/opensc.conf | grep file_cache_dir
        file_cache_dir = "/var/cache/opensc";

works, but is a global option, I would prefer a seperate option for p11_child.

As a result, currently, at least on RedHat, the default is to not use caching, and thus is performing poorly.

Caching in OpenSC is configured globally but does not work in p11_child, because neither $HOME nor $XDG_CACHE_HOME ist set in p11_child. Setting file_cache_dir would work, but needs a additional SELinux rule.

I would prefer a default in sssd, including a shipped SELinux rule, for p11_child which runs in context=system_u:system_r:sssd_t:s0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions