Skip to content

Commit

Permalink
feat: customize user paths default. Resolves: #689
Browse files Browse the repository at this point in the history
Signed-off-by: Thibault Soubiran <thibault.soubiran@protonmail.com>
  • Loading branch information
S0obi committed Aug 7, 2023
1 parent e3273a8 commit a87ac46
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
5 changes: 5 additions & 0 deletions roles/os_hardening/README.md
Expand Up @@ -290,6 +290,11 @@ To prevent some of the filesystems from being disabled, add them to the `os_file
- Description: true if this is a desktop system, ie Xorg, KDE/GNOME/Unity/etc.
- Type: bool
- Required: no
- `os_env_user_paths`
- Default: `[/usr/local/sbin, /usr/local/bin, /usr/sbin, /usr/bin, /sbin, /bin]`
- Description: Specify paths to the user's `PATH` variable.
- Type: list
- Required: no
- `os_env_extra_user_paths`
- Default: `"[]"`
- Description: add additional paths to the user's `PATH` variable (default is empty).
Expand Down
1 change: 1 addition & 0 deletions roles/os_hardening/defaults/main.yml
@@ -1,5 +1,6 @@
---
os_desktop_enable: false
os_env_user_paths: [/usr/local/sbin, /usr/local/bin, /usr/sbin, /usr/bin, /sbin, /bin]
os_env_extra_user_paths: []
os_auth_pw_max_age: 60
os_auth_pw_min_age: 7 # Discourage password cycling
Expand Down
7 changes: 1 addition & 6 deletions roles/os_hardening/tasks/minimize_access.yml
Expand Up @@ -7,12 +7,7 @@
- name: Find files with write-permissions for group # noqa command-instead-of-shell
ansible.builtin.shell: find -L {{ item }} -perm /go+w -type f
with_community.general.flattened:
- /usr/local/sbin
- /usr/local/bin
- /usr/sbin
- /usr/bin
- /sbin
- /bin
- "{{ os_env_user_paths }}"
- "{{ os_env_extra_user_paths }}"
register: minimize_access_directories
ignore_errors: true
Expand Down
2 changes: 1 addition & 1 deletion roles/os_hardening/templates/etc/login.defs.j2
Expand Up @@ -64,7 +64,7 @@ SU_NAME su
HUSHLOGIN_FILE .hushlogin

# *REQUIRED*: The default PATH settings, for superuser and normal users. (they are minimal, add the rest in the shell startup files)
ENV_SUPATH PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
ENV_SUPATH PATH={{ os_env_user_paths | join (':') }}
ENV_PATH PATH=/usr/local/bin:/usr/bin:/bin:{{ os_env_extra_user_paths | join (':') }}

# Terminal permissions
Expand Down

0 comments on commit a87ac46

Please sign in to comment.