56 const std::string scratch_dir =
publisher_->settings_.transaction()
59 const std::string scratch_wastebin =
publisher_->settings_.transaction()
63 tmp_dir =
publisher_->settings_.transaction().spool_area().tmp_dir();
65 std::string waste_dir =
CreateTempDir(scratch_wastebin +
"/waste");
66 if (waste_dir.empty())
67 throw EPublish(
"cannot create wastebin directory");
68 int rvi = rename(scratch_dir.c_str(), (waste_dir +
"/delete-me").c_str());
70 throw EPublish(
"cannot move scratch directory to wastebin");
76 std::vector<mode_t> modes;
77 std::vector<std::string> names;
79 for (
unsigned i = 0; i < names.size(); ++i) {
80 if (
HasPrefix(names[i],
"receiver.",
false ))
83 unlink((tmp_dir +
"/" + names[i]).c_str());
89 ServerLockFileCheck publish_check(
publisher_->is_publishing_);
90 const std::string rdonly_mnt =
publisher_->settings_.transaction()
94 union_mnt =
publisher_->settings_.transaction().spool_area().union_mnt();
95 const std::string fqrn =
publisher_->settings_.fqrn();
104 publisher_->settings_.transaction().spool_area().checkout_marker()));
105 if (marker.IsValid())
106 expected_hash = marker->hash();
109 result |= kFailRdOnlyBroken;
111 const std::string root_hash_xattr =
"user.root_hash";
112 std::string root_hash_str;
118 if (expected_hash != root_hash) {
119 if (marker.IsValid()) {
120 result |= kFailRdOnlyWrongRevision;
122 result |= kFailRdOnlyOutdated;
126 if (errno == ENOTCONN) {
128 result |= kFailRdOnlyBroken;
130 throw EPublish(
"cannot retrieve root hash from read-only mount point");
138 result |= kFailUnionBroken;
142 result |= kFailUnionLocked;
144 result |= kFailUnionWritable;
155 if (result & kFailRdOnlyBroken) {
159 if (result & kFailRdOnlyOutdated) {
161 "%s is not based on the newest published revision", fqrn.c_str());
163 if (result & kFailRdOnlyWrongRevision) {
167 if (result & kFailUnionBroken) {
171 if (result & kFailUnionWritable) {
173 "%s is not in a transaction but %s is mounted read/write",
174 fqrn.c_str(), union_mnt.c_str());
176 if (result & kFailUnionLocked) {
178 "%s is in a transaction but %s is not mounted read/write",
179 fqrn.c_str(), union_mnt.c_str());
184 switch (repair_mode) {
190 if (!publish_check.owns_lock()) {
193 "WARNING: The repository %s is currently publishing and should "
195 "be touched. If you are absolutely sure, that this is _not_ the "
196 "case,\nplease run the following command and retry:\n\n"
198 fqrn.c_str(),
publisher_->is_publishing_.path().c_str());
204 "Repository %s is in a transaction and cannot be repaired.\n"
205 "--> Run `cvmfs_server abort $name` to revert and repair.",
216 fqrn.c_str(), result);
233 if ((result & kFailRdOnlyOutdated) || (result & kFailRdOnlyWrongRevision)) {
234 if ((result & kFailUnionBroken) == 0) {
236 result |= kFailUnionBroken;
239 if ((result & kFailRdOnlyBroken) == 0) {
241 result |= kFailRdOnlyBroken;
245 result &= ~kFailRdOnlyOutdated;
246 result &= ~kFailRdOnlyWrongRevision;
249 if (result & kFailRdOnlyBroken) {
250 if ((result & kFailUnionBroken) == 0) {
252 result |= kFailUnionBroken;
255 result &= ~kFailRdOnlyBroken;
258 if (result & kFailUnionBroken) {
262 result |= kFailUnionLocked;
264 result &= ~kFailUnionBroken;
265 result &= ~kFailUnionWritable;
268 if (result & kFailUnionLocked) {
270 result &= ~kFailUnionLocked;
273 if (result & kFailUnionWritable) {
275 result &= ~kFailUnionWritable;
285 std::string mountpoint;
286 std::string info_msg;
287 std::string suid_helper_verb;
290 mountpoint =
publisher_->settings_.transaction().spool_area().union_mnt();
291 info_msg =
"Trying to unmount " + mountpoint;
292 suid_helper_verb =
"rw_umount";
295 mountpoint =
publisher_->settings_.transaction().spool_area().union_mnt();
296 info_msg =
"Trying to lazily unmount " + mountpoint;
297 suid_helper_verb =
"rw_lazy_umount";
300 mountpoint =
publisher_->settings_.transaction()
303 info_msg =
"Trying to unmount " + mountpoint;
304 suid_helper_verb =
"rdonly_umount";
307 mountpoint =
publisher_->settings_.transaction()
310 info_msg =
"Trying to forcefully stop " + mountpoint;
311 suid_helper_verb =
"kill_cvmfs";
314 mountpoint =
publisher_->settings_.transaction()
317 info_msg =
"Trying to lazily unmount " + mountpoint;
318 suid_helper_verb =
"rdonly_lazy_umount";
321 mountpoint =
publisher_->settings_.transaction().spool_area().union_mnt();
322 info_msg =
"Trying to mount " + mountpoint;
323 suid_helper_verb =
"rw_mount";
326 mountpoint =
publisher_->settings_.transaction()
329 info_msg =
"Trying to mount " + mountpoint;
330 suid_helper_verb =
"rdonly_mount";
333 mountpoint =
publisher_->settings_.transaction().spool_area().union_mnt();
334 info_msg =
"Trying to remount " + mountpoint +
" read/write";
335 suid_helper_verb =
"open";
338 mountpoint =
publisher_->settings_.transaction().spool_area().union_mnt();
339 info_msg =
"Trying to remount " + mountpoint +
" read-only";
340 suid_helper_verb =
"lock";
343 mountpoint =
publisher_->settings_.transaction()
346 info_msg =
"Trying to wipe out " + mountpoint +
" (async cleanup)";
347 suid_helper_verb =
"clear_scratch_async";
350 throw EPublish(
"internal error: unknown mountpoint alteration");
362 if (log_level & kLogStdout)
367 throw EPublish(info_msg +
"... fail");
373 const std::string config_path =
publisher_->settings_.transaction()
static void Mount(const string &path)
std::string ToString(const bool with_suffix=false) const
void AlterMountpoint(EMountpointAlterations how, int log_level)
const int kDefaultDirMode
FileSystemInfo GetFileSystemInfo(const std::string &path)
const char kSuffixCatalog
void SetInConfig(const std::string &path, const std::string &key, const std::string &value)
std::string CreateTempDir(const std::string &path_prefix)
bool HasPrefix(const string &str, const string &prefix, const bool ignore_case)
void RunSuidHelper(const std::string &verb, const std::string &fqrn)
bool ListDirectory(const std::string &directory, std::vector< std::string > *names, std::vector< mode_t > *modes)
Any MkFromHexPtr(const HexPtr hex, const char suffix)
void SetRootHash(const shash::Any &hash)
bool IsMountPoint(const std::string &path)
static CheckoutMarker * CreateFrom(const std::string &path)
CVMFS_EXPORT void LogCvmfs(const LogSource source, const int mask, const char *format,...)