瀏覽代碼

Validate user sudo rules before applying them

tags/v0.45.0
Ash Berlin 10 年之前
父節點
當前提交
192edba9c5
共有 1 個檔案被更改,包括 11 行新增0 行删除
  1. +11
    -0
      users/init.sls

+ 11
- 0
users/init.sls 查看文件

@@ -129,6 +129,17 @@ sudoer-{{ name }}:
- group: root
- mode: '0440'
{% if 'sudo_rules' in user %}
{% for rule in user['sudo_rules'] %}
"validate {{ name }} sudo rule {{ loop.index0 }} {{ name }} {{ rule }}":
cmd.run:
- name: 'visudo -cf - <<<"$rule"'
- env:
# Specify the rule via an env var to avoid shell quoting issues.
- rule: "{{ name }} {{ rule }}"
- require_in:
- file: /etc/sudoers.d/{{ name }}
{% endfor %}

/etc/sudoers.d/{{ name }}:
file.append:
- text:

Loading…
取消
儲存