5 #include "cvmfs_config.h"
29 std::string lease_path;
31 std::vector<std::string> tokens =
34 if (tokens.size() == 2)
50 if (settings->transaction().in_enter_session()) {
52 "opening a transaction is unsupported within the ephemeral "
56 if (options.
Has(
"retry-timeout")) {
57 settings->GetTransaction()->SetTimeout(options.
GetInt(
"retry-timeout"));
59 if (options.
Has(
"template-from")) {
60 if (!options.
Has(
"template-to"))
61 throw EPublish(
"invalid parameter combination for templates");
62 settings->GetTransaction()->SetTemplate(
65 if (options.
Has(
"template")) {
66 if (options.
Has(
"template-from") || options.
Has(
"template-to"))
67 throw EPublish(
"invalid parameter combination for templates");
68 std::string templ = options.
GetString(
"template");
69 std::vector<std::string> tokens =
SplitString(templ,
'=');
70 if (tokens.size() != 2)
71 throw EPublish(
"invalid syntax for --template parameter: " + templ);
72 settings->GetTransaction()->SetTemplate(tokens[0], tokens[1]);
78 throw EPublish(
"No write permission to repository",
83 throw EPublish(
"Autofs on /cvmfs has to be disabled");
85 settings->GetTransaction()->SetLeasePath(lease_path);
91 if (publisher->whitelist()->IsExpired()) {
92 throw EPublish(
"Repository whitelist for $name is expired",
105 double whitelist_valid_s =
106 difftime(publisher->whitelist()->expires(), time(NULL));
107 if (whitelist_valid_s < (12 * 60 * 60)) {
109 "Warning: Repository whitelist stays valid for less than 12 hours!");
115 "transaction hook failed, not opening a transaction");
120 publisher->Transaction();
122 const char *msg_prefix =
"CernVM-FS transaction error: ";
125 msg_prefix, e.
msg().c_str());
129 msg_prefix, e.
msg().c_str());
133 msg_prefix, e.
msg().c_str());
137 msg_prefix, e.
msg().c_str());
141 msg_prefix, e.
msg().c_str());
147 publisher->session()->SetKeepAlive(
true);
152 "post transaction hook failed");
int GetInt(const std::string &key) const
SettingsPublisher * CreateSettingsPublisher(const std::string &ident, bool needs_managed=false)
int CallServerHook(const std::string &func, const std::string &fqrn, const std::string &path_hooks="/etc/cvmfs/cvmfs_server_hooks.sh")
bool Has(const std::string &key) const
std::string GetString(const std::string &key) const
const SettingsPublisher & settings() const
const std::vector< Argument > & plain_args() const
vector< string > SplitString(const string &str, char delim)
FileSystemInfo GetFileSystemInfo(const std::string &path)
virtual int Main(const Options &options)
vector< string > SplitStringBounded(unsigned max_chunks, const string &str, char delim)
EFailures failure() const
bool SwitchCredentials(const uid_t uid, const gid_t gid, const bool temporarily)
Publisher(const SettingsPublisher &settings, const bool exists=true)
std::string MakeCanonicalPath(const std::string &path)
CVMFS_EXPORT void LogCvmfs(const LogSource source, const int mask, const char *format,...)