summaryrefslogtreecommitdiff
path: root/cpp/src/IceGrid/ServerI.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/IceGrid/ServerI.cpp')
-rw-r--r--cpp/src/IceGrid/ServerI.cpp17
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 + "'";
}