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 );
127 if (union_fs ==
"aufs") {
129 }
else if ((union_fs ==
"overlay") || (union_fs ==
"overlayfs")) {
131 }
else if (union_fs ==
"tarball") {
134 throw EPublish(
"unsupported union file system: " + union_fs);
150 throw EPublish(
"neither AUFS nor OverlayFS detected on the system");
173 const std::string &from,
const std::string &to)
176 throw EPublish(
"template transaction's 'from' path must not be empty");
178 throw EPublish(
"template transaction's 'to' path must not be empty");
193 const std::string &s3_config,
194 const std::string &tmp_dir)
208 const std::string &host,
210 const std::string &tmp_dir)
218 std::vector<std::string> tokens =
SplitString(locator,
',');
219 if (tokens.size() != 3) {
220 throw EPublish(
"malformed storage locator, expected format is "
221 "<type>,<temporary directory>,<endpoint>");
223 if (tokens[0] ==
"local") {
225 }
else if (tokens[0] ==
"S3") {
227 }
else if (tokens[0] ==
"gw") {
230 throw EPublish(
"unsupported storage type: " + tokens[0]);
285 : fqrn_(settings_publisher.fqrn())
286 , url_(settings_publisher.url())
287 , proxy_(settings_publisher.proxy())
288 , tmp_dir_(settings_publisher.transaction().spool_area().tmp_dir())
289 , keychain_(settings_publisher.fqrn())
297 : fqrn_(settings_replica.fqrn())
298 , url_(settings_replica.url())
299 , keychain_(settings_replica.fqrn())
333 : fqrn_(settings_repository.fqrn())
334 , url_(settings_repository.url())
335 , proxy_(settings_repository.proxy())
338 , whitelist_validity_days_(kDefaultWhitelistValidity)
342 , transaction_(fqrn_())
363 throw EPublish(
"unknown user name for repository owner: " + user_name);
394 std::map<std::string, std::string> result;
395 std::string session_dir = Env::GetEnterSessionDir();
396 if (session_dir.empty())
402 omgr.
ParsePath(session_dir +
"/env.conf",
false );
406 if (!omgr.
GetValue(
"CVMFS_FQRN", &fqrn)) {
407 throw EPublish(
"no repositories found in ephemeral writable shell",
411 std::vector<std::string> keys = omgr.
GetAllKeys();
412 for (
unsigned i = 0; i < keys.size(); ++i) {
421 if (!session_env.empty())
422 return session_env[
"CVMFS_FQRN"];
425 if (repositories.empty()) {
430 for (
unsigned i = 0; i < repositories.size(); ++i) {
433 if (repositories.size() > 1) {
438 return repositories[0];
443 const std::string &ident)
445 if (
HasPrefix(ident,
"http://",
true ) ||
451 if (!sanitizer.
IsValid(fqrn)) {
452 throw EPublish(
"malformed repository name: " + fqrn);
461 std::string server_path = repo_path +
"/server.conf";
462 std::string replica_path = repo_path +
"/replica.conf";
463 std::string fqrn = alias;
499 throw EPublish(
"cannot get extended attribute " + attr);
505 std::string session_dir = Env::GetEnterSessionDir();
507 std::string fqrn = session_env[
"CVMFS_FQRN"];
512 settings_publisher->GetTransaction()->SetInEnterSession(
true);
513 settings_publisher->GetTransaction()->GetSpoolArea()->SetSpoolArea(
516 std::string base_hash =
517 settings_publisher->GetReadOnlyXAttr(
"user.root_hash");
521 omgr.
ParsePath(settings_publisher->transaction().spool_area().client_config(),
525 settings_publisher->SetUrl(settings_publisher->GetReadOnlyXAttr(
"user.host"));
526 settings_publisher->SetProxy(
527 settings_publisher->GetReadOnlyXAttr(
"user.proxy"));
528 if (omgr.
GetValue(
"CVMFS_KEYS_DIR", &arg))
529 settings_publisher->GetKeychain()->SetKeychainDir(arg);
530 settings_publisher->GetTransaction()->SetLayoutRevision(
534 settings_publisher->GetTransaction()->SetUnionFsType(
"overlayfs");
535 settings_publisher->SetOwner(geteuid(), getegid());
537 return settings_publisher.
Release();
544 if (options_mgr_.
GetValue(
"CVMFS_CREATOR_VERSION", &arg)) {
547 if (options_mgr_.
GetValue(
"CVMFS_UNION_FS_TYPE", &arg)) {
550 if (options_mgr_.
GetValue(
"CVMFS_HASH_ALGORITHM", &arg)) {
553 if (options_mgr_.
GetValue(
"CVMFS_UPSTREAM_STORAGE", &arg)) {
556 if (options_mgr_.
GetValue(
"CVMFS_KEYS_DIR", &arg)) {
559 if (options_mgr_.
GetValue(
"CVMFS_COMPRESSION_ALGORITHM", &arg)) {
562 if (options_mgr_.
GetValue(
"CVMFS_ENFORCE_LIMITS", &arg)) {
564 options_mgr_.
IsOn(arg));
566 if (options_mgr_.
GetValue(
"CVMFS_ENABLE_MTIME_NS", &arg)) {
568 options_mgr_.
IsOn(arg));
570 if (options_mgr_.
GetValue(
"CVMFS_NESTED_KCATALOG_LIMIT", &arg)) {
574 if (options_mgr_.
GetValue(
"CVMFS_ROOT_KCATALOG_LIMIT", &arg)) {
578 if (options_mgr_.
GetValue(
"CVMFS_FILE_MBYTE_LIMIT", &arg)) {
582 if (options_mgr_.
GetValue(
"CVMFS_AUTOCATALOGS", &arg)) {
584 options_mgr_.
IsOn(arg));
586 if (options_mgr_.
GetValue(
"CVMFS_AUTOCATALOGS_MAX_WEIGHT", &arg)) {
590 if (options_mgr_.
GetValue(
"CVMFS_AUTOCATALOGS_MIN_WEIGHT", &arg)) {
594 if (options_mgr_.
GetValue(
"CVMFS_AUTO_REPAIR_MOUNTPOINT", &arg)) {
595 if (!options_mgr_.
IsOn(arg)) {
603 const std::string &ident,
bool needs_managed)
607 const std::string alias(ident.empty() ?
GetSingleAlias() : ident);
613 const std::string server_path =
config_path_ +
"/" + alias +
"/server.conf";
616 if (!session_env.empty() && (session_env[
"CVMFS_FQRN"] == alias)) {
626 return settings_publisher;
631 "Unable to find the configuration file `server.conf` for the cvmfs "
632 "publisher: " + alias,
638 throw EPublish(
"remote repositories are not supported in this context");
641 throw EPublish(
"Repository " + alias +
" is not a stratum 0 repository",
649 std::string xattr = settings_publisher->GetReadOnlyXAttr(
"user.root_hash");
650 settings_publisher->GetTransaction()->SetBaseHash(
659 settings_publisher->GetStorage()->SetLocator(
665 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
void SetEnableMtimeNs(bool value)
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
Setting< bool > enable_mtime_ns_