aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorB Stack <bgstack15@gmail.com>2020-03-11 08:34:06 -0400
committerB Stack <bgstack15@gmail.com>2020-03-11 08:34:06 -0400
commitb278cce1e12a7ce9dcd49bfbab7cf2fa7e3b1d35 (patch)
tree8f9359b6f42d8541a4a4f2887319e5caae80b0dc /src
parentadd DRYRUN and bash_completion to lm-helper (diff)
downloadlogout-manager-b278cce1e12a7ce9dcd49bfbab7cf2fa7e3b1d35.tar.gz
logout-manager-b278cce1e12a7ce9dcd49bfbab7cf2fa7e3b1d35.tar.bz2
logout-manager-b278cce1e12a7ce9dcd49bfbab7cf2fa7e3b1d35.zip
add usage of sudo
Diffstat (limited to 'src')
-rw-r--r--src/Makefile7
-rw-r--r--src/etc/logout-manager.conf6
-rw-r--r--src/etc/sudoers.d/30_logout-manager_sudo3
-rwxr-xr-xsrc/usr/libexec/logout-manager/lm-helper3
-rw-r--r--src/usr/share/doc/logout-manager/README.md7
5 files changed, 13 insertions, 13 deletions
diff --git a/src/Makefile b/src/Makefile
index 9fdad77..fa385cb 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -14,6 +14,7 @@
# bgscripts Makefile
# Improve:
# Document:
+# Includes a nice way to dynamically generate dependencies as self-reported by all the files.
# Dependencies:
APPNAME = logout-manager
@@ -30,6 +31,7 @@ DOCDIR = $(SHAREDIR)/doc/$(APPNAME)
APPDIR = $(SHAREDIR)/$(APPNAME)
APPSDIR = $(SHAREDIR)/applications
BASHCDIR = $(SYSCONFDIR)/bash_completion.d
+SUDOERSDIR = $(SYSCONFDIR)/sudoers.d
awkbin :=$(shell which awk)
cpbin :=$(shell which cp)
@@ -55,7 +57,7 @@ list:
deplist:
@if test -z "$(DISTRO)" ; then ${echobin} "Please run \`make deplist\` with DISTRO= one of: `make deplist_opts 2>&1 1>/dev/null | ${xargsbin}`. Aborted." ; exit 1 ; fi
- @${grepbin} -h --exclude='Makefile' --exclude-dir='doc' -A5 -riIE dependencies $(SRCDIR) | ${awkbin} -v 'distro=$(DISTRO)' 'tolower($$0) ~ distro {$$1="";$$2="";print}' | ${sortbin} | ${uniqbin} | ${xargsbin}
+ @${grepbin} -h --exclude='Makefile' --exclude-dir='doc' -A5 -riIE dependencies $(SRCDIR) | ${awkbin} -v 'distro=$(DISTRO)' 'tolower($$0) ~ distro {$$1="";$$2="";print}' | awk 'BEGIN{cmd="${xargsbin} -n1"} $$0 !~ /\(/{print $$0 | cmd ; close(cmd);} $$0 ~ /\(/{print;}' | ${sortbin} | ${uniqbin} | ${xargsbin}
deplist_opts:
@${echobin} "el7" 1>&2
@@ -63,7 +65,7 @@ deplist_opts:
install:
@${echobin} Installing files to ${DESTDIR}
- ${installbin} -d ${SYSCONFDIR} ${DEFAULTDIR} ${BINDIR} ${APPSDIR} ${APPDIR} ${DOCDIR} ${BASHCDIR}
+ ${installbin} -d ${SYSCONFDIR} ${DEFAULTDIR} ${BINDIR} ${APPSDIR} ${APPDIR} ${DOCDIR} ${BASHCDIR} ${SUDOERSDIR}
${cpbin} -pr ${SRCDIR}/etc/*.* ${SYSCONFDIR}
${cpbin} -pr ${SRCDIR}/etc/bash_completion.d/* ${BASHCDIR}
${cpbin} -pr ${SRCDIR}/etc/sysconfig/* ${DEFAULTDIR}
@@ -71,6 +73,7 @@ install:
${cpbin} -pr ${SRCDIR}/usr/share/applications/* ${APPSDIR}
${cpbin} -pr ${SRCDIR}/usr/share/${APPNAME}/*.* ${APPDIR}
${cpbin} -pr ${SRCDIR}/usr/share/doc/${APPNAME}/* ${DOCDIR}
+ ${installbin} -m 0640 -t ${SUDOERSDIR} ${SRCDIR}/etc/sudoers.d/*
# symlink, when alternatives is not being used
${lnbin} -s logout-manager-gtk.py ${BINDIR}/logout-manager
diff --git a/src/etc/logout-manager.conf b/src/etc/logout-manager.conf
index c37dfdf..51b86d1 100644
--- a/src/etc/logout-manager.conf
+++ b/src/etc/logout-manager.conf
@@ -1,9 +1,9 @@
[logout-manager]
-hibernate_command="/usr/libexec/logout-manager/lm-helper hibernate"
lock_command="/usr/libexec/logout-manager/lm-helper lock"
logout_command="/usr/libexec/logout-manager/lm-helper logout"
-reboot_command="/usr/libexec/logout-manager/lm-helper reboot"
-shutdown_command="/usr/libexec/logout-manager/lm-helper shutdown"
+hibernate_command="sudo /usr/libexec/logout-manager/lm-helper hibernate"
+reboot_command="sudo /usr/libexec/logout-manager/lm-helper reboot"
+shutdown_command="sudo /usr/libexec/logout-manager/lm-helper shutdown"
[icons]
size = 24
diff --git a/src/etc/sudoers.d/30_logout-manager_sudo b/src/etc/sudoers.d/30_logout-manager_sudo
new file mode 100644
index 0000000..ba621eb
--- /dev/null
+++ b/src/etc/sudoers.d/30_logout-manager_sudo
@@ -0,0 +1,3 @@
+# File: /etc/sudoers.d/30_logout-manager_sudo
+Defaults env_keep += "DRYRUN VERBOSE"
+ALL ALL = (root) NOPASSWD: /usr/libexec/logout-manager/lm-helper *
diff --git a/src/usr/libexec/logout-manager/lm-helper b/src/usr/libexec/logout-manager/lm-helper
index e791f28..6372827 100755
--- a/src/usr/libexec/logout-manager/lm-helper
+++ b/src/usr/libexec/logout-manager/lm-helper
@@ -1,6 +1,7 @@
#!/bin/sh
# Dependencies:
-# Devuan: wmctrl
+# Devuan: wmctrl sudo
+# el7: wmctrl sudo
case "${1}" in
help) # show this help screen
{
diff --git a/src/usr/share/doc/logout-manager/README.md b/src/usr/share/doc/logout-manager/README.md
index 7b8ed3d..cfc3843 100644
--- a/src/usr/share/doc/logout-manager/README.md
+++ b/src/usr/share/doc/logout-manager/README.md
@@ -36,12 +36,5 @@ This project is partially a programming playground for the [original author](htt
This whole thing is more complex than just logging out of my user session, and selecting a logout-type action from the display manager.
## Improve
-* add makefile
- * add the standard 'list' option
- * add a `list_dependencies` option or similar, which does the grep command
-
- grep -h -A5 -riIE dependencies * | awk 'tolower($0) ~ /devuan/ {$1="";$2="";print}' | sort | uniq | xargs
-
-* add libexec/ helper scripts for actually running commands
* add debian/ dir
* and dsc file
bgstack15