1
0
Fork 0
mirror of synced 2024-11-16 22:25:34 -05:00

Extend defaults section of sudoers to permit the following:

Default_Type ::= 'Defaults' |
                 'Defaults' '@' Host_List |
                 'Defaults' ':' User_List |
                 'Defaults' '!' Cmnd_List |
                 'Defaults' '>' Runas_List
This commit is contained in:
Robert Fairburn 2014-07-09 12:21:58 -05:00
parent 66ff6d8fee
commit ac278d226c
2 changed files with 34 additions and 5 deletions

View file

@ -4,9 +4,19 @@ sudoers:
groups:
sudo: 'ALL=(ALL) NOPASSWD: ALL'
defaults:
- env_reset
- mail_badpass
- secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
generic:
- env_rset
- mail_badpass
- secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
user_list:
johndoe: '!requiretty'
ADMINS: '!lecture'
host_list:
www1: 'log_year, logfile=/var/log/sudo.log'
command_list:
PROCESSES: 'noexec'
runas_list:
root: '!set_logname'
aliases:
hosts:
WEBSERVERS:

View file

@ -9,7 +9,12 @@
{%- set users = sudoers.get('users', {'root': 'ALL=(ALL:ALL) ALL'}) %}
{%- set groups = sudoers.get('groups', {'sudo': 'ALL=(ALL:ALL) ALL'}) %}
{%- else %}
{%- set defaults = sudoers.get('defaults', []) %}
{%- set defaults = sudoers.get('defaults', {}) %}
{%- set generic_defaults = defaults.get('generic', []) %}
{%- set user_list_defaults = defaults.get('user_list', {}) %}
{%- set host_list_defaults = defaults.get('host_list', {}) %}
{%- set command_list_defaults = defaults.get('command_list', {}) %}
{%- set runas_list_defaults = defaults.get('runas_list', {}) %}
{%- set users = sudoers.get('users', {}) %}
{%- set groups = sudoers.get('groups', {}) %}
{%- endif %}
@ -29,9 +34,23 @@
# This file is managed by salt
#
{% for default in defaults -%}
# Defaults specification
{% for default in generic_defaults -%}
Defaults {{ default }}
{% endfor %}
{%- for user,spec in user_list_defaults.items() %}
Defaults:{{ user }} {{ spec }}
{%- endfor %}
{%- for host,spec in host_list_defaults.items() %}
Defaults@{{ host }} {{ spec }}
{%- endfor %}
{%- for command,spec in command_list_defaults.items() %}
Defaults!{{ user }} {{ spec }}
{%- endfor %}
{%- for user,spec in runas_list_defaults.items() %}
Defaults>{{ user }} {{ spec }}
{%- endfor %}
# Host alias specification
{%- for name,hosts in host_aliases.items() %}
Host_Alias {{ name }} = {{ ",".join(hosts) }}