Implemented PolKit support.

Install gsmartcontrol binary to /usr/sbin.
Removed Fedora consolehelper support from spec file (in favor of PolKit).
This commit is contained in:
Alexander Shaduri
2017-08-27 17:33:09 +00:00
parent 731122e891
commit 1e72729056
6 changed files with 36 additions and 74 deletions
-4
View File
@@ -43,10 +43,6 @@ Don't rely on smartctl return code (2), parse the output instead.
https://developer.gnome.org/glib/2.34/glib-The-Main-Event-Loop.html#g-main-loop-quit
In main window add multi-selection support and right-click menu with various
tests, so that it's possible to run multiple tests in parallel from there.
Areca detection
Linux:
Somehow differentiate between the cards with expanders (-d areca,N/E) and without (-d areca,N).
+4
View File
@@ -44,6 +44,10 @@ desktop_DATA = gsmartcontrol.desktop
metainfodir = $(datadir)/metainfo
metainfo_DATA = gsmartcontrol.appdata.xml
# PolKit files
polkitdir = $(datadir)/polkit-1/actions
polkit_DATA = org.gsmartcontrol.policy
# Application pixmap (fallback icon for desktop files).
# Same as 48/gsmartcontrol.png.
+7 -3
View File
@@ -8,7 +8,7 @@
# Run gsmartcontrol with root, asking for root password first.
# export GSMARTCONTROL_SU to override a su command (e.g. "kdesu -c").
EXEC_BIN="@prefix@/bin/gsmartcontrol";
EXEC_BIN="@prefix@/sbin/gsmartcontrol";
prog_name="gsmartcontrol"
@@ -71,11 +71,12 @@ fi
# They're basically the same, only the order is different.
# pkexec is for PolKit
# sux requires xterm to ask for the password.
# xdg-su is basically like this script, except worse :)
# su-to-root is a debian/ubuntu official method (although gksu is available).
gnome_sus="su-to-root gnomesu gksu kdesu beesu xdg-su sux";
kde_sus="su-to-root kdesu gnomesu gksu beesu xdg-su sux";
gnome_sus="pkexec su-to-root gnomesu gksu kdesu beesu xdg-su sux";
kde_sus="pkexec su-to-root kdesu gnomesu gksu beesu xdg-su sux";
other_sus="$gnome_sus";
@@ -136,6 +137,9 @@ full_cmd="";
if [ "$GSMARTCONTROL_SU" != "" ]; then
full_cmd="$GSMARTCONTROL_SU '$EXEC_BIN $final_args_quoted'";
elif [ "$found_su" = "pkexec" ]; then
full_cmd="pkexec '$EXEC_BIN $final_args_quoted'";
elif [ "$found_su" = "sux" ]; then
full_cmd="xterm -e sux -c '$EXEC_BIN $final_args_quoted'";
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policyconfig PUBLIC
"-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
"http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd">
<policyconfig>
<action id="org.gsmartcontrol">
<message>Authentication is required to run GSmartControl</message>
<icon_name>gsmartcontrol</icon_name>
<defaults>
<allow_any>auth_admin</allow_any>
<allow_inactive>auth_admin</allow_inactive>
<allow_active>auth_admin</allow_active>
</defaults>
<annotate key="org.freedesktop.policykit.exec.path">/usr/sbin/gsmartcontrol</annotate>
<annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
</action>
</policyconfig>
+5 -66
View File
@@ -8,27 +8,19 @@ Vendor: Alexander Shaduri <ashaduri 'at' gmail.com>
Source: http://sourceforge.net/projects/gsmartcontrol/files/%{version}/%{name}-%{version}.tar.bz2
BuildRoot: %{_tmppath}/%{name}-%{version}-build
Summary: GSmartControl - Hard Disk Drive and SSD Health Inspection Tool
%if 0%{?mandriva_version}
Group: System/Kernel and hardware
%else
Group: Hardware/Other
%endif
# Empty debug packages cause errors in new RPM. Disable them.
%global debug_package %{nil}
# Dependencies for various distributions. The actual deps are:
# smartmontools, pcre, gtkmm3 >= 3.4.0
# (with the respective -devel packages of the libraries for build requirements).
# For non-specified distributions we don't specify any dependencies to avoid errors.
# SUSE / OpenSUSE. SLES also defines the correct suse_version.
%if 0%{?suse_version}
Requires: smartmontools
Requires: smartmontools, polkit, bash
BuildRequires: gcc-c++, libstdc++-devel, pcre-devel, gtkmm3-devel >= 3.4.0
BuildRequires: update-desktop-files
BuildRequires: fdupes
@@ -39,16 +31,9 @@ BuildRequires: fdupes
# Fedora, CentOS, RHEL
%if 0%{?fedora_version} || 0%{?rhel_version} || 0%{?centos_version}
# I'm not sure about centos and rhel versions
Requires: smartmontools
Requires: smartmontools, polkit, bash
BuildRequires: gcc-c++, pcre-devel, gtkmm30-devel >= 3.4.0
# Fedora with consolehelper.
# usermode-gtk is for consolehelper-gtk.
%if 0%{?fedora_version}
Requires: usermode-gtk
%endif
%endif
@@ -97,43 +82,6 @@ rm -f $RPM_BUILD_ROOT%{_datadir}/icons/hicolor/icon-theme.cache
%endif
%if 0%{?fedora_version}
# We still retain gsmartcontrol-root for consistency with other distributions.
# Make the desktop file run gsmartcontrol instead of gsmartcontrol-root
sed "s|gsmartcontrol-root|gsmartcontrol|g" %{buildroot}%{_datadir}/applications/gsmartcontrol.desktop > %{buildroot}%{_datadir}/applications/gsmartcontrol.desktop.new
mv -f %{buildroot}%{_datadir}/applications/gsmartcontrol.desktop.new %{buildroot}%{_datadir}/applications/gsmartcontrol.desktop
# The rest is taken from the official fedora spec:
# http://pkgs.fedoraproject.org/cgit/gsmartcontrol.git/tree/
# Set up for console-helper
mkdir -p %{buildroot}%{_sbindir}
# Add a copy as "gsmartcontrol-noroot", since gsmartcontrol will always
# ask for root password.
cp %{buildroot}%{_bindir}/%{name} %{buildroot}%{_bindir}/%{name}-noroot
mv %{buildroot}%{_bindir}/%{name} %{buildroot}%{_sbindir}/%{name}
ln -s consolehelper %{buildroot}%{_bindir}/%{name}
mkdir -p %{buildroot}%{_sysconfdir}/pam.d
cat <<EOF >%{buildroot}%{_sysconfdir}/pam.d/%{name}
#%%PAM-1.0
auth include config-util
account include config-util
session include config-util
EOF
mkdir -p %{buildroot}%{_sysconfdir}/security/console.apps
cat <<EOF >%{buildroot}%{_sysconfdir}/security/console.apps/%{name}
USER=root
PROGRAM=/usr/sbin/gsmartcontrol
SESSION=true
EOF
# endif fedora
%endif
%clean
rm -rf %buildroot
@@ -141,12 +89,8 @@ rm -rf %buildroot
%files
%defattr(-,root,root)
# In fedora /usr/bin/gsmartcontrol is linked to consolehelper, cannot set attrs on symlink.
%if 0%{?fedora_version}
%{_bindir}/*
%else
%attr(0755,root,root) %{_bindir}/*
%endif
%attr(0755,root,root) %{_bindir}/gsmartcontrol-root
%attr(0755,root,root) %{_sbindir}/gsmartcontrol
# %%attr(0644,root,root) %%config(noreplace) %%{_sysconfdir}/*
@@ -157,13 +101,8 @@ rm -rf %buildroot
# %%{_datadir}/gsmartcontrol/*
%{_datadir}/applications/*.desktop
%{_datadir}/metainfo
%{_datadir}/polkit-1/actions
%{_datadir}/icons/*
%{_datadir}/pixmaps/*
%if 0%{?fedora_version}
%config(noreplace) %{_sysconfdir}/pam.d/%{name}
%config(noreplace) %{_sysconfdir}/security/console.apps/%{name}
%{_sbindir}/gsmartcontrol
%endif
%changelog
+1 -1
View File
@@ -24,7 +24,7 @@ noinst_DATA = gsc_winres.rc.in gsmartcontrol.exe.manifest.in
# endif
bin_PROGRAMS = gsmartcontrol
sbin_PROGRAMS = gsmartcontrol
gsmartcontrol_LDADD = $(top_builddir)/src/applib/libapplib.a \
$(top_builddir)/src/libdebug/libdebug.a \