If i try to customize system-auth config in a custom authselect profile, which is based on the default profile sssd in RHEL 8 like distros, with community.general.pamd the module fails with "AttributeError: 'NoneType' object has no attribute 'group'". The reason for this issue is the first line in file '{imply "with-smartcard" if "with-smartcard-required"}'
I expected line 32 to change from
password sufficient pam_unix.so yescrypt shadow {if not "without-nullok":nullok} use_authtok$
to
password sufficient pam_unix.so yescrypt shadow {if not "without-nullok":nullok} use_authtok sha512$
Actual Results
Traceback (most recent call last):
File "/home/vagrant/.ansible/tmp/ansible-tmp-1673967229.709315-1209279-206495393597740/AnsiballZ_pamd.py", line 107, in <module>
_ansiballz_main()
File "/home/vagrant/.ansible/tmp/ansible-tmp-1673967229.709315-1209279-206495393597740/AnsiballZ_pamd.py", line 99, in _ansiballz_main
invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
File "/home/vagrant/.ansible/tmp/ansible-tmp-1673967229.709315-1209279-206495393597740/AnsiballZ_pamd.py", line 48, in invoke_module
run_name='__main__', alter_sys=True)
File "/usr/lib64/python3.6/runpy.py", line 205, in run_module
return _run_module_code(code, init_globals, run_name, mod_spec)
File "/usr/lib64/python3.6/runpy.py", line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/tmp/ansible_community.general.pamd_payload_0k32ymn2/ansible_community.general.pamd_payload.zip/ansible_collections/community/general/plugins/modules/pamd.py", line 845, in <modu le>
File "/tmp/ansible_community.general.pamd_payload_0k32ymn2/ansible_community.general.pamd_payload.zip/ansible_collections/community/general/plugins/modules/pamd.py", line 783, in main
File "/tmp/ansible_community.general.pamd_payload_0k32ymn2/ansible_community.general.pamd_payload.zip/ansible_collections/community/general/plugins/modules/pamd.py", line 426, in __init__
File "/tmp/ansible_community.general.pamd_payload_0k32ymn2/ansible_community.general.pamd_payload.zip/ansible_collections/community/general/plugins/modules/pamd.py", line 339, in rule_
from_string
AttributeError: 'NoneType' object has no attribute 'group'
msg: |-
MODULE FAILURE
See stdout/stderr for the exact error
rc: 1
Issue is happening because line '1 {imply "with-smartcard" if "with-smartcard-required"}$' is analyzed with method PamdRule.rule_from_string(line) in line 427 in plugins/modules/pamd.py and no groups are found in rule_match.
Summary
If i try to customize system-auth config in a custom authselect profile, which is based on the default profile sssd in RHEL 8 like distros, with community.general.pamd the module fails with "AttributeError: 'NoneType' object has no attribute 'group'". The reason for this issue is the first line in file '{imply "with-smartcard" if "with-smartcard-required"}'
Issue Type
Bug Report
Component Name
community.general.pamd
Ansible Version
Community.general Version
Configuration
OS / Environment
RHEL 8, Rocky Linux 8
Steps to Reproduce
Create a new authselect profile based on the sssd default profile
Following system-auth file is going to be created:
cat -nA /etc/authselect/custom/test/system-auth
The issue is on line 1.
Expected Results
I expected line 32 to change from
password sufficient pam_unix.so yescrypt shadow {if not "without-nullok":nullok} use_authtok$
topassword sufficient pam_unix.so yescrypt shadow {if not "without-nullok":nullok} use_authtok sha512$
Actual Results
Issue is happening because line '1 {imply "with-smartcard" if "with-smartcard-required"}$' is analyzed with method PamdRule.rule_from_string(line) in line 427 in plugins/modules/pamd.py and no groups are found in rule_match.
Additional handling is required for these type of lines. https://www.mankier.com/5/authselect-profiles#Profile_Files-Example
Code of Conduct