diff options
author | Benoit Foucher <benoit@zeroc.com> | 2017-04-12 20:06:29 +0200 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2017-04-12 20:06:29 +0200 |
commit | 16705e3c8f9f67749aac3c49b8231a6ff7f0fe2c (patch) | |
tree | 53368cc5d8ba84dd00c787087e0efa91c532b2bb /cpp/src/IceGrid/ServerI.cpp | |
parent | Fixed ICE-7726 - fixed IceGrid node bug which was causing IceGrid/noRestartUp... (diff) | |
download | ice-16705e3c8f9f67749aac3c49b8231a6ff7f0fe2c.tar.bz2 ice-16705e3c8f9f67749aac3c49b8231a6ff7f0fe2c.tar.xz ice-16705e3c8f9f67749aac3c49b8231a6ff7f0fe2c.zip |
Fixed ICE-7775 - don't call initgroups after fork, use thread-safe getpw* system calls
Diffstat (limited to 'cpp/src/IceGrid/ServerI.cpp')
-rw-r--r-- | cpp/src/IceGrid/ServerI.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/cpp/src/IceGrid/ServerI.cpp b/cpp/src/IceGrid/ServerI.cpp index 6168080c3dc..243a43e1519 100644 --- a/cpp/src/IceGrid/ServerI.cpp +++ b/cpp/src/IceGrid/ServerI.cpp @@ -2632,8 +2632,21 @@ ServerI::checkAndUpdateUser(const InternalServerDescriptorPtr& desc, bool /*upda // // Get the uid/gid associated with the given user. // - struct passwd* pw = getpwnam(user.c_str()); - if(!pw) + struct passwd pwbuf; + vector<char> buffer(4096); // 4KB initial buffer size + struct passwd *pw; + int err = getpwnam_r(user.c_str(), &pwbuf, &buffer[0], buffer.size(), &pw); + while(err == ERANGE && buffer.size() < 1024 * 1024) // Limit buffer to 1MB + { + buffer.resize(buffer.size() * 2); + } + if(err != 0) + { + Ice::SyscallException ex(__FILE__, __LINE__); + ex.error = err; + throw ex; + } + else if(pw == 0) { throw "unknown user account `" + user + "'"; } |