Changeset View
Changeset View
Standalone View
Standalone View
src/ioslaves/file/file_unix.cpp
Show First 20 Lines • Show All 72 Lines • ▼ Show 20 Line(s) | |||||
73 | } | 73 | } | ||
74 | 74 | | |||
75 | static const QString socketPath() | 75 | static const QString socketPath() | ||
76 | { | 76 | { | ||
77 | const QString runtimeDir = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation); | 77 | const QString runtimeDir = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation); | ||
78 | return QStringLiteral("%1/filehelper%2%3").arg(runtimeDir, KRandom::randomString(6)).arg(getpid()); | 78 | return QStringLiteral("%1/filehelper%2%3").arg(runtimeDir, KRandom::randomString(6)).arg(getpid()); | ||
79 | } | 79 | } | ||
80 | 80 | | |||
81 | static QString actionDetails(ActionType actionType, const QVariantList &args) | ||||
dfaure: `const QVariantList &` | |||||
dfaure: marked as done, but not done | |||||
82 | { | ||||
83 | QString action, detail; | ||||
84 | switch (actionType) { | ||||
dfaure: missing space after `switch` (same rule as `if`, `for` etc.) | |||||
85 | case CHMOD: | ||||
all those { ... } braces are unnecessary in this switch, which doesn't define any new variables dfaure: all those { ... } braces are unnecessary in this switch, which doesn't define any new variables | |||||
86 | action = i18n("Change File Permissions"); | ||||
87 | detail = i18n("New Permissions: %1", args[1].toInt()); | ||||
dfaure: no space before ':' in English | |||||
dfaure: Not done | |||||
88 | break; | ||||
89 | case CHOWN: | ||||
90 | action = i18n("Change File Owner"); | ||||
91 | detail = i18n("New Owner: UID=%1, GID=%2", args[1].toInt(), args[2].toInt()); | ||||
dfaure: same | |||||
dfaure: same | |||||
92 | break; | ||||
93 | case DEL: | ||||
94 | action = i18n("Remove File"); | ||||
95 | break; | ||||
96 | case RMDIR: | ||||
97 | action = i18n("Remove Directory"); | ||||
98 | break; | ||||
99 | case MKDIR: | ||||
100 | action = i18n("Create Directory"); | ||||
101 | detail = i18n("Directory Permissions: %1", args[1].toInt()); | ||||
102 | break; | ||||
103 | case OPEN: | ||||
104 | action = i18n("Open File"); | ||||
105 | break; | ||||
106 | case OPENDIR: | ||||
107 | action = i18n("Open Directory"); | ||||
108 | break; | ||||
109 | case RENAME: | ||||
110 | action = i18n("Rename"); | ||||
111 | detail = i18n("New Filename: %1", args[1].toString()); | ||||
112 | break; | ||||
113 | case SYMLINK: | ||||
114 | action = i18n("Create Symlink"); | ||||
115 | detail = i18n("Target: %1", args[1].toString()); | ||||
116 | break; | ||||
117 | case UTIME: | ||||
118 | action = i18n("Change Timestamp"); | ||||
119 | break; | ||||
120 | default: | ||||
121 | action = i18n("Unknown Action"); | ||||
dfaure: weird indentation | |||||
dfaure: still there | |||||
122 | break; | ||||
123 | } | ||||
124 | | ||||
125 | const QString metadata = i18n("Action: %1\n" | ||||
126 | "Source: %2\n" | ||||
127 | "%3", action, args[0].toString(), detail); | ||||
128 | return metadata; | ||||
129 | } | ||||
130 | | ||||
81 | bool FileProtocol::privilegeOperationUnitTestMode() | 131 | bool FileProtocol::privilegeOperationUnitTestMode() | ||
82 | { | 132 | { | ||
83 | return (metaData(QStringLiteral("UnitTesting")) == QLatin1String("true")) | 133 | return (metaData(QStringLiteral("UnitTesting")) == QLatin1String("true")) | ||
84 | && (requestPrivilegeOperation() == KIO::OperationAllowed); | 134 | && (requestPrivilegeOperation() == KIO::OperationAllowed); | ||
85 | } | 135 | } | ||
86 | 136 | | |||
87 | PrivilegeOperationReturnValue FileProtocol::tryOpen(QFile &f, const QByteArray &path, int flags, int mode, int errcode) | 137 | PrivilegeOperationReturnValue FileProtocol::tryOpen(QFile &f, const QByteArray &path, int flags, int mode, int errcode) | ||
88 | { | 138 | { | ||
▲ Show 20 Lines • Show All 785 Lines • ▼ Show 20 Line(s) | 918 | { | |||
874 | if (true) { | 924 | if (true) { | ||
875 | return PrivilegeOperationReturnValue::failure(errcode); | 925 | return PrivilegeOperationReturnValue::failure(errcode); | ||
876 | } | 926 | } | ||
877 | 927 | | |||
878 | if (!(errcode == EACCES || errcode == EPERM)) { | 928 | if (!(errcode == EACCES || errcode == EPERM)) { | ||
879 | return PrivilegeOperationReturnValue::failure(errcode); | 929 | return PrivilegeOperationReturnValue::failure(errcode); | ||
880 | } | 930 | } | ||
881 | 931 | | |||
882 | KIO::PrivilegeOperationStatus opStatus = requestPrivilegeOperation(); | 932 | const QString operationDetails = actionDetails(action, args); | ||
933 | KIO::PrivilegeOperationStatus opStatus = requestPrivilegeOperation(operationDetails); | ||||
883 | if (opStatus != KIO::OperationAllowed) { | 934 | if (opStatus != KIO::OperationAllowed) { | ||
884 | if (opStatus == KIO::OperationCanceled) { | 935 | if (opStatus == KIO::OperationCanceled) { | ||
885 | error(KIO::ERR_USER_CANCELED, QString()); | 936 | error(KIO::ERR_USER_CANCELED, QString()); | ||
886 | return PrivilegeOperationReturnValue::canceled(); | 937 | return PrivilegeOperationReturnValue::canceled(); | ||
887 | } | 938 | } | ||
888 | return PrivilegeOperationReturnValue::failure(errcode); | 939 | return PrivilegeOperationReturnValue::failure(errcode); | ||
889 | } | 940 | } | ||
890 | 941 | | |||
Show All 36 Lines |
const QVariantList &