[gparted] Use systemctl runtime mask to prevent automounting (#701676)



commit 4c109df9b59e55699bd42023cf4007ee359793e9
Author: Curtis Gedak <gedakc gmail com>
Date:   Sun Jun 9 09:46:18 2013 -0600

    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

 gparted.in |   31 ++++++++++++++++++++++++++++++-
 1 files changed, 30 insertions(+), 1 deletions(-)
---
diff --git a/gparted.in b/gparted.in
index 5e09df4..7cf8433 100644
--- a/gparted.in
+++ b/gparted.in
@@ -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.
 #
@@ -26,6 +26,20 @@
 #
 
 #
+#  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.
 #
@@ -87,6 +101,14 @@ if test "x`id -u`" != "x0"; then
 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.
 #  Else use udisks if binary exists and daemon is 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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]