Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package kpmcore for openSUSE:Factory checked in at 2022-03-05 14:44:05 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/kpmcore (Old) and /work/SRC/openSUSE:Factory/.kpmcore.new.1958 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "kpmcore" Sat Mar 5 14:44:05 2022 rev:9 rq:959253 version:21.12.3 Changes: -------- --- /work/SRC/openSUSE:Factory/kpmcore/kpmcore.changes 2019-02-24 17:12:44.864478903 +0100 +++ /work/SRC/openSUSE:Factory/.kpmcore.new.1958/kpmcore.changes 2022-03-05 14:44:50.327722445 +0100 @@ -1,0 +2,202 @@ +Wed Mar 2 09:26:10 UTC 2022 - Christophe Giboudeaux <[email protected]> + +- Update to 21.12.3 + * New bugfix release + * For more details please see: + * https://kde.org/announcements/gear/21.12.3/ +- Changes since 21.12.2: + * Do not repeatedly open and close file when reading from it. + * Do not repeatedly open and close file when writing to it. + * Make sure that path passed to WriteData is block device. + * Restrict CopyFileData to writing to already existing files. + * Rename CopyBlocks to CopyFileData. + * Check for relative paths in ExternalCommandHelper::CopyBlocks. + * Restrict QProcess::ProcessChannelMode to two used values. + * Be a bit more strict in root helper when checking path to /etc/fstab. +- Drop patches, now upstream: + * 0001-Do-not-repeatedly-open-and-close-file-when-reading-f.patch + * 0001-Do-not-repeatedly-open-and-close-file-when-writing-t.patch + * 0001-Make-sure-that-path-passed-to-WriteData-is-block-dev.patch + * 0001-Restrict-CopyFileData-to-writing-to-already-existing.patch + * 0001-Rename-CopyBlocks-to-CopyFileData.patch + * 0001-Check-for-relative-paths-in-ExternalCommandHelper-Co.patch + * 0001-Restrict-QProcess-ProcessChannelMode-to-two-used-val.patch + * 0001-Be-a-bit-more-strict-in-root-helper-when-checking-pa.patch + +------------------------------------------------------------------- +Thu Feb 24 11:13:02 UTC 2022 - Christophe Giboudeaux <[email protected]> + +- Backport more upstream changes: + * 0001-Restrict-CreateFile-method-to-WriteFstab-method-in-p.patch + * 0001-Add-a-comment-about-WriteOnly.patch + * 0001-Add-a-few-more-comments-explaining-copy-direction.patch + * 0001-Set-false-as-the-default-return-value-and-change-it-.patch + * 0001-Rename-blockSize-to-chunkSize-to-avoid-confusion-wit.patch + * 0001-Fix-a-typo-in-definition-of-MiB-constant.patch + * 0001-Rename-variables-into-more-appropriate-fstabPath-and.patch + +------------------------------------------------------------------- +Wed Feb 9 12:18:36 UTC 2022 - Christophe Giboudeaux <[email protected]> + +- Backport upstream changes to address security issues + (contributes to boo#1178848) + * 0001-Add-new-job-to-change-permission-of-the-newly-create.patch + * 0001-Move-the-changePosixPermission-to-the-Filesystem.patch + * 0001-Add-posix-permissions-on-filesystems-used-in-posix-s.patch + * 0001-Allow-running-chmod-in-externalcommand-helper.patch + * 0001-Add-support-for-copying-unknown-partitions.patch + * 0001-Fix-davfs-entries-being-omitted-from-fstab-file.patch + * 0001-Changing-swap-labels-while-swap-is-active-does-not-s.patch + * 0001-Be-a-bit-more-strict-in-root-helper-when-checking-pa.patch + * 0001-Restrict-QProcess-ProcessChannelMode-to-two-used-val.patch + * 0001-Check-for-relative-paths-in-ExternalCommandHelper-Co.patch + * 0001-Rename-CopyBlocks-to-CopyFileData.patch + * 0001-Restrict-CopyFileData-to-writing-to-already-existing.patch + * 0001-Make-sure-that-path-passed-to-WriteData-is-block-dev.patch + * 0001-Do-not-repeatedly-open-and-close-file-when-writing-t.patch + * 0001-Do-not-repeatedly-open-and-close-file-when-reading-f.patch + * 0001-Update-description-of-polkit-helper.patch + +------------------------------------------------------------------- +Sat Feb 5 09:12:55 UTC 2022 - Christophe Giboudeaux <[email protected]> + +- Update to 21.12.2 + * New bugfix release + * For more details please see: + * https://kde.org/announcements/gear/21.12.2/ +- Changes since 21.12.1: + * Fix infinite recursion in dummy backend. (kde#432704) + +------------------------------------------------------------------- +Thu Jan 13 08:58:19 UTC 2022 - Christophe Giboudeaux <[email protected]> + +- Update to 21.12.1 + * New bugfix release + * For more details please see: + * https://kde.org/announcements/gear/21.12.1/ +- Changes since 21.08.3: + * Fix broken fstab when mount point includes space. (kde#446218) + * Fix seek error when filling device with random data or zeroes. + * Do not destroy zfs pool when removing zfs partition. + * Bump minimal cmake version to 3.16 + * Initialize all fields in Partition + * Clear attributes on new partition creation + +------------------------------------------------------------------- +Sat Nov 13 16:52:20 UTC 2021 - Christophe Giboudeaux <[email protected]> + +- Update to 21.08.3 + * New bugfix release + * For more details please see: + * https://kde.org/announcements/gear/21.08.3/ +- No code change since 21.08.1 + +------------------------------------------------------------------- +Mon Sep 6 06:05:05 UTC 2021 - Christophe Giboudeaux <[email protected]> + +- Update to 21.08.1 + * New bugfix release + * For more details please see: + * https://kde.org/announcements/gear/21.08.1 +- No code change since 21.08.0 + +------------------------------------------------------------------- +Fri Aug 6 14:18:45 UTC 2021 - Christophe Giboudeaux <[email protected]> + +- Update to 21.08.0 + * New feature release + * For more details please see: + * https://kde.org/announcements/gear/21.08.0 +- No code change since 21.04.2 + +------------------------------------------------------------------- +Fri Jun 25 08:50:45 UTC 2021 - Christophe Giboudeaux <[email protected]> + +- Update to 21.04.2 + * New bugfix release + * For more details please see: + * https://kde.org/announcements/gear/21.04.2 +- No code change since 21.04.1 + +------------------------------------------------------------------- +Wed May 19 13:43:41 UTC 2021 - Christophe Giboudeaux <[email protected]> + +- Update to 21.04.1 + * New bugfix release + * For more details please see: + * https://kde.org/announcements/gear/21.04.1 +- No code change since 21.04.0 +- Use GCC 10 on Leap + +------------------------------------------------------------------- +Tue Apr 20 15:21:31 UTC 2021 - Christophe Giboudeaux <[email protected]> + +- Update to 21.04.0 + * New feature release + * For more details please see: + * https://kde.org/announcements/gear/21.04 + +------------------------------------------------------------------- +Tue Oct 27 13:32:06 UTC 2020 - Wolfgang Bauer <[email protected]> + +- Update to 4.2.0 + * KAuth helper replaced with pure PolkitQt1 helper + * KDE Partition Manager (including KPMcore library) is now fully + REUSE 3.0 compliant + * Support for partitions with unknown file system + * Fixed and improved mount point and /etc/fstab handling + * Fixed a crash that was present for a long time but hard to + reproduce reliably + * KPMcore gained support for GPT partition attributes (It is not + yet wired in KDE Partition Manager) + * KPMcore has more support for setting GPT partition label and + UUID (Again, not yet wired in KDE Partition Manager) + * Port away from various deprecated Qt/KDE methods + * Workaround bad JSON output from sfdisk (will be fixed in + util-linux 2.37). + * Import partition flags when importing partition table + * Apply colour scheme to secondary (MBR logical) partitions + +------------------------------------------------------------------- +Thu Aug 27 12:36:26 UTC 2020 - Christophe Giboudeaux <[email protected]> + +- Use %cmake_build instead of %make_jobs + +------------------------------------------------------------------- +Mon Feb 10 09:01:08 UTC 2020 - [email protected] + +- Update to 4.1.0 + * Support for Minix file system + * Initial support for file system specific features although it's + not exposed via KDE Partition Manager GUI yet + * Some bug fixes, in particular Calamares installer should work + better than with 4.0 + +------------------------------------------------------------------- +Mon Oct 7 10:05:58 UTC 2019 - [email protected] + +- Update to 4.0.1 + * Do not align partitions if they are mounted, moving data when + partitions are mounted is almost guaranteed to cause data loss + (kde#412575) + +------------------------------------------------------------------- +Fri May 24 20:29:12 UTC 2019 - [email protected] + +- Update to 4.0.0 + * Ported to KAuth to let the GUI run as unprivileged user + * KPMcore backend was ported away from libparted to sfdisk (part + of util-linux) + * Ported S.M.A.R.T. code away from unmaintained libatasmart to + smartmontools + * Better support for LUKS2 + * Detection support for Apple's APFS filesystem and Microsoft's + Bitlocker + * Many of the KPMcore classes now use d-pointers, which in the + future releases will help us to maintain binary compatibility + (ABI) a bit better ++++ 5 more lines (skipped) ++++ between /work/SRC/openSUSE:Factory/kpmcore/kpmcore.changes ++++ and /work/SRC/openSUSE:Factory/.kpmcore.new.1958/kpmcore.changes Old: ---- kpmcore-3.3.0.tar.xz New: ---- 0001-Add-a-comment-about-WriteOnly.patch 0001-Add-a-few-more-comments-explaining-copy-direction.patch 0001-Add-new-job-to-change-permission-of-the-newly-create.patch 0001-Add-posix-permissions-on-filesystems-used-in-posix-s.patch 0001-Add-support-for-copying-unknown-partitions.patch 0001-Allow-running-chmod-in-externalcommand-helper.patch 0001-Changing-swap-labels-while-swap-is-active-does-not-s.patch 0001-Fix-a-typo-in-definition-of-MiB-constant.patch 0001-Fix-davfs-entries-being-omitted-from-fstab-file.patch 0001-Move-the-changePosixPermission-to-the-Filesystem.patch 0001-Rename-blockSize-to-chunkSize-to-avoid-confusion-wit.patch 0001-Rename-variables-into-more-appropriate-fstabPath-and.patch 0001-Restrict-CreateFile-method-to-WriteFstab-method-in-p.patch 0001-Set-false-as-the-default-return-value-and-change-it-.patch 0001-Update-description-of-polkit-helper.patch applications.keyring kpmcore-21.12.3.tar.xz kpmcore-21.12.3.tar.xz.sig ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ kpmcore.spec ++++++ --- /var/tmp/diff_new_pack.TY4feV/_old 2022-03-05 14:44:51.239722675 +0100 +++ /var/tmp/diff_new_pack.TY4feV/_new 2022-03-05 14:44:51.243722676 +0100 @@ -1,7 +1,7 @@ # # spec file for package kpmcore # -# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2022 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -16,33 +16,58 @@ # -%global sover 7 -%bcond_without lang +# Latest stable Applications (e.g. 17.08 in KA, but 17.11.80 in KUA) +%{!?_kapp_version: %define _kapp_version %(echo %{version}| awk -F. '{print $1"."$2}')} +%bcond_without released +%global sover 11 Name: kpmcore -Version: 3.3.0 +Version: 21.12.3 Release: 0 Summary: KDE Partition Manager core library License: GPL-3.0-only Group: Productivity/Office/Other -Url: https://projects.kde.org/projects/extragear/sysadmin/kpmcore -Source: http://download.kde.org/stable/%{name}/%{version}/src/%{name}-%{version}.tar.xz +URL: https://www.kde.org +Source: https://download.kde.org/stable/release-service/%{version}/src/%{name}-%{version}.tar.xz +%if %{with released} +Source1: https://download.kde.org/stable/release-service/%{version}/src/%{name}-%{version}.tar.xz.sig +Source2: applications.keyring +%endif +# Upstream changes related to boo#1178848 +Patch0: 0001-Add-new-job-to-change-permission-of-the-newly-create.patch +Patch1: 0001-Move-the-changePosixPermission-to-the-Filesystem.patch +Patch2: 0001-Add-posix-permissions-on-filesystems-used-in-posix-s.patch +Patch3: 0001-Allow-running-chmod-in-externalcommand-helper.patch +Patch4: 0001-Add-support-for-copying-unknown-partitions.patch +Patch5: 0001-Fix-davfs-entries-being-omitted-from-fstab-file.patch +Patch6: 0001-Changing-swap-labels-while-swap-is-active-does-not-s.patch +Patch7: 0001-Update-description-of-polkit-helper.patch +Patch8: 0001-Fix-a-typo-in-definition-of-MiB-constant.patch +Patch9: 0001-Set-false-as-the-default-return-value-and-change-it-.patch +Patch10: 0001-Add-a-few-more-comments-explaining-copy-direction.patch +Patch11: 0001-Rename-blockSize-to-chunkSize-to-avoid-confusion-wit.patch +Patch12: 0001-Restrict-CreateFile-method-to-WriteFstab-method-in-p.patch +Patch13: 0001-Rename-variables-into-more-appropriate-fstabPath-and.patch +Patch14: 0001-Add-a-comment-about-WriteOnly.patch BuildRequires: extra-cmake-modules -BuildRequires: kcoreaddons-devel -BuildRequires: ki18n-devel -BuildRequires: kwidgetsaddons-devel -BuildRequires: libatasmart-devel -BuildRequires: libblkid-devel -BuildRequires: parted-devel +%if 0%{?suse_version} <= 1500 +BuildRequires: gcc10-c++ +%endif BuildRequires: pkgconfig BuildRequires: update-desktop-files -BuildRequires: pkgconfig(Qt5Core) >= 5.7.0 -BuildRequires: pkgconfig(Qt5DBus) -BuildRequires: pkgconfig(Qt5Gui) -BuildRequires: pkgconfig(Qt5Widgets) -Requires: libkpmcore%{sover} = %{version} +BuildRequires: cmake(KF5Auth) +BuildRequires: cmake(KF5CoreAddons) >= 5.73 +BuildRequires: cmake(KF5I18n) +BuildRequires: cmake(KF5WidgetsAddons) +BuildRequires: cmake(PolkitQt5-1) +BuildRequires: cmake(Qt5Core) >= 5.14.0 +BuildRequires: cmake(Qt5DBus) +BuildRequires: cmake(Qt5Gui) +BuildRequires: cmake(Qt5Widgets) +BuildRequires: pkgconfig(blkid) >= 2.33.2 %description -Library for managing partitions. Common code for KDE Partition Manager and other projects. +Library for managing partitions. Common code for KDE Partition Manager and +other projects. %package devel Summary: Development package for KDE Partition Manager core library @@ -50,54 +75,63 @@ Requires: libkpmcore%{sover} = %{version} %description devel -Library for managing partitions. Common code for KDE Partition Manager and other projects. +Library for managing partitions. Common code for KDE Partition Manager and +other projects. Development package for kpmcore. %package -n libkpmcore%{sover} Summary: KDE Partition Manager core library Group: System/Libraries -Requires: %{name} = %{version} +Requires: %{name} >= %{version} %description -n libkpmcore%{sover} -Library for managing partitions. Common code for KDE Partition Manager and other projects. +Library for managing partitions. Common code for KDE Partition Manager and +other projects. Main kpmcore library. %lang_package %prep -%setup -q +%autosetup -p1 %build +%if 0%{?suse_version} <= 1500 + export CXX=g++-10 +%endif + %cmake_kf5 -d build -%make_jobs +%cmake_build %install - %kf5_makeinstall -C build - %if %{with lang} - %find_lang kpmcore - %endif +%kf5_makeinstall -C build +%if %{with released} + %find_lang kpmcore --all-name +%endif %post -n libkpmcore%{sover} -p /sbin/ldconfig %postun -n libkpmcore%{sover} -p /sbin/ldconfig %files -%license COPYING.GPL3 -%{_kf5_servicetypesdir}/*desktop -%{_kf5_plugindir}/*.so -%{_kf5_servicesdir}/*desktop +%{_kf5_dbuspolicydir}/org.kde.kpmcore.*.conf +%{_kf5_libdir}/libexec/kpmcore_externalcommand +%{_kf5_plugindir}/libpmdummybackendplugin.so +%{_kf5_plugindir}/libpmsfdiskbackendplugin.so +%{_kf5_sharedir}/dbus-1/system-services/org.kde.kpmcore.helperinterface.service +%{_kf5_sharedir}/polkit-1/actions/org.kde.kpmcore.externalcommand.policy %files -n libkpmcore%{sover} -%license COPYING.GPL3 -%{_libdir}/libkpmcore.so.* +%license LICENSES/* +%{_kf5_libdir}/libkpmcore.so.%{sover} +%{_kf5_libdir}/libkpmcore.so.%{version} %files devel -%{_libdir}/cmake/KPMcore/ %{_includedir}/kpmcore/ -%{_libdir}/libkpmcore.so +%{_kf5_cmakedir}/KPMcore/ +%{_kf5_libdir}/libkpmcore.so -%if %{with lang} +%if %{with released} %files lang -f %{name}.lang %endif ++++++ 0001-Add-a-comment-about-WriteOnly.patch ++++++ >From 858f8d9baefb3e2402ad7cfabb31f77928004989 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= <[email protected]> Date: Sun, 20 Feb 2022 20:49:57 +0000 Subject: [PATCH] Add a comment about WriteOnly. --- src/util/externalcommandhelper.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/util/externalcommandhelper.cpp b/src/util/externalcommandhelper.cpp index 6da2a21..484f91a 100644 --- a/src/util/externalcommandhelper.cpp +++ b/src/util/externalcommandhelper.cpp @@ -137,6 +137,7 @@ bool ExternalCommandHelper::WriteFstab(const QByteArray& fileContents) QString fstabPath = QStringLiteral("/etc/fstab"); QFile fstabFile(fstabPath); + // WriteOnly implies O_TRUNC auto flags = QIODevice::WriteOnly | QIODevice::Unbuffered; if (!fstabFile.open(flags)) { qCritical() << xi18n("Could not open file <filename>%1</filename> for writing.", fstabPath); -- 2.35.1 ++++++ 0001-Add-a-few-more-comments-explaining-copy-direction.patch ++++++ >From d9ceb50238596a14fc836a6499724516cb447cf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= <[email protected]> Date: Sun, 20 Feb 2022 00:41:41 +0000 Subject: [PATCH] Add a few more comments explaining copy direction. --- src/util/externalcommandhelper.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/util/externalcommandhelper.cpp b/src/util/externalcommandhelper.cpp index 5c7e115..e2566cf 100644 --- a/src/util/externalcommandhelper.cpp +++ b/src/util/externalcommandhelper.cpp @@ -1,5 +1,5 @@ /* - SPDX-FileCopyrightText: 2017-2020 Andrius ??tikonas <[email protected]> + SPDX-FileCopyrightText: 2017-2022 Andrius ??tikonas <[email protected]> SPDX-FileCopyrightText: 2018 Huzaifa Faruqui <[email protected]> SPDX-FileCopyrightText: 2018 Caio Jord??o Carvalho <[email protected]> SPDX-FileCopyrightText: 2018-2019 Harald Sitter <[email protected]> @@ -188,11 +188,14 @@ QVariantMap ExternalCommandHelper::CopyFileData(const QString& sourceDevice, con reply[QStringLiteral("success")] = true; // This enum specified whether individual blocks are moved left or right + // When source and target devices are the same we have to be careful not to overwrite + // source data with newly written data. We don't have to do this if sourceDevice is not + // targetDevice but there are no disadvantages in applying the same scheme. // When partition is moved to the left, we start with the leftmost block, // and move it further left, then second leftmost block and so on. // But when we move partition to the right, we start with rightmost block. // To account for this difference, we introduce CopyDirection variable which takes - // care of some of the differences between these two cases. + // care of some of the differences in offset calculation between these two cases. enum CopyDirection : qint8 { Left = 1, Right = -1, -- 2.35.1 ++++++ 0001-Add-new-job-to-change-permission-of-the-newly-create.patch ++++++ >From 6c14ddb043ce22706740701b1c7413198b608c21 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Thu, 9 Dec 2021 16:54:41 +0100 Subject: [PATCH] Add new job to change permission of the newly created partition --- src/core/partition.cpp | 19 ++++++++++++ src/core/partition.h | 9 ++++++ src/jobs/CMakeLists.txt | 1 + src/jobs/changepermissionsjob.cpp | 42 ++++++++++++++++++++++++++ src/jobs/changepermissionsjob.h | 43 +++++++++++++++++++++++++++ src/ops/createfilesystemoperation.cpp | 5 ++++ src/ops/newoperation.cpp | 5 ++++ 7 files changed, 124 insertions(+) create mode 100644 src/jobs/changepermissionsjob.cpp create mode 100644 src/jobs/changepermissionsjob.h diff --git a/src/core/partition.cpp b/src/core/partition.cpp index 61c59f4..eeb0bd0 100644 --- a/src/core/partition.cpp +++ b/src/core/partition.cpp @@ -368,6 +368,25 @@ void Partition::setPartitionPath(const QString& s) setNumber(-1); } + +bool Partition::execChangePermission(Report& report) +{ + if (m_permission.isEmpty()) { + return true; + } + + ExternalCommand chmodCmd(report, + QStringLiteral("chmod"), + { + m_permission, + deviceNode() + }); + + if ( chmodCmd.run() && chmodCmd.exitCode() == 0 ) + return true; + return false; +} + void Partition::setFileSystem(FileSystem* fs) { m_FileSystem = fs; diff --git a/src/core/partition.h b/src/core/partition.h index e4bbff7..5bff232 100644 --- a/src/core/partition.h +++ b/src/core/partition.h @@ -259,6 +259,14 @@ public: } void deleteFileSystem(); + void setPermissions(const QString& permission) { + m_permission = permission; + } + + // sets the disk to have write and read permissions of 777. + // userful for pendrives and such. + bool execChangePermission(Report& report); + private: void setNumber(qint32 n) { m_Number = n; @@ -275,6 +283,7 @@ private: QString m_Label; QString m_Type; QString m_UUID; + QString m_permission; quint64 m_Attributes = 0; QString m_PartitionPath; QString m_MountPoint; diff --git a/src/jobs/CMakeLists.txt b/src/jobs/CMakeLists.txt index 6aec254..a6968de 100644 --- a/src/jobs/CMakeLists.txt +++ b/src/jobs/CMakeLists.txt @@ -31,6 +31,7 @@ set(JOBS_SRC jobs/setpartflagsjob.cpp jobs/copyfilesystemjob.cpp jobs/movefilesystemjob.cpp + jobs/changepermissionsjob.cpp ) set(JOBS_LIB_HDRS diff --git a/src/jobs/changepermissionsjob.cpp b/src/jobs/changepermissionsjob.cpp new file mode 100644 index 0000000..eabca29 --- /dev/null +++ b/src/jobs/changepermissionsjob.cpp @@ -0,0 +1,42 @@ +/* + SPDX-FileCopyrightText: Tomaz Canabrava <[email protected]> + + SPDX-License-Identifier: GPL-3.0-or-later +*/ + +#include "jobs/changepermissionsjob.h" + +#include "core/lvmdevice.h" +#include "core/partition.h" + +#include "util/report.h" + +#include <KLocalizedString> + +/** Creates a new CreateVolumeGroupJob + * @param permission the new permission for the partition, in chmod style. + * @param partition the partition to change the permission. + */ +ChangePermissionJob::ChangePermissionJob(Partition& partition) : + Job(), + m_Partition(partition) +{ +} + +bool ChangePermissionJob::run(Report& parent) +{ + bool rval = false; + + Report* report = jobStarted(parent); + + rval = m_Partition.execChangePermission(*report); + + jobFinished(*report, rval); + + return rval; +} + +QString ChangePermissionJob::description() const +{ + return xi18nc("@info/plain", "Change the permissions of: <filename>%1</filename> to %2", m_Partition.deviceNode(), m_permissions); +} diff --git a/src/jobs/changepermissionsjob.h b/src/jobs/changepermissionsjob.h new file mode 100644 index 0000000..805f180 --- /dev/null +++ b/src/jobs/changepermissionsjob.h @@ -0,0 +1,43 @@ +/* + SPDX-FileCopyrightText: 2021 Tomaz Canabrava <[email protected]> + + SPDX-License-Identifier: GPL-3.0-or-later +*/ + +#ifndef KPMCORE_CHANGEPERMISSIONJOB_H +#define KPMCORE_CHANGEPERMISSIONJOB_H + +#include "jobs/job.h" + +class Partition; +class Report; + +class QString; + +/** Check a FileSystem. + @author Volker Lanz <[email protected]> +*/ +class ChangePermissionJob : public Job +{ +public: + /* Permission should be set in the partition. */ + explicit ChangePermissionJob(Partition& p); + +public: + bool run(Report& parent) override; + QString description() const override; + +protected: + Partition& partition() { + return m_Partition; + } + const Partition& partition() const { + return m_Partition; + } + +private: + Partition& m_Partition; + QString m_permissions; +}; + +#endif diff --git a/src/ops/createfilesystemoperation.cpp b/src/ops/createfilesystemoperation.cpp index 4e6f40e..1f9890b 100644 --- a/src/ops/createfilesystemoperation.cpp +++ b/src/ops/createfilesystemoperation.cpp @@ -13,6 +13,7 @@ #include "jobs/deletefilesystemjob.h" #include "jobs/createfilesystemjob.h" #include "jobs/checkfilesystemjob.h" +#include "jobs/changepermissionsjob.h" #include "fs/filesystem.h" #include "fs/filesystemfactory.h" @@ -42,6 +43,10 @@ CreateFileSystemOperation::CreateFileSystemOperation(Device& d, Partition& p, Fi addJob(deleteJob()); addJob(createJob()); addJob(checkJob()); + + // if the user never configured a new permission, nothing will run, if he did, + // then we change the permissions on the newly created partition. + addJob(new ChangePermissionJob(p)); } CreateFileSystemOperation::~CreateFileSystemOperation() diff --git a/src/ops/newoperation.cpp b/src/ops/newoperation.cpp index 2c4fe51..7242af2 100644 --- a/src/ops/newoperation.cpp +++ b/src/ops/newoperation.cpp @@ -21,6 +21,7 @@ #include "jobs/setfilesystemlabeljob.h" #include "jobs/setpartflagsjob.h" #include "jobs/checkfilesystemjob.h" +#include "jobs/changepermissionsjob.h" #include "fs/filesystem.h" #include "fs/filesystemfactory.h" @@ -106,6 +107,10 @@ NewOperation::NewOperation(Device& d, Partition* p) : d_ptr->m_CheckFileSystemJob = new CheckFileSystemJob(newPartition()); addJob(checkJob()); + + // if the user never configured a new permission, nothing will run, if he did, + // then we change the permissions on the newly created partition. + addJob(new ChangePermissionJob(newPartition())); } } -- 2.35.1 ++++++ 0001-Add-posix-permissions-on-filesystems-used-in-posix-s.patch ++++++ >From 36bb57c0dd704b75326e23ee632a43458a07f4dc Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Tue, 28 Dec 2021 10:15:04 +0000 Subject: [PATCH] Add posix permissions on filesystems used in posix systems --- src/fs/btrfs.h | 2 ++ src/fs/f2fs.h | 2 ++ src/fs/hfsplus.h | 2 ++ src/fs/jfs.h | 2 ++ src/fs/minix.h | 5 ++++- src/fs/nilfs2.h | 2 ++ src/fs/ocfs2.h | 2 ++ src/fs/reiser4.h | 2 ++ src/fs/reiserfs.h | 2 ++ src/fs/udf.h | 2 ++ src/fs/xfs.h | 2 ++ src/fs/zfs.h | 2 ++ 12 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/fs/btrfs.h b/src/fs/btrfs.h index 8f69eaa..9cdea7c 100644 --- a/src/fs/btrfs.h +++ b/src/fs/btrfs.h @@ -42,6 +42,8 @@ public: bool writeLabel(Report& report, const QString& deviceNode, const QString& newLabel) override; bool writeLabelOnline(Report& report, const QString& deviceNode, const QString& mountPoint, const QString& newLabel) override; bool updateUUID(Report& report, const QString& deviceNode) const override; + QString posixPermissions() const override { return implPosixPermissions(); }; + void setPosixPermissions(const QString& permissions) override { implSetPosixPermissions(permissions); }; CommandSupportType supportGetUsed() const override { return m_GetUsed; diff --git a/src/fs/f2fs.h b/src/fs/f2fs.h index 4e5edd6..8bb7278 100644 --- a/src/fs/f2fs.h +++ b/src/fs/f2fs.h @@ -40,6 +40,8 @@ public: bool resize(Report& report, const QString& deviceNode, qint64 length) const override; // bool writeLabel(Report& report, const QString& deviceNode, const QString& newLabel) override; // bool updateUUID(Report& report, const QString& deviceNode) const override; + QString posixPermissions() const override { return implPosixPermissions(); }; + void setPosixPermissions(const QString& permissions) override { implSetPosixPermissions(permissions); }; CommandSupportType supportGetUsed() const override { return m_GetUsed; diff --git a/src/fs/hfsplus.h b/src/fs/hfsplus.h index 7df4a51..e591f2b 100644 --- a/src/fs/hfsplus.h +++ b/src/fs/hfsplus.h @@ -37,6 +37,8 @@ public: bool check(Report& report, const QString& deviceNode) const override; bool create(Report& report, const QString& deviceNode) override; + QString posixPermissions() const override { return implPosixPermissions(); }; + void setPosixPermissions(const QString& permissions) override { implSetPosixPermissions(permissions); }; CommandSupportType supportGetLabel() const override { return m_GetLabel; diff --git a/src/fs/jfs.h b/src/fs/jfs.h index 8c21e69..c0b8616 100644 --- a/src/fs/jfs.h +++ b/src/fs/jfs.h @@ -41,6 +41,8 @@ public: bool resizeOnline(Report& report, const QString& deviceNode, const QString& mountPoint, qint64 length) const override; bool writeLabel(Report& report, const QString& deviceNode, const QString& newLabel) override; bool writeLabelOnline(Report& report, const QString& deviceNode, const QString& mountPoint, const QString& newLabel) override; + QString posixPermissions() const override { return implPosixPermissions(); }; + void setPosixPermissions(const QString& permissions) override { implSetPosixPermissions(permissions); }; CommandSupportType supportGetUsed() const override { return m_GetUsed; diff --git a/src/fs/minix.h b/src/fs/minix.h index d0621b2..b4bd4d2 100644 --- a/src/fs/minix.h +++ b/src/fs/minix.h @@ -31,7 +31,10 @@ public: bool check(Report& report, const QString&deviceNode) const override; bool create(Report& report, const QString&deviceNode) override; - + + QString posixPermissions() const override { return implPosixPermissions(); }; + void setPosixPermissions(const QString& permissions) override { implSetPosixPermissions(permissions); }; + CommandSupportType supportGetLabel() const override { return m_GetLabel; } diff --git a/src/fs/nilfs2.h b/src/fs/nilfs2.h index e4ffee2..4c4b7cb 100644 --- a/src/fs/nilfs2.h +++ b/src/fs/nilfs2.h @@ -41,6 +41,8 @@ public: bool resizeOnline(Report& report, const QString& deviceNode, const QString& mountPoint, qint64 length) const override; bool writeLabel(Report& report, const QString& deviceNode, const QString& newLabel) override; bool updateUUID(Report& report, const QString& deviceNode) const override; + QString posixPermissions() const override { return implPosixPermissions(); }; + void setPosixPermissions(const QString& permissions) override { implSetPosixPermissions(permissions); }; CommandSupportType supportGetUsed() const override { return m_GetUsed; diff --git a/src/fs/ocfs2.h b/src/fs/ocfs2.h index 20e9d3a..fe10466 100644 --- a/src/fs/ocfs2.h +++ b/src/fs/ocfs2.h @@ -40,6 +40,8 @@ public: bool resize(Report& report, const QString& deviceNode, qint64 length) const override; bool writeLabel(Report& report, const QString& deviceNode, const QString& newLabel) override; bool updateUUID(Report& report, const QString& deviceNode) const override; + QString posixPermissions() const override { return implPosixPermissions(); }; + void setPosixPermissions(const QString& permissions) override { implSetPosixPermissions(permissions); }; CommandSupportType supportGetUsed() const override { return m_GetUsed; diff --git a/src/fs/reiser4.h b/src/fs/reiser4.h index 5cbb7e2..468ecc6 100644 --- a/src/fs/reiser4.h +++ b/src/fs/reiser4.h @@ -38,6 +38,8 @@ public: qint64 readUsedCapacity(const QString& deviceNode) const override; bool check(Report& report, const QString& deviceNode) const override; bool create(Report& report, const QString& deviceNode) override; + QString posixPermissions() const override { return implPosixPermissions(); }; + void setPosixPermissions(const QString& permissions) override { implSetPosixPermissions(permissions); }; CommandSupportType supportGetUsed() const override { return m_GetUsed; diff --git a/src/fs/reiserfs.h b/src/fs/reiserfs.h index 0ad56a3..f058478 100644 --- a/src/fs/reiserfs.h +++ b/src/fs/reiserfs.h @@ -44,6 +44,8 @@ public: bool resizeOnline(Report& report, const QString& deviceNode, const QString& mountPoint, qint64 length) const override; bool writeLabel(Report& report, const QString& deviceNode, const QString& newLabel) override; bool updateUUID(Report& report, const QString& deviceNode) const override; + QString posixPermissions() const override { return implPosixPermissions(); }; + void setPosixPermissions(const QString& permissions) override { implSetPosixPermissions(permissions); }; CommandSupportType supportGetUsed() const override { return m_GetUsed; diff --git a/src/fs/udf.h b/src/fs/udf.h index 1dd1d46..9266691 100644 --- a/src/fs/udf.h +++ b/src/fs/udf.h @@ -38,6 +38,8 @@ public: bool createWithLabel(Report& report, const QString& deviceNode, const QString& label) override; bool writeLabel(Report& report, const QString& deviceNode, const QString& newLabel) override; bool updateUUID(Report& report, const QString& deviceNode) const override; + QString posixPermissions() const override { return implPosixPermissions(); }; + void setPosixPermissions(const QString& permissions) override { implSetPosixPermissions(permissions); }; CommandSupportType supportGetUsed() const override { return m_GetUsed; diff --git a/src/fs/xfs.h b/src/fs/xfs.h index 66aad94..2112252 100644 --- a/src/fs/xfs.h +++ b/src/fs/xfs.h @@ -41,6 +41,8 @@ public: bool resize(Report& report, const QString& deviceNode, qint64 length) const override; bool resizeOnline(Report& report, const QString& deviceNode, const QString& mountPoint, qint64 length) const override; bool writeLabel(Report& report, const QString& deviceNode, const QString& newLabel) override; + QString posixPermissions() const override { return implPosixPermissions(); }; + void setPosixPermissions(const QString& permissions) override { implSetPosixPermissions(permissions); }; CommandSupportType supportGetUsed() const override { return m_GetUsed; diff --git a/src/fs/zfs.h b/src/fs/zfs.h index 61026c3..cb4b88d 100644 --- a/src/fs/zfs.h +++ b/src/fs/zfs.h @@ -36,6 +36,8 @@ public: void init() override; bool writeLabel(Report& report, const QString& deviceNode, const QString& newLabel) override; + QString posixPermissions() const override { return implPosixPermissions(); }; + void setPosixPermissions(const QString& permissions) override { implSetPosixPermissions(permissions); }; CommandSupportType supportGetUsed() const override { return m_GetUsed; -- 2.35.1 ++++++ 0001-Add-support-for-copying-unknown-partitions.patch ++++++ >From e58ab02bac8dd33964a71e4336d072e8ca4c71ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= <[email protected]> Date: Sat, 1 Jan 2022 16:18:57 +0000 Subject: [PATCH] Add support for copying unknown partitions. BUG: 447784 --- src/fs/unknown.cpp | 1 + src/fs/unknown.h | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/src/fs/unknown.cpp b/src/fs/unknown.cpp index 156862c..6b441e2 100644 --- a/src/fs/unknown.cpp +++ b/src/fs/unknown.cpp @@ -13,6 +13,7 @@ namespace FS { FileSystem::CommandSupportType unknown::m_Move = FileSystem::cmdSupportCore; +FileSystem::CommandSupportType unknown::m_Copy = FileSystem::cmdSupportCore; unknown::unknown(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) : FileSystem(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::Unknown) diff --git a/src/fs/unknown.h b/src/fs/unknown.h index 5f06943..a279370 100644 --- a/src/fs/unknown.h +++ b/src/fs/unknown.h @@ -37,7 +37,12 @@ public: return m_Move; } + CommandSupportType supportCopy() const override { + return m_Copy; + } + static CommandSupportType m_Move; + static CommandSupportType m_Copy; }; } -- 2.35.1 ++++++ 0001-Allow-running-chmod-in-externalcommand-helper.patch ++++++ >From d2fb56bcd21f1acc881e70472cae31d3e1c8313b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= <[email protected]> Date: Tue, 28 Dec 2021 15:26:01 +0000 Subject: [PATCH] Allow running chmod in externalcommand helper. --- src/util/externalcommand_whitelist.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/util/externalcommand_whitelist.h b/src/util/externalcommand_whitelist.h index 2f97447..3af6446 100644 --- a/src/util/externalcommand_whitelist.h +++ b/src/util/externalcommand_whitelist.h @@ -18,6 +18,7 @@ QStringLiteral("udevadm"), //Core programs QStringLiteral("blockdev"), QStringLiteral("blkid"), +QStringLiteral("chmod"), QStringLiteral("partx"), QStringLiteral("sfdisk"), QStringLiteral("wipefs"), -- 2.35.1 ++++++ 0001-Changing-swap-labels-while-swap-is-active-does-not-s.patch ++++++ >From 08d2e3dc2ce14b81b5973fe84c67a87ea022b4b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= <[email protected]> Date: Sat, 15 Jan 2022 23:14:49 +0000 Subject: [PATCH] Changing swap labels while swap is active does not seem to work anymore. --- src/fs/linuxswap.cpp | 6 ------ src/fs/linuxswap.h | 4 ---- 2 files changed, 10 deletions(-) diff --git a/src/fs/linuxswap.cpp b/src/fs/linuxswap.cpp index 553dc7e..0ad5f23 100644 --- a/src/fs/linuxswap.cpp +++ b/src/fs/linuxswap.cpp @@ -122,12 +122,6 @@ bool linuxswap::writeLabel(Report& report, const QString& deviceNode, const QStr return cmd.run(-1) && cmd.exitCode() == 0; } -bool linuxswap::writeLabelOnline(Report& report, const QString& deviceNode, const QString& mountPoint, const QString& newLabel) -{ - Q_UNUSED(mountPoint) - return writeLabel(report, deviceNode, newLabel); -} - QString linuxswap::mountTitle() const { return xi18nc("@title:menu", "Activate swap"); diff --git a/src/fs/linuxswap.h b/src/fs/linuxswap.h index c6aceeb..48d8607 100644 --- a/src/fs/linuxswap.h +++ b/src/fs/linuxswap.h @@ -40,7 +40,6 @@ public: bool create(Report& report, const QString& deviceNode) override; bool resize(Report& report, const QString& deviceNode, qint64 length) const override; bool writeLabel(Report& report, const QString& deviceNode, const QString& newLabel) override; - bool writeLabelOnline(Report& report, const QString& deviceNode, const QString& mountPoint, const QString& newLabel) override; bool copy(Report& report, const QString& targetDeviceNode, const QString& sourceDeviceNode) const override; bool updateUUID(Report& report, const QString& deviceNode) const override; qint64 readUsedCapacity(const QString& deviceNode) const override; @@ -76,9 +75,6 @@ public: CommandSupportType supportSetLabel() const override { return m_SetLabel; } - CommandSupportType supportSetLabelOnline() const override { - return m_SetLabel; - } CommandSupportType supportUpdateUUID() const override { return m_UpdateUUID; } -- 2.35.1 ++++++ 0001-Fix-a-typo-in-definition-of-MiB-constant.patch ++++++ >From fb1708b95898aa626c7e2a465cd336021487199c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= <[email protected]> Date: Tue, 15 Feb 2022 19:06:12 +0000 Subject: [PATCH] Fix a typo in definition of MiB constant. --- src/util/externalcommandhelper.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/externalcommandhelper.h b/src/util/externalcommandhelper.h index de10de7..bb1995f 100644 --- a/src/util/externalcommandhelper.h +++ b/src/util/externalcommandhelper.h @@ -21,7 +21,7 @@ #include <QString> class QDBusServiceWatcher; -constexpr qint64 MiB = 1 << 30; +constexpr qint64 MiB = 1 << 20; class ExternalCommandHelper : public QObject, public QDBusContext { -- 2.35.1 ++++++ 0001-Fix-davfs-entries-being-omitted-from-fstab-file.patch ++++++ >From 5ffc5c6f238c70735637035456a9484f4f0f41dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= <[email protected]> Date: Wed, 5 Jan 2022 23:00:17 +0000 Subject: [PATCH] Fix davfs entries being omitted from fstab file. BUG: 447961 --- src/core/fstab.cpp | 6 ++++-- src/core/fstab.h | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/core/fstab.cpp b/src/core/fstab.cpp index 486046b..ad3324f 100644 --- a/src/core/fstab.cpp +++ b/src/core/fstab.cpp @@ -240,7 +240,8 @@ static QString findBlkIdDevice(const char *token, const QString& value) static void parseFsSpec(const QString& m_fsSpec, FstabEntry::Type& m_entryType, QString& m_deviceNode) { - m_entryType = FstabEntry::Type::comment; + m_entryType = FstabEntry::Type::other; + m_deviceNode = m_fsSpec; if (m_fsSpec.startsWith(QStringLiteral("UUID="))) { m_entryType = FstabEntry::Type::uuid; m_deviceNode = findBlkIdDevice("UUID", QString(m_fsSpec).remove(QStringLiteral("UUID="))); @@ -255,7 +256,8 @@ static void parseFsSpec(const QString& m_fsSpec, FstabEntry::Type& m_entryType, m_deviceNode = findBlkIdDevice("PARTLABEL", QString(m_fsSpec).remove(QStringLiteral("PARTLABEL="))); } else if (m_fsSpec.startsWith(QStringLiteral("/"))) { m_entryType = FstabEntry::Type::deviceNode; - m_deviceNode = m_fsSpec; + } else if (m_fsSpec.isEmpty()) { + m_entryType = FstabEntry::Type::comment; } } diff --git a/src/core/fstab.h b/src/core/fstab.h index 27880a5..be3efe4 100644 --- a/src/core/fstab.h +++ b/src/core/fstab.h @@ -26,7 +26,7 @@ struct FstabEntryPrivate; class LIBKPMCORE_EXPORT FstabEntry { public: - enum class Type { deviceNode, uuid, label, partlabel, partuuid, comment }; + enum class Type { deviceNode, uuid, label, partlabel, partuuid, comment, other }; FstabEntry(const QString& fsSpec, const QString& mountPoint, const QString& type, const QString& options, int dumpFreq = 0, int passNumber = 0, const QString& comment = QString()); -- 2.35.1 ++++++ 0001-Move-the-changePosixPermission-to-the-Filesystem.patch ++++++ >From 9093b27bd819f6418dd654497dff2bc7cada539a Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Sun, 12 Dec 2021 19:36:14 +0000 Subject: [PATCH] Move the changePosixPermission to the Filesystem And implement it on ext2, 3, 4. I don't know all the filesystems that can have posix permissions, those three will do. if we need more in the future we implement them, it's two lines of code. --- src/core/partition.cpp | 19 ---------- src/core/partition.h | 8 ---- src/fs/ext2.h | 3 ++ src/fs/ext3.h | 3 ++ src/fs/ext4.h | 3 ++ src/fs/filesystem.cpp | 63 +++++++++++++++++++++++++++++++ src/fs/filesystem.h | 11 ++++++ src/jobs/changepermissionsjob.cpp | 4 +- 8 files changed, 86 insertions(+), 28 deletions(-) diff --git a/src/fs/ext2.h b/src/fs/ext2.h index 07c6abf..58e51b8 100644 --- a/src/fs/ext2.h +++ b/src/fs/ext2.h @@ -91,6 +91,9 @@ public: SupportTool supportToolName() const override; bool supportToolFound() const override; + QString posixPermissions() const override { return implPosixPermissions(); }; + void setPosixPermissions(const QString& permissions) override { implSetPosixPermissions(permissions); }; + public: static CommandSupportType m_GetUsed; static CommandSupportType m_GetLabel; diff --git a/src/fs/ext3.h b/src/fs/ext3.h index af4b1d3..99b6f6f 100644 --- a/src/fs/ext3.h +++ b/src/fs/ext3.h @@ -42,6 +42,9 @@ public: CommandSupportType supportGrowOnline() const override { return m_Grow; } + + QString posixPermissions() const override { return implPosixPermissions(); }; + void setPosixPermissions(const QString& permissions) override { implSetPosixPermissions(permissions); }; }; } diff --git a/src/fs/ext4.h b/src/fs/ext4.h index 821b6a7..b631a8c 100644 --- a/src/fs/ext4.h +++ b/src/fs/ext4.h @@ -42,6 +42,9 @@ public: CommandSupportType supportGrowOnline() const override { return m_Grow; } + + QString posixPermissions() const override { return implPosixPermissions(); }; + void setPosixPermissions(const QString& permissions) override { implSetPosixPermissions(permissions); }; }; } diff --git a/src/fs/filesystem.cpp b/src/fs/filesystem.cpp index e046fa5..ec57a1f 100644 --- a/src/fs/filesystem.cpp +++ b/src/fs/filesystem.cpp @@ -31,6 +31,7 @@ #include <QFileInfo> #include <QStandardPaths> #include <QStorageInfo> +#include <QTemporaryDir> const std::vector<QColor> FileSystem::defaultColorCode = { @@ -80,6 +81,7 @@ struct FileSystemPrivate { qint64 m_SectorsUsed; QString m_Label; QString m_UUID; + QString m_posixPermissions; QStringList m_AvailableFeatures; QVariantMap m_Features; }; @@ -126,6 +128,67 @@ FileSystem::~FileSystem() { } +QString FileSystem::implPosixPermissions() const +{ + return d->m_posixPermissions; +} + +void FileSystem::implSetPosixPermissions(const QString& permissions) +{ + d->m_posixPermissions = permissions; +} + + +bool FileSystem::execChangePosixPermission(Report& report, const QString& deviceNode) +{ + // do nothing if the posix permissions is not used here. + if (d->m_posixPermissions.isEmpty()) { + return true; + } + + QTemporaryDir tmpDir; + + ExternalCommand mountCmd(report, QStringLiteral("mount"), + { deviceNode, tmpDir.path() }); + + bool step = mountCmd.run() && mountCmd.exitCode() == 0; + if (!step) { + return false; + } + + ExternalCommand chmodCmd(report, QStringLiteral("chmod"), + // forcing recursive, should be empty but + // programming is weird. + { + d->m_posixPermissions, + tmpDir.path(), + QStringLiteral("-R") + }); + + const bool chmodStep = chmodCmd.run() && chmodCmd.exitCode() == 0; + + ExternalCommand umountCmd(report, QStringLiteral("umount"), + // forcing recursive, should be empty but + // programming is weird. + { + deviceNode, + }); + + const bool umountStep = umountCmd.run() && umountCmd.exitCode() == 0; + + // we can't return false if chmodStep fails because we still need to umount + // the drive. + if (!chmodStep) { + return false; + } + + if (!umountStep) { + return false; + } + + return true; +} + /** Reads the capacity in use on this FileSystem @param deviceNode the device node for the Partition the FileSystem is on @return the used capacity in bytes or -1 in case of an error diff --git a/src/fs/filesystem.h b/src/fs/filesystem.h index c7b8093..724d7b1 100644 --- a/src/fs/filesystem.h +++ b/src/fs/filesystem.h @@ -113,6 +113,9 @@ protected: FileSystem(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, FileSystem::Type type); FileSystem(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features, FileSystem::Type type); + QString implPosixPermissions() const; + void implSetPosixPermissions(const QString& permissions); + public: virtual ~FileSystem(); @@ -199,6 +202,14 @@ public: virtual SupportTool supportToolName() const; virtual bool supportToolFound() const; + virtual QString posixPermissions() const { return QString{}; }; + virtual void setPosixPermissions(const QString& permissions) { Q_UNUSED(permissions); }; + + // Tries to change the posix permission on the filesystem, if the + // filesystem supports it. by supports I mean reimplements `posixPermissions()` + // and setPosixPermissions. + bool execChangePosixPermission(Report& report, const QString& deviceNode); + /** * Returns the (possibly translated) name of the type of this filesystem. * @see nameForType() diff --git a/src/jobs/changepermissionsjob.cpp b/src/jobs/changepermissionsjob.cpp index eabca29..98320b6 100644 --- a/src/jobs/changepermissionsjob.cpp +++ b/src/jobs/changepermissionsjob.cpp @@ -27,9 +27,11 @@ bool ChangePermissionJob::run(Report& parent) { bool rval = false; + auto &fs = m_Partition.fileSystem(); + Report* report = jobStarted(parent); - rval = m_Partition.execChangePermission(*report); + rval = fs.execChangePosixPermission(*report, m_Partition.deviceNode()); jobFinished(*report, rval); -- 2.35.1 ++++++ 0001-Rename-blockSize-to-chunkSize-to-avoid-confusion-wit.patch ++++++ >From 27b85117c4109ccf1deee9dfacd4b88bf3bdc98a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= <[email protected]> Date: Sun, 20 Feb 2022 14:41:16 +0000 Subject: [PATCH] Rename blockSize to chunkSize to avoid confusion with physical blocks. --- src/util/externalcommandhelper.cpp | 52 +++++++++++++++--------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/src/util/externalcommandhelper.cpp b/src/util/externalcommandhelper.cpp index e2566cf..ce3b6cf 100644 --- a/src/util/externalcommandhelper.cpp +++ b/src/util/externalcommandhelper.cpp @@ -156,19 +156,19 @@ bool ExternalCommandHelper::CreateFile(const QString &filePath, const QByteArray } // If targetDevice is empty then return QByteArray with data that was read from disk. -QVariantMap ExternalCommandHelper::CopyFileData(const QString& sourceDevice, const qint64 sourceOffset, const qint64 sourceLength, const QString& targetDevice, const qint64 targetOffset, const qint64 blockSize) +QVariantMap ExternalCommandHelper::CopyFileData(const QString& sourceDevice, const qint64 sourceOffset, const qint64 sourceLength, const QString& targetDevice, const qint64 targetOffset, const qint64 chunkSize) { if (!isCallerAuthorized()) { return {}; } // Avoid division by zero further down - if (!blockSize) { + if (!chunkSize) { return {}; } // Prevent some out of memory situations - if (blockSize > 100 * MiB) { + if (chunkSize > 100 * MiB) { return {}; } @@ -187,13 +187,13 @@ QVariantMap ExternalCommandHelper::CopyFileData(const QString& sourceDevice, con QVariantMap reply; reply[QStringLiteral("success")] = true; - // This enum specified whether individual blocks are moved left or right + // This enum specified whether individual data chunks are moved left or right // When source and target devices are the same we have to be careful not to overwrite // source data with newly written data. We don't have to do this if sourceDevice is not // targetDevice but there are no disadvantages in applying the same scheme. - // When partition is moved to the left, we start with the leftmost block, - // and move it further left, then second leftmost block and so on. - // But when we move partition to the right, we start with rightmost block. + // When partition is moved to the left, we start with the leftmost chunk, + // and move it further left, then second leftmost chunk and so on. + // But when we move partition to the right, we start with rightmost chunk. // To account for this difference, we introduce CopyDirection variable which takes // care of some of the differences in offset calculation between these two cases. enum CopyDirection : qint8 { @@ -202,26 +202,26 @@ QVariantMap ExternalCommandHelper::CopyFileData(const QString& sourceDevice, con }; qint8 copyDirection = targetOffset > sourceOffset ? CopyDirection::Right : CopyDirection::Left; - // Let readOffset (r) and writeOffset (w) be the offsets of the first block that we move. + // Let readOffset (r) and writeOffset (w) be the offsets of the first chunk that we move. // When we move data to the left: // ______target______ ______source______ // r <- w================= qint64 readOffset = sourceOffset; qint64 writeOffset = targetOffset; - // When we move data to the right, we start moving data from the last block + // When we move data to the right, we start moving data from the last chunk // ______source______ ______target______ // =================r -> w if (copyDirection == CopyDirection::Right) { - readOffset = sourceOffset + sourceLength - blockSize; - writeOffset = targetOffset + sourceLength - blockSize; + readOffset = sourceOffset + sourceLength - chunkSize; + writeOffset = targetOffset + sourceLength - chunkSize; } - const qint64 blocksToCopy = sourceLength / blockSize; - const qint64 lastBlock = sourceLength % blockSize; + const qint64 chunksToCopy = sourceLength / chunkSize; + const qint64 lastBlock = sourceLength % chunkSize; qint64 bytesWritten = 0; - qint64 blocksCopied = 0; + qint64 chunksCopied = 0; QByteArray buffer; int percent = 0; @@ -229,7 +229,7 @@ QVariantMap ExternalCommandHelper::CopyFileData(const QString& sourceDevice, con timer.start(); - QString reportText = xi18nc("@info:progress", "Copying %1 blocks (%2 bytes) from %3 to %4, direction: %5.", blocksToCopy, + QString reportText = xi18nc("@info:progress", "Copying %1 chunks (%2 bytes) from %3 to %4, direction: %5.", chunksToCopy, sourceLength, readOffset, writeOffset, copyDirection == CopyDirection::Left ? i18nc("direction: left", "left") : i18nc("direction: right", "right")); Q_EMIT report(reportText); @@ -238,20 +238,20 @@ QVariantMap ExternalCommandHelper::CopyFileData(const QString& sourceDevice, con QFile target(targetDevice); QFile source(sourceDevice); - while (blocksCopied < blocksToCopy) { - if (!(rval = readData(source, buffer, readOffset + blockSize * blocksCopied * copyDirection, blockSize))) + while (chunksCopied < chunksToCopy) { + if (!(rval = readData(source, buffer, readOffset + chunkSize * chunksCopied * copyDirection, chunkSize))) break; - if (!(rval = writeData(target, buffer, writeOffset + blockSize * blocksCopied * copyDirection))) + if (!(rval = writeData(target, buffer, writeOffset + chunkSize * chunksCopied * copyDirection))) break; bytesWritten += buffer.size(); - if (++blocksCopied * 100 / blocksToCopy != percent) { - percent = blocksCopied * 100 / blocksToCopy; + if (++chunksCopied * 100 / chunksToCopy != percent) { + percent = chunksCopied * 100 / chunksToCopy; if (percent % 5 == 0 && timer.elapsed() > 1000) { - const qint64 mibsPerSec = (blocksCopied * blockSize / 1024 / 1024) / (timer.elapsed() / 1000); + const qint64 mibsPerSec = (chunksCopied * chunkSize / 1024 / 1024) / (timer.elapsed() / 1000); const qint64 estSecsLeft = (100 - percent) * timer.elapsed() / percent / 1000; reportText = xi18nc("@info:progress", "Copying %1 MiB/second, estimated time left: %2", mibsPerSec, QTime(0, 0).addSecs(estSecsLeft).toString()); Q_EMIT report(reportText); @@ -262,11 +262,11 @@ QVariantMap ExternalCommandHelper::CopyFileData(const QString& sourceDevice, con // copy the remainder if (rval && lastBlock > 0) { - Q_ASSERT(lastBlock < blockSize); + Q_ASSERT(lastBlock < chunkSize); - const qint64 lastBlockReadOffset = copyDirection == CopyDirection::Left ? readOffset + blockSize * blocksCopied : sourceOffset; - const qint64 lastBlockWriteOffset = copyDirection == CopyDirection::Left ? writeOffset + blockSize * blocksCopied : targetOffset; - reportText = xi18nc("@info:progress", "Copying remainder of block size %1 from %2 to %3.", lastBlock, lastBlockReadOffset, lastBlockWriteOffset); + const qint64 lastBlockReadOffset = copyDirection == CopyDirection::Left ? readOffset + chunkSize * chunksCopied : sourceOffset; + const qint64 lastBlockWriteOffset = copyDirection == CopyDirection::Left ? writeOffset + chunkSize * chunksCopied : targetOffset; + reportText = xi18nc("@info:progress", "Copying remainder of chunk size %1 from %2 to %3.", lastBlock, lastBlockReadOffset, lastBlockWriteOffset); Q_EMIT report(reportText); rval = readData(source, buffer, lastBlockReadOffset, lastBlock); @@ -280,7 +280,7 @@ QVariantMap ExternalCommandHelper::CopyFileData(const QString& sourceDevice, con } } - reportText = xi18ncp("@info:progress argument 2 is a string such as 7 bytes (localized accordingly)", "Copying 1 block (%2) finished.", "Copying %1 blocks (%2) finished.", blocksCopied, i18np("1 byte", "%1 bytes", bytesWritten)); + reportText = xi18ncp("@info:progress argument 2 is a string such as 7 bytes (localized accordingly)", "Copying 1 chunk (%2) finished.", "Copying %1 chunks (%2) finished.", chunksCopied, i18np("1 byte", "%1 bytes", bytesWritten)); Q_EMIT report(reportText); reply[QStringLiteral("success")] = rval; -- 2.35.1 ++++++ 0001-Rename-variables-into-more-appropriate-fstabPath-and.patch ++++++ >From d92ebc0b760939cf0f1644af99c42907fe68eb9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= <[email protected]> Date: Sun, 20 Feb 2022 20:47:43 +0000 Subject: [PATCH] Rename variables into more appropriate fstabPath and fstabFile. --- src/util/externalcommandhelper.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/util/externalcommandhelper.cpp b/src/util/externalcommandhelper.cpp index 9cf8e32..6da2a21 100644 --- a/src/util/externalcommandhelper.cpp +++ b/src/util/externalcommandhelper.cpp @@ -134,17 +134,17 @@ bool ExternalCommandHelper::WriteFstab(const QByteArray& fileContents) if (!isCallerAuthorized()) { return false; } - QString filePath = QStringLiteral("/etc/fstab"); - QFile device(filePath); + QString fstabPath = QStringLiteral("/etc/fstab"); + QFile fstabFile(fstabPath); auto flags = QIODevice::WriteOnly | QIODevice::Unbuffered; - if (!device.open(flags)) { - qCritical() << xi18n("Could not open file <filename>%1</filename> for writing.", filePath); + if (!fstabFile.open(flags)) { + qCritical() << xi18n("Could not open file <filename>%1</filename> for writing.", fstabPath); return false; } - if (device.write(fileContents) != fileContents.size()) { - qCritical() << xi18n("Could not write to file <filename>%1</filename>.", filePath); + if (fstabFile.write(fileContents) != fileContents.size()) { + qCritical() << xi18n("Could not write to file <filename>%1</filename>.", fstabPath); return false; } -- 2.35.1 ++++++ 0001-Restrict-CreateFile-method-to-WriteFstab-method-in-p.patch ++++++ >From e483bab0d5ac409c9b484e9e154b06a1a3a77f9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= <[email protected]> Date: Sun, 20 Feb 2022 19:42:25 +0000 Subject: [PATCH] Restrict CreateFile method to WriteFstab method in polkit helper. --- src/core/fstab.cpp | 4 ++-- src/core/fstab.h | 2 +- src/util/externalcommand.cpp | 4 ++-- src/util/externalcommand.h | 2 +- src/util/externalcommandhelper.cpp | 8 ++------ src/util/externalcommandhelper.h | 2 +- 6 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/core/fstab.cpp b/src/core/fstab.cpp index ad3324f..116e1d4 100644 --- a/src/core/fstab.cpp +++ b/src/core/fstab.cpp @@ -295,7 +295,7 @@ static void writeEntry(QTextStream& s, const FstabEntry& entry, std::array<unsig << entry.comment() << "\n"; } -bool writeMountpoints(const FstabEntryList& fstabEntries, const QString& filename) +bool writeMountpoints(const FstabEntryList& fstabEntries) { QString fstabContents; QTextStream out(&fstabContents); @@ -306,5 +306,5 @@ bool writeMountpoints(const FstabEntryList& fstabEntries, const QString& filenam writeEntry(out, e, columnWidth); ExternalCommand cmd; - return cmd.createFile(fstabContents.toLocal8Bit(), filename); + return cmd.writeFstab(fstabContents.toLocal8Bit()); } diff --git a/src/core/fstab.h b/src/core/fstab.h index be3efe4..1b38e7b 100644 --- a/src/core/fstab.h +++ b/src/core/fstab.h @@ -116,6 +116,6 @@ QString unescapeSpaces(const QString& mountPoint); LIBKPMCORE_EXPORT FstabEntryList readFstabEntries(const QString& fstabPath = QStringLiteral("/etc/fstab")); LIBKPMCORE_EXPORT QStringList possibleMountPoints(const QString& deviceNode, const QString& fstabPath = QStringLiteral("/etc/fstab")); -LIBKPMCORE_EXPORT bool writeMountpoints(const FstabEntryList& fstabEntries, const QString& filename = QStringLiteral("/etc/fstab")); +LIBKPMCORE_EXPORT bool writeMountpoints(const FstabEntryList& fstabEntries); #endif diff --git a/src/util/externalcommand.cpp b/src/util/externalcommand.cpp index 0bcd7c3..7b5a7d2 100644 --- a/src/util/externalcommand.cpp +++ b/src/util/externalcommand.cpp @@ -231,13 +231,13 @@ bool ExternalCommand::writeData(Report& commandReport, const QByteArray& buffer, return waitForDbusReply(pcall); } -bool ExternalCommand::createFile(const QByteArray& fileContents, const QString& filePath) +bool ExternalCommand::writeFstab(const QByteArray& fileContents) { auto interface = helperInterface(); if (!interface) return false; - QDBusPendingCall pcall = interface->CreateFile(filePath, fileContents); + QDBusPendingCall pcall = interface->WriteFstab(fileContents); return waitForDbusReply(pcall); } diff --git a/src/util/externalcommand.h b/src/util/externalcommand.h index 4297983..9816f4c 100644 --- a/src/util/externalcommand.h +++ b/src/util/externalcommand.h @@ -57,7 +57,7 @@ public: bool copyBlocks(const CopySource& source, CopyTarget& target); QByteArray readData(const CopySourceDevice& source); bool writeData(Report& commandReport, const QByteArray& buffer, const QString& deviceNode, const quint64 firstByte); // same as copyBlocks but from QByteArray - bool createFile(const QByteArray& filePath, const QString& fileContents); // similar to writeData but creates a new file + bool writeFstab(const QByteArray& fileContents); /**< @param cmd the command to run */ void setCommand(const QString& cmd); diff --git a/src/util/externalcommandhelper.cpp b/src/util/externalcommandhelper.cpp index ce3b6cf..9cf8e32 100644 --- a/src/util/externalcommandhelper.cpp +++ b/src/util/externalcommandhelper.cpp @@ -126,19 +126,15 @@ bool ExternalCommandHelper::writeData(QFile& device, const QByteArray& buffer, c } /** Creates a new file with given contents. - @param filePath file to write to @param fileContents the data that we write @return true on success */ -bool ExternalCommandHelper::CreateFile(const QString &filePath, const QByteArray& fileContents) +bool ExternalCommandHelper::WriteFstab(const QByteArray& fileContents) { if (!isCallerAuthorized()) { return false; } - // Do not allow using this helper for writing to arbitrary location - if ( filePath != QStringLiteral("/etc/fstab") ) - return false; - + QString filePath = QStringLiteral("/etc/fstab"); QFile device(filePath); auto flags = QIODevice::WriteOnly | QIODevice::Unbuffered; diff --git a/src/util/externalcommandhelper.h b/src/util/externalcommandhelper.h index bb1995f..0954e8e 100644 --- a/src/util/externalcommandhelper.h +++ b/src/util/externalcommandhelper.h @@ -43,7 +43,7 @@ public Q_SLOTS: const QString& targetDevice, const qint64 targetOffset, const qint64 blockSize); Q_SCRIPTABLE QByteArray ReadData(const QString& device, const qint64 offset, const qint64 length); Q_SCRIPTABLE bool WriteData(const QByteArray& buffer, const QString& targetDevice, const qint64 targetOffset); - Q_SCRIPTABLE bool CreateFile(const QString& filePath, const QByteArray& fileContents); + Q_SCRIPTABLE bool WriteFstab(const QByteArray& fileContents); private: bool isCallerAuthorized(); -- 2.35.1 ++++++ 0001-Set-false-as-the-default-return-value-and-change-it-.patch ++++++ >From 7e7202a02de3a0b531ddc59d79196659fc97ec82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= <[email protected]> Date: Tue, 15 Feb 2022 19:56:46 +0000 Subject: [PATCH] Set "false" as the default return value and change it to "true" on success. --- src/util/externalcommandhelper.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/util/externalcommandhelper.cpp b/src/util/externalcommandhelper.cpp index a61dcba..58edd93 100644 --- a/src/util/externalcommandhelper.cpp +++ b/src/util/externalcommandhelper.cpp @@ -334,10 +334,9 @@ QVariantMap ExternalCommandHelper::RunCommand(const QString& command, const QStr } QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8")); QVariantMap reply; - reply[QStringLiteral("success")] = true; + reply[QStringLiteral("success")] = false; if (command.isEmpty()) { - reply[QStringLiteral("success")] = false; return reply; } @@ -345,7 +344,6 @@ QVariantMap ExternalCommandHelper::RunCommand(const QString& command, const QStr QString basename = command.mid(command.lastIndexOf(QLatin1Char('/')) + 1); if (allowedCommands.find(basename) == allowedCommands.end()) { // TODO: C++20: replace with contains qInfo() << command <<" command is not one of the whitelisted command"; - reply[QStringLiteral("success")] = false; return reply; } @@ -355,7 +353,6 @@ QVariantMap ExternalCommandHelper::RunCommand(const QString& command, const QStr cmd.setEnvironment( { QStringLiteral("LVM_SUPPRESS_FD_WARNINGS=1") } ); if((processChannelMode != QProcess::SeparateChannels) && (processChannelMode != QProcess::MergedChannels)) { - reply[QStringLiteral("success")] = false; return reply; } cmd.setProcessChannelMode(static_cast<QProcess::ProcessChannelMode>(processChannelMode)); @@ -367,6 +364,7 @@ QVariantMap ExternalCommandHelper::RunCommand(const QString& command, const QStr reply[QStringLiteral("output")] = output; reply[QStringLiteral("exitCode")] = cmd.exitCode(); + reply[QStringLiteral("success")] = true; return reply; } -- 2.35.1 ++++++ 0001-Update-description-of-polkit-helper.patch ++++++ >From 5717c3aa0bcff02134288483885f64c7b337649d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= <[email protected]> Date: Tue, 8 Feb 2022 21:39:18 +0000 Subject: [PATCH] Update description of polkit helper. --- src/util/org.kde.kpmcore.externalcommand.policy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/org.kde.kpmcore.externalcommand.policy b/src/util/org.kde.kpmcore.externalcommand.policy index a9b0cdb..2995497 100644 --- a/src/util/org.kde.kpmcore.externalcommand.policy +++ b/src/util/org.kde.kpmcore.externalcommand.policy @@ -9,7 +9,7 @@ SPDX-License-Identifier: CC0-1.0 <policyconfig> <icon_name>partitionmanager</icon_name> <action id="org.kde.kpmcore.externalcommand.init" > - <description>Start external command daemon</description> + <description>Run privileged partition manager helper</description> <description xml:lang="ast">Aniciu del degorriu de comandos esternos</description> <description xml:lang="ca">Inicia el dimoni d'ordres externes</description> <description xml:lang="ca@valencia">Inicia el dimoni d'ordres externes</description> -- 2.35.1 ++++++ kpmcore-3.3.0.tar.xz -> kpmcore-21.12.3.tar.xz ++++++ ++++ 307142 lines of diff (skipped)
