5 #include "cvmfs_config.h"
26 if (getenv(
"TMPDIR") != NULL)
46 std::vector<std::string> targets;
54 for (
unsigned i = 0; i < targets.size(); ++i) {
55 bool rv =
MkdirDeep(targets[i], 0700,
true );
123 if (union_fs ==
"aufs") {
125 }
else if ((union_fs ==
"overlay") || (union_fs ==
"overlayfs")) {
127 }
else if (union_fs ==
"tarball") {
130 throw EPublish(
"unsupported union file system: " + union_fs);
146 throw EPublish(
"neither AUFS nor OverlayFS detected on the system");
169 const std::string &from,
const std::string &to)
172 throw EPublish(
"template transaction's 'from' path must not be empty");
174 throw EPublish(
"template transaction's 'to' path must not be empty");
189 const std::string &s3_config,
190 const std::string &tmp_dir)
204 const std::string &host,
206 const std::string &tmp_dir)
214 std::vector<std::string> tokens =
SplitString(locator,
',');
215 if (tokens.size() != 3) {
216 throw EPublish(
"malformed storage locator, expected format is "
217 "<type>,<temporary directory>,<endpoint>");
219 if (tokens[0] ==
"local") {
221 }
else if (tokens[0] ==
"S3") {
223 }
else if (tokens[0] ==
"gw") {
226 throw EPublish(
"unsupported storage type: " + tokens[0]);
281 : fqrn_(settings_publisher.fqrn())
282 , url_(settings_publisher.url())
283 , proxy_(settings_publisher.proxy())
284 , tmp_dir_(settings_publisher.transaction().spool_area().tmp_dir())
285 , keychain_(settings_publisher.fqrn())
293 : fqrn_(settings_replica.fqrn())
294 , url_(settings_replica.url())
295 , keychain_(settings_replica.fqrn())
329 : fqrn_(settings_repository.fqrn())
330 , url_(settings_repository.url())
331 , proxy_(settings_repository.proxy())
334 , whitelist_validity_days_(kDefaultWhitelistValidity)
338 , transaction_(fqrn_())
359 throw EPublish(
"unknown user name for repository owner: " + user_name);
390 std::map<std::string, std::string> result;
391 std::string session_dir = Env::GetEnterSessionDir();
392 if (session_dir.empty())
398 omgr.
ParsePath(session_dir +
"/env.conf",
false );
402 if (!omgr.
GetValue(
"CVMFS_FQRN", &fqrn)) {
403 throw EPublish(
"no repositories found in ephemeral writable shell",
407 std::vector<std::string> keys = omgr.
GetAllKeys();
408 for (
unsigned i = 0; i < keys.size(); ++i) {
417 if (!session_env.empty())
418 return session_env[
"CVMFS_FQRN"];
421 if (repositories.empty()) {
426 for (
unsigned i = 0; i < repositories.size(); ++i) {
429 if (repositories.size() > 1) {
434 return repositories[0];
439 const std::string &ident)
441 if (
HasPrefix(ident,
"http://",
true ) ||
447 if (!sanitizer.
IsValid(fqrn)) {
448 throw EPublish(
"malformed repository name: " + fqrn);
457 std::string server_path = repo_path +
"/server.conf";
458 std::string replica_path = repo_path +
"/replica.conf";
459 std::string fqrn = alias;
495 throw EPublish(
"cannot get extended attribute " + attr);
501 std::string session_dir = Env::GetEnterSessionDir();
503 std::string fqrn = session_env[
"CVMFS_FQRN"];
508 settings_publisher->GetTransaction()->SetInEnterSession(
true);
509 settings_publisher->GetTransaction()->GetSpoolArea()->SetSpoolArea(
512 std::string base_hash =
513 settings_publisher->GetReadOnlyXAttr(
"user.root_hash");
517 omgr.
ParsePath(settings_publisher->transaction().spool_area().client_config(),
521 settings_publisher->SetUrl(settings_publisher->GetReadOnlyXAttr(
"user.host"));
522 settings_publisher->SetProxy(
523 settings_publisher->GetReadOnlyXAttr(
"user.proxy"));
524 if (omgr.
GetValue(
"CVMFS_KEYS_DIR", &arg))
525 settings_publisher->GetKeychain()->SetKeychainDir(arg);
526 settings_publisher->GetTransaction()->SetLayoutRevision(
530 settings_publisher->GetTransaction()->SetUnionFsType(
"overlayfs");
531 settings_publisher->SetOwner(geteuid(), getegid());
533 return settings_publisher.
Release();
540 if (options_mgr_.
GetValue(
"CVMFS_CREATOR_VERSION", &arg)) {
543 if (options_mgr_.
GetValue(
"CVMFS_UNION_FS_TYPE", &arg)) {
546 if (options_mgr_.
GetValue(
"CVMFS_HASH_ALGORITHM", &arg)) {
549 if (options_mgr_.
GetValue(
"CVMFS_UPSTREAM_STORAGE", &arg)) {
552 if (options_mgr_.
GetValue(
"CVMFS_KEYS_DIR", &arg)) {
555 if (options_mgr_.
GetValue(
"CVMFS_COMPRESSION_ALGORITHM", &arg)) {
558 if (options_mgr_.
GetValue(
"CVMFS_ENFORCE_LIMITS", &arg)) {
560 options_mgr_.
IsOn(arg));
562 if (options_mgr_.
GetValue(
"CVMFS_NESTED_KCATALOG_LIMIT", &arg)) {
566 if (options_mgr_.
GetValue(
"CVMFS_ROOT_KCATALOG_LIMIT", &arg)) {
570 if (options_mgr_.
GetValue(
"CVMFS_FILE_MBYTE_LIMIT", &arg)) {
574 if (options_mgr_.
GetValue(
"CVMFS_AUTOCATALOGS", &arg)) {
576 options_mgr_.
IsOn(arg));
578 if (options_mgr_.
GetValue(
"CVMFS_AUTOCATALOGS_MAX_WEIGHT", &arg)) {
582 if (options_mgr_.
GetValue(
"CVMFS_AUTOCATALOGS_MIN_WEIGHT", &arg)) {
586 if (options_mgr_.
GetValue(
"CVMFS_AUTO_REPAIR_MOUNTPOINT", &arg)) {
587 if (!options_mgr_.
IsOn(arg)) {
595 const std::string &ident,
bool needs_managed)
599 const std::string alias(ident.empty() ?
GetSingleAlias() : ident);
605 const std::string server_path =
config_path_ +
"/" + alias +
"/server.conf";
608 if (!session_env.empty() && (session_env[
"CVMFS_FQRN"] == alias)) {
618 return settings_publisher;
623 "Unable to find the configuration file `server.conf` for the cvmfs "
624 "publisher: " + alias,
630 throw EPublish(
"remote repositories are not supported in this context");
633 throw EPublish(
"Repository " + alias +
" is not a stratum 0 repository",
641 std::string xattr = settings_publisher->GetReadOnlyXAttr(
"user.root_hash");
642 settings_publisher->GetTransaction()->SetBaseHash(
651 settings_publisher->GetStorage()->SetLocator(
657 return settings_publisher.
Release();
void SetUnionFsType(const std::string &union_fs)
SettingsKeychain * GetKeychain()
std::string GetValueOrDie(const std::string &key)
Setting< std::string > keychain_dir_
void SetIgnoreInvalidLease(bool value)
Algorithms ParseCompressionAlgorithm(const std::string &algorithm_option)
std::string readonly_mnt() const
bool HasGatewayKey() const
Setting< unsigned > timeout_s_
virtual void ParsePath(const std::string &config_file, const bool external)=0
SettingsPublisher * CreateSettingsPublisher(const std::string &ident, bool needs_managed=false)
SettingsTransaction * GetTransaction()
void SetUrl(const std::string &url)
void SetUnionMount(const std::string &path)
void MakeGateway(const std::string &host, unsigned port, const std::string &tmp_dir)
NameString GetFileName(const PathString &path)
Setting< bool > is_managed_
void SetTimeout(unsigned seconds)
SettingsKeychain * GetKeychain()
void SetKeychainDir(const std::string &keychain_dir)
Setting< gid_t > owner_gid_
std::string keychain_dir() const
void SetLimitNestedCatalogKentries(unsigned value)
void SetAutobalanceMaxWeight(unsigned value)
string JoinStrings(const vector< string > &strings, const string &joint)
void SetIsSilent(bool value)
void set_taint_environment(bool value)
Setting< UnionFsType > union_fs_
bool IsOn(const std::string ¶m_value) const
Setting< upload::SpoolerDefinition::DriverType > type_
void SetTemplate(const std::string &from, const std::string &to)
const SettingsPublisher & settings() const
Setting< bool > enforce_limits_
std::string GetSingleAlias()
Setting< std::string > union_mnt_
SettingsRepository(const std::string &fqrn)
void SetLayoutRevision(const unsigned revision)
std::string log_dir() const
Setting< bool > ignore_invalid_lease_
void SetLeasePath(const std::string &path)
Setting< std::string > tmp_dir_
static const char * kDriverNames[]
corresponds to DriverType
std::string cert_bundle() const
std::vector< std::string > FindDirectories(const std::string &parent_dir)
Setting< unsigned > layout_revision_
void SetAutobalanceMinWeight(unsigned value)
SettingsPublisher(const std::string &fqrn)
OptionsManager * options_mgr_
Setting< bool > is_silent_
bool HasMasterKeys() const
void ApplyOptionsFromServerPath(const OptionsManager &options_mgr_, SettingsPublisher *settings_publisher)
Setting< shash::Any > base_hash_
Setting< unsigned > limit_root_catalog_kentries_
bool FileExists(const std::string &path)
std::string cache_dir() const
bool HasRepositoryKeys() const
std::string proxy() const
const SettingsKeychain & keychain() const
void SetTmpDir(const std::string &tmp_dir)
bool IsManagedRepository() const
Setting< bool > in_enter_session_
vector< string > SplitString(const string &str, char delim)
void SetDryRun(bool value)
Setting< std::string > template_from_
Setting< uid_t > owner_uid_
Setting< bool > use_catalog_autobalance_
void SetProxy(const std::string &proxy)
const char kSuffixCatalog
std::string GetReadOnlyXAttr(const std::string &attr)
void SetUrl(const std::string &url)
std::vector< std::string > GetAllKeys()
std::string ovl_work_dir() const
SettingsRepository CreateSettingsRepository(const std::string &ident)
Setting< unsigned > autobalance_max_weight_
void SetLimitRootCatalogKentries(unsigned value)
bool MkdirDeep(const std::string &path, const mode_t mode, bool verify_writable)
void SetIsManaged(bool value)
Setting< std::string > workspace_
const SettingsTransaction & transaction() const
SettingsPublisher * CreateSettingsPublisherFromSession()
SettingsKeychain keychain_
std::string proxy() const
void SetHashAlgorithm(const std::string &algorithm)
string StringifyInt(const int64_t value)
void SetLocator(const std::string &locator)
Setting< std::string > fqrn_
void SetCertBundle(const std::string &cert_bundle)
Setting< bool > print_changeset_
SettingsStorage * GetStorage()
bool HasPrefix(const string &str, const string &prefix, const bool ignore_case)
Setting< zlib::Algorithms > compression_algorithm_
bool GetValue(const std::string &key, std::string *value) const
OptionsManager * options_mgr_
Setting< std::string > fqrn_
bool DirectoryExists(const std::string &path)
Setting< std::string > cert_bundle_
void SetLimitFileSizeMb(unsigned value)
Setting< std::string > url_
Setting< std::string > template_to_
void SetUseCatalogAutobalance(bool value)
Setting< EUnionMountRepairMode > repair_mode_
Setting< unsigned > autobalance_min_weight_
void SetCompressionAlgorithm(const std::string &algorithm)
Setting< std::string > private_key_path_
void SetSpoolArea(const std::string &path)
Setting< shash::Algorithms > hash_algorithm_
void SetEnforceLimits(bool value)
Setting< std::string > tmp_dir_
void ParsePath(const std::string &config_file, const bool external)
void SetProxy(const std::string &proxy)
Setting< std::string > master_private_key_path_
const SettingsKeychain & keychain() const
static const unsigned kDefaultWhitelistValidity
std::string tmp_dir() const
Setting< std::string > proxy_
void SetBaseHash(const shash::Any &hash)
Setting< std::string > endpoint_
uint64_t String2Uint64(const string &value)
void SetPrintChangeset(bool value)
bool GetUidOf(const std::string &username, uid_t *uid, gid_t *main_gid)
Algorithms ParseHashAlgorithm(const string &algorithm_option)
std::string scratch_dir() const
std::map< std::string, std::string > GetSessionEnvironment()
SettingsSpoolArea * GetSpoolArea()
bool HasDanglingRepositoryKeys() const
Any MkFromHexPtr(const HexPtr hex, const char suffix)
Setting< unsigned > limit_file_size_mb_
void MakeLocal(const std::string &path)
Setting< std::string > master_public_key_path_
void SetOwner(const std::string &user_name)
void SetRepairMode(const EUnionMountRepairMode val)
Setting< unsigned > limit_nested_catalog_kentries_
SettingsKeychain keychain_
Setting< std::string > certificate_path_
Setting< std::string > proxy_
void MakeS3(const std::string &s3_config, const std::string &tmp_dir)
Setting< std::string > tmp_dir_
std::string GetLocator() const
Setting< std::string > url_
void SetInEnterSession(const bool value)
Setting< std::string > gw_key_path_
Setting< std::string > lease_path_
std::string tmp_dir() const
static const unsigned kRequiredLayoutRevision
class static __attribute__((visibility("default"))) Repository std::string GetFqrnFromUrl(const std::string &url)
bool HasDanglingMasterKeys() const