| Directory: | cvmfs/ |
|---|---|
| File: | cvmfs/options.cc |
| Date: | 2025-10-26 02:35:25 |
| Exec | Total | Coverage | |
|---|---|---|---|
| Lines: | 274 | 361 | 75.9% |
| Branches: | 280 | 675 | 41.5% |
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /** | ||
| 2 | * This file is part of the CernVM File System. | ||
| 3 | * | ||
| 4 | * Fills an internal map of key-value pairs from ASCII files in key=value | ||
| 5 | * style. Parameters can be overwritten. Used to read configuration from | ||
| 6 | * /etc/cvmfs/... | ||
| 7 | */ | ||
| 8 | |||
| 9 | |||
| 10 | #include "options.h" | ||
| 11 | |||
| 12 | #include <fcntl.h> | ||
| 13 | #include <sys/wait.h> | ||
| 14 | #include <unistd.h> | ||
| 15 | |||
| 16 | #include <cassert> | ||
| 17 | #include <cstdio> | ||
| 18 | #include <cstdlib> | ||
| 19 | #include <utility> | ||
| 20 | |||
| 21 | #include "sanitizer.h" | ||
| 22 | #include "util/exception.h" | ||
| 23 | #include "util/logging.h" | ||
| 24 | #include "util/posix.h" | ||
| 25 | #include "util/string.h" | ||
| 26 | |||
| 27 | using namespace std; // NOLINT | ||
| 28 | |||
| 29 | #ifdef CVMFS_NAMESPACE_GUARD | ||
| 30 | namespace CVMFS_NAMESPACE_GUARD { | ||
| 31 | #endif | ||
| 32 | |||
| 33 | |||
| 34 | 9034 | static string EscapeShell(const std::string &raw) { | |
| 35 |
2/2✓ Branch 1 taken 134412 times.
✓ Branch 2 taken 8977 times.
|
143389 | for (unsigned i = 0, l = raw.length(); i < l; ++i) { |
| 36 |
6/6✓ Branch 1 taken 118550 times.
✓ Branch 2 taken 15862 times.
✓ Branch 4 taken 105214 times.
✓ Branch 5 taken 13336 times.
✓ Branch 6 taken 57 times.
✓ Branch 7 taken 134355 times.
|
255488 | if (!(((raw[i] >= '0') && (raw[i] <= '9')) |
| 37 |
4/4✓ Branch 1 taken 104769 times.
✓ Branch 2 taken 16307 times.
✓ Branch 4 taken 96326 times.
✓ Branch 5 taken 8443 times.
|
121076 | || ((raw[i] >= 'A') && (raw[i] <= 'Z')) |
| 38 |
5/6✓ Branch 1 taken 90002 times.
✓ Branch 2 taken 22631 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 90002 times.
✓ Branch 7 taken 12139 times.
✓ Branch 8 taken 10492 times.
|
112633 | || ((raw[i] >= 'a') && (raw[i] <= 'z')) || (raw[i] == '/') |
| 39 |
6/6✓ Branch 1 taken 11733 times.
✓ Branch 2 taken 406 times.
✓ Branch 4 taken 6525 times.
✓ Branch 5 taken 5208 times.
✓ Branch 7 taken 201 times.
✓ Branch 8 taken 6324 times.
|
12139 | || (raw[i] == ':') || (raw[i] == '.') || (raw[i] == '_') |
| 40 |
3/4✓ Branch 1 taken 57 times.
✓ Branch 2 taken 144 times.
✓ Branch 4 taken 57 times.
✗ Branch 5 not taken.
|
201 | || (raw[i] == '-') || (raw[i] == ','))) { |
| 41 | 57 | goto escape_shell_quote; | |
| 42 | } | ||
| 43 | } | ||
| 44 |
1/2✓ Branch 1 taken 8977 times.
✗ Branch 2 not taken.
|
8977 | return raw; |
| 45 | |||
| 46 | 57 | escape_shell_quote: | |
| 47 |
1/2✓ Branch 2 taken 57 times.
✗ Branch 3 not taken.
|
114 | string result = "'"; |
| 48 |
2/2✓ Branch 1 taken 2013 times.
✓ Branch 2 taken 57 times.
|
2070 | for (unsigned i = 0, l = raw.length(); i < l; ++i) { |
| 49 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2013 times.
|
2013 | if (raw[i] == '\'') |
| 50 | ✗ | result += "\\"; | |
| 51 |
1/2✓ Branch 2 taken 2013 times.
✗ Branch 3 not taken.
|
2013 | result += raw[i]; |
| 52 | } | ||
| 53 |
1/2✓ Branch 1 taken 57 times.
✗ Branch 2 not taken.
|
57 | result += "'"; |
| 54 | 57 | return result; | |
| 55 | } | ||
| 56 | |||
| 57 | |||
| 58 | 10758 | string OptionsManager::TrimParameter(const string ¶meter) { | |
| 59 | 10758 | string result = Trim(parameter); | |
| 60 | // Strip "readonly" | ||
| 61 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 10758 times.
|
10758 | if (result.find("readonly ") == 0) { |
| 62 | ✗ | result = result.substr(9); | |
| 63 | ✗ | result = Trim(result); | |
| 64 |
2/2✓ Branch 1 taken 414 times.
✓ Branch 2 taken 10344 times.
|
10758 | } else if (result.find("export ") == 0) { |
| 65 |
1/2✓ Branch 1 taken 414 times.
✗ Branch 2 not taken.
|
414 | result = result.substr(7); |
| 66 |
1/2✓ Branch 1 taken 414 times.
✗ Branch 2 not taken.
|
414 | result = Trim(result); |
| 67 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 10344 times.
|
10344 | } else if (result.find("eval ") == 0) { |
| 68 | ✗ | result = result.substr(5); | |
| 69 | ✗ | result = Trim(result); | |
| 70 | } | ||
| 71 | 10758 | return result; | |
| 72 | } | ||
| 73 | |||
| 74 | 12000 | string OptionsManager::SanitizeParameterAssignment(string *line, | |
| 75 | vector<string> *tokens) { | ||
| 76 | 12000 | const size_t comment_idx = line->find("#"); | |
| 77 |
2/2✓ Branch 0 taken 828 times.
✓ Branch 1 taken 11172 times.
|
12000 | if (comment_idx != string::npos) |
| 78 |
1/2✓ Branch 1 taken 828 times.
✗ Branch 2 not taken.
|
828 | *line = line->substr(0, comment_idx); |
| 79 |
1/2✓ Branch 1 taken 12000 times.
✗ Branch 2 not taken.
|
12000 | *line = Trim(*line); |
| 80 |
2/2✓ Branch 1 taken 828 times.
✓ Branch 2 taken 11172 times.
|
12000 | if (line->empty()) |
| 81 |
1/2✓ Branch 2 taken 828 times.
✗ Branch 3 not taken.
|
828 | return ""; |
| 82 |
1/2✓ Branch 1 taken 11172 times.
✗ Branch 2 not taken.
|
11172 | *tokens = SplitString(*line, '='); |
| 83 |
2/2✓ Branch 1 taken 414 times.
✓ Branch 2 taken 10758 times.
|
11172 | if (tokens->size() < 2) |
| 84 |
1/2✓ Branch 2 taken 414 times.
✗ Branch 3 not taken.
|
414 | return ""; |
| 85 |
1/2✓ Branch 2 taken 10758 times.
✗ Branch 3 not taken.
|
10758 | string parameter = TrimParameter((*tokens)[0]); |
| 86 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 10758 times.
|
10758 | if (parameter.find(" ") != string::npos) |
| 87 | ✗ | return ""; | |
| 88 | 10758 | return parameter; | |
| 89 | 10758 | } | |
| 90 | |||
| 91 | 231 | void OptionsManager::SwitchTemplateManager( | |
| 92 | OptionsTemplateManager *opt_templ_mgr_param) { | ||
| 93 |
1/2✓ Branch 0 taken 231 times.
✗ Branch 1 not taken.
|
231 | delete opt_templ_mgr_; |
| 94 |
1/2✓ Branch 0 taken 231 times.
✗ Branch 1 not taken.
|
231 | if (opt_templ_mgr_param != NULL) { |
| 95 | 231 | opt_templ_mgr_ = opt_templ_mgr_param; | |
| 96 | } else { | ||
| 97 | ✗ | opt_templ_mgr_ = new OptionsTemplateManager(); | |
| 98 | } | ||
| 99 | 231 | for (std::map<std::string, std::string>::iterator it = | |
| 100 | 231 | templatable_values_.begin(); | |
| 101 |
2/2✓ Branch 2 taken 111 times.
✓ Branch 3 taken 231 times.
|
342 | it != templatable_values_.end(); |
| 102 | 111 | it++) { | |
| 103 |
2/4✓ Branch 3 taken 111 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 111 times.
✗ Branch 7 not taken.
|
111 | config_[it->first].value = it->second; |
| 104 |
2/4✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 111 times.
✗ Branch 6 not taken.
|
111 | opt_templ_mgr_->ParseString(&(config_[it->first].value)); |
| 105 |
2/4✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 111 times.
✗ Branch 6 not taken.
|
111 | UpdateEnvironment(it->first, config_[it->first]); |
| 106 | } | ||
| 107 | 231 | } | |
| 108 | |||
| 109 | 261 | bool SimpleOptionsParser::TryParsePath(const string &config_file) { | |
| 110 |
1/2✓ Branch 2 taken 261 times.
✗ Branch 3 not taken.
|
261 | LogCvmfs(kLogCvmfs, kLogDebug, "Fast-parsing config file %s", |
| 111 | config_file.c_str()); | ||
| 112 | 261 | string line; | |
| 113 |
1/2✓ Branch 2 taken 261 times.
✗ Branch 3 not taken.
|
261 | FILE *fconfig = fopen(config_file.c_str(), "r"); |
| 114 |
2/2✓ Branch 0 taken 29 times.
✓ Branch 1 taken 232 times.
|
261 | if (fconfig == NULL) |
| 115 | 29 | return false; | |
| 116 | |||
| 117 | // Read line by line and extract parameters | ||
| 118 |
3/4✓ Branch 1 taken 3596 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3364 times.
✓ Branch 4 taken 232 times.
|
3596 | while (GetLineFile(fconfig, &line)) { |
| 119 | 3364 | vector<string> tokens; | |
| 120 |
1/2✓ Branch 1 taken 3364 times.
✗ Branch 2 not taken.
|
3364 | const string parameter = SanitizeParameterAssignment(&line, &tokens); |
| 121 |
2/2✓ Branch 1 taken 870 times.
✓ Branch 2 taken 2494 times.
|
3364 | if (parameter.empty()) |
| 122 | 870 | continue; | |
| 123 | |||
| 124 | // Strip quotes from value | ||
| 125 |
1/2✓ Branch 3 taken 2494 times.
✗ Branch 4 not taken.
|
2494 | tokens.erase(tokens.begin()); |
| 126 |
3/6✓ Branch 2 taken 2494 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 2494 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 2494 times.
✗ Branch 9 not taken.
|
4988 | string value = Trim(JoinStrings(tokens, "=")); |
| 127 | 2494 | const unsigned value_length = value.length(); | |
| 128 |
2/2✓ Branch 0 taken 1798 times.
✓ Branch 1 taken 696 times.
|
2494 | if (value_length > 2) { |
| 129 |
3/7✓ Branch 1 taken 1798 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 174 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 174 times.
|
1972 | if (((value[0] == '"') && ((value[value_length - 1] == '"'))) |
| 130 |
9/13✓ Branch 0 taken 174 times.
✓ Branch 1 taken 1624 times.
✓ Branch 3 taken 1624 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 174 times.
✓ Branch 6 taken 1450 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 174 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 174 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 348 times.
✓ Branch 13 taken 1450 times.
|
1972 | || ((value[0] == '\'') && ((value[value_length - 1] == '\'')))) { |
| 131 |
1/2✓ Branch 1 taken 348 times.
✗ Branch 2 not taken.
|
348 | value = value.substr(1, value_length - 2); |
| 132 | } | ||
| 133 | } | ||
| 134 | |||
| 135 | 2494 | ConfigValue config_value; | |
| 136 |
1/2✓ Branch 1 taken 2494 times.
✗ Branch 2 not taken.
|
2494 | config_value.source = config_file; |
| 137 |
1/2✓ Branch 1 taken 2494 times.
✗ Branch 2 not taken.
|
2494 | config_value.value = value; |
| 138 |
2/4✓ Branch 1 taken 2494 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2494 times.
✗ Branch 5 not taken.
|
2494 | PopulateParameter(parameter, config_value); |
| 139 |
4/4✓ Branch 3 taken 2494 times.
✓ Branch 4 taken 870 times.
✓ Branch 6 taken 2494 times.
✓ Branch 7 taken 870 times.
|
4234 | } |
| 140 |
1/2✓ Branch 1 taken 232 times.
✗ Branch 2 not taken.
|
232 | fclose(fconfig); |
| 141 | 232 | return true; | |
| 142 | 261 | } | |
| 143 | |||
| 144 | 804 | void BashOptionsManager::ParsePath(const string &config_file, | |
| 145 | const bool external) { | ||
| 146 |
1/2✓ Branch 2 taken 804 times.
✗ Branch 3 not taken.
|
804 | LogCvmfs(kLogCvmfs, kLogDebug, "Parsing config file %s", config_file.c_str()); |
| 147 | int retval; | ||
| 148 | int pipe_open[2]; | ||
| 149 | int pipe_quit[2]; | ||
| 150 | 804 | pid_t pid_child = 0; | |
| 151 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 804 times.
|
804 | if (external) { |
| 152 | // cvmfs can run in the process group of automount in which case | ||
| 153 | // autofs won't mount an additional config repository. We create a | ||
| 154 | // short-lived process that detaches from the process group and triggers | ||
| 155 | // autofs to mount the config repository, if necessary. It holds a file | ||
| 156 | // handle to the config file until the main process opened the file, too. | ||
| 157 | ✗ | MakePipe(pipe_open); | |
| 158 | ✗ | MakePipe(pipe_quit); | |
| 159 | ✗ | switch (pid_child = fork()) { | |
| 160 | ✗ | case -1: | |
| 161 | ✗ | PANIC(NULL); | |
| 162 | ✗ | case 0: { // Child | |
| 163 | ✗ | close(pipe_open[0]); | |
| 164 | ✗ | close(pipe_quit[1]); | |
| 165 | // If this is not a process group leader, create a new session | ||
| 166 | ✗ | if (getpgrp() != getpid()) { | |
| 167 | ✗ | const pid_t new_session = setsid(); | |
| 168 | ✗ | assert(new_session != (pid_t)-1); | |
| 169 | } | ||
| 170 | ✗ | (void)open(config_file.c_str(), O_RDONLY); | |
| 171 | ✗ | char ready = 'R'; | |
| 172 | ✗ | WritePipe(pipe_open[1], &ready, 1); | |
| 173 | ✗ | retval = read(pipe_quit[0], &ready, 1); | |
| 174 | ✗ | _exit(retval); // Don't flush shared file descriptors | |
| 175 | } | ||
| 176 | } | ||
| 177 | // Parent | ||
| 178 | ✗ | close(pipe_open[1]); | |
| 179 | ✗ | close(pipe_quit[0]); | |
| 180 | ✗ | char ready = 0; | |
| 181 | ✗ | ReadPipe(pipe_open[0], &ready, 1); | |
| 182 | ✗ | assert(ready == 'R'); | |
| 183 | ✗ | close(pipe_open[0]); | |
| 184 | } | ||
| 185 |
1/2✓ Branch 1 taken 804 times.
✗ Branch 2 not taken.
|
804 | const string config_path = GetParentPath(config_file); |
| 186 |
1/2✓ Branch 2 taken 804 times.
✗ Branch 3 not taken.
|
804 | FILE *fconfig = fopen(config_file.c_str(), "r"); |
| 187 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 804 times.
|
804 | if (pid_child > 0) { |
| 188 | ✗ | char c = 'C'; | |
| 189 | ✗ | WritePipe(pipe_quit[1], &c, 1); | |
| 190 | int statloc; | ||
| 191 | ✗ | waitpid(pid_child, &statloc, 0); | |
| 192 | ✗ | close(pipe_quit[1]); | |
| 193 | } | ||
| 194 |
2/2✓ Branch 0 taken 40 times.
✓ Branch 1 taken 764 times.
|
804 | if (!fconfig) { |
| 195 |
2/8✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 40 times.
|
40 | if (external && !DirectoryExists(config_path)) { |
| 196 | ✗ | string repo_required; | |
| 197 | ✗ | if (GetValue("CVMFS_CONFIG_REPO_REQUIRED", &repo_required) | |
| 198 | ✗ | && IsOn(repo_required)) { | |
| 199 | ✗ | LogCvmfs( | |
| 200 | kLogCvmfs, kLogStderr | kLogSyslogErr, | ||
| 201 | "required configuration repository directory does not exist: %s", | ||
| 202 | config_path.c_str()); | ||
| 203 | // Do not crash as in abort(), which can trigger core file creation | ||
| 204 | // from the mount helper | ||
| 205 | ✗ | exit(1); | |
| 206 | } | ||
| 207 | |||
| 208 | ✗ | LogCvmfs(kLogCvmfs, kLogDebug | kLogSyslogWarn, | |
| 209 | "configuration repository directory does not exist: %s", | ||
| 210 | config_path.c_str()); | ||
| 211 | } | ||
| 212 | 40 | return; | |
| 213 | } | ||
| 214 | |||
| 215 | int fd_stdin; | ||
| 216 | int fd_stdout; | ||
| 217 | int fd_stderr; | ||
| 218 |
1/2✓ Branch 1 taken 764 times.
✗ Branch 2 not taken.
|
764 | retval = Shell(&fd_stdin, &fd_stdout, &fd_stderr); |
| 219 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 764 times.
|
764 | assert(retval); |
| 220 | |||
| 221 | // Let the shell read the file | ||
| 222 | 1528 | string line; | |
| 223 |
1/2✓ Branch 2 taken 764 times.
✗ Branch 3 not taken.
|
1528 | const string newline = "\n"; |
| 224 |
5/15✗ Branch 1 not taken.
✓ Branch 2 taken 764 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 8 taken 764 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 764 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 764 times.
✗ Branch 15 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 764 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1528 | const string cd = "cd \"" + ((config_path == "") ? "/" : config_path) + "\"" |
| 225 |
1/2✓ Branch 1 taken 764 times.
✗ Branch 2 not taken.
|
1528 | + newline; |
| 226 |
1/2✓ Branch 3 taken 764 times.
✗ Branch 4 not taken.
|
764 | WritePipe(fd_stdin, cd.data(), cd.length()); |
| 227 |
3/4✓ Branch 1 taken 9400 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8636 times.
✓ Branch 4 taken 764 times.
|
9400 | while (GetLineFile(fconfig, &line)) { |
| 228 |
1/2✓ Branch 3 taken 8636 times.
✗ Branch 4 not taken.
|
8636 | WritePipe(fd_stdin, line.data(), line.length()); |
| 229 |
1/2✓ Branch 3 taken 8636 times.
✗ Branch 4 not taken.
|
8636 | WritePipe(fd_stdin, newline.data(), newline.length()); |
| 230 | } | ||
| 231 |
1/2✓ Branch 1 taken 764 times.
✗ Branch 2 not taken.
|
764 | rewind(fconfig); |
| 232 | |||
| 233 | // Read line by line and extract parameters | ||
| 234 |
3/4✓ Branch 1 taken 9400 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8636 times.
✓ Branch 4 taken 764 times.
|
9400 | while (GetLineFile(fconfig, &line)) { |
| 235 | 8636 | vector<string> tokens; | |
| 236 |
1/2✓ Branch 1 taken 8636 times.
✗ Branch 2 not taken.
|
8636 | const string parameter = SanitizeParameterAssignment(&line, &tokens); |
| 237 |
2/2✓ Branch 1 taken 1200 times.
✓ Branch 2 taken 7436 times.
|
8636 | if (parameter.empty()) |
| 238 | 1200 | continue; | |
| 239 | |||
| 240 | 7436 | ConfigValue value; | |
| 241 |
1/2✓ Branch 1 taken 7436 times.
✗ Branch 2 not taken.
|
7436 | value.source = config_file; |
| 242 |
2/4✓ Branch 1 taken 7436 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7436 times.
✗ Branch 5 not taken.
|
7436 | const string sh_echo = "echo $" + parameter + "\n"; |
| 243 |
1/2✓ Branch 3 taken 7436 times.
✗ Branch 4 not taken.
|
7436 | WritePipe(fd_stdin, sh_echo.data(), sh_echo.length()); |
| 244 |
1/2✓ Branch 1 taken 7436 times.
✗ Branch 2 not taken.
|
7436 | GetLineFd(fd_stdout, &value.value); |
| 245 |
2/4✓ Branch 1 taken 7436 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7436 times.
✗ Branch 5 not taken.
|
7436 | PopulateParameter(parameter, value); |
| 246 |
4/4✓ Branch 3 taken 7436 times.
✓ Branch 4 taken 1200 times.
✓ Branch 6 taken 7436 times.
✓ Branch 7 taken 1200 times.
|
9836 | } |
| 247 | |||
| 248 |
1/2✓ Branch 1 taken 764 times.
✗ Branch 2 not taken.
|
764 | close(fd_stderr); |
| 249 |
1/2✓ Branch 1 taken 764 times.
✗ Branch 2 not taken.
|
764 | close(fd_stdout); |
| 250 |
1/2✓ Branch 1 taken 764 times.
✗ Branch 2 not taken.
|
764 | close(fd_stdin); |
| 251 |
1/2✓ Branch 1 taken 764 times.
✗ Branch 2 not taken.
|
764 | fclose(fconfig); |
| 252 | } | ||
| 253 | |||
| 254 | |||
| 255 | 855 | bool OptionsManager::HasConfigRepository(const string &fqrn, | |
| 256 | string *config_path) { | ||
| 257 | 855 | string cvmfs_mount_dir; | |
| 258 |
3/6✓ Branch 2 taken 855 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 855 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 855 times.
|
855 | if (!GetValue("CVMFS_MOUNT_DIR", &cvmfs_mount_dir)) { |
| 259 | ✗ | LogCvmfs(kLogCvmfs, kLogDebug | kLogSyslogErr, "CVMFS_MOUNT_DIR missing"); | |
| 260 | ✗ | return false; | |
| 261 | } | ||
| 262 | |||
| 263 | 855 | string config_repository; | |
| 264 |
4/6✓ Branch 2 taken 855 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 855 times.
✗ Branch 6 not taken.
✓ Branch 9 taken 54 times.
✓ Branch 10 taken 801 times.
|
855 | if (GetValue("CVMFS_CONFIG_REPOSITORY", &config_repository)) { |
| 265 |
3/6✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 54 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 54 times.
|
54 | if (config_repository.empty() || (config_repository == fqrn)) |
| 266 | ✗ | return false; | |
| 267 |
1/2✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
|
54 | const sanitizer::RepositorySanitizer repository_sanitizer; |
| 268 |
2/4✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 54 times.
|
54 | if (!repository_sanitizer.IsValid(config_repository)) { |
| 269 | ✗ | LogCvmfs(kLogCvmfs, kLogDebug | kLogSyslogErr, | |
| 270 | "invalid CVMFS_CONFIG_REPOSITORY: %s", | ||
| 271 | config_repository.c_str()); | ||
| 272 | ✗ | return false; | |
| 273 | } | ||
| 274 |
3/6✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 54 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 54 times.
✗ Branch 8 not taken.
|
54 | *config_path = cvmfs_mount_dir + "/" + config_repository + "/etc/cvmfs/"; |
| 275 | 54 | return true; | |
| 276 | 54 | } | |
| 277 | 801 | return false; | |
| 278 | 855 | } | |
| 279 | |||
| 280 | ✗ | void OptionsManager::SetupGlobalEnvironmentParams() { | |
| 281 | ✗ | SetValue("CVMFS_ARCH", GetArch()); | |
| 282 | |||
| 283 | // Set CVMFS_VERSION environment variable | ||
| 284 | ✗ | SetValue("CVMFS_VERSION", CVMFS_VERSION); | |
| 285 | |||
| 286 | // Calculate and set CVMFS_VERSION_NUMERIC | ||
| 287 | // Format: major * 10000 + minor * 100 + patch | ||
| 288 | // Example: 2.13.2 becomes 21302 | ||
| 289 | ✗ | const int version_numeric = CVMFS_VERSION_MAJOR * 10000 | |
| 290 | + CVMFS_VERSION_MINOR * 100 + CVMFS_VERSION_PATCH; | ||
| 291 | char version_numeric_str[16]; | ||
| 292 | ✗ | snprintf(version_numeric_str, sizeof(version_numeric_str), "%d", | |
| 293 | version_numeric); | ||
| 294 | ✗ | SetValue("CVMFS_VERSION_NUMERIC", version_numeric_str); | |
| 295 | } | ||
| 296 | |||
| 297 | ✗ | void OptionsManager::ParseDefault(const string &fqrn) { | |
| 298 | ✗ | if (taint_environment_) { | |
| 299 | ✗ | const int retval = setenv("CVMFS_FQRN", fqrn.c_str(), 1); | |
| 300 | ✗ | assert(retval == 0); | |
| 301 | } | ||
| 302 | |||
| 303 | ✗ | SetupGlobalEnvironmentParams(); | |
| 304 | ✗ | protected_parameters_.clear(); | |
| 305 | ✗ | ParsePath("/etc/cvmfs/default.conf", false); | |
| 306 | vector<string> dist_defaults = FindFilesBySuffix("/etc/cvmfs/default.d", | ||
| 307 | ✗ | ".conf"); | |
| 308 | ✗ | for (unsigned i = 0; i < dist_defaults.size(); ++i) { | |
| 309 | ✗ | ParsePath(dist_defaults[i], false); | |
| 310 | } | ||
| 311 | ✗ | ProtectParameter("CVMFS_CONFIG_REPOSITORY"); | |
| 312 | ✗ | string external_config_path; | |
| 313 | ✗ | if ((fqrn != "") && HasConfigRepository(fqrn, &external_config_path)) | |
| 314 | ✗ | ParsePath(external_config_path + "default.conf", true); | |
| 315 | ✗ | ParsePath("/etc/cvmfs/default.local", false); | |
| 316 | |||
| 317 | ✗ | if (fqrn != "") { | |
| 318 | ✗ | string domain; | |
| 319 | ✗ | vector<string> tokens = SplitString(fqrn, '.'); | |
| 320 | ✗ | assert(tokens.size() > 1); | |
| 321 | ✗ | tokens.erase(tokens.begin()); | |
| 322 | ✗ | domain = JoinStrings(tokens, "."); | |
| 323 | |||
| 324 | ✗ | if (HasConfigRepository(fqrn, &external_config_path)) | |
| 325 | ✗ | ParsePath(external_config_path + "domain.d/" + domain + ".conf", true); | |
| 326 | ✗ | ParsePath("/etc/cvmfs/domain.d/" + domain + ".conf", false); | |
| 327 | ✗ | ParsePath("/etc/cvmfs/domain.d/" + domain + ".local", false); | |
| 328 | |||
| 329 | ✗ | if (HasConfigRepository(fqrn, &external_config_path)) | |
| 330 | ✗ | ParsePath(external_config_path + "config.d/" + fqrn + ".conf", true); | |
| 331 | ✗ | ParsePath("/etc/cvmfs/config.d/" + fqrn + ".conf", false); | |
| 332 | ✗ | ParsePath("/etc/cvmfs/config.d/" + fqrn + ".local", false); | |
| 333 | } | ||
| 334 | } | ||
| 335 | |||
| 336 | |||
| 337 | 17994 | void OptionsManager::PopulateParameter(const string ¶m, ConfigValue val) { | |
| 338 |
1/2✓ Branch 1 taken 17994 times.
✗ Branch 2 not taken.
|
17994 | const map<string, string>::const_iterator iter = protected_parameters_.find( |
| 339 | 17994 | param); | |
| 340 |
5/6✓ Branch 3 taken 69 times.
✓ Branch 4 taken 17925 times.
✓ Branch 7 taken 69 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 69 times.
✓ Branch 10 taken 17925 times.
|
17994 | if ((iter != protected_parameters_.end()) && (iter->second != val.value)) { |
| 341 |
1/3✓ Branch 4 taken 69 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
|
138 | LogCvmfs(kLogCvmfs, kLogDebug | kLogSyslogErr, |
| 342 | "error in cvmfs configuration: attempt to change protected %s " | ||
| 343 | "from %s to %s", | ||
| 344 | 69 | param.c_str(), iter->second.c_str(), val.value.c_str()); | |
| 345 | 69 | return; | |
| 346 | } | ||
| 347 |
2/4✓ Branch 1 taken 17925 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 17925 times.
✗ Branch 5 not taken.
|
17925 | ParseValue(param, &val); |
| 348 |
2/4✓ Branch 1 taken 17925 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 17925 times.
✗ Branch 5 not taken.
|
17925 | config_[param] = val; |
| 349 |
1/2✓ Branch 1 taken 17925 times.
✗ Branch 2 not taken.
|
17925 | UpdateEnvironment(param, val); |
| 350 | } | ||
| 351 | |||
| 352 | 18036 | void OptionsManager::UpdateEnvironment(const string ¶m, ConfigValue val) { | |
| 353 |
2/2✓ Branch 0 taken 15900 times.
✓ Branch 1 taken 2136 times.
|
18036 | if (taint_environment_) { |
| 354 | 15900 | const int retval = setenv(param.c_str(), val.value.c_str(), 1); | |
| 355 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 15900 times.
|
15900 | assert(retval == 0); |
| 356 | } | ||
| 357 | 18036 | } | |
| 358 | |||
| 359 | 17925 | void OptionsManager::ParseValue(std::string param, ConfigValue *val) { | |
| 360 |
1/2✓ Branch 1 taken 17925 times.
✗ Branch 2 not taken.
|
17925 | const string orig = val->value; |
| 361 |
1/2✓ Branch 1 taken 17925 times.
✗ Branch 2 not taken.
|
17925 | const bool has_templ = opt_templ_mgr_->ParseString(&(val->value)); |
| 362 |
2/2✓ Branch 0 taken 456 times.
✓ Branch 1 taken 17469 times.
|
17925 | if (has_templ) { |
| 363 |
2/4✓ Branch 1 taken 456 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 456 times.
✗ Branch 5 not taken.
|
456 | templatable_values_[param] = orig; |
| 364 | } | ||
| 365 | 17925 | } | |
| 366 | |||
| 367 | |||
| 368 | 69 | void OptionsManager::ProtectParameter(const string ¶m) { | |
| 369 | 69 | string value; | |
| 370 | // We don't care about the result. If param does not yet exists, we lock it | ||
| 371 | // to the empty string. | ||
| 372 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
69 | (void)GetValue(param, &value); |
| 373 |
2/4✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 69 times.
✗ Branch 5 not taken.
|
69 | protected_parameters_[param] = value; |
| 374 | 69 | } | |
| 375 | |||
| 376 | |||
| 377 | 69 | void OptionsManager::ClearConfig() { config_.clear(); } | |
| 378 | |||
| 379 | |||
| 380 | 8764 | bool OptionsManager::IsDefined(const std::string &key) { | |
| 381 |
1/2✓ Branch 1 taken 8764 times.
✗ Branch 2 not taken.
|
8764 | const map<string, ConfigValue>::const_iterator iter = config_.find(key); |
| 382 | 8764 | return iter != config_.end(); | |
| 383 | } | ||
| 384 | |||
| 385 | |||
| 386 | 98883 | bool OptionsManager::GetValue(const string &key, string *value) const { | |
| 387 |
1/2✓ Branch 1 taken 98883 times.
✗ Branch 2 not taken.
|
98883 | const map<string, ConfigValue>::const_iterator iter = config_.find(key); |
| 388 |
2/2✓ Branch 2 taken 24856 times.
✓ Branch 3 taken 74027 times.
|
98883 | if (iter != config_.end()) { |
| 389 |
1/2✓ Branch 2 taken 24856 times.
✗ Branch 3 not taken.
|
24856 | *value = iter->second.value; |
| 390 | 24856 | return true; | |
| 391 | } | ||
| 392 |
1/2✓ Branch 1 taken 74027 times.
✗ Branch 2 not taken.
|
74027 | *value = ""; |
| 393 | 74027 | return false; | |
| 394 | } | ||
| 395 | |||
| 396 | |||
| 397 | 105 | std::string OptionsManager::GetValueOrDie(const string &key) { | |
| 398 | 105 | std::string value; | |
| 399 |
1/2✓ Branch 1 taken 105 times.
✗ Branch 2 not taken.
|
105 | const bool retval = GetValue(key, &value); |
| 400 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
|
105 | if (!retval) { |
| 401 | ✗ | PANIC(kLogStderr | kLogDebug, "%s configuration parameter missing", | |
| 402 | key.c_str()); | ||
| 403 | } | ||
| 404 | 105 | return value; | |
| 405 | } | ||
| 406 | |||
| 407 | |||
| 408 | 9448 | bool OptionsManager::GetSource(const string &key, string *value) { | |
| 409 |
1/2✓ Branch 1 taken 9448 times.
✗ Branch 2 not taken.
|
9448 | const map<string, ConfigValue>::const_iterator iter = config_.find(key); |
| 410 |
1/2✓ Branch 3 taken 9448 times.
✗ Branch 4 not taken.
|
9448 | if (iter != config_.end()) { |
| 411 |
1/2✓ Branch 2 taken 9448 times.
✗ Branch 3 not taken.
|
9448 | *value = iter->second.source; |
| 412 | 9448 | return true; | |
| 413 | } | ||
| 414 | ✗ | *value = ""; | |
| 415 | ✗ | return false; | |
| 416 | } | ||
| 417 | |||
| 418 | |||
| 419 | 1857 | bool OptionsManager::IsOn(const std::string ¶m_value) const { | |
| 420 |
1/2✓ Branch 1 taken 1857 times.
✗ Branch 2 not taken.
|
1857 | const string uppercase = ToUpper(param_value); |
| 421 |
2/4✓ Branch 2 taken 1713 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1713 times.
✗ Branch 6 not taken.
|
3570 | return ((uppercase == "YES") || (uppercase == "ON") || (uppercase == "1") |
| 422 |
3/4✓ Branch 0 taken 1713 times.
✓ Branch 1 taken 144 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1713 times.
|
5427 | || (uppercase == "TRUE")); |
| 423 | 1857 | } | |
| 424 | |||
| 425 | |||
| 426 | 36 | bool OptionsManager::IsOff(const std::string ¶m_value) const { | |
| 427 |
1/2✓ Branch 1 taken 36 times.
✗ Branch 2 not taken.
|
36 | const string uppercase = ToUpper(param_value); |
| 428 |
3/4✓ Branch 2 taken 18 times.
✓ Branch 3 taken 18 times.
✓ Branch 5 taken 18 times.
✗ Branch 6 not taken.
|
72 | return ((uppercase == "NO") || (uppercase == "OFF") || (uppercase == "0") |
| 429 |
2/4✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 18 times.
|
108 | || (uppercase == "FALSE")); |
| 430 | 36 | } | |
| 431 | |||
| 432 | |||
| 433 | 1616 | vector<string> OptionsManager::GetAllKeys() { | |
| 434 | 1616 | vector<string> result; | |
| 435 | 1616 | for (map<string, ConfigValue>::const_iterator i = config_.begin(), | |
| 436 | 1616 | iEnd = config_.end(); | |
| 437 |
2/2✓ Branch 1 taken 10000 times.
✓ Branch 2 taken 1616 times.
|
11616 | i != iEnd; |
| 438 | 10000 | ++i) { | |
| 439 |
1/2✓ Branch 2 taken 10000 times.
✗ Branch 3 not taken.
|
10000 | result.push_back(i->first); |
| 440 | } | ||
| 441 | 1616 | return result; | |
| 442 | } | ||
| 443 | |||
| 444 | |||
| 445 | 436 | vector<string> OptionsManager::GetEnvironmentSubset(const string &key_prefix, | |
| 446 | bool strip_prefix) { | ||
| 447 | 436 | vector<string> result; | |
| 448 | 436 | for (map<string, ConfigValue>::const_iterator i = config_.begin(), | |
| 449 | 436 | iEnd = config_.end(); | |
| 450 |
2/2✓ Branch 1 taken 3864 times.
✓ Branch 2 taken 436 times.
|
4300 | i != iEnd; |
| 451 | 3864 | ++i) { | |
| 452 | 3864 | const bool ignore_prefix = false; | |
| 453 |
3/4✓ Branch 2 taken 3864 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 483 times.
✓ Branch 5 taken 3381 times.
|
3864 | if (HasPrefix(i->first, key_prefix, ignore_prefix)) { |
| 454 | const string output_key = strip_prefix | ||
| 455 | 69 | ? i->first.substr(key_prefix.length()) | |
| 456 |
4/6✓ Branch 0 taken 69 times.
✓ Branch 1 taken 414 times.
✓ Branch 4 taken 69 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 414 times.
✗ Branch 9 not taken.
|
552 | : i->first; |
| 457 |
3/6✓ Branch 2 taken 483 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 483 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 483 times.
✗ Branch 9 not taken.
|
483 | result.push_back(output_key + "=" + i->second.value); |
| 458 | 483 | } | |
| 459 | } | ||
| 460 | 436 | return result; | |
| 461 | } | ||
| 462 | |||
| 463 | |||
| 464 | 1478 | string OptionsManager::Dump() { | |
| 465 | 1478 | string result; | |
| 466 |
1/2✓ Branch 1 taken 1478 times.
✗ Branch 2 not taken.
|
1478 | vector<string> keys = GetAllKeys(); |
| 467 |
2/2✓ Branch 1 taken 9034 times.
✓ Branch 2 taken 1478 times.
|
10512 | for (unsigned i = 0, l = keys.size(); i < l; ++i) { |
| 468 | bool retval; | ||
| 469 | 9034 | string value; | |
| 470 | 9034 | string source; | |
| 471 | |||
| 472 |
1/2✓ Branch 2 taken 9034 times.
✗ Branch 3 not taken.
|
9034 | retval = GetValue(keys[i], &value); |
| 473 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9034 times.
|
9034 | assert(retval); |
| 474 |
1/2✓ Branch 2 taken 9034 times.
✗ Branch 3 not taken.
|
9034 | retval = GetSource(keys[i], &source); |
| 475 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9034 times.
|
9034 | assert(retval); |
| 476 |
5/10✓ Branch 1 taken 9034 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 9034 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 9034 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 9034 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 9034 times.
✗ Branch 15 not taken.
|
18068 | result += keys[i] + "=" + EscapeShell(value) + " # from " + source |
| 477 |
2/4✓ Branch 1 taken 9034 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 9034 times.
✗ Branch 5 not taken.
|
9034 | + "\n"; |
| 478 | 9034 | } | |
| 479 | 2956 | return result; | |
| 480 | 1478 | } | |
| 481 | |||
| 482 | ✗ | void OptionsManager::SetValueFromTalk(const string &key, const string &value) { | |
| 483 | ✗ | ConfigValue config_value; | |
| 484 | ✗ | config_value.source = "cvmfs_talk"; | |
| 485 | ✗ | config_value.value = value; | |
| 486 | ✗ | PopulateParameter(key, config_value); | |
| 487 | } | ||
| 488 | |||
| 489 | 8064 | void OptionsManager::SetValue(const string &key, const string &value) { | |
| 490 | 8064 | ConfigValue config_value; | |
| 491 |
1/2✓ Branch 1 taken 8064 times.
✗ Branch 2 not taken.
|
8064 | config_value.source = "@INTERNAL@"; |
| 492 |
1/2✓ Branch 1 taken 8064 times.
✗ Branch 2 not taken.
|
8064 | config_value.value = value; |
| 493 |
2/4✓ Branch 1 taken 8064 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 8064 times.
✗ Branch 5 not taken.
|
8064 | PopulateParameter(key, config_value); |
| 494 | 8064 | } | |
| 495 | |||
| 496 | |||
| 497 | 528 | void OptionsManager::UnsetValue(const string &key) { | |
| 498 | 528 | protected_parameters_.erase(key); | |
| 499 | 528 | config_.erase(key); | |
| 500 |
2/2✓ Branch 0 taken 459 times.
✓ Branch 1 taken 69 times.
|
528 | if (taint_environment_) |
| 501 | 459 | unsetenv(key.c_str()); | |
| 502 | 528 | } | |
| 503 | |||
| 504 | const char *DefaultOptionsTemplateManager ::kTemplateIdentFqrn = "fqrn"; | ||
| 505 | |||
| 506 | const char *DefaultOptionsTemplateManager ::kTemplateIdentOrg = "org"; | ||
| 507 | |||
| 508 | 712 | DefaultOptionsTemplateManager::DefaultOptionsTemplateManager(std::string fqrn) { | |
| 509 |
3/6✓ Branch 1 taken 712 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 712 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 712 times.
✗ Branch 9 not taken.
|
712 | SetTemplate(kTemplateIdentFqrn, fqrn); |
| 510 |
1/2✓ Branch 1 taken 712 times.
✗ Branch 2 not taken.
|
712 | vector<string> fqrn_parts = SplitString(fqrn, '.'); |
| 511 |
3/6✓ Branch 2 taken 712 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 712 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 712 times.
✗ Branch 10 not taken.
|
712 | SetTemplate(kTemplateIdentOrg, fqrn_parts[0]); |
| 512 | 712 | } | |
| 513 | |||
| 514 | 1641 | void OptionsTemplateManager::SetTemplate(std::string name, std::string val) { | |
| 515 | 1641 | templates_[name] = val; | |
| 516 | 1641 | } | |
| 517 | |||
| 518 | 1977 | std::string OptionsTemplateManager::GetTemplate(std::string name) { | |
| 519 |
2/2✓ Branch 1 taken 476 times.
✓ Branch 2 taken 1501 times.
|
1977 | if (templates_.count(name)) { |
| 520 | 476 | return templates_[name]; | |
| 521 | } else { | ||
| 522 |
2/4✓ Branch 1 taken 1501 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1501 times.
✗ Branch 5 not taken.
|
1501 | std::string var_name = "@" + name + "@"; |
| 523 |
1/2✓ Branch 2 taken 1501 times.
✗ Branch 3 not taken.
|
1501 | LogCvmfs(kLogCvmfs, kLogDebug, "Undeclared variable: %s", var_name.c_str()); |
| 524 | 1501 | return var_name; | |
| 525 | 1501 | } | |
| 526 | } | ||
| 527 | |||
| 528 | 18184 | bool OptionsTemplateManager::ParseString(std::string *input) { | |
| 529 | 18184 | std::string result; | |
| 530 |
1/2✓ Branch 1 taken 18184 times.
✗ Branch 2 not taken.
|
18184 | std::string in = *input; |
| 531 | 18184 | bool has_vars = false; | |
| 532 | 18184 | int mode = 0; | |
| 533 | 18184 | std::string stock; | |
| 534 |
2/2✓ Branch 1 taken 475862 times.
✓ Branch 2 taken 18184 times.
|
494046 | for (std::string::size_type i = 0; i < in.size(); i++) { |
| 535 |
2/3✓ Branch 0 taken 465271 times.
✓ Branch 1 taken 10591 times.
✗ Branch 2 not taken.
|
475862 | switch (mode) { |
| 536 | 465271 | case 0: | |
| 537 |
3/4✓ Branch 1 taken 465271 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2206 times.
✓ Branch 4 taken 463065 times.
|
465271 | if (in[i] == '@') { |
| 538 | 2206 | mode = 1; | |
| 539 | } else { | ||
| 540 |
2/4✓ Branch 1 taken 463065 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 463065 times.
✗ Branch 5 not taken.
|
463065 | result += in[i]; |
| 541 | } | ||
| 542 | 465271 | break; | |
| 543 | 10591 | case 1: | |
| 544 |
3/4✓ Branch 1 taken 10591 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1718 times.
✓ Branch 4 taken 8873 times.
|
10591 | if (in[i] == '@') { |
| 545 | 1718 | mode = 0; | |
| 546 |
3/6✓ Branch 1 taken 1718 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1718 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1718 times.
✗ Branch 8 not taken.
|
1718 | result += GetTemplate(stock); |
| 547 |
1/2✓ Branch 1 taken 1718 times.
✗ Branch 2 not taken.
|
1718 | stock = ""; |
| 548 | 1718 | has_vars = true; | |
| 549 | } else { | ||
| 550 |
2/4✓ Branch 1 taken 8873 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 8873 times.
✗ Branch 5 not taken.
|
8873 | stock += in[i]; |
| 551 | } | ||
| 552 | 10591 | break; | |
| 553 | } | ||
| 554 | } | ||
| 555 |
2/2✓ Branch 0 taken 488 times.
✓ Branch 1 taken 17696 times.
|
18184 | if (mode == 1) { |
| 556 |
2/4✓ Branch 1 taken 488 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 488 times.
✗ Branch 5 not taken.
|
488 | result += "@" + stock; |
| 557 | } | ||
| 558 |
1/2✓ Branch 1 taken 18184 times.
✗ Branch 2 not taken.
|
18184 | *input = result; |
| 559 | 18184 | return has_vars; | |
| 560 | 18184 | } | |
| 561 | |||
| 562 | 259 | bool OptionsTemplateManager::HasTemplate(std::string name) { | |
| 563 | 259 | return templates_.count(name); | |
| 564 | } | ||
| 565 | |||
| 566 | #ifdef CVMFS_NAMESPACE_GUARD | ||
| 567 | } // namespace CVMFS_NAMESPACE_GUARD | ||
| 568 | #endif | ||
| 569 |