Skip to content
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
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,14 @@ You can use a defined `host_alias` name as well as host names.
You can use a defined `runas_alias` name as well as user names.

4. `selinux_role` - Optional selinux role to apply to the specification.
**NOTE** - only a single value is supported. However, due to historical
reasons, the value can be a list - if a list is given, only the first value
is used. Please use a `string` value.

5. `selinux_type` - Optional selinux type to apply to the specification.
**NOTE** - only a single value is supported. However, due to historical
reasons, the value can be a list - if a list is given, only the first value
is used. Please use a `string` value.

6. `solaris_privs` - Optional Solaris privset to apply to the specification.

Expand Down Expand Up @@ -192,6 +198,8 @@ sudo_sudoers_files:
- ALL
commands:
- ALL
selinux_role: sysadm_r
selinux_type: sysadm_t
```

#### default_overrides
Expand Down
16 changes: 8 additions & 8 deletions templates/sudoers.j2
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,17 @@ Defaults {{ default }}
{%- if spec.operators is defined and spec.operators | length > 0 -%}
({{ spec.operators | join(", ") }})
{%- endif -%}
{%- if spec.selinux_type is defined and spec.selinux_type | length > 0 -%}
TYPE={{ spec.selinux_type | join(", ") }}
{%- if spec.selinux_type is defined and spec.selinux_type | length > 0 %}
TYPE={{ spec.selinux_type if spec.selinux_type is string else spec.selinux_type[0] }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit weird that we entirely ignore all but the first list entries -- I suppose this should have been a single value all along? But that's water under the bridge now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit weird that we entirely ignore all but the first list entries -- I suppose this should have been a single value all along?

That's what I understand according to https://www.sudo.ws/docs/man/1.8.15/sudoers.man/#Quick_guide_to_EBNF - it should have been a single value all along - perhaps @radosroka can confirm.

{%- endif -%}
{%- if spec.selinux_role is defined and spec.selinux_role | length > 0 -%}
ROLE={{ spec.selinux_role | join(", ") }}
{%- if spec.selinux_role is defined and spec.selinux_role | length > 0 %}
ROLE={{ spec.selinux_role if spec.selinux_role is string else spec.selinux_role[0] }}
{%- endif -%}
{%- if spec.solaris_privs is defined and spec.solaris_privs | length > 0 -%}
PRIVS={{ spec.solaris_privs | join(", ") }}
{%- if spec.solaris_privs is defined and spec.solaris_privs | length > 0 %}
PRIVS={{ spec.solaris_privs | join(",") }}
{%- endif -%}
{%- if spec.solaris_limitprivs is defined and spec.solaris_limitprivs | length > 0 -%}
LIMITPRIVS={{ spec.solaris_limitprivs | join(", ") }}
{%- if spec.solaris_limitprivs is defined and spec.solaris_limitprivs | length > 0 %}
LIMITPRIVS={{ spec.solaris_limitprivs | join(",") }}
{%- endif -%}
{%- if spec.tags is defined and spec.tags | length > 0 -%}
{{ spec.tags | join(":") }}:
Expand Down
2 changes: 1 addition & 1 deletion tests/files/tests_large_configuration_sudoers.ok
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ User_Alias PINGERS = username

# User specifications
root ALL=(ALL) ALL
%wheel ALL=(ALL) ALL
%wheel ALL=(ALL) TYPE=sysadm_t ROLE=sysadm_r /bin/pwd, /usr/bin/cd

# Default override specifications
Defaults: PINGERS !requiretty
Expand Down
5 changes: 4 additions & 1 deletion tests/tests_large_configuration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,11 @@
- ALL
operators:
- ALL
selinux_type: sysadm_t
selinux_role: sysadm_r
commands:
- ALL
- /bin/pwd
- /usr/bin/cd
default_overrides:
- type: user
defaults:
Expand Down