nghttpx: Use ImmutableString for user

This commit is contained in:
Tatsuhiro Tsujikawa 2016-02-14 22:21:55 +09:00
parent 466e4b7a1e
commit 7aabc6b125
3 changed files with 4 additions and 4 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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
}