Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 9fa20fb1 authored by Andrius Štikonas's avatar Andrius Štikonas

Remove "mv" command from allowed external command list

parent 77add454
......@@ -19,6 +19,7 @@
#include "core/fstab.h"
#include "util/externalcommand.h"
#include "util/report.h"
#if defined(Q_OS_LINUX)
#include <blkid/blkid.h>
......@@ -228,9 +229,8 @@ static void parseFsSpec(const QString& m_fsSpec, FstabEntry::Type& m_entryType,
}
}
static void writeEntry(QFile& output, const FstabEntry& entry)
static void writeEntry(QTextStream& s, const FstabEntry& entry)
{
QTextStream s(&output);
if (entry.entryType() == FstabEntry::Type::comment) {
s << entry.comment() << "\n";
return;
......@@ -256,32 +256,13 @@ static void writeEntry(QFile& output, const FstabEntry& entry)
bool writeMountpoints(const FstabEntryList& fstabEntries, const QString& filename)
{
QTemporaryFile out;
out.setAutoRemove(false);
if (!out.open()) {
qWarning() << "could not open output file " << out.fileName();
return false;
} else {
for (const auto &e : fstabEntries)
writeEntry(out, e);
out.close();
const QString bakFilename = QStringLiteral("%1.bak").arg(filename);
ExternalCommand mvCmd(QStringLiteral("mv"), { filename, bakFilename } );
if ( !(mvCmd.run(-1) && mvCmd.exitCode() == 0) ) {
qWarning() << "could not backup " << filename << " to " << bakFilename;
return false;
}
ExternalCommand mvCmd2(QStringLiteral("mv"), { out.fileName(), filename } );
Report report(nullptr);
QByteArray fstabContents;
QTextStream out(&fstabContents);
if ( !(mvCmd2.run(-1) && mvCmd2.exitCode() == 0) ) {
qWarning() << "could not move " << out.fileName() << " to " << filename;
return false;
}
}
for (const auto &e : fstabEntries)
writeEntry(out, e);
return true;
ExternalCommand cmd;
return cmd.writeData(report, fstabContents, filename, 0);
}
......@@ -151,19 +151,14 @@ Device* SfdiskBackend::scanDevice(const QString& deviceNode)
QRegularExpressionMatchIterator i = re.globalMatch(content);
while (i.hasNext()) {
QRegularExpressionMatch reMatch = i.next();
QString name = reMatch.captured(1);
if ((QStringLiteral("/dev/md") + name) == deviceNode) {
Log(Log::Level::information) << xi18nc("@info:status", "Software RAID Device found: %1", deviceNode);
d = new SoftwareRAID( QStringLiteral("md") + name, SoftwareRAID::Status::Active );
break;
}
}
}
......
......@@ -19,9 +19,6 @@
#define KPMCORE_EXTERNALCOMMAND_WHITELIST_H
QString allowedCommands[] = {
// TODO try to remove these later
QStringLiteral("mv"),
// TODO no root needed
QStringLiteral("lsblk"),
QStringLiteral("udevadm"),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment