Google APIs Client Library for C++
|
Helper functions for managing sensitive files. More...
#include "client/util/file_utils.h"
Static Public Member Functions | |
static util::Status | VerifyIsSecureFile (const string &path, bool writable_allowed) |
Checks that the provided path is secure file. | |
static util::Status | VerifyIsSecureDirectory (const string &path) |
Checks that the provided path is a secure directory. | |
static util::Status | CreateSecureDirectoryRecursively (const string &path) |
Creates a secure directory at the specified path if it does not already exist. | |
static util::Status | WriteSensitiveStringToFile (const StringPiece &data, const string &path, bool overwrite) |
Writes the given data to a secure file at the specified path. | |
static util::Status | DeleteSensitiveFile (const string &path) |
Deletes the file, but does not prevent the data from being unrecoverable. |
Helper functions for managing sensitive files.
WARNING(ewiseblatt): 20130304 These files are not reliably secure. We are managing OS level permissions and relying on the OS to protect the contents. We make some attempt to securely delete the contents of files but not necessarily robust. For truely sensitive data, consider encrypting the files instead.
static util::Status CreateSecureDirectoryRecursively | ( | const string & | path | ) | [static] |
Creates a secure directory at the specified path if it does not already exist.
Any directories that are created will be created wth secure permissions (user rwx only).
[in] | path | The desired directory path. |
static util::Status DeleteSensitiveFile | ( | const string & | path | ) | [static] |
Deletes the file, but does not prevent the data from being unrecoverable.
This function will make some attempts to prevent the data from being reovered, it is still not secure. There are many ways in which the OS itself may have leaked some data on disk.
[in] | path | The to the file to delete |
static util::Status VerifyIsSecureDirectory | ( | const string & | path | ) | [static] |
Checks that the provided path is a secure directory.
[in] | path | The path to check should be an existing directoy. |
static util::Status VerifyIsSecureFile | ( | const string & | path, |
bool | writable_allowed | ||
) | [static] |
Checks that the provided path is secure file.
Secure paths can only be user read-writable and not a symbolic link.
[in] | path | The path to check should be an existing file. |
[in] | writable_allowed | true if path may be writable. false if it must be read-only. |
static util::Status WriteSensitiveStringToFile | ( | const StringPiece & | data, |
const string & | path, | ||
bool | overwrite | ||
) | [static] |
Writes the given data to a secure file at the specified path.
[in] | data | The data to write is considered a binary string so will not be implicitly null terminated. |
[in] | path | The path to write to. |
[in] | overwrite | If true then overwrite any existing file at the path. Otherwise fail if a file already exists. |