Commit 7aabc6b1 authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

nghttpx: Use ImmutableString for user

parent 466e4b7a
......@@ -1738,7 +1738,7 @@ int parse_config(const char *opt, const char *optarg,
<< strerror(errno);
return -1;
}
mod_config()->user = strcopy(pwd->pw_name);
mod_config()->user = pwd->pw_name;
mod_config()->uid = pwd->pw_uid;
mod_config()->gid = pwd->pw_gid;
......
......@@ -583,7 +583,7 @@ struct Config {
ConnectionConfig conn;
ImmutableString pid_file;
ImmutableString conf_path;
std::unique_ptr<char[]> user;
ImmutableString user;
std::unique_ptr<char[]> mruby_file;
char **original_argv;
char **argv;
......
......@@ -64,7 +64,7 @@ void drop_privileges(
#endif // HAVE_NEVERBLEED
) {
if (getuid() == 0 && get_config()->uid != 0) {
if (initgroups(get_config()->user.get(), get_config()->gid) != 0) {
if (initgroups(get_config()->user.c_str(), get_config()->gid) != 0) {
auto error = errno;
LOG(FATAL) << "Could not change supplementary groups: "
<< strerror(error);
......@@ -86,7 +86,7 @@ void drop_privileges(
}
#ifdef HAVE_NEVERBLEED
if (nb) {
neverbleed_setuidgid(nb, get_config()->user.get(), 1);
neverbleed_setuidgid(nb, get_config()->user.c_str(), 1);
}
#endif // HAVE_NEVERBLEED
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment