GCC Code Coverage Report


Directory: cvmfs/
File: cvmfs/publish/cmd_enter.h
Date: 2024-04-28 02:33:07
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 { }
25 virtual std::string GetName() const { return "enter"; }
26 virtual std::string GetBrief() const {
27 return "Open an ephemeral namespace to publish content";
28 }
29 virtual std::string GetUsage() const {
30 return \
31 "[options] <fully qualified repository name> [-- <command> <params>]";
32 }
33 virtual ParameterList GetParams() const {
34 ParameterList p;
35 p.push_back(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("cvmfs-config", 'C', "path",
40 "Path to extra configuration for the CernVM-FS client"));
41 p.push_back(Parameter::Switch("root", 'r', "Run as fake root"));
42 p.push_back(Parameter::Switch("keep-session", 'k',
43 "Do not remove the session directory when the shell exits"));
44 p.push_back(Parameter::Switch("keep-logs", 'l',
45 "Clean the session directory on shell exit except for the logs"));
46 p.push_back(Parameter::Switch("transaction", 't',
47 "Open a transaction within the ephemeral shell"));
48 p.push_back(
49 Parameter::Optional("repo-config", 'x', "repository configuration",
50 "Path to the configuration of the repository as in "
51 "/etc/cvmfs/repositories.d"));
52 return p;
53 }
54 virtual unsigned GetMinPlainArgs() const { return 1; }
55
56 virtual int Main(const Options &options);
57
58 private:
59 void MountOverlayfs();
60 void CreateUnderlay(const std::string &source_dir,
61 const std::string &dest_dir,
62 const std::vector<std::string> &empty_dirs,
63 std::vector<std::string> *new_paths);
64 void WriteCvmfsConfig(const std::string &extra_config);
65 void MountCvmfs();
66 pid_t RunInteractiveShell();
67
68 std::string GetCvmfsXattr(const std::string &name);
69 void CleanupSession(bool keep_logs,
70 const std::vector<std::string> &new_paths);
71
72 SettingsSpoolArea settings_spool_area_;
73 std::string fqrn_;
74 std::string cvmfs2_binary_;
75 std::string repo_config_;
76 std::string overlayfs_binary_;
77 std::string session_dir_; ///< In $HOME/.cvmfs/fqrn, container spool area
78 std::string env_conf_; ///< Stores the session directory environment
79 std::string rootfs_dir_; ///< Destination to chroot() to in the namespace
80 std::string stdout_path_; ///< Logs stdout of background commands
81 std::string stderr_path_; ///< Logs stdout of background commands
82 };
83
84 } // namespace publish
85
86 #endif // CVMFS_PUBLISH_CMD_ENTER_H_
87