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"
|
2015-11-12 20:43:11 +01:00
|
|
|
#include "../config/CryConfigFile.h"
|
2015-10-29 10:47:14 +01:00
|
|
|
#include <boost/filesystem/path.hpp>
|
2016-02-11 16:39:42 +01:00
|
|
|
#include <cpp-utils/tempfile/TempFile.h>
|
|
|
|
#include <cpp-utils/io/Console.h>
|
|
|
|
#include <cpp-utils/random/RandomGenerator.h>
|
|
|
|
#include <cpp-utils/network/HttpClient.h>
|
2015-11-13 00:06:53 +01:00
|
|
|
#include "CallAfterTimeout.h"
|
2015-10-29 10:47:14 +01:00
|
|
|
|
|
|
|
namespace cryfs {
|
|
|
|
class Cli final {
|
|
|
|
public:
|
2016-01-28 18:55:26 +01:00
|
|
|
Cli(cpputils::RandomGenerator &keyGenerator, const cpputils::SCryptSettings &scryptSettings, std::shared_ptr<cpputils::Console> console, std::shared_ptr<cpputils::HttpClient> httpClient);
|
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);
|
2015-11-19 10:08:09 +01:00
|
|
|
std::string _getPassword(const program_options::ProgramOptions &options, std::function<std::string()> askPassword);
|
|
|
|
static std::string _askPasswordForExistingFilesystem();
|
|
|
|
static std::string _askPasswordForNewFilesystem();
|
2016-02-12 23:18:13 +01:00
|
|
|
static std::string _askPasswordFromStdin(const std::string &prompt);
|
2015-11-19 10:08:09 +01:00
|
|
|
static bool _confirmPassword(const std::string &password);
|
|
|
|
static bool _checkPassword(const std::string &password);
|
2015-11-03 21:22:35 +01:00
|
|
|
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);
|
2015-11-13 00:06:53 +01:00
|
|
|
boost::optional<cpputils::unique_ref<CallAfterTimeout>> _createIdleCallback(boost::optional<double> minutes, std::function<void()> callback);
|
2015-11-03 21:22:35 +01:00
|
|
|
|
|
|
|
cpputils::RandomGenerator &_keyGenerator;
|
2015-11-04 05:27:00 +01:00
|
|
|
cpputils::SCryptSettings _scryptSettings;
|
2016-01-25 15:01:34 +01:00
|
|
|
std::shared_ptr<cpputils::Console> _console;
|
2016-01-28 18:55:26 +01:00
|
|
|
std::shared_ptr<cpputils::HttpClient> _httpClient;
|
2015-11-27 14:06:17 +01:00
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(Cli);
|
2015-10-29 10:47:14 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|