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 );
125 if (union_fs ==
"aufs") {
127 }
else if ((union_fs ==
"overlay") || (union_fs ==
"overlayfs")) {
129 }
else if (union_fs ==
"tarball") {
132 throw EPublish(
"unsupported union file system: " + union_fs);
148 throw EPublish(
"neither AUFS nor OverlayFS detected on the system");
169 const std::string &to) {
171 throw EPublish(
"template transaction's 'from' path must not be empty");
173 throw EPublish(
"template transaction's 'to' path must not be empty");
187 const std::string &tmp_dir) {
201 const std::string &tmp_dir) {
208 std::vector<std::string> tokens =
SplitString(locator,
',');
209 if (tokens.size() != 3) {
210 throw EPublish(
"malformed storage locator, expected format is "
211 "<type>,<temporary directory>,<endpoint>");
213 if (tokens[0] ==
"local") {
215 }
else if (tokens[0] ==
"S3") {
217 }
else if (tokens[0] ==
"gw") {
220 throw EPublish(
"unsupported storage type: " + tokens[0]);
273 : fqrn_(settings_publisher.fqrn())
274 , url_(settings_publisher.url())
275 , proxy_(settings_publisher.proxy())
276 , tmp_dir_(settings_publisher.transaction().spool_area().tmp_dir())
277 , keychain_(settings_publisher.fqrn()) {
283 : fqrn_(settings_replica.fqrn())
284 , url_(settings_replica.url())
285 , keychain_(settings_replica.fqrn()) { }
315 : fqrn_(settings_repository.fqrn())
316 , url_(settings_repository.url())
317 , proxy_(settings_repository.proxy())
320 , whitelist_validity_days_(kDefaultWhitelistValidity)
324 , transaction_(fqrn_())
325 , keychain_(fqrn_()) {
342 throw EPublish(
"unknown user name for repository owner: " + user_name);
367 std::map<std::string, std::string> result;
368 std::string session_dir = Env::GetEnterSessionDir();
369 if (session_dir.empty())
375 omgr.
ParsePath(session_dir +
"/env.conf",
false );
379 if (!omgr.
GetValue(
"CVMFS_FQRN", &fqrn)) {
380 throw EPublish(
"no repositories found in ephemeral writable shell",
384 std::vector<std::string> keys = omgr.
GetAllKeys();
385 for (
unsigned i = 0; i < keys.size(); ++i) {
394 if (!session_env.empty())
395 return session_env[
"CVMFS_FQRN"];
398 if (repositories.empty()) {
403 for (
unsigned i = 0; i < repositories.size(); ++i) {
406 if (repositories.size() > 1) {
411 return repositories[0];
416 const std::string &ident) {
422 if (!sanitizer.
IsValid(fqrn)) {
423 throw EPublish(
"malformed repository name: " + fqrn);
432 std::string server_path = repo_path +
"/server.conf";
433 std::string replica_path = repo_path +
"/replica.conf";
434 std::string fqrn = alias;
470 throw EPublish(
"cannot get extended attribute " + attr);
476 std::string session_dir = Env::GetEnterSessionDir();
478 std::string fqrn = session_env[
"CVMFS_FQRN"];
483 settings_publisher->GetTransaction()->SetInEnterSession(
true);
484 settings_publisher->GetTransaction()->GetSpoolArea()->SetSpoolArea(
487 std::string base_hash = settings_publisher->GetReadOnlyXAttr(
492 omgr.
ParsePath(settings_publisher->transaction().spool_area().client_config(),
496 settings_publisher->SetUrl(settings_publisher->GetReadOnlyXAttr(
"user.host"));
497 settings_publisher->SetProxy(
498 settings_publisher->GetReadOnlyXAttr(
"user.proxy"));
499 if (omgr.
GetValue(
"CVMFS_KEYS_DIR", &arg))
500 settings_publisher->GetKeychain()->SetKeychainDir(arg);
501 settings_publisher->GetTransaction()->SetLayoutRevision(
503 settings_publisher->GetTransaction()->SetBaseHash(
505 settings_publisher->GetTransaction()->SetUnionFsType(
"overlayfs");
506 settings_publisher->SetOwner(geteuid(), getegid());
508 return settings_publisher.
Release();
514 if (options_mgr_.
GetValue(
"CVMFS_CREATOR_VERSION", &arg)) {
517 if (options_mgr_.
GetValue(
"CVMFS_UNION_FS_TYPE", &arg)) {
520 if (options_mgr_.
GetValue(
"CVMFS_HASH_ALGORITHM", &arg)) {
523 if (options_mgr_.
GetValue(
"CVMFS_UPSTREAM_STORAGE", &arg)) {
526 if (options_mgr_.
GetValue(
"CVMFS_KEYS_DIR", &arg)) {
529 if (options_mgr_.
GetValue(
"CVMFS_COMPRESSION_ALGORITHM", &arg)) {
532 if (options_mgr_.
GetValue(
"CVMFS_ENFORCE_LIMITS", &arg)) {
534 options_mgr_.
IsOn(arg));
536 if (options_mgr_.
GetValue(
"CVMFS_ENABLE_MTIME_NS", &arg)) {
538 options_mgr_.
IsOn(arg));
540 if (options_mgr_.
GetValue(
"CVMFS_NESTED_KCATALOG_LIMIT", &arg)) {
544 if (options_mgr_.
GetValue(
"CVMFS_ROOT_KCATALOG_LIMIT", &arg)) {
548 if (options_mgr_.
GetValue(
"CVMFS_FILE_MBYTE_LIMIT", &arg)) {
552 if (options_mgr_.
GetValue(
"CVMFS_AUTOCATALOGS", &arg)) {
554 options_mgr_.
IsOn(arg));
556 if (options_mgr_.
GetValue(
"CVMFS_AUTOCATALOGS_MAX_WEIGHT", &arg)) {
560 if (options_mgr_.
GetValue(
"CVMFS_AUTOCATALOGS_MIN_WEIGHT", &arg)) {
564 if (options_mgr_.
GetValue(
"CVMFS_AUTO_REPAIR_MOUNTPOINT", &arg)) {
565 if (!options_mgr_.
IsOn(arg)) {
573 const std::string &ident,
bool needs_managed) {
576 const std::string alias(ident.empty() ?
GetSingleAlias() : ident);
582 const std::string server_path =
config_path_ +
"/" + alias +
"/server.conf";
585 if (!session_env.empty() && (session_env[
"CVMFS_FQRN"] == alias)) {
595 return settings_publisher;
600 "Unable to find the configuration file `server.conf` for the cvmfs "
608 throw EPublish(
"remote repositories are not supported in this context");
611 throw EPublish(
"Repository " + alias +
" is not a stratum 0 repository",
619 std::string xattr = settings_publisher->GetReadOnlyXAttr(
"user.root_hash");
620 settings_publisher->GetTransaction()->SetBaseHash(
629 settings_publisher->GetStorage()->SetLocator(
635 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_