Patchwork [3/3] sudoers.oeclass: New class able to handle sudoers extensions (/etc/sudoers.d)

login
register
mail settings
Submitter Kim B√łndergaard
Date Oct. 4, 2013, 5:52 a.m.
Message ID <5622d8db1f1c556b84d38e3a2820181597c8dfd4.1380865838.git.kibo@prevas.dk>
Download mbox | patch
Permalink /patch/280469/
State Accepted
Delegated to: Esben Haabendal
Headers show

Comments

Kim B√łndergaard - Oct. 4, 2013, 5:52 a.m.
---
 classes/sudoers.oeclass | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 classes/sudoers.oeclass
Esben Haabendal - Oct. 14, 2013, 2:27 p.m.
Merged to master, thanks.

I adjusted the class documentation to the new syntax that the doc parser
is now implementing.

/Esben

Patch

diff --git a/classes/sudoers.oeclass b/classes/sudoers.oeclass
new file mode 100644
index 0000000..ea453e2
--- /dev/null
+++ b/classes/sudoers.oeclass
@@ -0,0 +1,29 @@ 
+## @class sudoers
+# OE-lite class for handling entries to the sudoers.d directory
+#
+# Inherit this class to ensure all sudoers.d entries becomes unique.
+# Let SUDOERS_FILES list all SRC files going to sudoers.d
+#
+# Notice: Files in sudoers.d are read in lexical order. If the order is important 
+#         accross recipes this class is too simple
+#
+# @var SUDOERS_FILES Lists all files going to sudoers.d
+
+# -*- mode:python; -*-
+
+SUDOERS_FILES ?= ""
+
+do_install[postfuncs] += "do_install_sudoers"
+do_install_sudoers () {
+	if [ -z "${SUDOERS_FILES}" ]; then
+		return
+	fi
+
+	sudoers_dir=${D}${sysconfdir}/sudoers.d
+	install -m 0755 -d $sudoers_dir
+	i=1
+	for f in ${SUDOERS_FILES} ; do
+		install -m 0644 $f $sudoers_dir/${PN}_$i
+		i=$((i+1))
+	done
+}