Changeset View
Changeset View
Standalone View
Standalone View
src/buffer/katesecuretextbuffer_p.h
Context not available. | |||||
23 | 23 | | |||
---|---|---|---|---|---|
24 | #include <QObject> | 24 | #include <QObject> | ||
25 | #include <QString> | 25 | #include <QString> | ||
26 | #include <QCryptographicHash> | ||||
26 | 27 | | |||
27 | #include <kauth.h> | 28 | #include <kauth.h> | ||
28 | 29 | | |||
Context not available. | |||||
43 | 44 | | |||
44 | public: | 45 | public: | ||
45 | 46 | | |||
46 | /** | | |||
47 | * We support Prepare action for temporary file creation | | |||
48 | * and Move action for moving final file to its destination | | |||
49 | */ | | |||
50 | enum ActionMode { | | |||
51 | Prepare = 1, | | |||
52 | Move = 2 | | |||
53 | }; | | |||
54 | | ||||
55 | SecureTextBuffer() {} | 47 | SecureTextBuffer() {} | ||
56 | 48 | | |||
57 | ~SecureTextBuffer() {} | 49 | ~SecureTextBuffer() {} | ||
58 | 50 | | |||
59 | /** | 51 | /** | ||
60 | * Common helper methods | 52 | * Common helper method | ||
61 | */ | 53 | */ | ||
62 | static void setOwner(const QString &filename, const uint ownerId, const uint groupId); | 54 | static void setOwner(const int filedes, const uint ownerId, const uint groupId); | ||
63 | static void syncToDisk(const int fd); | 55 | | ||
56 | static const QCryptographicHash::Algorithm checksumAlgorithm = QCryptographicHash::Algorithm::Sha512; | ||||
64 | 57 | | |||
65 | private: | 58 | private: | ||
66 | static const qint64 bufferLength = 4096; | 59 | static const qint64 bufferLength = 4096; | ||
67 | 60 | | |||
68 | /** | 61 | /** | ||
69 | * Creates temporary file based on given target file path. | 62 | * Saves file contents using sets permissions. | ||
70 | * Temporary file is set to not be deleted on object destroy | | |||
71 | * so KTextEditor can save contents in it. | | |||
72 | */ | 63 | */ | ||
73 | static QString prepareTempFileInternal(const QString &targetFile, const uint ownerId); | 64 | static bool saveFileInternal(const QString &sourceFile, const QString &targetFile, | ||
65 | const QByteArray &checksum, const uint ownerId, const uint groupId); | ||||
74 | 66 | | |||
75 | /** | 67 | static bool moveFile(const QString &sourceFile, const QString &targetFile); | ||
76 | * Move file to its given destination and set owner. | 68 | | ||
77 | */ | 69 | static void syncToDisk(const int fd); | ||
78 | static bool moveFileInternal(const QString &sourceFile, const QString &targetFile, const uint ownerId, const uint groupId); | | |||
79 | 70 | | |||
80 | public Q_SLOTS: | 71 | public Q_SLOTS: | ||
81 | /** | 72 | /** | ||
Context not available. |