Use systemctl runtime mask to prevent automounting (#701676)

With the beta release of Fedora 19, invoking gparted appears to
automatically mount partitions.  The systemd daemon appears to be
performing the automounting.  Hence use systemctl runtime mask to
prevent this automounting from occurring.

Bug #701676 - gparted doesn't inhibit systemd mounting, leading to
              potential data loss
This commit is contained in:
Curtis Gedak 2013-06-09 09:46:18 -06:00 committed by Mike Fleetwood
parent 20006e1f8e
commit 4c109df9b5
1 changed files with 30 additions and 1 deletions

View File

@ -7,7 +7,7 @@
# File system problems can occur if devices are mounted
# prior to the completion of GParted's operations.
#
# Copyright (C) 2008, 2009, 2010 Curtis Gedak
# Copyright (C) 2008, 2009, 2010, 2013 Curtis Gedak
#
# This file is part of GParted.
#
@ -25,6 +25,20 @@
# along with GParted. If not, see <http://www.gnu.org/licenses/>.
#
#
# Search PATH to determine if systemctl program can be found
# and if appropriate daemon is running.
#
HAVE_SYSTEMCTL=no
for k in '' `echo "$PATH" | sed 's,:, ,g'`; do
if test -x "$k/systemctl"; then
if test "z`ps -e | grep systemd`" != "z"; then
HAVE_SYSTEMCTL=yes
break
fi
fi
done
#
# Search PATH to determine if udisks program can be found
# and if appropriate daemon is running.
@ -86,6 +100,14 @@ if test "x`id -u`" != "x0"; then
exit 1
fi
#
# Use systemctl to prevent automount by masking currently unmasked mount points
#
if test "x$HAVE_SYSTEMCTL" = "xyes"; then
MOUNTLIST=`systemctl list-unit-files --full --all -t mount --no-legend | grep -v masked | cut -f1 -d' '`
systemctl --runtime mask --quiet -- $MOUNTLIST
fi
#
# Use both udisks and hal-lock for invocation if both binaries exist and both
# daemons are running.
@ -114,3 +136,10 @@ elif test "x$HAVE_HAL_LOCK" = "xyes"; then
else
$BASE_CMD
fi
#
# Use systemctl to restore that status of any mount points changed above
#
if test "x$HAVE_SYSTEMCTL" = "xyes"; then
systemctl --runtime unmask --quiet -- $MOUNTLIST
fi