Comment 64 for bug 1652282

Revision history for this message
In , Mike Fleetwood (mfleetwo) wrote :

Created attachment 357573
Interim workaround for display access (draft 1)

Hi Curtis,

Here's an interim workaround for this bug. The patchset is only draft
because of an installation issue / dilemma with the location of the
polkit action file. More on that below.

Suggested NEWS fragments describing the change
==============================================

Release Notes
-------------

Provides an interim workaround to allow GParted to run under Wayland by
using xhost to grant and revoke root access to the X11 display. This
must be enabled while building the software with:
    ./configure --enable-xhost-root

Pkexec from Polkit has been made the first choice graphical SU program
as all the desktops have settled on using Polkit as the privileged
access mechanism. Also execution of the graphical SU program has been
moved from gparted.desktop to the gparted shell wrapper. Therefore
gparted can be run either by an unprivileged user or by root and as such
is installed in $prefix/bin rather than $prefix/sbin. This additionally
means distributions can drop their pkexec scripts used to launch
gparted.

Dependencies (new/updated)
--------------------------
  * Uses pkexec command (part of polkit) for root privilege escalation
    when available.
  * Uses xhost command to grant and revoke root access to the display
    when configured to do so.

Issue / dilemma with polkit action file installation location
=============================================================

The ./Makefile.am contains this line:
    polkit_actiondir = /usr/share/polkit-1/actions
from this commit in the patchset:
    Add required polkit action file (#776437)

This is to install the gparted polkit action file into that location,
the only location which polkit looks for action files. (See the above
mentioned commit comment for more details). Without it being there
polkit won't authorise GParted to run as root.

However that setting breaks 'make distcheck' because it doesn't install
the file in the ./gparted-$version/_inst and is against GNU programming
standards for program installations. [1][2] To make 'make distcheck'
work and satisfy the standards it should be:
    polkit_actiondir = $(datadir)/polkit-1/actions
But with the default prefix being /usr/local it will install the file
into /usr/local/polkit-1/actions and fail authorising GParted as
detailed above.

So you can either have 'make install' do the needed thing or make have
'make distcheck' work, not both!

[1] Automake Manual, 27.10 Installing to Hard-Coded Locations
https://www.gnu.org/software/automake/manual/automake.html#Hard_002dCoded-Install-Paths

[2] GNU Coding Standards, 7.2.5 Variables for Installation Directories
https://www.gnu.org/prep/standards/standards.html#Directory-Variables

I have also looked at some other packages which install polkit action
files. They seem to use polkit_actiondir = $(datadir)/polkit-1/actions
so I assume only produce an installion with the polkit action file
installed correctly when prefix = /usr. [3][4][5][6]

[3] gnome-settings-daemon plugins/power/Makefile.am
        polkit_policydir = $(datadir)/polkit-1/actions
https://github.com/GNOME/gnome-settings-daemon/blob/master/plugins/power/Makefile.am#L16

[4] udisks data/Makefile.am
        polkitdir = $(datadir)/polkit-1/actions
https://github.com/storaged-project/udisks/blob/master/data/Makefile.am#L31

[5] firewalld config/Makefile.am
        polkit1_actiondir = $(datadir)/polkit-1/actions
https://github.com/firewalld/firewalld/blob/master/config/Makefile.am#L22
    but firewalld also sets the default prefix to /usr with this line
    in configure.ac
        AC_PREFIX_DEFAULT([/usr])
https://github.com/firewalld/firewalld/blob/master/configure.ac#L12

   configure.ac AC_PREFIX_DEFAULT([/usr]), therefore $(datadir) is

[6] polkit actions/Makefile.am
        polkit_actiondir = $(datadir)/polkit-1/actions
https://cgit.freedesktop.org/polkit/tree/actions/Makefile.am#n2

I am thinking of following GNU standards and using polkit_policydir =
$(datadir)/polkit-1/actions. This will work when configured with
'./configure --prefix=/usr' and with 'make distcheck'. So it will work
for distros building gparted packages. Then for user installations
using the default prefix of /usr/local they will continue to use the
distro provided copy of org.gnome.gparted.policy, if any. Otherwise
there will be an extra (manual) step of copying org.gnome.gparted.policy
from /usr/local/polkit-1/actions/ to /usr/polkit-1/actions/.

Summary
=======

Apart from the polkit action file question the patchset is quite close
to being ready.

Mike