If available use udisks2-inhibit to prevent automounting (#745349)

In order to prevent potential corruption of newly created file systems,
when available use udisks2-inhibit with gpartedbin execution to prevent
automounting.

Original report:

Xubuntu install fail due partition auto mount defeats Gparted
https://bugs.launchpad.net/ubuntu/+source/thunar/+bug/1078445

Some GNU/Linux distributions use the udisks2 "udisksd" daemon and have
udisks2-inhibit at a known location.  The known location is not in the
default PATH environment variable.

One known distribution that matches this criteria is xubuntu 14.04.

Interestingly neither kubuntu 14.04 nor ubuntu 14.04 appear to have the
udisks2 "udisksd" daemon running and do not suffer from this specific
automounting problem.

Bug 745349 - gparted wrapper script needs updated for udisks2
This commit is contained in:
Curtis Gedak 2015-03-10 10:56:47 -06:00 committed by Mike Fleetwood
parent e82fde776c
commit 4acb8e4fbb

View file

@ -9,7 +9,7 @@
# GParted's operations, or if multiple partition editing
# tools are in use concurrently.
#
# Copyright (C) 2008, 2009, 2010, 2013 Curtis Gedak
# Copyright (C) 2008, 2009, 2010, 2013, 2015 Curtis Gedak
#
# This file is part of GParted.
#
@ -50,6 +50,17 @@ for k in '' `echo "$PATH" | sed 's,:, ,g'`; do
fi
done
#
# Check if udisks2-inhibit exists in known location
# and if appropriate daemon is running.
#
HAVE_UDISKS2_INHIBIT=no
if test -x "/usr/lib/udisks2/udisks2-inhibit"; then
if test "z`ps -e | grep 'udisksd'`" != "z"; then
HAVE_UDISKS2_INHIBIT=yes
fi
fi
#
# Search PATH to determine if udisks program can be found
# and if appropriate daemon is running.
@ -150,7 +161,8 @@ for rule in $UDEV_TEMP_MDADM_RULES; do
done
#
# Use both udisks and hal-lock for invocation if both binaries exist and both
# Use udisks2-inhibit if udisks2-inhibit exists and deamon running.
# Else use both udisks and hal-lock for invocation if both binaries exist and both
# daemons are running.
# Else use udisks if binary exists and daemon is running.
# Else use both devkit-disks and hal-lock for invocation if both binaries exist
@ -159,7 +171,9 @@ done
# Otherwise use hal-lock for invocation if binary exists and daemon is running.
# If the above checks fail then simply run gpartedbin.
#
if test "x$HAVE_UDISKS" = "xyes" && test "x$HAVE_HAL_LOCK" = "xyes"; then
if test "x$HAVE_UDISKS2_INHIBIT" = "xyes"; then
/usr/lib/udisks2/udisks2-inhibit $BASE_CMD
elif test "x$HAVE_UDISKS" = "xyes" && test "x$HAVE_HAL_LOCK" = "xyes"; then
udisks --inhibit -- \
hal-lock --interface org.freedesktop.Hal.Device.Storage --exclusive \
--run "$BASE_CMD"