MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / createUser

Function createUser

programs/install/Install.cpp:169–190  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

167}
168
169static void createUser(const String & user_name, [[maybe_unused]] const String & group_name)
170{
171 if (!user_name.empty())
172 {
173#if defined(OS_DARWIN)
174 // TODO: implement.
175 throw Exception(ErrorCodes::NOT_IMPLEMENTED, "Unable to create a user in macOS");
176#elif defined(OS_FREEBSD)
177 std::string command = group_name.empty()
178 ? fmt::format("pw useradd -s /bin/false -d /nonexistent -n {}", shellQuote(user_name))
179 : fmt::format("pw useradd -s /bin/false -d /nonexistent -g {} -n {}", shellQuote(group_name), shellQuote(user_name));
180 fmt::print(" {}\n", command);
181 executeScript(command);
182#else
183 std::string command = group_name.empty()
184 ? fmt::format("useradd -r --shell /bin/false --home-dir /nonexistent --user-group {}", shellQuote(user_name))
185 : fmt::format("useradd -r --shell /bin/false --home-dir /nonexistent -g {} {}", shellQuote(group_name), shellQuote(user_name));
186 fmt::print(" {}\n", command);
187 executeScript(command);
188#endif
189 }
190}
191
192
193static std::string formatWithSudo(std::string command, bool needed = true)

Callers 1

Install.cppFile · 0.85

Calls 6

shellQuoteFunction · 0.85
executeScriptFunction · 0.85
ExceptionClass · 0.50
formatFunction · 0.50
printFunction · 0.50
emptyMethod · 0.45

Tested by

no test coverage detected