Skip to content

Commit

Permalink
refactor: [security] Injection risk
Browse files Browse the repository at this point in the history
Use the start method of QProcess and pass the arguments as separate strings

Log: security
  • Loading branch information
Johnson-zs committed Sep 19, 2024
1 parent e3b9a8a commit c7875fc
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions src/plugins/daemon/daemonplugin-accesscontrol/accesscontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,28 @@ void AccessControl::createUserMountDir(const QString &objPath)
}
}
// ACL
QString aclCmd = QString("setfacl -m o:rx %1").arg(userMountRoot);
QProcess::execute(aclCmd);
fmInfo() << "acl the /media/anyuser folder";
// ACL
QStringList aclCmd;
aclCmd << "-m" << "o:rx" << userMountRoot;

QProcess process;
process.start("setfacl", aclCmd);

if (!process.waitForFinished(3000)) {
fmWarning() << "Failed to execute command:" << process.errorString();
} else {
// 检查返回值
if (process.exitStatus() == QProcess::CrashExit) {
fmWarning() << "Process crashed";
} else {
int exitCode = process.exitCode();
if (exitCode != 0) {
fmWarning() << "Command failed with exit code:" << exitCode;
} else {
fmInfo() << "Command: setfacl" << aclCmd << "executed successfully.";
}
}
}
}

void AccessControl::createUserMountDirs()
Expand Down

0 comments on commit c7875fc

Please sign in to comment.