Move root privilege escalation into gparted wrapper script (#776437)

Move calling of the privilege escalation program which allows a normal
user to run GParted as root from the desktop file into the gparted
wrapper script.  This is in preparation for further changes needed to
grant root access to the X11 display under Wayland.

Don't introduce yet another script so that there aren't two different
names to run GParted by for normal users and root.  Using the same
gparted name but placing two different scripts at /usr/bin/gparted and
/usr/sbin/gparted is not possible because on Arch Linux /usr/sbin is a
symbolic link to /usr/bin.

    Frequently asked questions, Does Arch follow the FHS?
    https://wiki.archlinux.org/index.php/Frequently_asked_questions#Does_Arch_follow_the_FHS.3F

    "Arch Linux follows the file system hierarchy for operating systems
    using the systemd service manager.  See file-hierarchy(7) for an
    explanation of each directory along with their designations.  In
    particular, /bin, /sbin, and /usr/sbin are symbolic links to
    /usr/bin, and /lib (and /lib64 if applicable) are symbolic links to
    /usr/lib".

Bug 776437 - GParted fails to run as root under Wayland
This commit is contained in:
Mike Fleetwood 2017-06-16 07:30:30 +01:00 committed by Curtis Gedak
parent d7fe48ed6d
commit a2cc5014c6
3 changed files with 34 additions and 30 deletions

20
README
View File

@ -270,20 +270,18 @@ system. These commands include:
{filemanager} - used in attempt data rescue to display discovered {filemanager} - used in attempt data rescue to display discovered
file systems. (e.g., nautilus, pcmanfm) file systems. (e.g., nautilus, pcmanfm)
hal-lock - used to prevent automounting of file systems hal-lock - used to prevent automounting of file systems
gksudo - used to acquire root privileges in .desktop file, gksudo - used to acquire root privileges in gparted shell
but only if available when gparted source is script wrapper, but only if available when gparted
configured. source is configured
gksu - alternatively used to acquire root privileges in gksu - alternatively used to acquire root privileges in
.desktop file if gksu not available, but only if gparted shell script wrapper, second choice if
available when gparted source is configured. available when gparted source is configured
kdesudo - alternatively used to acquire root privileges in kdesudo - alternatively used to acquire root privileges in
.desktop file if gksudo and gksu not available, but gparted shell script wrapper, third choice if
only if available when gparted source is available when gparted source is configured
configured.
xdg-su - alternatively used to acquire root privileges in xdg-su - alternatively used to acquire root privileges in
.desktop file if gksudo, gksu, and kdesudo are not gparted shell script wrapper, last choice if
available, but only if available when gparted available when gparted source is configured
source is configured.
udevinfo - used in dmraid to query udev name udevinfo - used in dmraid to query udev name
udevadm - used in dmraid to query udev name udevadm - used in dmraid to query udev name
yelp - used to display help manual yelp - used to display help manual

View File

@ -3,7 +3,7 @@ _Name=GParted
_GenericName=Partition Editor _GenericName=Partition Editor
_X-GNOME-FullName=GParted Partition Editor _X-GNOME-FullName=GParted Partition Editor
_Comment=Create, reorganize, and delete partitions _Comment=Create, reorganize, and delete partitions
Exec=@gksuprog@ @installdir@/gparted %f Exec=@installdir@/gparted %f
Icon=gparted Icon=gparted
Terminal=false Terminal=false
Type=Application Type=Application

View File

@ -36,6 +36,30 @@ if test "z`ps -e | grep gpartedbin`" != "z"; then
exit 1 exit 1
fi fi
#
# Define base command for executing GParted
#
BASE_CMD="@installdir@/gpartedbin $*"
#
# For non-root users try to get authorisation to run GParted as root.
#
if test "x`id -u`" != "x0"; then
#
# If there is no configured SU program run gpartedbin as
# non-root to display the graphical error about needing root
# privileges.
#
if test "x@gksuprog@" = "x"; then
echo "Root privileges are required for running gparted."
$BASE_CMD
exit 1
fi
@gksuprog@ '@installdir@/gparted' "$@"
exit $?
fi
# #
# Search PATH to determine if systemctl program can be found # Search PATH to determine if systemctl program can be found
# and if appropriate daemon is running. # and if appropriate daemon is running.
@ -104,24 +128,6 @@ for k in '' `echo "$PATH" | sed 's,:, ,g'`; do
fi fi
done 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 systemctl to prevent automount by masking currently unmasked mount points # Use systemctl to prevent automount by masking currently unmasked mount points
# #