# The mode of the sudo drop-in, set before there is anything in it.
#
# The name of a `path` resource is the path it manages, so this file --
# `resources.d/path/etc/sudoers.d/60-detc` -- is about `/etc/sudoers.d/60-detc`
# and mirrors `templates.d/etc/sudoers.d/60-detc` exactly.  One spelling for
# one file.
#
# `_order: 10` is the whole point of shipping this.  Templates are rendered at
# 50, and `sudo` refuses to read a drop-in that anybody but its owner may
# write.  At the default order of 60 this would put the file at 0440 *after*
# the template had already created it at 0644, and the window in between is a
# window in which any local account could have written itself a rule.  At 10
# the file is made empty with the right mode first, and the template write
# preserves the mode of a file that already exists, so it is never once wrong.
#
# `ensure: file` only while there is a group to write, because the file has to
# exist for the mode to be on it.  With both lists empty the template writes no
# file at all, so this declares it absent: on a node that never set a group
# that is what is already there, and nothing is written, and on one that took
# its last group away the drop-in goes with it.  Declaring the file with no
# group in it, as this used to, created an empty drop-in on every node that
# had configured nothing.
_order: 10
{% if sudo.groups or sudo.nopasswd_groups %}ensure: file
mode: "0440"
owner: root
group: root
{% else %}ensure: absent
{% endif -%}
