aboutsummaryrefslogtreecommitdiff
path: root/system/usbguard/config
diff options
context:
space:
mode:
authorMichael Edie <michael@sawbox.net>2019-06-22 20:53:13 +0700
committerWilly Sudiarto Raharjo <willysr@slackbuilds.org>2019-06-22 20:53:13 +0700
commit96cadfe7d17ab90f83cf3d8b24dd6602a120254d (patch)
treeac1bc5dcc16008b010c1a103dc0cfdead31685e2 /system/usbguard/config
parentef3c179517626bc74865500083746d43666ad791 (diff)
system/usbguard: Added (protection against rogue USB devices).
Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
Diffstat (limited to 'system/usbguard/config')
-rw-r--r--system/usbguard/config/rc.usbguard63
-rw-r--r--system/usbguard/config/usbguard.logrotate10
2 files changed, 73 insertions, 0 deletions
diff --git a/system/usbguard/config/rc.usbguard b/system/usbguard/config/rc.usbguard
new file mode 100644
index 0000000000000..71f7975d24a69
--- /dev/null
+++ b/system/usbguard/config/rc.usbguard
@@ -0,0 +1,63 @@
+#!/bin/sh
+#
+# Start/Stop/Restart the USBGuard daemon.
+#
+
+PIDFILE=/var/run/usbguard.pid
+USBGUARD_OPTS="-f -s"
+
+# Start
+usbguard_start() {
+ if [ -x /usr/sbin/usbguard-daemon ]; then
+ if [ -e "$PIDFILE" ]; then
+ echo "USBGuard daemon already started!"
+ else
+ echo "Starting USBGuard daemon..."
+ /usr/sbin/usbguard-daemon $USBGUARD_OPTS
+ fi
+ fi
+}
+
+# Stop
+usbguard_stop() {
+ echo "Stopping USBGuard daemon..."
+ if [ -e "$PIDFILE" ]; then
+ kill $(cat $PIDFILE)
+ rm -f $PIDFILE 2>&1 >/dev/null
+ fi
+ # Just in case:
+ killall usbguard-daemon 2>&1 >/dev/null
+}
+
+# Restart
+usbguard_restart() {
+ usbguard_stop
+ sleep 3
+ usbguard_start
+}
+
+# Status
+usbguard_status() {
+ if [ -e "$PIDFILE" ]; then
+ echo "usbguard-daemon is running."
+ else
+ echo "usbguard-daemon is stopped."
+ fi
+}
+
+case "$1" in
+'start')
+ usbguard_start
+ ;;
+'stop')
+ usbguard_stop
+ ;;
+'restart')
+ usbguard_restart
+ ;;
+'status')
+ usbguard_status
+ ;;
+*)
+ echo "usage: $0 start|stop|restart|status"
+esac
diff --git a/system/usbguard/config/usbguard.logrotate b/system/usbguard/config/usbguard.logrotate
new file mode 100644
index 0000000000000..1ed4e106fe9ce
--- /dev/null
+++ b/system/usbguard/config/usbguard.logrotate
@@ -0,0 +1,10 @@
+/var/log/usbguard/usbguard-audit.log {
+ daily
+ rotate 7
+ copytruncate
+ delaycompress
+ compress
+ notifempty
+ missingok
+}
+