From caa7656829bf53c645325a1a3a739d7e428bd0dc Mon Sep 17 00:00:00 2001 From: Curtis Gedak Date: Sun, 27 Feb 2011 11:41:40 -0700 Subject: [PATCH] Ensure graphical error message displayed when run by non-root user Ubuntu launchpad bug 696937 - Running gparted as non-root user displays no graphical error message https://bugs.launchpad.net/ubuntu/+source/gparted/+bug/696937 --- gparted.in | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/gparted.in b/gparted.in index 88632169..ac4c5c5a 100644 --- a/gparted.in +++ b/gparted.in @@ -51,6 +51,24 @@ for k in '' `echo "$PATH" | sed 's,:, ,g'`; do fi done +# +# Define base command for executing GParted +# +BASE_CMD="@installdir@/gpartedbin $*" + +# +# If no root privileges, then invoke gpartedbin directly +# so that a graphical warning is displayed. +# Otherwise udisks, devkit-disks, or hal-lock in the later +# invocation may prevent gpartedbin from starting and hence +# the user will not see a graphical warning. +# +if test "x`id -u`" != "x0"; then + echo "Root privileges are required for running gparted." + $BASE_CMD + exit 1 +fi + # # Use both udisks and hal-lock for invocation if both binaries exist and both # daemons are running. @@ -61,7 +79,6 @@ done # Otherwise use hal-lock for invocation if binary exists and daemon is running. # If the above checks fail then simply run gpartedbin. # -BASE_CMD="@installdir@/gpartedbin $*" if test "x$HAVE_UDISKS" = "xyes" && test "x$HAVE_HAL_LOCK" = "xyes"; then udisks --inhibit -- \ hal-lock --interface org.freedesktop.Hal.Device.Storage --exclusive \