commit 69bf6829d8bc8d5ff5b8c0458639c11d078ddc12 Author: CentOS Sources Date: Thu Apr 23 23:06:34 2020 +0000 import scap-workbench-1.2.0-4.el8 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..358b156 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +SOURCES/scap-workbench-1.2.0.tar.bz2 diff --git a/.scap-workbench.metadata b/.scap-workbench.metadata new file mode 100644 index 0000000..013ce4c --- /dev/null +++ b/.scap-workbench.metadata @@ -0,0 +1 @@ +50904817a4b01772bff7bc58a972d1f8f65b9026 SOURCES/scap-workbench-1.2.0.tar.bz2 diff --git a/SOURCES/oscap_version_suffix.patch b/SOURCES/oscap_version_suffix.patch new file mode 100644 index 0000000..1bb2c7d --- /dev/null +++ b/SOURCES/oscap_version_suffix.patch @@ -0,0 +1,41 @@ +From d4a0508caf6f319b3c19ee370a24c4716eb77bcf Mon Sep 17 00:00:00 2001 +From: Martin Preisler +Date: Thu, 9 Aug 2018 12:38:10 -0400 +Subject: [PATCH] Support oscap version suffix when scanning remote + +Previously we only supported versions such as 1.2.3, now we also support +1.2.3_alpha4. +--- + src/OscapCapabilities.cpp | 12 +++++++++--- + 1 file changed, 9 insertions(+), 3 deletions(-) + +diff --git a/src/OscapCapabilities.cpp b/src/OscapCapabilities.cpp +index 03099fbf..c85804f5 100644 +--- a/src/OscapCapabilities.cpp ++++ b/src/OscapCapabilities.cpp +@@ -50,8 +50,10 @@ void OscapCapabilities::clear() + + static bool versionGreaterOrEqual(const QString& a, const QString& b) + { +- const QStringList aSplit = a.split('.'); +- const QStringList bSplit = b.split('.'); ++ // the first split chops off any suffix such as _alpha2 ++ // we have a guarantee that _ will occur at most once in the string ++ const QStringList aSplit = a.split("_")[0].split('.'); ++ const QStringList bSplit = b.split("_")[0].split('.'); + + // we only compare versions of the same number of components! + assert(aSplit.size() == bSplit.size()); +@@ -89,7 +91,11 @@ void OscapCapabilities::parse(const QString& mmv) + const QStringList firstLine = lines[0].split(' ', QString::SkipEmptyParts); + const QString& versionCandidate = firstLine.last(); + +- if (!versionCandidate.contains(QRegExp("^([0-9]+\\.){2,}[0-9]+$"))) ++ // Examples: ++ // 1.3.0_alpha2 ++ // 0.8.0 ++ // 1.2.18 ++ if (!versionCandidate.contains(QRegExp("^([0-9]+\\.){2,}[0-9]+(_[a-z0-9]+)?$"))) + return; // TODO: Throw exception? + + mVersion = versionCandidate; diff --git a/SOURCES/scap-workbench-1.2.1-missing-quotes.patch b/SOURCES/scap-workbench-1.2.1-missing-quotes.patch new file mode 100644 index 0000000..5da3399 --- /dev/null +++ b/SOURCES/scap-workbench-1.2.1-missing-quotes.patch @@ -0,0 +1,51 @@ +From 9a85a7dd795112a53a04e5552a350ca2e1effbb0 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Jan=20=C4=8Cern=C3=BD?= +Date: Wed, 24 Oct 2018 15:04:18 +0200 +Subject: [PATCH] Fix SCAP Workbench errors shown in Diagnostics Windows + +This patch addresses the follwong part of messages chunk. Even if it +says that "oscap" process has written the content, it's the wrapper +script in fact. + +``` +14:34:53 | error | The 'oscap' process has written the following +content to stderr: +chown: cannot access '/tmp/SCAP': No such file or directory + +14:34:53 | error | The 'oscap' process has written the following +content to stderr: +chown: cannot access 'Workbench.h22666': No such file or directory + +14:34:53 | error | The 'oscap' process has written the following +content to stderr: +chown: cannot access '/tmp/SCAP': No such file or directory + +14:34:53 | error | The 'oscap' process has written the following +content to stderr: +chown: cannot access 'Workbench.M22666': No such file or directory + +14:34:53 | error | The 'oscap' process has written the following +content to stderr: +chown: cannot access '/tmp/SCAP': No such file or directory + +14:34:53 | error | The 'oscap' process has written the following +content to stderr: +chown: cannot access 'Workbench.X22666': No such file or directory +``` +--- + scap-workbench-oscap.sh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/scap-workbench-oscap.sh b/scap-workbench-oscap.sh +index 216376f2..90664446 100755 +--- a/scap-workbench-oscap.sh ++++ b/scap-workbench-oscap.sh +@@ -93,7 +93,7 @@ function chown_copy + + # chown only required if wrapper_{uid,gid} differs from real_{uid,gid} + if [ $wrapper_uid -ne $real_uid ] || [ $wrapper_gid -ne $real_gid ]; then +- chown $wrapper_uid:$wrapper_gid $where ++ chown $wrapper_uid:$wrapper_gid "$where" + fi + } + diff --git a/SOURCES/scap-workbench-1.2.1-no-spaces-in-temporary-file-names.patch b/SOURCES/scap-workbench-1.2.1-no-spaces-in-temporary-file-names.patch new file mode 100644 index 0000000..b51b132 --- /dev/null +++ b/SOURCES/scap-workbench-1.2.1-no-spaces-in-temporary-file-names.patch @@ -0,0 +1,773 @@ +From 8a7aade15b48402403604f17d6cf7690d1a7c752 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Jan=20=C4=8Cern=C3=BD?= +Date: Fri, 13 Dec 2019 13:52:52 +0100 +Subject: [PATCH 1/2] Remove space from temporary file names + +We use QTemporaryFile to create temporary files. According to +https://doc.qt.io/qt-5/qtemporaryfile.html, the default filename +is determined from QCoreApplication::applicationName(). It returns +"SCAP Workbench" which leads to creating temporary files with a space +character in their name, eg. "/tmp/SCAP Workbench.XM8663". The space +can cause problems with missing quotes s.a. the problems described in +https://github.com/OpenSCAP/scap-workbench/issues/196. +To avoid these problems, it's probably better to create the temporary +files without the space. + +We will create 2 temporary classes: SpacelessQTemporaryFile and +SpacelessQTemporaryDir which are derived from QTemporaryFile and +QTemporaryDir and call the constructor with a filename template. + +The QTemporaryDir replaces usage of our custom TemporaryDir class. +We don't need this class anymore because since version 1.2.0 we +require Qt version 5 where QTemporaryDir is present. +--- + include/Exceptions.h | 3 - + include/ForwardDecls.h | 1 - + include/OscapScannerLocal.h | 5 +- + include/RPMOpenHelper.h | 4 +- + include/RemediationRoleSaver.h | 4 +- + include/RemoteSsh.h | 4 +- + include/ResultViewer.h | 4 +- + include/ScanningSession.h | 9 +- + include/TemporaryDir.h | 74 ---------------- + include/Utils.h | 12 +++ + src/OscapScannerBase.cpp | 1 - + src/OscapScannerLocal.cpp | 17 ++-- + src/OscapScannerRemoteSsh.cpp | 5 +- + src/RPMOpenHelper.cpp | 4 +- + src/RemediationRoleSaver.cpp | 6 +- + src/RemoteSsh.cpp | 4 +- + src/ResultViewer.cpp | 2 +- + src/SaveAsRPMDialog.cpp | 5 +- + src/ScanningSession.cpp | 4 +- + src/TemporaryDir.cpp | 149 --------------------------------- + src/Utils.cpp | 6 ++ + src/main.cpp | 3 - + 22 files changed, 53 insertions(+), 273 deletions(-) + delete mode 100644 include/TemporaryDir.h + delete mode 100644 src/TemporaryDir.cpp + +diff --git a/include/Exceptions.h b/include/Exceptions.h +index 84bee42d..1b876895 100644 +--- a/include/Exceptions.h ++++ b/include/Exceptions.h +@@ -57,9 +57,6 @@ SCAP_WORKBENCH_SIMPLE_EXCEPTION(SshConnectionException, + SCAP_WORKBENCH_SIMPLE_EXCEPTION(TailoringWindowException, + "There was a problem with TailoringWindow!\n"); + +-SCAP_WORKBENCH_SIMPLE_EXCEPTION(TemporaryDirException, +- "There was a problem with TemporaryDir!\n"); +- + SCAP_WORKBENCH_SIMPLE_EXCEPTION(OscapScannerRemoteSshException, + "There was a problem with OscapScannerRemoteSsh!\n"); + +diff --git a/include/ForwardDecls.h b/include/ForwardDecls.h +index b9735476..3059a1c3 100644 +--- a/include/ForwardDecls.h ++++ b/include/ForwardDecls.h +@@ -50,7 +50,6 @@ class SyncProcess; + class SSGIntegrationDialog; + class TailoringWindow; + class TailorProfileDialog; +-class TemporaryDir; + class XCCDFItemPropertiesDockWidget; + class XCCDFItemSelectUndoCommand; + class XCCDFValueChangeUndoCommand; +diff --git a/include/OscapScannerLocal.h b/include/OscapScannerLocal.h +index 4370744b..00b5ab39 100644 +--- a/include/OscapScannerLocal.h ++++ b/include/OscapScannerLocal.h +@@ -22,10 +22,9 @@ + #ifndef SCAP_WORKBENCH_OSCAP_SCANNER_LOCAL_H_ + #define SCAP_WORKBENCH_OSCAP_SCANNER_LOCAL_H_ + +-#include +- + #include "ForwardDecls.h" + #include "OscapScannerBase.h" ++#include "Utils.h" + + + class OscapScannerLocal : public OscapScannerBase +@@ -54,7 +53,7 @@ class OscapScannerLocal : public OscapScannerBase + + void evaluateWithOfflineRemediation(); + void evaluateWithOtherSettings(); +- static void setFilenameToTempFile(QTemporaryFile& file); ++ static void setFilenameToTempFile(SpacelessQTemporaryFile& file); + }; + + #endif +diff --git a/include/RPMOpenHelper.h b/include/RPMOpenHelper.h +index 18d1bad1..b6bd606c 100644 +--- a/include/RPMOpenHelper.h ++++ b/include/RPMOpenHelper.h +@@ -23,7 +23,7 @@ + #define SCAP_WORKBENCH_RPM_OPEN_HELPER_H_ + + #include "ForwardDecls.h" +-#include "TemporaryDir.h" ++#include "Utils.h" + #include + + /** +@@ -66,7 +66,7 @@ class RPMOpenHelper + private: + static QString getRPMExtractPath(); + +- TemporaryDir mTempDir; ++ SpacelessQTemporaryDir mTempDir; + + QString mInputPath; + QString mTailoringPath; +diff --git a/include/RemediationRoleSaver.h b/include/RemediationRoleSaver.h +index c668739e..1681b901 100644 +--- a/include/RemediationRoleSaver.h ++++ b/include/RemediationRoleSaver.h +@@ -103,7 +103,7 @@ class ResultBasedProcessRemediationSaver : public RemediationSaverBase + + private: + virtual void saveToFile(const QString& filename); +- QTemporaryFile mArfFile; ++ SpacelessQTemporaryFile mArfFile; + }; + + +@@ -138,7 +138,7 @@ class ResultBasedLibraryRemediationSaver : public RemediationSaverBase + + private: + virtual void saveToFile(const QString& filename); +- QTemporaryFile mArfFile; ++ SpacelessQTemporaryFile mArfFile; + }; + + +diff --git a/include/RemoteSsh.h b/include/RemoteSsh.h +index 7971a0e7..8ae8ba7b 100644 +--- a/include/RemoteSsh.h ++++ b/include/RemoteSsh.h +@@ -24,7 +24,7 @@ + + #include "ForwardDecls.h" + #include "ProcessHelpers.h" +-#include "TemporaryDir.h" ++#include "Utils.h" + #include + + class SshConnection : public QObject +@@ -57,7 +57,7 @@ class SshConnection : public QObject + QString mTarget; + unsigned short mPort; + +- TemporaryDir* mSocketDir; ++ SpacelessQTemporaryDir* mSocketDir; + QString mMasterSocket; + QProcessEnvironment mEnvironment; + +diff --git a/include/ResultViewer.h b/include/ResultViewer.h +index 978a23a4..a6da89da 100644 +--- a/include/ResultViewer.h ++++ b/include/ResultViewer.h +@@ -23,9 +23,9 @@ + #define SCAP_WORKBENCH_RESULT_VIEWER_H_ + + #include "ForwardDecls.h" ++#include "Utils.h" + + #include +-#include + #include + #include + #include +@@ -97,7 +97,7 @@ class ResultViewer : public QWidget + QByteArray mResults; + QByteArray mReport; + /// If user requests to open the file via desktop services +- QTemporaryFile* mReportFile; ++ SpacelessQTemporaryFile* mReportFile; + QByteArray mARF; + }; + +diff --git a/include/ScanningSession.h b/include/ScanningSession.h +index c1d2b490..25ccc604 100644 +--- a/include/ScanningSession.h ++++ b/include/ScanningSession.h +@@ -23,9 +23,8 @@ + #define SCAP_WORKBENCH_SCANNING_SESSION_H_ + + #include "ForwardDecls.h" ++#include "Utils.h" + +-#include +-#include + #include + #include + #include +@@ -292,7 +291,7 @@ class ScanningSession + mutable struct xccdf_tailoring* mTailoring; + + /// Temporary copy of opened DS or XCCDF file +- QTemporaryDir* mTempOpenDir; ++ SpacelessQTemporaryDir* mTempOpenDir; + /// Path to temporary DS or XCCDF file + QString mTempOpenPath; + /// Path to original DS or XCCDF file +@@ -301,9 +300,9 @@ class ScanningSession + QSet mClosureOfOriginalFile; + + /// Temporary file provides auto deletion and a valid temp file path +- QTemporaryFile mTailoringFile; ++ SpacelessQTemporaryFile mTailoringFile; + /// Temporary file provides auto deletion and a valid temp file path +- QTemporaryFile mGuideFile; ++ SpacelessQTemporaryFile mGuideFile; + + /// Whether or not validation should be skipped + bool mSkipValid; +diff --git a/include/TemporaryDir.h b/include/TemporaryDir.h +deleted file mode 100644 +index fadabeca..00000000 +--- a/include/TemporaryDir.h ++++ /dev/null +@@ -1,74 +0,0 @@ +-/* +- * Copyright 2013 Red Hat Inc., Durham, North Carolina. +- * All Rights Reserved. +- * +- * This program is free software: you can redistribute it and/or modify +- * it under the terms of the GNU General Public License as published by +- * the Free Software Foundation, either version 3 of the License, or +- * (at your option) any later version. +- * +- * This program is distributed in the hope that it will be useful, +- * but WITHOUT ANY WARRANTY; without even the implied warranty of +- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +- * GNU General Public License for more details. +- * +- * You should have received a copy of the GNU General Public License +- * along with this program. If not, see . +- * +- * Authors: +- * Martin Preisler +- */ +- +-#ifndef SCAP_WORKBENCH_TEMPORARY_DIR_H_ +-#define SCAP_WORKBENCH_TEMPORARY_DIR_H_ +- +-#include "ForwardDecls.h" +-#include +- +-/** +- * @brief Creates a (LOCAL!) temporary directory and auto destroys it if told so +- * +- * This structure is lazy, it only creates the temp directory when asked about +- * its path. Before you query the path the directory won't be created. +- * +- * @note Default setting is to auto-remove the directory on destruction. +- * @internal We should replace this with QTemporaryDir when scap-workbench moves to Qt5 +- */ +-class TemporaryDir +-{ +- public: +- TemporaryDir(); +- ~TemporaryDir(); +- +- /** +- * @brief Changes the auto-remove settings +- * +- * If autoRemove is true the structure will recursively remove the entire +- * temporary directory (that is the default setting). Else it will just +- * create it and it's up to the user to destroy it. +- */ +- void setAutoRemove(const bool autoRemove); +- +- /// @see TemporaryDir::setAutoRemove +- bool getAutoRemove() const; +- +- /** +- * @brief Returns absolute path of created temporary directory +- * +- * @exception TemporaryDirException Failed to create temporary directory (nonzero exit code from mktemp -d) +- */ +- const QString& getPath() const; +- +- private: +- /** +- * Ensures that temporary directory has been created and the stored path is valid. +- */ +- void ensurePath() const; +- +- /// Holds absolute path of the created temporary directory +- mutable QString mPath; +- /// @see TemporaryDir::setAutoRemove +- bool mAutoRemove; +-}; +- +-#endif +diff --git a/include/Utils.h b/include/Utils.h +index c3b6f013..fb9c1507 100644 +--- a/include/Utils.h ++++ b/include/Utils.h +@@ -28,6 +28,8 @@ + #include + #include + #include ++#include ++#include + + /** + * @brief Retrieves QDir representing the share directory +@@ -115,4 +117,14 @@ void openUrlGuarded(const QUrl& url); + */ + const QString& getSetSidPath(); + ++class SpacelessQTemporaryFile: public QTemporaryFile { ++ public: ++ SpacelessQTemporaryFile (); ++}; ++ ++class SpacelessQTemporaryDir: public QTemporaryDir { ++ public: ++ SpacelessQTemporaryDir (); ++}; ++ + #endif +diff --git a/src/OscapScannerBase.cpp b/src/OscapScannerBase.cpp +index 3d4075cf..daf08b9c 100644 +--- a/src/OscapScannerBase.cpp ++++ b/src/OscapScannerBase.cpp +@@ -24,7 +24,6 @@ + + #include + #include +-#include + #include + + extern "C" +diff --git a/src/OscapScannerLocal.cpp b/src/OscapScannerLocal.cpp +index 48687f25..dd9891fa 100644 +--- a/src/OscapScannerLocal.cpp ++++ b/src/OscapScannerLocal.cpp +@@ -22,7 +22,6 @@ + #include "OscapScannerLocal.h" + #include "ProcessHelpers.h" + #include "ScanningSession.h" +-#include "TemporaryDir.h" + + #include + #include +@@ -33,7 +32,7 @@ extern "C" + #include + } + +-void OscapScannerLocal::setFilenameToTempFile(QTemporaryFile& file) ++void OscapScannerLocal::setFilenameToTempFile(SpacelessQTemporaryFile& file) + { + file.open(); + file.close(); +@@ -97,21 +96,21 @@ void OscapScannerLocal::evaluate() + // This is mainly for check-engine-results and oval-results, to ensure + // we get a full report, including info from these files. openscap's XSLT + // uses info in the check engine results if it can find them. +- TemporaryDir workingDir; +- process.setWorkingDirectory(workingDir.getPath()); ++ SpacelessQTemporaryDir workingDir; ++ process.setWorkingDirectory(workingDir.path()); + + QStringList args; +- QTemporaryFile inputARFFile; ++ SpacelessQTemporaryFile inputARFFile; + +- QTemporaryFile arfFile; ++ SpacelessQTemporaryFile arfFile; + arfFile.setAutoRemove(true); + setFilenameToTempFile(arfFile); + +- QTemporaryFile reportFile; ++ SpacelessQTemporaryFile reportFile; + reportFile.setAutoRemove(true); + setFilenameToTempFile(reportFile); + +- QTemporaryFile resultFile; ++ SpacelessQTemporaryFile resultFile; + resultFile.setAutoRemove(true); + setFilenameToTempFile(resultFile); + +@@ -223,7 +222,7 @@ QStringList OscapScannerLocal::getCommandLineArgs() const + + if (mScannerMode == SM_OFFLINE_REMEDIATION) + { +- QTemporaryFile inputARFFile; ++ SpacelessQTemporaryFile inputARFFile; + inputARFFile.setAutoRemove(true); + inputARFFile.open(); + inputARFFile.write(getARFForRemediation()); +diff --git a/src/OscapScannerRemoteSsh.cpp b/src/OscapScannerRemoteSsh.cpp +index 44611a77..dcfd6d5f 100644 +--- a/src/OscapScannerRemoteSsh.cpp ++++ b/src/OscapScannerRemoteSsh.cpp +@@ -25,7 +25,6 @@ + + #include + #include +-#include + #include + #include + #include +@@ -105,7 +104,7 @@ QStringList OscapScannerRemoteSsh::getCommandLineArgs() const + + if (mScannerMode == SM_OFFLINE_REMEDIATION) + { +- QTemporaryFile inputARFFile; ++ SpacelessQTemporaryFile inputARFFile; + inputARFFile.setAutoRemove(true); + inputARFFile.open(); + inputARFFile.write(getARFForRemediation()); +@@ -381,7 +380,7 @@ QString OscapScannerRemoteSsh::copyInputFileOver() + + QString localPath = ""; + +- QTemporaryFile inputARFFile; ++ SpacelessQTemporaryFile inputARFFile; + inputARFFile.setAutoRemove(true); + if (mScannerMode == SM_OFFLINE_REMEDIATION) + { +diff --git a/src/RPMOpenHelper.cpp b/src/RPMOpenHelper.cpp +index 565eaa16..b12f109d 100644 +--- a/src/RPMOpenHelper.cpp ++++ b/src/RPMOpenHelper.cpp +@@ -33,12 +33,12 @@ RPMOpenHelper::RPMOpenHelper(const QString& path) + const QFileInfo pathInfo(path); + proc.setCommand(getRPMExtractPath()); + proc.setArguments(QStringList(pathInfo.absoluteFilePath())); +- proc.setWorkingDirectory(mTempDir.getPath()); ++ proc.setWorkingDirectory(mTempDir.path()); + } + + proc.run(); + +- const QDir tempDir(mTempDir.getPath()); ++ const QDir tempDir(mTempDir.path()); + + if (proc.getExitCode() != 0) + { +diff --git a/src/RemediationRoleSaver.cpp b/src/RemediationRoleSaver.cpp +index 247475e0..900a221d 100644 +--- a/src/RemediationRoleSaver.cpp ++++ b/src/RemediationRoleSaver.cpp +@@ -27,6 +27,7 @@ + + #include "RemediationRoleSaver.h" + #include "DiagnosticsDialog.h" ++#include "Utils.h" + + extern "C" + { +@@ -41,7 +42,6 @@ extern "C" + #endif + } + +-#include "TemporaryDir.h" + + + const QString bashSaveMessage = QObject::tr("Save remediation role as a bash script"); +@@ -197,8 +197,8 @@ void ResultBasedProcessRemediationSaver::saveToFile(const QString& filename) + // This is a lightweight launch though. + QProcess process(mParentWindow); + +- TemporaryDir workingDir; +- process.setWorkingDirectory(workingDir.getPath()); ++ SpacelessQTemporaryDir workingDir; ++ process.setWorkingDirectory(workingDir.path()); + QString program(SCAP_WORKBENCH_LOCAL_OSCAP_PATH); + + process.start(program, args); +diff --git a/src/RemoteSsh.cpp b/src/RemoteSsh.cpp +index 36c359ff..9f737b8a 100644 +--- a/src/RemoteSsh.cpp ++++ b/src/RemoteSsh.cpp +@@ -109,8 +109,8 @@ void SshConnection::connect() + mSocketDir = 0; + } + +- mSocketDir = new TemporaryDir(); +- mMasterSocket = mSocketDir->getPath() + "/ssh_socket"; ++ mSocketDir = new SpacelessQTemporaryDir(); ++ mMasterSocket = mSocketDir->path() + "/ssh_socket"; + } + catch (const SyncProcessException& e) + { +diff --git a/src/ResultViewer.cpp b/src/ResultViewer.cpp +index c65be2d2..1e730e99 100644 +--- a/src/ResultViewer.cpp ++++ b/src/ResultViewer.cpp +@@ -158,7 +158,7 @@ void ResultViewer::openReport() + mReportFile = 0; + } + +- mReportFile = new QTemporaryFile(); ++ mReportFile = new SpacelessQTemporaryFile(); + mReportFile->setFileTemplate(mReportFile->fileTemplate() + ".html"); + mReportFile->open(); + mReportFile->write(mReport); +diff --git a/src/SaveAsRPMDialog.cpp b/src/SaveAsRPMDialog.cpp +index 6c537444..611d15fd 100644 +--- a/src/SaveAsRPMDialog.cpp ++++ b/src/SaveAsRPMDialog.cpp +@@ -21,7 +21,6 @@ + + #include "SaveAsRPMDialog.h" + #include "MainWindow.h" +-#include "TemporaryDir.h" + #include "ScanningSession.h" + #include "ProcessHelpers.h" + +@@ -128,7 +127,7 @@ void SaveAsRPMDialog::slotFinished(int result) + args.append(cwd.relativeFilePath(*it)); + } + +- TemporaryDir tailoringDir; ++ SpacelessQTemporaryDir tailoringDir; + + // Tailoring file is a special case since it may be in memory only. + // In case it is memory only we don't want it to cause our common ancestor dir to be / +@@ -138,7 +137,7 @@ void SaveAsRPMDialog::slotFinished(int result) + QFileInfo tailoringFile(mScanningSession->getTailoringFilePath()); + assert(tailoringFile.exists()); + +- const QString tailoringFilePath = QString("%1/%2").arg(tailoringDir.getPath(), "tailoring-xccdf.xml"); ++ const QString tailoringFilePath = QString("%1/%2").arg(tailoringDir.path(), "tailoring-xccdf.xml"); + + ScanningSession::copyOrReplace(tailoringFile.absoluteFilePath(), + tailoringFilePath); +diff --git a/src/ScanningSession.cpp b/src/ScanningSession.cpp +index a486761d..20ce501f 100644 +--- a/src/ScanningSession.cpp ++++ b/src/ScanningSession.cpp +@@ -34,8 +34,6 @@ extern "C" { + + #include + #include +-#include +-#include + #include + #include + #include +@@ -161,7 +159,7 @@ void ScanningSession::cloneToTemporaryFile(const QString& path) + // Clean the temporary directory if it is open already, then create + // a new one. + cleanTmpDir(); +- mTempOpenDir = new QTemporaryDir(); ++ mTempOpenDir = new SpacelessQTemporaryDir(); + + // Recalling is unlikely to succeed, so throw a fatal exception + if (!mTempOpenDir->isValid()) +diff --git a/src/TemporaryDir.cpp b/src/TemporaryDir.cpp +deleted file mode 100644 +index 0fed2556..00000000 +--- a/src/TemporaryDir.cpp ++++ /dev/null +@@ -1,149 +0,0 @@ +-/* +- * Copyright 2013 Red Hat Inc., Durham, North Carolina. +- * All Rights Reserved. +- * +- * This program is free software: you can redistribute it and/or modify +- * it under the terms of the GNU General Public License as published by +- * the Free Software Foundation, either version 3 of the License, or +- * (at your option) any later version. +- * +- * This program is distributed in the hope that it will be useful, +- * but WITHOUT ANY WARRANTY; without even the implied warranty of +- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +- * GNU General Public License for more details. +- * +- * You should have received a copy of the GNU General Public License +- * along with this program. If not, see . +- * +- * Authors: +- * Martin Preisler +- */ +- +-#include "TemporaryDir.h" +-#include "ProcessHelpers.h" +-#include "Exceptions.h" +- +-#include +-#include +- +-static bool recursiveRemoveDir(const QString& dirName) +-{ +- // Adapted code from: +- // http://john.nachtimwald.com/2010/06/08/qt-remove-directory-and-its-contents/ +- +- bool result = true; +- QDir dir(dirName); +- +- if (dir.exists(dirName)) +- { +- for (QFileInfo info : dir.entryInfoList(QDir::NoDotAndDotDot | QDir::System | QDir::Hidden | QDir::AllDirs | QDir::Files, QDir::DirsFirst)) +- { +- if (info.isDir()) +- result = recursiveRemoveDir(info.absoluteFilePath()); +- else +- result = QFile::remove(info.absoluteFilePath()); +- +- if (!result) +- return result; +- } +- result = dir.rmdir(dirName); +- } +- +- return result; +-} +- +-TemporaryDir::TemporaryDir(): +- mAutoRemove(true) +-{} +- +-TemporaryDir::~TemporaryDir() +-{ +- if (!mPath.isEmpty() && mAutoRemove) +- { +- if (!recursiveRemoveDir(mPath)) +- { +- // We don't throw on destruction! The worst thing that can happen +- // is leftover files which is not a big deal anyway. +- +- std::cerr << "Failed to remove temporary directory '" << mPath.toUtf8().constData() << "'." << std::endl; +- } +- } +-} +- +-void TemporaryDir::setAutoRemove(const bool autoRemove) +-{ +- mAutoRemove = autoRemove; +-} +- +-bool TemporaryDir::getAutoRemove() const +-{ +- return mAutoRemove; +-} +- +-const QString& TemporaryDir::getPath() const +-{ +- ensurePath(); +- return mPath; +-} +- +-// nextRand adapted from from QTemporaryDir from Qt5, licensed under LGPL2.1+ +- +-// Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +-// Contact: http://www.qt-project.org/legal +-// +-// GNU Lesser General Public License Usage +-// Alternatively, this file may be used under the terms of the GNU Lesser +-// General Public License version 2.1 or version 3 as published by the Free +-// Software Foundation and appearing in the file LICENSE.LGPLv21 and +-// LICENSE.LGPLv3 included in the packaging of this file. Please review the +-// following information to ensure the GNU Lesser General Public License +-// requirements will be met: https://www.gnu.org/licenses/lgpl.html and +-// http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +-// +-// In addition, as a special exception, Digia gives you certain additional +-// rights. These rights are described in the Digia Qt LGPL Exception +-// version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +- +-static int nextRand(int& v) +-{ +- int r = v % 62; +- v /= 62; +- if (v < 62) +- v = qrand(); +- return r; +-} +- +-void TemporaryDir::ensurePath() const +-{ +- static const char letters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; +- +- if (mPath.isEmpty()) +- { +- QString dirName; +- while (true) +- { +- dirName = ""; +- +- int v = qrand(); +- dirName += letters[nextRand(v)]; +- dirName += letters[nextRand(v)]; +- dirName += letters[nextRand(v)]; +- dirName += letters[nextRand(v)]; +- dirName += letters[nextRand(v)]; +- dirName += letters[nextRand(v)]; +- +- if (QDir::temp().mkdir(dirName)) +- break; +- } +- +- const QDir dir(QDir::temp().absoluteFilePath(dirName)); +- +- if (!dir.exists()) +- throw TemporaryDirException( +- QString("Failed to create temporary directory. mkdir succeeded " +- "but the directory does not exist!") +- ); +- +- mPath = dir.absolutePath(); +- } +-} +diff --git a/src/Utils.cpp b/src/Utils.cpp +index 802cd503..d3562fac 100644 +--- a/src/Utils.cpp ++++ b/src/Utils.cpp +@@ -217,3 +217,9 @@ const QString& getSetSidPath() + return ret; + #endif + } ++ ++SpacelessQTemporaryFile::SpacelessQTemporaryFile () : ++ QTemporaryFile(QDir::cleanPath(QDir::tempPath() + "/" + "XXXXXX")) {} ++ ++SpacelessQTemporaryDir::SpacelessQTemporaryDir () : ++ QTemporaryDir(QDir::cleanPath(QDir::tempPath() + "/" + "XXXXXX")) {} +diff --git a/src/main.cpp b/src/main.cpp +index ebc7b4ba..5f6480a8 100644 +--- a/src/main.cpp ++++ b/src/main.cpp +@@ -35,9 +35,6 @@ int main(int argc, char** argv) + FreeConsole(); + #endif + +- // Needed for TemporaryDir +- qsrand(QTime::currentTime().msec()); +- + Application app(argc, argv); + return app.exec(); + } + +From c8b9c4a7e57a01293e4f622f18f139b29ea544d8 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Jan=20=C4=8Cern=C3=BD?= +Date: Mon, 6 Jan 2020 17:54:04 +0100 +Subject: [PATCH 2/2] Add scap-workbench to temporary file name template + +This way it will be obvious that the files have been created by +SCAP Workbench. +--- + src/Utils.cpp | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/Utils.cpp b/src/Utils.cpp +index d3562fac..fbeb809c 100644 +--- a/src/Utils.cpp ++++ b/src/Utils.cpp +@@ -219,7 +219,7 @@ const QString& getSetSidPath() + } + + SpacelessQTemporaryFile::SpacelessQTemporaryFile () : +- QTemporaryFile(QDir::cleanPath(QDir::tempPath() + "/" + "XXXXXX")) {} ++ QTemporaryFile(QDir::cleanPath(QDir::tempPath() + "/" + "scap-workbench-XXXXXX")) {} + + SpacelessQTemporaryDir::SpacelessQTemporaryDir () : +- QTemporaryDir(QDir::cleanPath(QDir::tempPath() + "/" + "XXXXXX")) {} ++ QTemporaryDir(QDir::cleanPath(QDir::tempPath() + "/" + "scap-workbench-XXXXXX")) {} diff --git a/SPECS/scap-workbench.spec b/SPECS/scap-workbench.spec new file mode 100644 index 0000000..6b39672 --- /dev/null +++ b/SPECS/scap-workbench.spec @@ -0,0 +1,204 @@ +%{!?_pkgdocdir: %global _pkgdocdir %{_docdir}/%{name}-%{version}} + +Name: scap-workbench +Version: 1.2.0 +Release: 4%{?dist} +Summary: Scanning, tailoring, editing and validation tool for SCAP content + +License: GPLv3+ +URL: http://www.open-scap.org/tools/scap-workbench +Source0: https://github.com/OpenSCAP/scap-workbench/releases/download/%{version}/scap-workbench-%{version}.tar.bz2 +Patch1: oscap_version_suffix.patch +Patch2: scap-workbench-1.2.1-missing-quotes.patch +Patch3: scap-workbench-1.2.1-no-spaces-in-temporary-file-names.patch +Group: System Environment/Base + +BuildRequires: cmake >= 2.6 +BuildRequires: qt5-devel >= 5.0.0 + +BuildRequires: openscap-devel >= 1.2.11 +BuildRequires: openscap-utils >= 1.2.11 +Requires: openscap-utils >= 1.2.11 +# ssh to scan remote machines +BuildRequires: openssh-clients +Requires: openssh-clients +Requires: openssh-askpass +# because of 'setsid' which we use to force ssh to use GUI askpass +BuildRequires: util-linux +Requires: util-linux +# for privileged local scanning +Requires: polkit +# default content +Requires: scap-security-guide +# fonts, see https://bugzilla.redhat.com/show_bug.cgi?id=1134418 +Requires: font(:lang=en) + +%description +scap-workbench is GUI tool that provides scanning functionality for SCAP +content. The tool is based on OpenSCAP library. + +%prep +%setup -q +%patch1 -p1 +%patch2 -p1 +%patch3 -p1 + +%build +%cmake -D CMAKE_INSTALL_DOCDIR=%{_pkgdocdir} . +make %{?_smp_mflags} + +%install +make install DESTDIR=%{buildroot} + +%files +%{_bindir}/scap-workbench +%{_datadir}/applications/scap-workbench.desktop +%{_datadir}/scap-workbench/*.png +%{_datadir}/scap-workbench/translations/* +%{_libexecdir}/scap-workbench-oscap.sh +%{_libexecdir}/scap-workbench-pkexec-oscap.sh +%{_libexecdir}/scap-workbench-rpm-extract.sh +%{_datadir}/polkit-1/actions/scap-workbench-oscap.policy +%{_datadir}/pixmaps/scap-workbench.png +%{_datadir}/pixmaps/scap-workbench.svg +%{_datadir}/appdata/scap-workbench.appdata.xml +%doc %{_mandir}/man8/scap-workbench.8.gz +%doc %{_pkgdocdir}/user_manual.html +%doc %{_pkgdocdir}/COPYING +%doc %{_pkgdocdir}/README.md + +%changelog +* Tue Jan 28 2020 Jan Černý 1.2.0-4 +- Fix error messages in the diagnostics window (RHBZ#1781074) + +* Mon Oct 15 2018 Watson Yuuma Sato - 1.2.0-3 +- Rebuilt to fix openscap dependency (RHBZ#1639405) + +* Thu Aug 30 2018 Jan Černý 1.2.0-2 +- Support the OpenSCAP version suffix (RHBZ#1622998) + +* Wed Jul 18 2018 Martin Preisler 1.2.0-1 +- Updated to new upstream release 1.2.0 +- Now using Qt5 + +* Fri Feb 09 2018 Fedora Release Engineering - 1.1.6-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild + +* Fri Nov 10 2017 Martin Preisler 1.1.6-1 +- Updated to new upstream release 1.1.6 + +* Thu Aug 03 2017 Fedora Release Engineering - 1.1.5-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild + +* Thu Jul 27 2017 Fedora Release Engineering - 1.1.5-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild + +* Mon Jun 19 2017 Martin Preisler 1.1.5-1 +- Updated to new upstream release 1.1.5 + +* Sat Feb 11 2017 Fedora Release Engineering - 1.1.4-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild + +* Tue Jan 17 2017 Martin Preisler - 1.1.4-2 +- Rebuilt for OpenSCAP 1.2.13 + +* Mon Jan 02 2017 Martin Preisler 1.1.4-1 +- Updated to new upstream release 1.1.4 + +* Mon Dec 12 2016 Martin Preisler 1.1.3-1 +- Updated to new upstream release 1.1.3 +- Bumped openscap requirement to 1.2.11 because of the remote resource warning + +* Mon Jun 20 2016 Martin Preisler 1.1.2-1 +- Updated to new upstream release 1.1.2 +- Removed SCL related bits + +* Thu Feb 04 2016 Fedora Release Engineering - 1.1.1-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild + +* Mon Nov 02 2015 Martin Preisler 1.1.1-2 +- Require English fonts (bz#1134418) +- Updated with latest upstream URLs +- Reorganized the spec a little + +* Tue Sep 29 2015 Martin Preisler 1.1.1-1 +- Updated to new upstream release 1.1.1-1 + +* Wed Jul 29 2015 Martin Preisler 1.1.0-4 +- Make BuildRequires more explicit by requiring qt >= 4.0.0 and cmake >= 2.6 + +* Fri Jun 19 2015 Fedora Release Engineering - 1.1.0-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild + +* Sat May 02 2015 Kalev Lember - 1.1.0-2 +- Rebuilt for GCC 5 C++11 ABI change + +* Tue Mar 24 2015 Martin Preisler 1.1.0-1 +- Updated to new upstream release 1.1.0 +- Added openssh-clients and util-linux to BuildRequires, workbench checks those + at configure time now +- Added scap-security-guide to Requires + +* Fri Jan 09 2015 Martin Preisler 1.0.3-1 +- Updated to new upstream release 1.0.3 + +* Thu Oct 30 2014 Martin Preisler 1.0.2-2 +- Fix RPM open functionality, see rhbz#1154039 + +* Wed Sep 24 2014 Martin Preisler 1.0.2-1 +- Updated to new upstream release 1.0.2 + +* Fri Sep 05 2014 Martin Preisler 1.0.1-1 +- Updated to new upstream release 1.0.1 + +* Mon Aug 18 2014 Fedora Release Engineering - 1.0.0-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild + +* Fri Jun 27 2014 Martin Preisler 1.0.0-1 +- Updated to new version + +* Tue Jun 10 2014 Martin Preisler 0.8.9-1 +- Updated to new version +- appdata is now available + +* Sun Jun 08 2014 Fedora Release Engineering - 0.8.8-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild + +* Wed Mar 26 2014 Martin Preisler 0.8.8-1 +- Updated to new version + +* Wed Feb 19 2014 Martin Preisler 0.8.7-1 +- Updated to new version + +* Thu Jan 30 2014 Martin Preisler 0.8.6-1 +- Updated to new version +- Require polkit + +* Mon Jan 20 2014 Martin Preisler 0.8.5-2 +- Require openssh-askpass for GUI openssh challenge responses + +* Fri Jan 10 2014 Martin Preisler 0.8.5-1 +- Updated to new version + +* Mon Dec 09 2013 Martin Preisler 0.8.4-1 +- Updated to new version + +* Fri Nov 29 2013 Martin Preisler 0.8.3-1 +- Updated to new version +- Added measures to deal with unversioned pkgdocdir in Fedora 20+ + +* Mon Nov 18 2013 Martin Preisler 0.8.2-2 +- Removed the openscap detection workaround, it is no longer needed with openscap 0.9.13 + +* Wed Oct 30 2013 Martin Preisler 0.8.2-1 +- Updated to new version +- Added a workaround to the cmake invocation because of faulty openscap .pc file + +* Fri Sep 20 2013 Martin Preisler 0.8.1-1 +- Updated to new version + +* Sun Aug 04 2013 Fedora Release Engineering - 0.8.0-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild + +* Thu Jul 04 2013 Martin Preisler 0.8.0-1 +- Initial release of the rewritten workbench