diff --git a/gsmartcontrol/TODO b/gsmartcontrol/TODO index 681f117..bf085fb 100644 --- a/gsmartcontrol/TODO +++ b/gsmartcontrol/TODO @@ -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). diff --git a/gsmartcontrol/data/Makefile.am b/gsmartcontrol/data/Makefile.am index 788d1f1..dab3871 100644 --- a/gsmartcontrol/data/Makefile.am +++ b/gsmartcontrol/data/Makefile.am @@ -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. diff --git a/gsmartcontrol/data/gsmartcontrol-root.in b/gsmartcontrol/data/gsmartcontrol-root.in index 969bcd2..8b94755 100644 --- a/gsmartcontrol/data/gsmartcontrol-root.in +++ b/gsmartcontrol/data/gsmartcontrol-root.in @@ -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'"; diff --git a/gsmartcontrol/data/org.gsmartcontrol.policy b/gsmartcontrol/data/org.gsmartcontrol.policy new file mode 100644 index 0000000..3d8ae3f --- /dev/null +++ b/gsmartcontrol/data/org.gsmartcontrol.policy @@ -0,0 +1,19 @@ + + + + + + Authentication is required to run GSmartControl + gsmartcontrol + + auth_admin + auth_admin + auth_admin + + /usr/sbin/gsmartcontrol + true + + + diff --git a/gsmartcontrol/gsmartcontrol.spec.in b/gsmartcontrol/gsmartcontrol.spec.in index 93e4d1a..ac4d08a 100644 --- a/gsmartcontrol/gsmartcontrol.spec.in +++ b/gsmartcontrol/gsmartcontrol.spec.in @@ -8,27 +8,19 @@ Vendor: Alexander Shaduri 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 <%{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 <%{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 diff --git a/gsmartcontrol/src/Makefile.am b/gsmartcontrol/src/Makefile.am index 22ede39..b14700a 100644 --- a/gsmartcontrol/src/Makefile.am +++ b/gsmartcontrol/src/Makefile.am @@ -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 \