diff --git a/src/shrpx_config.cc b/src/shrpx_config.cc index 8d23b9ac..1e023d18 100644 --- a/src/shrpx_config.cc +++ b/src/shrpx_config.cc @@ -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; diff --git a/src/shrpx_config.h b/src/shrpx_config.h index c7a3ef59..03b3700b 100644 --- a/src/shrpx_config.h +++ b/src/shrpx_config.h @@ -583,7 +583,7 @@ struct Config { ConnectionConfig conn; ImmutableString pid_file; ImmutableString conf_path; - std::unique_ptr user; + ImmutableString user; std::unique_ptr mruby_file; char **original_argv; char **argv; diff --git a/src/shrpx_worker_process.cc b/src/shrpx_worker_process.cc index f7dacc7c..8d09b5d2 100644 --- a/src/shrpx_worker_process.cc +++ b/src/shrpx_worker_process.cc @@ -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 }