GCC Code Coverage Report


Directory: cvmfs/
File: cvmfs/publish/cmd_enter.h
Date: 2025-06-22 02:36:02
Exec Total Coverage
Lines: 0 23 0.0%
Branches: 0 86 0.0%

Line Branch Exec Source
1 /**
2 * This file is part of the CernVM File System.
3 */
4
5 #ifndef CVMFS_PUBLISH_CMD_ENTER_H_
6 #define CVMFS_PUBLISH_CMD_ENTER_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "publish/command.h"
12 #include "publish/settings.h"
13
14 namespace publish {
15
16 class SettingsPublisher;
17
18 class CmdEnter : public Command {
19 public:
20 CmdEnter()
21 : settings_spool_area_("unset") // will be set by SetSpoolArea in Main()
22 , cvmfs2_binary_("/usr/bin/cvmfs2")
23 , overlayfs_binary_("/usr/bin/fuse-overlayfs") { }
24 virtual std::string GetName() const { return "enter"; }
25 virtual std::string GetBrief() const {
26 return "Open an ephemeral namespace to publish content";
27 }
28 virtual std::string GetUsage() const {
29 return "[options] <fully qualified repository name> [-- <command> "
30 "<params>]";
31 }
32 virtual ParameterList GetParams() const {
33 ParameterList p;
34 p.push_back(
35 Parameter::Optional("stratum0", 'w', "stratum0 url",
36 "HTTP endpoint of the authoritative storage"));
37 p.push_back(Parameter::Optional("cvmfs2", 'c', "path",
38 "Path to the cvmfs2 binary"));
39 p.push_back(Parameter::Optional(
40 "cvmfs-config", 'C', "path",
41 "Path to extra configuration for the CernVM-FS client"));
42 p.push_back(Parameter::Switch("root", 'r', "Run as fake root"));
43 p.push_back(Parameter::Switch(
44 "keep-session", 'k',
45 "Do not remove the session directory when the shell exits"));
46 p.push_back(Parameter::Switch(
47 "keep-logs", 'l',
48 "Clean the session directory on shell exit except for the logs"));
49 p.push_back(Parameter::Switch(
50 "transaction", 't', "Open a transaction within the ephemeral shell"));
51 p.push_back(
52 Parameter::Optional("repo-config", 'x', "repository configuration",
53 "Path to the configuration of the repository as in "
54 "/etc/cvmfs/repositories.d"));
55 return p;
56 }
57 virtual unsigned GetMinPlainArgs() const { return 1; }
58
59 virtual int Main(const Options &options);
60
61 private:
62 void MountOverlayfs();
63 void CreateUnderlay(const std::string &source_dir,
64 const std::string &dest_dir,
65 const std::vector<std::string> &empty_dirs,
66 std::vector<std::string> *new_paths);
67 void WriteCvmfsConfig(const std::string &extra_config);
68 void MountCvmfs();
69 pid_t RunInteractiveShell();
70
71 std::string GetCvmfsXattr(const std::string &name);
72 void CleanupSession(bool keep_logs,
73 const std::vector<std::string> &new_paths);
74
75 SettingsSpoolArea settings_spool_area_;
76 std::string fqrn_;
77 std::string cvmfs2_binary_;
78 std::string repo_config_;
79 std::string overlayfs_binary_;
80 std::string session_dir_; ///< In $HOME/.cvmfs/fqrn, container spool area
81 std::string env_conf_; ///< Stores the session directory environment
82 std::string rootfs_dir_; ///< Destination to chroot() to in the namespace
83 std::string stdout_path_; ///< Logs stdout of background commands
84 std::string stderr_path_; ///< Logs stdout of background commands
85 };
86
87 } // namespace publish
88
89 #endif // CVMFS_PUBLISH_CMD_ENTER_H_
90