diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2020-10-17 19:31:06 +0000 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2020-10-17 19:31:06 +0000 |
commit | 801e6d96d878c3752048006b3a3c284b09a4c092 (patch) | |
tree | f9f05cc068effb83485bfaad33a4d8c4474c8209 /src/libstore/lock.hh | |
parent | 2c9a8e7421408b1c98b04f258540749bb4f686e1 (diff) | |
parent | d334fd48824b41b57e267cd2926fa9619b7718e3 (diff) |
Merge commit 'd334fd48824b41b57e267cd2926fa9619b7718e3' into auto-uid-allocation
Diffstat (limited to 'src/libstore/lock.hh')
-rw-r--r-- | src/libstore/lock.hh | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/libstore/lock.hh b/src/libstore/lock.hh new file mode 100644 index 000000000..bfb55b0d9 --- /dev/null +++ b/src/libstore/lock.hh @@ -0,0 +1,41 @@ +#pragma once + +#include "types.hh" + +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(); + +bool useBuildUsers(); + +} |