mirror of
https://github.com/nghttp2/nghttp2.git
synced 2025-12-07 02:28:53 +08:00
nghttpx: Use ImmutableString for user
This commit is contained in:
@@ -1738,7 +1738,7 @@ int parse_config(const char *opt, const char *optarg,
|
|||||||
<< strerror(errno);
|
<< strerror(errno);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
mod_config()->user = strcopy(pwd->pw_name);
|
mod_config()->user = pwd->pw_name;
|
||||||
mod_config()->uid = pwd->pw_uid;
|
mod_config()->uid = pwd->pw_uid;
|
||||||
mod_config()->gid = pwd->pw_gid;
|
mod_config()->gid = pwd->pw_gid;
|
||||||
|
|
||||||
|
|||||||
@@ -583,7 +583,7 @@ struct Config {
|
|||||||
ConnectionConfig conn;
|
ConnectionConfig conn;
|
||||||
ImmutableString pid_file;
|
ImmutableString pid_file;
|
||||||
ImmutableString conf_path;
|
ImmutableString conf_path;
|
||||||
std::unique_ptr<char[]> user;
|
ImmutableString user;
|
||||||
std::unique_ptr<char[]> mruby_file;
|
std::unique_ptr<char[]> mruby_file;
|
||||||
char **original_argv;
|
char **original_argv;
|
||||||
char **argv;
|
char **argv;
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ void drop_privileges(
|
|||||||
#endif // HAVE_NEVERBLEED
|
#endif // HAVE_NEVERBLEED
|
||||||
) {
|
) {
|
||||||
if (getuid() == 0 && get_config()->uid != 0) {
|
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;
|
auto error = errno;
|
||||||
LOG(FATAL) << "Could not change supplementary groups: "
|
LOG(FATAL) << "Could not change supplementary groups: "
|
||||||
<< strerror(error);
|
<< strerror(error);
|
||||||
@@ -86,7 +86,7 @@ void drop_privileges(
|
|||||||
}
|
}
|
||||||
#ifdef HAVE_NEVERBLEED
|
#ifdef HAVE_NEVERBLEED
|
||||||
if (nb) {
|
if (nb) {
|
||||||
neverbleed_setuidgid(nb, get_config()->user.get(), 1);
|
neverbleed_setuidgid(nb, get_config()->user.c_str(), 1);
|
||||||
}
|
}
|
||||||
#endif // HAVE_NEVERBLEED
|
#endif // HAVE_NEVERBLEED
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user