aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlexander Bantyev <balsoft@balsoft.ru>2020-05-05 13:04:36 +0300
committerAlexander Bantyev <balsoft@balsoft.ru>2020-05-05 13:04:36 +0300
commit04967dee9d08befe4661e6fa5da4a00da0538a13 (patch)
tree1c8c76963236c27e73750b29baea5b9a54d74c19 /src
parentc089c52d5f1cff888552f485775b74226dcbe618 (diff)
Wait for build users when none are available
Diffstat (limited to 'src')
-rw-r--r--src/libstore/build.cc23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/libstore/build.cc b/src/libstore/build.cc
index 147093fae..1b7e6d75e 100644
--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -507,6 +507,9 @@ private:
Path fnUserLock;
AutoCloseFD fdUserLock;
+ bool findFreeUser();
+
+
string user;
uid_t uid;
gid_t gid;
@@ -526,10 +529,19 @@ public:
};
-
UserLock::UserLock()
{
assert(settings.buildUsersGroup != "");
+ createDirs(settings.nixStateDir + "/userpool");
+
+ if (findFreeUser()) return;
+
+ printError("waiting for build users");
+
+ do std::this_thread::sleep_for(std::chrono::seconds(2)); while (! findFreeUser());
+}
+
+bool UserLock::findFreeUser() {
/* Get the members of the build-users-group. */
struct group * gr = getgrnam(settings.buildUsersGroup.get().c_str());
@@ -559,7 +571,6 @@ UserLock::UserLock()
throw Error(format("the user '%1%' in the group '%2%' does not exist")
% i % settings.buildUsersGroup);
- createDirs(settings.nixStateDir + "/userpool");
fnUserLock = (format("%1%/userpool/%2%") % settings.nixStateDir % pw->pw_uid).str();
@@ -590,16 +601,12 @@ UserLock::UserLock()
supplementaryGIDs.resize(ngroups);
#endif
- return;
+ return true;
}
}
-
- throw Error(format("all build users are currently in use; "
- "consider creating additional users and adding them to the '%1%' group")
- % settings.buildUsersGroup);
+ return false;
}
-
void UserLock::kill()
{
killUser(uid);