Skip to content

Commit 66e0c73

Browse files
Merge pull request #14426 from teacup-on-rockingchair/fix_sle16_pam_options
Fix sle16 pam options
2 parents b938dd6 + 3c613e4 commit 66e0c73

11 files changed

Lines changed: 151 additions & 122 deletions

File tree

linux_os/guide/system/accounts/accounts-restrictions/root_logins/use_pam_wheel_for_su/ansible/shared.yml

Lines changed: 0 additions & 11 deletions
This file was deleted.

linux_os/guide/system/accounts/accounts-restrictions/root_logins/use_pam_wheel_for_su/bash/shared.sh

Lines changed: 0 additions & 4 deletions
This file was deleted.

linux_os/guide/system/accounts/accounts-restrictions/root_logins/use_pam_wheel_for_su/oval/shared.xml

Lines changed: 0 additions & 21 deletions
This file was deleted.

linux_os/guide/system/accounts/accounts-restrictions/root_logins/use_pam_wheel_for_su/rule.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,14 @@ vuldiscussion: |-
6161
When operating systems provide the capability to escalate a functional capability, it is critical the user re-authenticate.
6262
6363
platform: package[pam]
64+
65+
template:
66+
name: pam_options
67+
vars:
68+
path: /etc/pam.d/su
69+
type: auth
70+
control_flag: required
71+
module: pam_wheel.so
72+
arguments:
73+
- argument: use_uid
74+
new_argument: use_uid

linux_os/guide/system/accounts/accounts-restrictions/root_logins/use_pam_wheel_group_for_su/ansible/shared.yml

Lines changed: 0 additions & 14 deletions
This file was deleted.

linux_os/guide/system/accounts/accounts-restrictions/root_logins/use_pam_wheel_group_for_su/bash/shared.sh

Lines changed: 0 additions & 15 deletions
This file was deleted.

linux_os/guide/system/accounts/accounts-restrictions/root_logins/use_pam_wheel_group_for_su/oval/shared.xml

Lines changed: 0 additions & 31 deletions
This file was deleted.

linux_os/guide/system/accounts/accounts-restrictions/root_logins/use_pam_wheel_group_for_su/rule.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,24 @@ ocil: |-
3737
Run the following command to check if the line is present:
3838
<pre>grep pam_wheel /etc/pam.d/su</pre>
3939
The output should contain the following line:
40-
<pre>auth required pam_wheel.so use_uid group={{{ xccdf_value("var_pam_wheel_group_for_su") }}}</pre>
40+
<pre>auth required pam_wheel.so use_uid group={{{ xccdf_value("var_pam_wheel_group_for_su.var") }}}</pre>
4141
4242
warnings:
4343
- general: |-
4444
Note that <tt>ensure_pam_wheel_group_empty</tt> rule complements this requirement by
4545
ensuring the referenced group exists and has no members.
46+
47+
template:
48+
name: pam_options
49+
vars:
50+
path: /etc/pam.d/su
51+
type: auth
52+
control_flag: required
53+
module: pam_wheel.so
54+
arguments:
55+
- variable: group
56+
variable_name: var_pam_wheel_group_for_su
57+
operation: equals
58+
datatype: string
59+
- argument: use_uid
60+
new_argument: use_uid

shared/templates/pam_options/ansible.template

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@
1010
# updated the Ansible pamd module to do that, we will need to use regexp
1111
# for now.
1212

13-
14-
# declare the XCCDF vars if any
15-
{{% for arg in ARGUMENTS %}}
16-
{{% if arg['variable']|length %}}
17-
- (xccdf-var var_password_pam_{{{ arg['variable'] }}})
13+
{{% if product == 'sle16' %}}
14+
- name: Copy default /usr/lib/pam.d/{{ '{{{ PATH }}}' | basename }} to {{{ PATH }}}
15+
ansible.builtin.copy:
16+
src: /usr/lib/pam.d/{{ '{{{ PATH }}}' | basename }}
17+
dest: {{{ PATH }}}
18+
force: no
19+
mode: '0644'
1820
{{% endif %}}
19-
{{% endfor %}}
2021

2122
- name: Set control_flag fact
2223
ansible.builtin.set_fact:
@@ -33,15 +34,15 @@
3334
path: {{{ PATH }}}
3435
line: '{{{ TYPE }}} {{{ CONTROL_FLAG }}} {{{ MODULE }}}'
3536
state: present
36-
when: check_pam_module_result.stdout is defined and '"{{{ MODULE }}}" not in check_pam_module_result.stdout'
37+
when: check_pam_module_result is not skipped and check_pam_module_result.stdout is defined and "{{{ MODULE }}}" not in check_pam_module_result.stdout
3738

3839
- name: Ensure '{{{ MODULE }}}' module has conforming control flag
3940
ansible.builtin.lineinfile:
4041
path: {{{ PATH }}}
4142
regexp: '^(\s*{{{ TYPE }}}\s+)\S+(\s+{{{ MODULE }}}\s+.*)'
4243
line: '\g<1>{{{ CONTROL_FLAG }}}\g<2>'
4344
backrefs: yes
44-
when: control_flag|length
45+
when: check_pam_module_result is not skipped and control_flag|length
4546

4647
{{% for arg in ARGUMENTS %}}
4748
# NOTE: if 'remove_argument' is present and set to some value, we assume
@@ -56,13 +57,22 @@
5657
{{% elif arg['variable']|length %}}
5758
# NOTE(gyee): if 'var' is used, user is meant to set the argument to a
5859
# static value
60+
{{% if arg['variable_name'] %}}
61+
{{% set pam_variable_name = arg['variable_name'] %}}
62+
{{% else %}}
63+
{{% set pam_variable_name = "var_password_pam_" + arg['variable'] %}}
64+
{{% endif %}}
65+
{{{ ansible_instantiate_variables(pam_variable_name) }}}
66+
67+
{{% set pam_variable_value = "{{ " + pam_variable_name + " }}" %}}
5968

60-
- name: Ensure "{{{ MODULE }}}" module has argument "{{{ arg['variable'] }}}={{ var_password_pam_{{{ arg['variable'] }}} }}"
69+
- name: Ensure "{{{ MODULE }}}" module has argument "{{{ arg['variable'] }}}={{{ pam_variable_value }}}"
6170
ansible.builtin.lineinfile:
6271
path: {{{ PATH }}}
6372
regexp: '^(\s*{{{ TYPE }}}\s+{{{ CONTROL_FLAG }}}\s+{{{ MODULE }}}(?:\s+\S+)*\s+{{{ arg['variable'] }}}=)(?:\S+)((\s+\S+)*\s*\\*\s*)$'
64-
line: '\g<1>{{ var_password_pam_{{{ arg['variable'] }}} }}\g<2>'
73+
line: '\g<1>{{{ pam_variable_value }}}\g<2>'
6574
backrefs: yes
75+
when: check_pam_module_result is not skipped
6676

6777
- name: Check the presence of "{{{ arg['variable'] }}}" argument in "{{{ MODULE }}}" module
6878
ansible.builtin.shell: |
@@ -74,9 +84,9 @@
7484
ansible.builtin.lineinfile:
7585
path: {{{ PATH }}}
7686
regexp: '^(\s*{{{ TYPE }}}\s+{{{ CONTROL_FLAG }}}\s+{{{ MODULE }}})((\s+\S+)*\s*(\\)*$)'
77-
line: '\g<1> {{{ arg['variable'] }}}={{ var_password_pam_{{{ arg['variable'] }}} }}\g<2>'
87+
line: '\g<1> {{{ arg['variable'] }}}={{{ pam_variable_value }}}\g<2>'
7888
backrefs: yes
79-
when: check_pam_module_argument_result is not skipped and '"{{{ arg['variable'] }}}" not in check_pam_module_argument_result.stdout'
89+
when: check_pam_module_argument_result is not skipped and "{{{ arg['variable'] }}}" not in check_pam_module_argument_result.stdout
8090
{{% else %}}
8191
- name: Set argument_value fact
8292
ansible.builtin.set_fact:
@@ -102,6 +112,6 @@
102112
regexp: '^(\s*{{{ TYPE }}}\s+{{{ CONTROL_FLAG }}}\s+{{{ MODULE }}})((\s+\S+)*\s*(\\)*$)'
103113
line: '\g<1> {{{ arg['new_argument'] }}}\g<2>'
104114
backrefs: yes
105-
when: check_pam_module_argument_result is not skipped and '"{{{ arg['argument'] }}}" not in check_pam_module_argument_result.stdout'
115+
when: check_pam_module_argument_result is not skipped and "{{{ arg['argument'] }}}" not in check_pam_module_argument_result.stdout
106116
{{% endif %}}
107117
{{% endfor %}}

shared/templates/pam_options/bash.template

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,22 @@ declare -a ARGS=()
1010
declare -a NEW_ARGS=()
1111
declare -a DEL_ARGS=()
1212

13+
{{% if product == 'sle16' %}}
14+
PAM_DEFAULTS_FILE_NAME="/usr/lib/pam.d/$(basename "{{{ PATH }}}")"
15+
if ! [ -e "{{{ PATH }}}" ] ; then
16+
cp "${PAM_DEFAULTS_FILE_NAME}" "{{{ PATH }}}"
17+
fi
18+
{{% endif %}}
19+
1320
{{% for arg in ARGUMENTS -%}}
1421
{{% if arg['variable'] | length -%}}
15-
{{{ bash_instantiate_variables("var_password_pam_" + arg['variable']) }}}
16-
VALUES+=("${{{ "var_password_pam_" + arg['variable'] }}}")
22+
{{% if arg['variable_name'] %}}
23+
{{% set pam_variable_name = arg['variable_name'] %}}
24+
{{% else %}}
25+
{{% set pam_variable_name = "var_password_pam_" + arg['variable'] %}}
26+
{{% endif %}}
27+
{{{ bash_instantiate_variables(pam_variable_name) }}}
28+
VALUES+=("${{{ pam_variable_name }}}")
1729
VALUE_NAMES+=("{{{ arg['variable'] }}}")
1830
{{%- else %}}
1931
VALUES+=("")

0 commit comments

Comments
 (0)