Merge lp:~mandel/ubuntu-download-manager/typos-logs-unlock-not-locked into lp:ubuntu-download-manager
Status: | Merged | ||||||||
---|---|---|---|---|---|---|---|---|---|
Merge reported by: | Muhamad Hafizie Bin Ruzaimi | ||||||||
Merged at revision: | not available | ||||||||
Proposed branch: | lp:~mandel/ubuntu-download-manager/typos-logs-unlock-not-locked | ||||||||
Merge into: | lp:ubuntu-download-manager | ||||||||
Diff against target: | 0 lines | ||||||||
To merge this branch: | bzr merge lp:~mandel/ubuntu-download-manager/typos-logs-unlock-not-locked | ||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ubuntu Phablet Team | Pending | ||
Review via email: mp+384605@code.launchpad.net |
Commit message
=== modified file 'ubuntu-
--- ubuntu-
+++ ubuntu-
@@ -30,7 +30,7 @@
#include "system/logger.h"
#include "system/
-#define DOWN_LOG(LEVEL) LOG(LEVEL) << ((parent() != nullptr)
+#define DOWN_LOG(LEVEL) LOG(LEVEL) << ((parent() != nullptr)
namespace {
@@ -117,7 +117,7 @@
cleanUpCur
// unlock the file name so that other downloads can use it it if is
// no used in the file system
- _fileNameMutex-
+ unlockFilePath();
_downloading = false;
emit canceled(true);
}
@@ -623,19 +623,34 @@
FileDownload:
auto fileMan = FileManager:
- LOG(INFO) << "EMIT finished" << filePath();
- setState(
-
if (fileMan-
- LOG(INFO) << "Rename '" << _tempFilePath << "' to '"
+ DOWN_LOG(INFO) << "Rename '" << _tempFilePath << "' to '"
<< _filePath << "'";
- fileMan-
+ QFile tempFile(
+ auto r = tempFile.
+ if (!r) {
+ DOWN_LOG(WARNING) << "Could not rename '" << _tempFilePath << "' to '"
+ << _filePath << "' due to " << tempFile.
+ }
}
- _fileNameMutex-
+
+ setState(
+ unlockFilePath();
+
+ DOWN_LOG(INFO) << "EMIT finished" << filePath();
emit finished(
}
void
+FileDownload:
+ if (!isConfined() && metadata(
+ _fileNameMutex-
+ } else {
+ _fileNameMutex-
+ }
+}
+
+void
FileDownload:
bool success = true;
QFile:
@@ -685,7 +700,7 @@
_reply = nullptr;
cleanUpCur
// let other downloads use the same file name
- _fileNameMutex-
+ unlockFilePath();
Download:
}
=== modified file 'ubuntu-
--- ubuntu-
+++ ubuntu-
@@ -122,6 +122,7 @@
void onOnlineStateCh
void initFileNames();
void emitFinished();
+ void unlockFilePath();
private:
bool _downloading = false;
=== modified file 'ubuntu-
--- ubuntu-
+++ ubuntu-
@@ -16,6 +16,8 @@
* boston, ma 02110-1301, usa.
*/
+#include <QDir>
+#include <QFileInfo>
#include <ubuntu/
#include <ubuntu/
#include "downloads/
@@ -24,7 +26,7 @@
#include "system/logger.h"
#include "system/
-#define GROUP_LOG(LEVEL) LOG(LEVEL) << "Group Download{" << objectName() << "}"
+#define GROUP_LOG(LEVEL) LOG(LEVEL) << "Group Download {" << objectName() << " } "
namespace Ubuntu {
@@ -167,6 +169,7 @@
GroupDownload:
TRACE;
cancelAllD
+ GROUP_LOG(INFO) << "EMIT canceled";
emit canceled(true);
}
@@ -181,6 +184,7 @@
}
}
+ GROUP_LOG(INFO) << "EMIT paused";
emit paused(true);
}
@@ -193,6 +197,7 @@
}
}
+ GROUP_LOG(INFO) << "EMIT resumed";
emit resumed(true);
}
@@ -206,9 +211,12 @@
}
}
+ GROUP_LOG(INFO) << "EMIT started";
emit started(true);
} else {
+ GROUP_LOG(INFO) << "EMIT started";
emit started(true);
+ GROUP_LOG(INFO) << "EMIT finished " << _finishedDownlo
emit finished(
}
}
@@ -257,6 +265,8 @@
// files that we managed to download
cancelAllD
QString errorMsg = down->url(
+
+ GROUP_LOG(INFO) << "EMIT error " << errorMsg;
emitError(
}
@@ -351,6 +361,17 @@
// that downloads we are done :)
if (_downloads.count() == _finishedDownlo
+#ifndef NDEBUG
+ foreach(const QString& file, _finishedDownloads) {
+ auto parentDir = QFileInfo(
+ DLOG(INFO) << "Files for path dir '" << parentDir.
+ auto children = parentDir.
+ foreach(const QString& child, children) {
+ DLOG(INFO) << "\t" << child;
+ }
+ }
+#endif
+ GROUP_LOG(INFO) << "EMIT finished " << _finishedDownlo
emit finished(
}
}
=== modified file 'ubuntu-
--- ubuntu-
+++ ubuntu-
@@ -82,7 +82,7 @@
_mutex.lock();
auto removed = _paths.
if (!removed) {
- LOG(WARNING) << "Tired to remove filename '" << filename
+ LOG(WARNING) << "Tried to remove filename '" << filename
<< "' when it was not owned by any object.";
} else {
LOG(INFO) << "Released path '" << filename << "'";
=== modified file 'ubuntu-
--- ubuntu-
+++ ubuntu-
@@ -2285,8 +2285,14 @@
QCOMPARE(2, calledMethods.
auto methodName = calledMethods[
QCOMPARE(
+ auto path = qobject_
+ calledMethods[
+ QCOMPARE(
methodName = calledMethods[
QCOMPARE(
+ path = qobject_
+ calledMethods[
+ QCOMPARE(
}
void
@@ -2307,8 +2313,14 @@
QCOMPARE(2, calledMethods.
auto methodName = calledMethods[
QCOMPARE(
+ auto path = qobject_
+ calledMethods[
+ QCOMPARE(
methodName = calledMethods[
QCOMPARE(
+ path = qobject_
+ calledMethods[
+ QCOMPARE(
}
void
@@ -2336,8 +2348,14 @@
QCOMPARE(2, calledMethods.
auto methodName = calledMethods[
QCOMPARE(
+ auto path = qobject_
+ calledMethods[
+ QCOMPARE(
methodName = calledMethods[
QCOMPARE(
+ path = qobject_
+ calledMethods[
+ QCOMPARE(
}
void
@@ -2378,8 +2396,14 @@
QCOMPARE(2, calledMethods.
auto methodName = calledMethods[
QCOMPARE(
+ auto path = qobject_
+ calledMethods[
+ QCOMPARE(
methodName = calledMethods[
QCOMPARE(
+ path = qobject_
+ calledMethods[
+ QCOMPARE(
}
void
@@ -2412,6 +2436,177 @@
QCOMPARE(2, calledMethods.
auto methodName = calledMethods[
QCOMPARE(
- methodName = calledMethods[
- QCOMPARE(
+ auto path = qobject_
+ calledMethods[
+ QCOMPARE(
+ methodName = calledMethods[
+ QCOMPARE(
+ path = qobject_
+ calledMethods[
+ QCOMPARE(
+}
+
+void
+TestDownload:
+ QVariantMap metadata;
+ QString localPath = "/home/
+ metadata[
+
+ _fileNameMutex-
+ QScopedPointer<
+ _isConfined, _rootPath, _url, metadata, _headers));
+ QSignalSpy spy(download.
+ SIGNAL(
+
+ download->start(); // change state
+ download-
+ download->cancel(); // change state
+ download-
+
+ // assert that the filename was correctly managed
+ auto calledMethods = _fileNameMutex-
+ QCOMPARE(2, calledMethods.
+ auto methodName = calledMethods[
+ QCOMPARE(
+ auto path = qobject_
+ calledMethods[
+ QCOMPARE(
+ methodName = calledMethods[
+ QCOMPARE(
+ path = qobject_
+ calledMethods[
+ QCOMPARE(
+}
+
+void
+TestDownload:
+ QVariantMap metadata;
+ QString localPath = "/home/
+ metadata[
+
+ _fileNameMutex-
+ _reqFactory-
+ QScopedPointer<
+ _isConfined, _rootPath, _url, metadata, _headers));
+ QSignalSpy spy(download.
+
+ download->start(); // change state
+ download-
+
+ QList<MethodData> calledMethods = _reqFactory-
+ QCOMPARE(1, calledMethods.
+ FakeNetworkReply* reply = reinterpret_
+ calledMethods[
+
+ // emit the finish signal and expect it to be raised
+ emit reply->finished();
+ QCOMPARE(
+ QCOMPARE(
+
+ calledMethods = _fileNameMutex-
+ QCOMPARE(2, calledMethods.
+ auto methodName = calledMethods[
+ QCOMPARE(
+ auto path = qobject_
+ calledMethods[
+ QCOMPARE(
+ methodName = calledMethods[
+ QCOMPARE(
+ path = qobject_
+ calledMethods[
+ QCOMPARE(
+}
+
+void
+TestDownload:
+ _fileNameMutex-
+ _processFactory
+ _reqFactory-
+
+ QString command = "cd";
+ QVariantMap metadata;
+ metadata[
+ QString localPath = "/home/
+ metadata[
+
+ QScopedPointer<
+ _isConfined, _rootPath, _url, metadata, _headers));
+ QSignalSpy spy(download.
+
+ download->start(); // change state
+ download-
+
+ // we need to set the data before we pause!!!
+ QList<MethodData> calledMethods = _reqFactory-
+ QCOMPARE(1, calledMethods.
+ FakeNetworkReply* reply = reinterpret_
+ calledMethods[
+
+ // makes the process to be executed
+ reply->
+
+ calledMethods = _processFactory
+ QCOMPARE(1, calledMethods.
+ FakeProcess* process = reinterpret_
+ calledMethods[
+
+ process-
+ QTRY_COMPARE(
+
+ calledMethods = _fileNameMutex-
+ QCOMPARE(2, calledMethods.
+ auto methodName = calledMethods[
+ QCOMPARE(
+ auto path = qobject_
+ calledMethods[
+ QCOMPARE(
+ methodName = calledMethods[
+ QCOMPARE(
+ path = qobject_
+ calledMethods[
+ QCOMPARE(
+}
+
+void
+TestDownload:
+ QVariantMap metadata;
+ QString localPath = "/home/
+ metadata[
+
+ // fake an error and make sure that unlock is called
+ _fileNameMutex-
+ _reqFactory-
+ QScopedPointer<
+ _isConfined, _rootPath, _url, metadata, _headers));
+ QSignalSpy errorSpy(
+
+ download->start(); // change state
+ download-
+
+ // we need to set the data before we pause!!!
+ QList<MethodData> calledMethods = _reqFactory-
+ QCOMPARE(1, calledMethods.
+ FakeNetworkReply* reply = reinterpret_
+ calledMethods[
+
+ // set the attrs in the reply so that we do raise two signals
+ reply->
+ reply->
+
+ // emit the error and esure that the signals are raised
+ reply->
+ QCOMPARE(
+
+ calledMethods = _fileNameMutex-
+ QCOMPARE(2, calledMethods.
+ auto methodName = calledMethods[
+ QCOMPARE(
+ auto path = qobject_
+ calledMethods[
+ QCOMPARE(
+ methodName = calledMethods[
+ QCOMPARE(
+ path = qobject_
+ calledMethods[
+ QCOMPARE(
}
=== modified file 'ubuntu-
--- ubuntu-
+++ ubuntu-
@@ -169,6 +169,10 @@
void testFinishUnloc
void testProcessFini
void testErrorUnlock
+ void testCancelUnloc
+ void testFinishUnloc
+ void testProcessFini
+ void testErrorUnlock
private:
QString _id;
Description of the change
diff -Nru ubuntu-
--- ubuntu-
+++ ubuntu-
@@ -1,3 +1,10 @@
+ubuntu-
+
+ * Disallow post-processing commands from unconfined apps (Fixes CVE-
+ 2016-1579)
+
+ -- Michael Sheldon <email address hidden> Fri, 08 Apr 2016 17:50:24 +0000
+
ubuntu-
* Fix error reporting in download manager for network errors (LP:
diff -Nru ubuntu-
--- ubuntu-
+++ ubuntu-
@@ -1023,6 +1023,11 @@
return;
} else if (_metadata.
+ if (isConfined()) {
+ DOWN_LOG(ERROR) << "Post processing commands are unavailable to confined applications";
+ emitError(
+ return;
+ }
// just emit processing if we DO NOT have a hash because else we
// already emitted it.
if (_hash.isEmpty()) {