Changeset View
Changeset View
Standalone View
Standalone View
src/ioslaves/file/file_unix.cpp
Show First 20 Lines • Show All 845 Lines • ▼ Show 20 Line(s) | 831 | { | |||
---|---|---|---|---|---|
846 | if (opStatus != KIO::OperationAllowed) { | 846 | if (opStatus != KIO::OperationAllowed) { | ||
847 | if (opStatus == KIO::OperationCanceled) { | 847 | if (opStatus == KIO::OperationCanceled) { | ||
848 | error(KIO::ERR_USER_CANCELED, QString()); | 848 | error(KIO::ERR_USER_CANCELED, QString()); | ||
849 | return PrivilegeOperationReturnValue::canceled(); | 849 | return PrivilegeOperationReturnValue::canceled(); | ||
850 | } | 850 | } | ||
851 | return PrivilegeOperationReturnValue::failure(errcode); | 851 | return PrivilegeOperationReturnValue::failure(errcode); | ||
852 | } | 852 | } | ||
853 | 853 | | |||
854 | const QUrl targetUrl = QUrl::fromLocalFile(args.first().toString()); // target is always the first item. | ||||
855 | const bool useParent = action != CHOWN && action != CHMOD && action != UTIME; | ||||
856 | const QString targetPath = useParent ? targetUrl.adjusted(QUrl::RemoveFilename).toLocalFile() : targetUrl.toLocalFile(); | ||||
857 | bool userIsOwner = QFileInfo(targetPath).ownerId() == getuid(); | ||||
858 | if (action == RENAME) { // for rename check src and dest owner | ||||
859 | QString dest = QUrl(args[1].toString()).toLocalFile(); | ||||
860 | userIsOwner = userIsOwner && QFileInfo(dest).ownerId() == getuid(); | ||||
861 | } | ||||
862 | if (userIsOwner) { | ||||
863 | error(KIO::ERR_PRIVILEGE_NOT_REQUIRED, targetPath); | ||||
864 | return PrivilegeOperationReturnValue::canceled(); | ||||
865 | } | ||||
866 | | ||||
854 | QByteArray helperArgs; | 867 | QByteArray helperArgs; | ||
855 | QDataStream out(&helperArgs, QIODevice::WriteOnly); | 868 | QDataStream out(&helperArgs, QIODevice::WriteOnly); | ||
856 | out << action; | 869 | out << action; | ||
857 | foreach (const QVariant &arg, args) { | 870 | foreach (const QVariant &arg, args) { | ||
858 | out << arg; | 871 | out << arg; | ||
859 | } | 872 | } | ||
860 | 873 | | |||
861 | const QString actionId = QStringLiteral("org.kde.kio.file.exec"); | 874 | const QString actionId = QStringLiteral("org.kde.kio.file.exec"); | ||
Show All 15 Lines |