Commit fba3ad56 authored by Martin Kampas's avatar Martin Kampas

[sandbox] Re-enable sandbox dependent code

Reverts parts of 1cf47e0a
parent 4be8a49b
......@@ -12,12 +12,14 @@ public_headers = \
HEADERS = \
$${public_headers} \
sandbox_p.h \
ssucoreconfig.h \
mobility-booty/qofonoservice_linux_p.h \
mobility-booty/qsysteminfo_linux_common_p.h \
mobility-booty/qsysteminfo_dbus_p.h
SOURCES = \
sandbox.cpp \
ssu.cpp \
ssucoreconfig.cpp \
ssudeviceinfo.cpp \
......
......@@ -10,6 +10,7 @@
#include <QFileInfo>
#include <QDateTime>
#include "sandbox_p.h"
#include "ssusettings.h"
#include "ssulog.h"
......@@ -18,32 +19,22 @@ SsuSettings::SsuSettings(): QSettings(){
}
SsuSettings::SsuSettings(const QString &fileName, Format format, QObject *parent):
QSettings(SsuSettings::sandboxPrefix() + fileName, format, parent){
QSettings(Sandbox::map(fileName), format, parent){
}
SsuSettings::SsuSettings(const QString &fileName, Format format, const QString &defaultFileName, QObject *parent):
QSettings(SsuSettings::sandboxPrefix() + fileName, format, parent){
defaultSettingsFile = SsuSettings::sandboxPrefix() + defaultFileName;
QSettings(Sandbox::map(fileName), format, parent){
defaultSettingsFile = Sandbox::map(defaultFileName);
upgrade();
}
SsuSettings::SsuSettings(const QString &fileName, const QString &settingsDirectory, QObject *parent):
QSettings(SsuSettings::sandboxPrefix() + fileName, QSettings::IniFormat, parent){
settingsd = SsuSettings::sandboxPrefix() + settingsDirectory;
QSettings(Sandbox::map(fileName), QSettings::IniFormat, parent){
settingsd = Sandbox::map(settingsDirectory);
merge();
}
QString SsuSettings::sandboxPrefix(){
/// @TODO: do some verification on the sandbox dir before using it
QString sandboxDir = getenv("SSU_SANDBOX_DIR");
if (!sandboxDir.isEmpty() && !sandboxDir.endsWith("/"))
sandboxDir += "/";
return sandboxDir;
}
void SsuSettings::merge(bool keepOld){
if (settingsd == "")
return;
......
......@@ -28,7 +28,6 @@ class SsuSettings: public QSettings {
* style settings are supported in this mode.
*/
SsuSettings(const QString &fileName, const QString &settingsDirectory, QObject *parent=0);
static QString sandboxPrefix();
private:
QString defaultSettingsFile, settingsd;
......
......@@ -10,6 +10,7 @@
#include <QDirIterator>
#include "ssukickstarter.h"
#include "libssu/sandbox_p.h"
#include "libssu/ssurepomanager.h"
#include "libssu/ssuvariables.h"
......@@ -22,7 +23,7 @@
SsuKickstarter::SsuKickstarter() {
pathPrefix = SsuSettings::sandboxPrefix();
pathPrefix = Sandbox::effectiveRootDir().path();
SsuDeviceInfo deviceInfo;
deviceModel = deviceInfo.deviceModel();
......
......@@ -15,6 +15,7 @@
#include "ssukickstarter.h"
#include "constants.h"
#include "libssu/sandbox_p.h"
#include "ssuks.h"
......@@ -43,14 +44,13 @@ void SsuKs::run(){
}
QString sandbox;
Sandbox *sb;
if (repoParameters.contains("sandbox")){
setenv("SSU_SANDBOX_DIR", repoParameters.value("sandbox").toLatin1(), 1);
sandbox = repoParameters.value("sandbox");
repoParameters.remove("sandbox");
}
sandbox = SsuSettings::sandboxPrefix();
if (!sandbox.isEmpty()){
// copy files into sandbox
QDirIterator it(SSU_DATA_DIR, QDir::AllEntries|QDir::NoDot|QDir::NoDotDot, QDirIterator::Subdirectories);
while (it.hasNext()){
it.next();
......@@ -72,6 +72,15 @@ void SsuKs::run(){
QString("%1/%2")
.arg(sandbox)
.arg(SSU_BOARD_MAPPING_CONFIGURATION_DIR));
sb = new Sandbox(sandbox, Sandbox::UseDirectly, Sandbox::ThisProcess);
if (sb->activate())
qout << "Using sandbox at " << sandbox << endl;
else {
qout << "Failed to activate sandbox" << endl;
return;
}
}
SsuKickstarter kickstarter;
......
......@@ -7,6 +7,7 @@ SUBDIRS = \
ut_deviceinfo \
ut_repomanager \
ut_rndssucli \
ut_sandbox \
ut_settings \
ut_ssuurlresolver \
ut_urlresolver \
......
......@@ -7,16 +7,15 @@
#include <QtTest/QtTest>
#include "libssu/sandbox_p.h"
#include "coreconfigtest.h"
int main(int argc, char **argv){
/*
Sandbox sandbox(QString("%1/configroot").arg(TESTS_DATA_PATH),
Sandbox::UseAsSkeleton, Sandbox::ThisProcess);
if (!sandbox.activate()){
qFatal("Failed to activate sandbox");
}
*/
CoreconfigTest coreconfigTest;
......
......@@ -7,16 +7,15 @@
#include <QtTest/QtTest>
#include "libssu/sandbox_p.h"
#include "deviceinfotest.h"
int main(int argc, char **argv){
/*
Sandbox sandbox(QString("%1/configroot").arg(TESTS_DATA_PATH),
Sandbox::UseAsSkeleton, Sandbox::ThisProcess);
if (!sandbox.activate()){
qFatal("Failed to activate sandbox");
}
*/
DeviceInfoTest deviceinfoTest;
......
......@@ -7,16 +7,15 @@
#include <QtTest/QtTest>
#include "libssu/sandbox_p.h"
#include "repomanagertest.h"
int main(int argc, char **argv){
/*
Sandbox sandbox(QString("%1/configroot").arg(TESTS_DATA_PATH),
Sandbox::UseAsSkeleton, Sandbox::ThisProcess);
if (!sandbox.activate()){
qFatal("Failed to activate sandbox");
}
*/
RepoManagerTest repomanagerTest;
......
......@@ -12,12 +12,12 @@
#include <QtTest/QtTest>
#include "libssu/sandbox_p.h"
#include "testutils/process.h"
typedef QStringList Args; // improve readability
void RndSsuCliTest::init(){
/*
Q_ASSERT(m_sandbox == 0);
m_sandbox = new Sandbox(QString("%1/configroot").arg(TESTS_DATA_PATH),
......@@ -26,14 +26,11 @@ void RndSsuCliTest::init(){
QFAIL("Failed to activate sandbox");
}
setenv("LD_PRELOAD", qPrintable(QString("%1/libsandboxhook.so").arg(TESTS_PATH)), 1);
*/
}
void RndSsuCliTest::cleanup(){
/*
delete m_sandbox;
m_sandbox = 0;
*/
}
void RndSsuCliTest::testSubcommandFlavour(){
......
......@@ -15,55 +15,55 @@ void SandboxTest::test(){
const QDir::Filters noHidden = QDir::AllEntries | QDir::NoDotAndDotDot;
QCOMPARE(QDir(TESTS_DATA_PATH "/world").entryList(noHidden, QDir::Name),
QCOMPARE(QDir(Sandbox::map(TESTS_DATA_PATH "/world")).entryList(noHidden, QDir::Name),
QStringList()
<< "world-and-sandbox"
<< "world-only"
<< "world-only-to-be-copied-into-sandbox");
QVERIFY(!QFileInfo(TESTS_DATA_PATH "/world/world-only").isWritable());
QCOMPARE(readAll(TESTS_DATA_PATH "/world/world-only").trimmed(),
QVERIFY(!QFileInfo(Sandbox::map(TESTS_DATA_PATH "/world/world-only")).isWritable());
QCOMPARE(readAll(Sandbox::map(TESTS_DATA_PATH "/world/world-only")).trimmed(),
QString("world/world-only"));
QVERIFY(!QFileInfo(TESTS_DATA_PATH "/world/world-and-sandbox").isWritable());
QCOMPARE(readAll(TESTS_DATA_PATH "/world/world-and-sandbox").trimmed(),
QVERIFY(!QFileInfo(Sandbox::map(TESTS_DATA_PATH "/world/world-and-sandbox")).isWritable());
QCOMPARE(readAll(Sandbox::map(TESTS_DATA_PATH "/world/world-and-sandbox")).trimmed(),
QString("world/world-and-sandbox"));
QVERIFY(!QFileInfo(TESTS_DATA_PATH "/world/world-only-to-be-copied-into-sandbox").isWritable());
QCOMPARE(readAll(TESTS_DATA_PATH "/world/world-only-to-be-copied-into-sandbox").trimmed(),
QString("world/world-only-to-be-copied-into-sandbox"));
QVERIFY(!QFileInfo(Sandbox::map(TESTS_DATA_PATH "/world/world-only-to-be-copied-into-sandbox"))
.isWritable());
QCOMPARE(readAll(Sandbox::map(TESTS_DATA_PATH "/world/world-only-to-be-copied-into-sandbox"))
.trimmed(), QString("world/world-only-to-be-copied-into-sandbox"));
QVERIFY(!QFileInfo(TESTS_DATA_PATH "/world/sandbox-only").exists());
QVERIFY(!QFileInfo(Sandbox::map(TESTS_DATA_PATH "/world/sandbox-only")).exists());
Sandbox sandbox(TESTS_DATA_PATH "/sandbox",
Sandbox sandbox(Sandbox::map(TESTS_DATA_PATH "/sandbox"),
Sandbox::UseAsSkeleton, Sandbox::ThisProcess | Sandbox::ChildProcesses);
sandbox.addWorldFiles(TESTS_DATA_PATH "/world", QDir::AllEntries,
sandbox.addWorldFiles(Sandbox::map(TESTS_DATA_PATH "/world"), QDir::AllEntries,
QStringList() << "*-to-be-copied-into-sandbox");
QVERIFY(sandbox.activate());
QCOMPARE(QDir(TESTS_DATA_PATH "/world").entryList(noHidden, QDir::Name),
QCOMPARE(QDir(Sandbox::map(TESTS_DATA_PATH "/world")).entryList(noHidden, QDir::Name),
QStringList()
<< "sandbox-only"
<< "world-and-sandbox"
<< "world-only"
<< "world-only-to-be-copied-into-sandbox");
QVERIFY(!QFileInfo(TESTS_DATA_PATH "/world/world-only").isWritable());
QCOMPARE(readAll(TESTS_DATA_PATH "/world/world-only").trimmed(),
QString("world/world-only"));
QVERIFY(!QFileInfo(Sandbox::map(TESTS_DATA_PATH "/world/world-only")).exists());
QVERIFY(QFileInfo(TESTS_DATA_PATH "/world/world-and-sandbox").isWritable());
QCOMPARE(readAll(TESTS_DATA_PATH "/world/world-and-sandbox").trimmed(),
QVERIFY(QFileInfo(Sandbox::map(TESTS_DATA_PATH "/world/world-and-sandbox")).isWritable());
QCOMPARE(readAll(Sandbox::map(TESTS_DATA_PATH "/world/world-and-sandbox")).trimmed(),
QString("sandbox/world-and-sandbox"));
QVERIFY(QFileInfo(TESTS_DATA_PATH "/world/world-only-to-be-copied-into-sandbox").isWritable());
QCOMPARE(readAll(TESTS_DATA_PATH "/world/world-only-to-be-copied-into-sandbox").trimmed(),
QString("world/world-only-to-be-copied-into-sandbox"));
QVERIFY(QFileInfo(Sandbox::map(TESTS_DATA_PATH "/world/world-only-to-be-copied-into-sandbox"))
.isWritable());
QCOMPARE(readAll(Sandbox::map(TESTS_DATA_PATH "/world/world-only-to-be-copied-into-sandbox"))
.trimmed(), QString("world/world-only-to-be-copied-into-sandbox"));
QVERIFY(QFileInfo(TESTS_DATA_PATH "/world/sandbox-only").exists());
QVERIFY(QFileInfo(TESTS_DATA_PATH "/world/sandbox-only").isWritable());
QCOMPARE(readAll(TESTS_DATA_PATH "/world/sandbox-only").trimmed(),
QVERIFY(QFileInfo(Sandbox::map(TESTS_DATA_PATH "/world/sandbox-only")).exists());
QVERIFY(QFileInfo(Sandbox::map(TESTS_DATA_PATH "/world/sandbox-only")).isWritable());
QCOMPARE(readAll(Sandbox::map(TESTS_DATA_PATH "/world/sandbox-only")).trimmed(),
QString("sandbox/sandbox-only"));
}
......
......@@ -7,16 +7,15 @@
#include <QtTest/QtTest>
#include "libssu/sandbox_p.h"
#include "urlresolvertest.cpp"
int main(int argc, char **argv){
/*
Sandbox sandbox(QString("%1/configroot").arg(TESTS_DATA_PATH),
Sandbox::UseAsSkeleton, Sandbox::ThisProcess);
if (!sandbox.activate()){
qFatal("Failed to activate sandbox");
}
*/
UrlResolverTest urlResolverTest;
......
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