-
Notifications
You must be signed in to change notification settings - Fork 6.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better user-group creating in postinst, BaseDaemon::getDefaultCorePath [#METR-23811] #295
Conversation
@@ -188,6 +188,9 @@ static std::string getCanonicalPath(std::string && path) | |||
return path; | |||
} | |||
|
|||
std::string Server::getDefaultCorePath() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style.
@@ -701,6 +703,10 @@ void BaseDaemon::closeLogs() | |||
logger().warning("Logging to console but received signal to close log file (ignoring)."); | |||
} | |||
|
|||
std::string BaseDaemon::getDefaultCorePath () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style.
@@ -61,6 +61,8 @@ class Server : public BaseDaemon | |||
private: | |||
|
|||
void attachSystemTables(const std::string & path, bool has_zookeeper) const; | |||
|
|||
std::string getDefaultCorePath() override; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing const.
@@ -436,19 +436,21 @@ static void terminate_handler() | |||
} | |||
|
|||
|
|||
static std::string createDirectory(const std::string & _path) | |||
static std::string createDirectory(const std::string & _path, bool strip_file = 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is ancient code. Why not to throw away and use Poco::File::createDirectories instead
?
if (core_path.empty()) | ||
core_path = getDefaultCorePath(); | ||
|
||
try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to catch. Let it fail.
core_path = !log_path.empty() ? log_path : "/opt/"; | ||
try { | ||
createDirectory(core_path, false); | ||
} catch (...) { } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same.
} catch (...) { } | ||
|
||
Poco::File cores = core_path; | ||
if ( !( cores.exists() && cores.isDirectory() ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for whitespace in inner side of parens (style).
|
||
try { | ||
createDirectory(core_path, false); | ||
} catch (...) { } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Silent catching of all exceptions is prohibited in style.
@@ -34,7 +34,7 @@ function make_control { | |||
do | |||
case "$DAEMON_PKG" in | |||
'clickhouse-server' ) | |||
add_daemon_impl clickhouse-server-base '' 'clickhouse-server binary' | |||
add_daemon_impl clickhouse-server-base 'adduser' 'clickhouse-server binary' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I read this just now:
useradd is a low level utility for adding users. On Debian, administrators should usually use adduser(8) instead.
What if people are installing debian package on non-debian system (this way is used in practice)? Dependencies are cost too much... I am not sure that adduser
gives enough comparing to useradd
. BTW, I call these kind of programs "trash-scripts".
#mkdir -p /var/log/clickhouse | ||
#chmod 1775 /var/log/clickhouse | ||
#chown root:metrika /var/log/clickhouse | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to cleanup.
No description provided.