From 50b48aec6ddd451a6d1709c0942477b503457663 Mon Sep 17 00:00:00 2001 From: tpearson Date: Wed, 3 Feb 2010 02:15:56 +0000 Subject: Added abandoned KDE3 version of K3B git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/k3b@1084400 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- libk3b/scripts/Makefile.am | 11 ++++++++ libk3b/scripts/k3b_automount | 66 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 libk3b/scripts/Makefile.am create mode 100755 libk3b/scripts/k3b_automount (limited to 'libk3b/scripts') diff --git a/libk3b/scripts/Makefile.am b/libk3b/scripts/Makefile.am new file mode 100644 index 0000000..6318b9b --- /dev/null +++ b/libk3b/scripts/Makefile.am @@ -0,0 +1,11 @@ +bin_SCRIPTS = k3b_automount + +# k3b_automount needs to be installed setuid root +install-exec-hook: + @(chown 0 $(DESTDIR)$(bindir)/k3b_automount && chmod 4755 $(DESTDIR)$(bindir)/k3b_automount) || echo "Please make k3b_automount setuid root" >&2 + @echo "" + @echo "k3b_automount is by default installed with a set SETUID root bit!" + @echo "This is needed for K3b to be able to temporarily disable automounting via" + @echo "subfs or supermount while burning." + @echo "" + diff --git a/libk3b/scripts/k3b_automount b/libk3b/scripts/k3b_automount new file mode 100755 index 0000000..e86e960 --- /dev/null +++ b/libk3b/scripts/k3b_automount @@ -0,0 +1,66 @@ +#!/bin/bash + +# +# This script is able to disable and enable automounting for a device. +# It's usage is as follows: +# +# k3b_automount disable /dev/cdrom +# or +# k3b_automount enable /dev/cdrom +# +# /dev/cdrom needs to have an entry in /etc/fstab. +# +# The supported automounting systems are subfs and supermount. +# +# Exit codes: +# 0 - success +# 1 - wrong usage +# 2 - device not configured with subfs/supermount in /etc/fstab +# X - failed to mount/umount +# + +DISABLE=1 + +if [ $1 = "disable" ]; then + DISABLE=1 +elif [ $1 = "enable" ]; then + DISABLE=0 +else + echo "Usage: $0 disable|enable " + exit 1 +fi + +DEVICE=$2 + +if [ -z $DEVICE ]; then + echo "Usage: $0 disable|enable " + exit 1 +fi + +# we have a mode and a device + +# open the fstab file and search the DEVICE +if [ -n "`grep $DEVICE /etc/fstab | grep "subfs\|supermount"`" ]; then + if [ $DISABLE = 1 ]; then + umount $DEVICE + else + mount $DEVICE + fi + exit $? +fi + +# +# Ok, not using subfs or supermount +# If some other userspace automounter (like ivman) is running it is sufficient +# to unmount the device now to get the burning started. This however does not +# fix the problem with DVD+RW burning which may be mounted once the burning has +# been started. +# +# So we unmount the device in case it is mounted with iso9660 or udf (just to add +# some security to this suid script. :( +# +if [ $DISABLE = 1 ] && [ -n "`grep $DEVICE /etc/mtab | grep "iso9660\|udf"`" ]; then + umount $DEVICE + exit $? +fi +exit 2 -- cgit v1.2.3