Index: src/core/chmodjob.cpp =================================================================== --- src/core/chmodjob.cpp +++ src/core/chmodjob.cpp @@ -87,6 +87,10 @@ if (!(flags & HideProgressInfo)) { KIO::getJobTracker()->registerJob(job); } + if (!(flags & NoPrivilegeExecution)) { + job->d_func()->m_privilegeExecutionEnabled = true; + job->d_func()->m_operationType = ChangeAttr; + } return job; } }; @@ -231,6 +235,7 @@ /*qDebug() << "chmod'ing" << info.url << "to" << QString::number(info.permissions,8);*/ KIO::SimpleJob *job = KIO::chmod(info.url, info.permissions); + job->setParentJob(q); // copy the metadata for acl and default acl const QString aclString = q->queryMetaData(QStringLiteral("ACL_STRING")); const QString defaultAclString = q->queryMetaData(QStringLiteral("DEFAULT_ACL_STRING")); Index: src/core/copyjob.cpp =================================================================== --- src/core/copyjob.cpp +++ src/core/copyjob.cpp @@ -264,6 +264,8 @@ void slotReport(); + KIO::JobFlag privilegeExecFlag() const { return m_privilegeExecutionEnabled ? PrivilegeExecution : DefaultFlags; } + Q_DECLARE_PUBLIC(CopyJob) static inline CopyJob *newJob(const QList &src, const QUrl &dest, @@ -278,6 +280,22 @@ job->d_func()->m_bOverwriteAllDirs = true; job->d_func()->m_bOverwriteAllFiles = true; } + if (!(flags & KIO::NoPrivilegeExecution)) { + job->d_func()->m_privilegeExecutionEnabled = true; + FileOperationType copyType; + switch (mode) { + case CopyJob::Copy: + copyType = Copy; + break; + case CopyJob::Move: + copyType = Move; + break; + case CopyJob::Link: + copyType = Symlink; + break; + } + job->d_func()->m_operationType = copyType; + } return job; } }; @@ -923,6 +941,7 @@ KIO_ARGS << m_currentSrcURL << dest << (qint8) false /*no overwrite*/; SimpleJob *newJob = SimpleJobPrivate::newJobNoUi(slave_url, CMD_RENAME, packedArgs); + newJob->setParentJob(q); Scheduler::setJobPriority(newJob, 1); q->addSubjob(newJob); if (m_currentSrcURL.adjusted(QUrl::RemoveFilename) != dest.adjusted(QUrl::RemoveFilename)) { // For the user, moving isn't renaming. Only renaming is. @@ -1227,6 +1246,7 @@ // Create the directory - with default permissions so that we can put files into it // TODO : change permissions once all is finished; but for stuff coming from CDROM it sucks... KIO::SimpleJob *newjob = KIO::mkdir(udir, -1); + newjob->setParentJob(q); Scheduler::setJobPriority(newjob, 1); if (shouldOverwriteFile(udir.path())) { // if we are overwriting an existing file or symlink newjob->addMetaData(QStringLiteral("overwrite"), QStringLiteral("true")); @@ -1328,7 +1348,8 @@ assert(!q->hasSubjobs()); // The only problem with this trick is that the error handling for this del operation // is not going to be right... see 'Very special case' above. - KIO::Job *newjob = KIO::del((*it).uSource, HideProgressInfo); + KIO::Job *newjob = KIO::del((*it).uSource, HideProgressInfo | privilegeExecFlag()); + newjob->setParentJob(q); q->addSubjob(newjob); return; // Don't move to next file yet ! } @@ -1504,7 +1525,8 @@ (uSource.userName() == uDest.userName()) && (uSource.password() == uDest.password())) { // This is the case of creating a real symlink - KIO::SimpleJob *newJob = KIO::symlink(uSource.path(), uDest, flags | HideProgressInfo /*no GUI*/); + KIO::SimpleJob *newJob = KIO::symlink(uSource.path(), uDest, flags | HideProgressInfo /*no GUI*/ | privilegeExecFlag()); + newJob->setParentJob(q_func()); Scheduler::setJobPriority(newJob, 1); qCDebug(KIO_COPYJOB_DEBUG) << "Linking target=" << uSource.path() << "link=" << uDest; //emit linking( this, uSource.path(), uDest ); @@ -1632,7 +1654,8 @@ (uSource.password() == uDest.password())) // Copying a symlink - only on the same protocol/host/etc. (#5601, downloading an FTP file through its link), { - KIO::SimpleJob *newJob = KIO::symlink((*it).linkDest, uDest, flags | HideProgressInfo /*no GUI*/); + KIO::SimpleJob *newJob = KIO::symlink((*it).linkDest, uDest, flags | HideProgressInfo /*no GUI*/ | privilegeExecFlag()); + newJob->setParentJob(q); Scheduler::setJobPriority(newJob, 1); newjob = newJob; qCDebug(KIO_COPYJOB_DEBUG) << "Linking target=" << (*it).linkDest << "link=" << uDest; @@ -1644,7 +1667,8 @@ m_bCurrentOperationIsLink = true; // NOTE: if we are moving stuff, the deletion of the source will be done in slotResultCopyingFiles } else if (m_mode == CopyJob::Move) { // Moving a file - KIO::FileCopyJob *moveJob = KIO::file_move(uSource, uDest, permissions, flags | HideProgressInfo/*no GUI*/); + KIO::FileCopyJob *moveJob = KIO::file_move(uSource, uDest, permissions, flags | HideProgressInfo/*no GUI*/ | privilegeExecFlag()); + moveJob->setParentJob(q); moveJob->setSourceSize((*it).size); moveJob->setModificationTime((*it).mtime); // #55804 newjob = moveJob; @@ -1655,7 +1679,7 @@ m_bURLDirty = true; //Observer::self()->slotMoving( this, uSource, uDest ); } else { // Copying a file - KIO::FileCopyJob *copyJob = KIO::file_copy(uSource, uDest, permissions, flags | HideProgressInfo/*no GUI*/); + KIO::FileCopyJob *copyJob = KIO::file_copy(uSource, uDest, permissions, flags | HideProgressInfo/*no GUI*/ | privilegeExecFlag()); copyJob->setParentJob(q); // in case of rename dialog copyJob->setSourceSize((*it).size); copyJob->setModificationTime((*it).mtime); @@ -1686,6 +1710,7 @@ // Take first dir to delete out of list - last ones first ! QList::Iterator it = --dirsToRemove.end(); SimpleJob *job = KIO::rmdir(*it); + job->setParentJob(q); Scheduler::setJobPriority(job, 1); dirsToRemove.erase(it); q->addSubjob(job); @@ -1710,6 +1735,7 @@ ++m_directoriesCopiedIterator; KIO::SimpleJob *job = KIO::setModificationTime(url, dt); + job->setParentJob(q); Scheduler::setJobPriority(job, 1); q->addSubjob(job); Index: src/core/deletejob.cpp =================================================================== --- src/core/deletejob.cpp +++ src/core/deletejob.cpp @@ -110,6 +110,10 @@ if (!(flags & HideProgressInfo)) { KIO::getJobTracker()->registerJob(job); } + if (!(flags & NoPrivilegeExecution)) { + job->d_func()->m_privilegeExecutionEnabled = true; + job->d_func()->m_operationType = Delete; + } return job; } }; @@ -305,6 +309,7 @@ job = KIO::http_delete(*it, KIO::HideProgressInfo); } else { job = KIO::file_delete(*it, KIO::HideProgressInfo); + job->setParentJob(q); } Scheduler::setJobPriority(job, 1); m_currentURL = (*it); @@ -343,6 +348,7 @@ // Call rmdir - works for kioslaves with canDeleteRecursive too, // CMD_DEL will trigger the recursive deletion in the slave. SimpleJob *job = KIO::rmdir(*it); + job->setParentJob(q); job->addMetaData(QStringLiteral("recurse"), QStringLiteral("true")); Scheduler::setJobPriority(job, 1); dirs.erase(it); Index: src/core/filecopyjob.cpp =================================================================== --- src/core/filecopyjob.cpp +++ src/core/filecopyjob.cpp @@ -111,6 +111,10 @@ if (!(flags & HideProgressInfo)) { KIO::getJobTracker()->registerJob(job); } + if (!(flags & NoPrivilegeExecution)) { + job->d_func()->m_privilegeExecutionEnabled = true; + job->d_func()->m_operationType = move ? Move : Copy; + } return job; } }; @@ -217,6 +221,7 @@ //qDebug(); KIO_ARGS << m_src << m_dest << m_permissions << (qint8)(m_flags & Overwrite); m_copyJob = new DirectCopyJob(slave_url, packedArgs); + m_copyJob->setParentJob(q); if (m_modificationTime.isValid()) { m_copyJob->addMetaData(QStringLiteral("modified"), m_modificationTime.toString(Qt::ISODate)); // #55804 } @@ -232,6 +237,7 @@ m_mustChmod = true; // CMD_RENAME by itself doesn't change permissions KIO_ARGS << m_src << m_dest << (qint8)(m_flags & Overwrite); m_moveJob = SimpleJobPrivate::newJobNoUi(slave_url, CMD_RENAME, packedArgs); + m_moveJob->setParentJob(q); if (m_modificationTime.isValid()) { m_moveJob->addMetaData(QStringLiteral("modified"), m_modificationTime.toString(Qt::ISODate)); // #55804 } @@ -332,6 +338,7 @@ m_resumeAnswerSent = false; m_getJob = nullptr; // for now m_putJob = put(m_dest, m_permissions, (m_flags | HideProgressInfo) /* no GUI */); + m_putJob->setParentJob(q); //qDebug() << "m_putJob=" << m_putJob << "m_dest=" << m_dest; if (m_modificationTime.isValid()) { m_putJob->setModificationTime(m_modificationTime); @@ -388,6 +395,7 @@ if (job == m_putJob) { m_getJob = KIO::get(m_src, NoReload, HideProgressInfo /* no GUI */); + m_getJob->setParentJob(q); //qDebug() << "m_getJob=" << m_getJob << m_src; m_getJob->addMetaData(QStringLiteral("errorPage"), QStringLiteral("false")); m_getJob->addMetaData(QStringLiteral("AllowCompressedPage"), QStringLiteral("false")); Index: src/core/job_p.h =================================================================== --- src/core/job_p.h +++ src/core/job_p.h @@ -249,6 +249,23 @@ if (!(flags & HideProgressInfo)) { KIO::getJobTracker()->registerJob(job); } + if (!(flags & NoPrivilegeExecution)) { + job->d_func()->m_privilegeExecutionEnabled = true; + // Only delete, rename and symlink operation accept JobFlags. + FileOperationType opType; + switch (command) { + case CMD_DEL: + opType = Delete; + break; + case CMD_RENAME: + opType = Rename; + break; + case CMD_SYMLINK: + opType = Symlink; + break; + } + job->d_func()->m_operationType = opType; + } return job; } }; @@ -322,6 +339,10 @@ if (!(flags & HideProgressInfo)) { KIO::getJobTracker()->registerJob(job); } + if (!(flags & NoPrivilegeExecution)) { + job->d_func()->m_privilegeExecutionEnabled = true; + job->d_func()->m_operationType = Transfer; + } return job; } @@ -335,6 +356,10 @@ if (!(flags & HideProgressInfo)) { KIO::getJobTracker()->registerJob(job); } + if (!(flags & NoPrivilegeExecution)) { + job->d_func()->m_privilegeExecutionEnabled = true; + job->d_func()->m_operationType = Transfer; + } return job; } }; Index: src/core/mkpathjob.cpp =================================================================== --- src/core/mkpathjob.cpp +++ src/core/mkpathjob.cpp @@ -88,6 +88,10 @@ if (!(flags & HideProgressInfo)) { KIO::getJobTracker()->registerJob(job); } + if (!(flags & NoPrivilegeExecution)) { + job->d_func()->m_privilegeExecutionEnabled = true; + job->d_func()->m_operationType = MkDir; + } return job; } @@ -106,14 +110,14 @@ void MkpathJobPrivate::slotStart() { Q_Q(MkpathJob); - if (m_pathIterator == m_pathComponents.constBegin()) { // first time: emit total q->setTotalAmount(KJob::Directories, m_pathComponents.count()); } if (m_pathIterator != m_pathComponents.constEnd()) { m_url.setPath(m_url.path() + '/' + *m_pathIterator); KIO::Job* job = KIO::mkdir(m_url); + job->setParentJob(q); q->addSubjob(job); q->setProcessedAmount(KJob::Directories, q->processedAmount(KJob::Directories) + 1); } else { Index: src/core/simplejob.cpp =================================================================== --- src/core/simplejob.cpp +++ src/core/simplejob.cpp @@ -377,7 +377,7 @@ { //qDebug() << "rename " << src << " " << dest; KIO_ARGS << src << dest << (qint8)(flags & Overwrite); - return SimpleJobPrivate::newJob(src, CMD_RENAME, packedArgs); + return SimpleJobPrivate::newJob(src, CMD_RENAME, packedArgs, flags); } SimpleJob *KIO::symlink(const QString &target, const QUrl &dest, JobFlags flags) Index: src/core/storedtransferjob.cpp =================================================================== --- src/core/storedtransferjob.cpp +++ src/core/storedtransferjob.cpp @@ -61,6 +61,10 @@ if (!(flags & HideProgressInfo)) { KIO::getJobTracker()->registerJob(job); } + if (!(flags & NoPrivilegeExecution)) { + job->d_func()->m_privilegeExecutionEnabled = true; + job->d_func()->m_operationType = Transfer; + } return job; } @@ -74,6 +78,10 @@ if (!(flags & HideProgressInfo)) { KIO::getJobTracker()->registerJob(job); } + if (!(flags & NoPrivilegeExecution)) { + job->d_func()->m_privilegeExecutionEnabled = true; + job->d_func()->m_operationType = Transfer; + } return job; } };