96aa09b extdom-extop: refactor tests to use unshare+chroot to override nss_files configuration

6 files Authored by Alexander Bokovoy 3 years ago, Committed by rcritten 3 years ago,
    extdom-extop: refactor tests to use unshare+chroot to override nss_files configuration
    
    Unit tests for ipa-extdom-extop plugin use nss_files.so.2 module to test the
    functionality instead of relying on SSSD API or nss_sss.so.2 module. The latter
    two cannot be used in build environment.
    
    nss_files.so.2 always tries to open /etc/passwd and /etc/group. In past, we
    overloaded 'fopen()' to change the path to opened file but this stops working
    after glibc consolidate file opening in nss_files with the code starting at
    https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=299210c1fa67e2dfb564475986fce11cd33db9ad,
    this method is not usable anymore and builds against glibc 2.31.9000+ fail in
    cmocka unit test execution in Rawhide.
    
    Apply an alternative approach that uses a new user namespace to unshare the
    test from its parent and chroot to the test data where expected /etc/passwd and
    /etc/group are provided. This method works only on Linux, thus only run the
    unit test on Linux.
    
    In case unshare() or chroot() fail, we have to skip tests that use
    nss_files.so.2.
    
    Fixes: https://pagure.io/freeipa/issue/8437
    Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
    Reviewed-By: Rob Crittenden <rcritten@redhat.com>
    
        
file modified
+2 -0
daemons/ipa-slapi-plugins/ipa-extdom-extop/test_data/etc/group daemons/ipa-slapi-plugins/ipa-extdom-extop/test_data/group
file renamed
file was renamed with no change to the file
daemons/ipa-slapi-plugins/ipa-extdom-extop/test_data/etc/passwd daemons/ipa-slapi-plugins/ipa-extdom-extop/test_data/passwd
file renamed
file was renamed with no change to the file
file modified
+9 -0