2015-10-29 10:47:14 +01:00
|
|
|
#pragma once
|
|
|
|
#ifndef MESSMER_CRYFS_CLI_H
|
|
|
|
#define MESSMER_CRYFS_CLI_H
|
|
|
|
|
|
|
|
#include "program_options/ProgramOptions.h"
|
|
|
|
#include "config/CryConfigFile.h"
|
|
|
|
#include <boost/filesystem/path.hpp>
|
2015-10-30 18:28:33 +01:00
|
|
|
#include <messmer/cpp-utils/tempfile/TempFile.h>
|
2015-11-03 21:22:35 +01:00
|
|
|
#include <messmer/cpp-utils/random/RandomGenerator.h>
|
2015-10-29 10:47:14 +01:00
|
|
|
|
|
|
|
namespace cryfs {
|
|
|
|
class Cli final {
|
|
|
|
public:
|
2015-11-04 05:27:00 +01:00
|
|
|
Cli(cpputils::RandomGenerator &keyGenerator, const cpputils::SCryptSettings &scryptSettings);
|
2015-10-29 10:47:14 +01:00
|
|
|
int main(int argc, char *argv[]);
|
|
|
|
|
|
|
|
private:
|
2015-11-03 21:22:35 +01:00
|
|
|
void _runFilesystem(const program_options::ProgramOptions &options);
|
|
|
|
CryConfigFile _loadOrCreateConfig(const program_options::ProgramOptions &options);
|
|
|
|
boost::filesystem::path _determineConfigFile(const program_options::ProgramOptions &options);
|
|
|
|
std::string _getPassword(const program_options::ProgramOptions &options);
|
|
|
|
std::string _askPassword();
|
|
|
|
bool _checkPassword(const std::string &password);
|
|
|
|
void _showVersion();
|
|
|
|
void _initLogfile(const program_options::ProgramOptions &options);
|
|
|
|
void _sanityChecks(const program_options::ProgramOptions &options);
|
|
|
|
void _checkMountdirDoesntContainBasedir(const program_options::ProgramOptions &options);
|
|
|
|
bool _pathContains(const boost::filesystem::path &parent, const boost::filesystem::path &child);
|
|
|
|
void _checkDirAccessible(const boost::filesystem::path &dir, const std::string &name);
|
|
|
|
std::shared_ptr<cpputils::TempFile> _checkDirWriteable(const boost::filesystem::path &dir, const std::string &name);
|
|
|
|
void _checkDirReadable(const boost::filesystem::path &dir, std::shared_ptr<cpputils::TempFile> tempfile, const std::string &name);
|
|
|
|
|
|
|
|
cpputils::RandomGenerator &_keyGenerator;
|
2015-11-04 05:27:00 +01:00
|
|
|
cpputils::SCryptSettings _scryptSettings;
|
2015-10-29 10:47:14 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|