diff options
Diffstat (limited to 'src/common/include/permissible-set.h')
-rw-r--r-- | src/common/include/permissible-set.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/common/include/permissible-set.h b/src/common/include/permissible-set.h index 9c2889ae..aaa6d5b0 100644 --- a/src/common/include/permissible-set.h +++ b/src/common/include/permissible-set.h @@ -48,6 +48,7 @@ public: DECLARE_EXCEPTION_TYPE(Base, FileWriteError) DECLARE_EXCEPTION_TYPE(Base, FileInitError) DECLARE_EXCEPTION_TYPE(Base, FileRemoveError) + DECLARE_EXCEPTION_TYPE(Base, FileIntegrityError) }; /** @@ -61,11 +62,31 @@ public: std::string getPermissibleFileLocation(uid_t uid, int installationType); /** + * Calculate a SHA-1 hash of given string + * + * @param[in] content content string to be hashed + * @return a 40 char long string that contains the hash encoded in hex + */ +std::string calculateHash(const std::string& content); + +/** + * Hash the file content and compare the result with the hash at the beginning + * of the file (if present) in order to detect possible corruption. + * @throws FileReadError + * @throws FileIntegrityError + * + * @param[in] nameFile path to the labels file + * @param[in] fstream open ifstream from the labe;s file + */ +void verifyFileIntegrity(const std::string &nameFile, std::ifstream &fstream); + +/** * Update permissible file, 1st removing some labels from the list and then, * adding new labels to the list (in this particular order). * @throws FileLockError * @throws FileOpenError * @throws FileWriteError + * @throws FileIntegrityError * * @param[in] uid user id * @param[in] installationType type of installation (global or local) @@ -81,6 +102,7 @@ void updatePermissibleFile(uid_t uid, int installationType, * @throws FileLockError * @throws FileOpenError * @throws FileReadError + * @throws FileIntegrityError * * @param[in] nameFile path to the labels file * @param[out] appLabels vector to which application labels are added |