Skip to content

Commit 696b975

Browse files
authored
Merge pull request #42 from stackhpc/sudoers
Add sudoers element
2 parents d1d7dcd + bed0a1b commit 696b975

File tree

5 files changed

+33
-0
lines changed

5 files changed

+33
-0
lines changed

elements/sudoers/README.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
=======
2+
sudoers
3+
=======
4+
5+
This element allows for injecting sudoers configuration into an image.
6+
7+
Environment Variables
8+
---------------------
9+
10+
DIB_SUDOERS_FILENAME
11+
:Required: No
12+
:Default: dib
13+
:Description: Name of the sudoers file in /etc/sudoers.d/
14+
15+
DIB_SUDOERS_CONFIG
16+
:Required: Yes
17+
:Default: None
18+
:Description: Sudoers configuration to inject

elements/sudoers/element-deps

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-installs
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export DIB_SUDOERS_FILENAME=${DIB_SUDOERS_FILENAME:-dib}
2+
export DIB_SUDOERS_CONFIG=${DIB_SUDOERS_CONFIG:?Please set DIB_SUDOERS_CONFIG}

elements/sudoers/install.d/50-sudoers

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then
4+
set -x
5+
fi
6+
set -eu
7+
set -o pipefail
8+
9+
echo "${DIB_SUDOERS_CONFIG}" > /etc/sudoers.d/${DIB_SUDOERS_FILENAME}
10+
chmod 0440 /etc/sudoers.d/${DIB_SUDOERS_FILENAME}
11+
visudo -c || (rm /etc/sudoers.d/${DIB_SUDOERS_FILENAME} && false)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sudo:

0 commit comments

Comments
 (0)