25 if (!repo_and_path.empty()) {
26 std::vector<std::string> tokens =
SplitString(repo_and_path,
'/');
38 std::string session_dir = Env::GetEnterSessionDir();
40 if (!session_dir.empty()) {
52 repository_ident,
true );
67 throw EPublish(
"No write permission to repository",
72 settings->transaction().spool_area().union_mnt() +
"/",
76 "Current working directory is in %s. Please release, "
77 "e.g. by 'cd $HOME'.",
78 settings->transaction().spool_area().union_mnt().c_str());
82 if (!options.
Has(
"force")) {
84 "You are about to DISCARD ALL CHANGES OF THE CURRENT TRANSACTION "
85 "for %s! Are you sure (y/N)? ", settings->fqrn().c_str());
86 char answer[] = {0, 0, 0};
87 char *rv_charp = fgets(answer, 3, stdin);
88 if (rv_charp && (answer[0] !=
'Y') && (answer[0] !=
'y'))
94 settings->SetIgnoreInvalidLease(
true);
97 std::vector<LsofEntry> lsof_entries =
98 Lsof(settings->transaction().spool_area().union_mnt());
99 if (!lsof_entries.empty()) {
100 if (options.
Has(
"force")) {
102 "WARNING: Open file descriptors on %s (possible race!)"
103 "\nThe following lsof report might show the culprit:\n",
104 settings->transaction().spool_area().union_mnt().c_str());
107 "\nWARNING! There are open read-only file descriptors in %s\n"
108 " --> This is potentially harmful and might cause problems "
110 " We can anyway perform the requested operation, but this "
112 " break other processes with open file descriptors on %s!\n"
114 " The following lsof report might show the processes with "
115 "open file handles\n",
116 settings->transaction().spool_area().union_mnt().c_str(),
117 settings->transaction().spool_area().union_mnt().c_str());
120 for (
unsigned i = 0; i < lsof_entries.size(); ++i) {
121 std::string owner_name;
124 lsof_entries[i].executable.c_str(),
127 lsof_entries[i].path.c_str());
130 if (!options.
Has(
"force")) {
132 "\n Do you want to proceed anyway? (y/N) ");
133 char answer[] = {0, 0, 0};
134 char *rv_charp = fgets(answer, 3, stdin);
135 if (rv_charp && (answer[0] !=
'Y') && (answer[0] !=
'y'))
144 settings->fqrn().c_str());
149 "abort hook failed, not aborting");
167 "post abort hook failed");
171 if (settings->transaction().in_enter_session()) {
173 "Discarding changes and closing current transaction...");
175 publisher->ExitShell();
std::string StripTrailingPath(const std::string &repo_and_path)
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
bool GetUserNameOf(uid_t uid, std::string *username)
const SettingsPublisher & settings() const
bool SafeWriteToFile(const std::string &content, const std::string &path, int mode)
void SetConfigPath(const std::string &config_path)
const std::vector< Argument > & plain_args() const
vector< string > SplitString(const string &str, char delim)
bool HasPrefix(const string &str, const string &prefix, const bool ignore_case)
EFailures failure() const
bool SwitchCredentials(const uid_t uid, const gid_t gid, const bool temporarily)
std::vector< LsofEntry > Lsof(const std::string &path)
Publisher(const SettingsPublisher &settings, const bool exists=true)
std::string GetCurrentWorkingDirectory()
virtual int Main(const Options &options)
CVMFS_EXPORT void LogCvmfs(const LogSource source, const int mask, const char *format,...)