2020-05-20 00:25:44 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "types.hh"
|
|
|
|
|
2022-11-03 18:43:40 +02:00
|
|
|
#include <optional>
|
2009-01-12 18:30:32 +02:00
|
|
|
|
2020-05-20 00:25:44 +03:00
|
|
|
namespace nix {
|
|
|
|
|
|
|
|
struct UserLock
|
|
|
|
{
|
|
|
|
virtual ~UserLock() { }
|
|
|
|
|
|
|
|
/* Get the first and last UID. */
|
|
|
|
virtual std::pair<uid_t, uid_t> getUIDRange() = 0;
|
|
|
|
|
|
|
|
/* Get the first UID. */
|
|
|
|
uid_t getUID()
|
|
|
|
{
|
|
|
|
return getUIDRange().first;
|
|
|
|
}
|
|
|
|
|
|
|
|
uid_t getUIDCount()
|
|
|
|
{
|
|
|
|
return getUIDRange().second - getUIDRange().first + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual gid_t getGID() = 0;
|
|
|
|
|
|
|
|
virtual std::vector<gid_t> getSupplementaryGIDs() = 0;
|
|
|
|
|
|
|
|
/* Kill any processes currently executing as this user. */
|
|
|
|
virtual void kill() = 0;
|
|
|
|
|
|
|
|
virtual std::optional<Path> getCgroup() { return {}; };
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Acquire a user lock. Note that this may return nullptr if no user
|
|
|
|
is available. */
|
|
|
|
std::unique_ptr<UserLock> acquireUserLock();
|
|
|
|
|
2020-05-20 12:24:21 +03:00
|
|
|
bool useBuildUsers();
|
|
|
|
|
2020-05-20 00:25:44 +03:00
|
|
|
}
|