Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复隐藏的安全隐患 #18

Merged
merged 2 commits into from
Jun 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/src/corelib/clonejob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,12 +344,12 @@ void CloneJob::run()
return;
}

Helper::processExec(QString("fsck -f -y %1").arg(info.indexNumber()));
Helper::processExec("fsck", {"-f", "-y", QString::number(info.indexNumber())});

if (info.fileSystemType() == DPartInfo::EXT4
|| info.fileSystemType() == DPartInfo::EXT3
|| info.fileSystemType() == DPartInfo::EXT2) {
Helper::processExec(QString("resize2fs -p -f %1").arg(info.indexNumber()));
Helper::processExec("resize2fs", {"-p", "-f", QString::number(info.indexNumber())});
}
}

Expand Down
23 changes: 12 additions & 11 deletions app/src/corelib/ddevicediskinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

static QString getPTName(const QString &device)
{
Helper::processExec(QStringLiteral("/sbin/blkid -p -s PTTYPE -d -i %1").arg(device));
Helper::processExec("/sbin/blkid", {"-p", "-s", "PTTYPE", "-d", "-i", device});

const QByteArray &data = Helper::lastProcessStandardOutput();

Expand Down Expand Up @@ -182,7 +182,7 @@ void DDeviceDiskInfoPrivate::refresh()
{
children.clear();

const QJsonArray &block_devices = Helper::getBlockDevices(name);
const QJsonArray &block_devices = Helper::getBlockDevices({name});

if (!block_devices.isEmpty())
init(block_devices.first().toObject());
Expand Down Expand Up @@ -259,9 +259,9 @@ bool DDeviceDiskInfoPrivate::openDataStream(int index)
}

if (currentMode == DDiskInfo::Read) {
process->start(QStringLiteral("dd if=%1 bs=512 count=2048 status=none").arg(filePath()), QIODevice::ReadOnly);
process->start("dd", {QString("if=%1").arg(filePath()), "bs=512", "count=2048", "status=none"}, QIODevice::ReadOnly);
} else {
process->start(QStringLiteral("dd of=%1 bs=512 status=none conv=fsync").arg(filePath()));
process->start("dd", {QString("of=%1").arg(filePath()), "bs=512", "status=none", "conv=fsync"});
}

break;
Expand All @@ -274,9 +274,9 @@ bool DDeviceDiskInfoPrivate::openDataStream(int index)
}

if (currentMode == DDiskInfo::Read)
process->start(QStringLiteral("sfdisk -d %1").arg(filePath()), QIODevice::ReadOnly);
process->start("sfdisk", {"-d", filePath()}, QIODevice::ReadOnly);
else
process->start(QStringLiteral("sfdisk %1 --no-reread").arg(filePath()));
process->start("sfdisk", {filePath(), "--no-reread"});

break;
}
Expand All @@ -302,10 +302,11 @@ bool DDeviceDiskInfoPrivate::openDataStream(int index)
}

if (currentMode == DDiskInfo::Read) {
const QString &executer = Helper::getPartcloneExecuter(part);
process->start(QStringLiteral("%1 -s %2 -o - -c -z %3 -L /tmp/partclone.log").arg(executer).arg(part.filePath()).arg(Global::bufferSize), QIODevice::ReadOnly);
QStringList args = {"-s", part.filePath(), "-o", "-", "-c", "-z", QString::number(Global::bufferSize), "-L", "/var/log/partclone.log"};
const QString &executer = Helper::getPartcloneExecuter(part, args);
process->start(executer, args, QIODevice::ReadOnly);
} else {
process->start(QStringLiteral("partclone.restore -s - -o %2 -z %3 -L /tmp/partclone.log").arg(part.filePath()).arg(Global::bufferSize));
process->start("partclone.restore", {"-s", "-", "-o", part.filePath(), "-z", QString::number(Global::bufferSize), "-L", "/var/log/partclone.log"});
}

break;
Expand Down Expand Up @@ -520,7 +521,7 @@ DDeviceDiskInfo::DDeviceDiskInfo()

DDeviceDiskInfo::DDeviceDiskInfo(const QString &filePath)
{
const QJsonArray &block_devices = Helper::getBlockDevices(filePath);
const QJsonArray &block_devices = Helper::getBlockDevices({filePath});

if (!block_devices.isEmpty()) {
const QJsonObject &obj = block_devices.first().toObject();
Expand All @@ -529,7 +530,7 @@ DDeviceDiskInfo::DDeviceDiskInfo(const QString &filePath)
d_func()->init(obj);

if (d->type == Part) {
const QJsonArray &parent = Helper::getBlockDevices(obj.value("pkname").toString());
const QJsonArray &parent = Helper::getBlockDevices({obj.value("pkname").toString()});

if (!parent.isEmpty()) {
const QJsonObject &parent_obj = parent.first().toObject();
Expand Down
4 changes: 2 additions & 2 deletions app/src/corelib/ddevicepartinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ void DDevicePartInfoPrivate::init(const QJsonObject &obj)
sizeEnd = size - 1;
index = 0;
} else {
int code = Helper::processExec(QStringLiteral("partx %1 -b -P -o START,END,SECTORS,SIZE,TYPE,NR,UUID").arg(name));
int code = Helper::processExec("partx", {name, "-b", "-P", "-o", "START,END,SECTORS,SIZE,TYPE,NR,UUID"});

if (code == 0) {
const QByteArray &data = Helper::lastProcessStandardOutput();
Expand Down Expand Up @@ -185,7 +185,7 @@ DDevicePartInfo::DDevicePartInfo()
DDevicePartInfo::DDevicePartInfo(const QString &name)
: DPartInfo(new DDevicePartInfoPrivate(this))
{
const QJsonArray &block_devices = Helper::getBlockDevices(name);
const QJsonArray &block_devices = Helper::getBlockDevices({name});

if (!block_devices.isEmpty()) {
const QJsonObject &obj = block_devices.first().toObject();
Expand Down
Loading