Commit 1aeefc01 authored by Fabian Vogt's avatar Fabian Vogt

Merge branch 'ebadffix' into 'master'

Don't try to mount outside of remote dirs

See merge request kde/kio-fuse!5
parents 83b1018a dfd8e3c7
......@@ -1078,8 +1078,17 @@ void KIOFuseVFS::lookup(fuse_req_t req, fuse_ino_t parent, const char *name)
if(auto child = that->nodeByName(parentNode, nodeName))
return that->replyEntry(req, child);
// Not found - try again
that->mountUrl(QUrl(that->remoteUrl(parentNode).toString() + QLatin1Char('/') + nodeName), [=](auto node, int error) {
QUrl url = that->remoteUrl(parentNode);
if(url.isEmpty())
{
// Directory not remote, so definitely does not exist
fuse_reply_err(req, ENOENT);
return;
}
// Not in the local tree, but remote - try again
url.setPath(url.path() + QLatin1Char('/') + nodeName);
that->mountUrl(url, [=](auto node, int error) {
if(error && error != ENOENT)
fuse_reply_err(req, error);
else
......
......@@ -53,6 +53,8 @@ private Q_SLOTS:
void testDeletionOps();
void testArchiveOps();
void testKioErrorMapping();
void testRootLookup();
void testFilenameEscaping();
#ifdef WASTE_DISK_SPACE
void testReadWrite4GBFile();
#endif // WASTE_DISK_SPACE
......@@ -576,6 +578,42 @@ void FileOpsTest::testKioErrorMapping()
QCOMPARE(errno, EPERM);
}
void FileOpsTest::testRootLookup()
{
struct stat st;
// Verify that it does not exist...
QCOMPARE(stat(qPrintable(QStringLiteral("%1/invalid").arg(m_mountDir.path())), &st), -1);
// ... and set errno correctly
QCOMPARE(errno, ENOENT);
}
void FileOpsTest::testFilenameEscaping()
{
QTemporaryDir localDir;
QVERIFY(localDir.isValid());
// Mount the temporary dir
QString reply = m_kiofuse_iface.mountUrl(QStringLiteral("file://%1").arg(localDir.path())).value();
QVERIFY(!reply.isEmpty());
QDir mirrorDir(reply);
QVERIFY(mirrorDir.exists());
// Create a file in localDir with an "unusual" filename
for(const QString &name : {QStringLiteral("file0?name"),
QStringLiteral("file1#name"), QStringLiteral("file2%20name"),
QStringLiteral("file2 \nname?asdf&foo#bar")})
{
QFile localFile(localDir.filePath(name));
QVERIFY(localFile.open(QFile::WriteOnly));
QCOMPARE(localFile.write("teststring", 10), 10);
localFile.close();
QFile mirrorFile(mirrorDir.filePath(name));
QVERIFY2(mirrorFile.open(QFile::ReadOnly), name.toUtf8().data());
QCOMPARE(mirrorFile.readAll(), QStringLiteral("teststring").toUtf8());
}
}
#ifdef WASTE_DISK_SPACE
void FileOpsTest::testReadWrite4GBFile()
......
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