Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stabilization] Fix accounts_umask_etc_bashrc #11957

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
- name: Check if umask in {{{ etc_bash_rc }}} is already set
ansible.builtin.lineinfile:
path: {{{ etc_bash_rc }}}
regexp: ^[^#]*\bumask\s+
regexp: ^[^#]*\bumask\s+\d+$
state: absent
check_mode: true
changed_when: false
Expand All @@ -23,8 +23,8 @@
- name: Replace user umask in {{{ etc_bash_rc }}}
ansible.builtin.replace:
path: {{{ etc_bash_rc }}}
regexp: ^([^#]*\b)umask(\s*)
replace: \g<1>umask\g<2>{{ var_accounts_user_umask }}
regexp: ^([^#]*\b)umask\s+\d+$
replace: \g<1>umask {{ var_accounts_user_umask }}
when:
- umask_replace.found > 0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<ind:textfilecontent54_object id="obj_umask_from_etc_bashrc"
comment="Umask value from {{{ etc_bash_rc }}}" version="1">
<ind:filepath>{{{ etc_bash_rc }}}</ind:filepath>
<ind:pattern operation="pattern match">^[^#]*\bumask\s+([^#\s]*)</ind:pattern>
<ind:pattern operation="pattern match">^[^#]*\bumask\s+(\d{3})\s*$</ind:pattern>
<ind:instance datatype="int" operation="greater than or equal">1</ind:instance>
</ind:textfilecontent54_object>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
# packages = bash

# This TS is a regression test for https://github.com/ComplianceAsCode/content/issues/11937

sed -i '/umask/d' /etc/bashrc
echo " [ \`umask\` -eq 0 ] && umask 027022" >> /etc/bashrc
umask 000
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
# packages = bash

sed -i '/umask/d' /etc/bashrc
echo " [ `umask` -eq 0 ] && umask 022" >> /etc/bashrc
echo " [ \`umask\` -eq 0 ] && umask 022" >> /etc/bashrc
umask 000
Loading