2020-10-11 16:34:36 +00:00
|
|
|
#pragma once
|
2017-10-25 11:01:50 +00:00
|
|
|
|
2020-10-11 16:34:36 +00:00
|
|
|
#include "sync.hh"
|
|
|
|
#include "types.hh"
|
|
|
|
#include "util.hh"
|
2009-01-12 16:30:32 +00:00
|
|
|
|
2006-09-04 21:06:23 +00:00
|
|
|
namespace nix {
|
|
|
|
|
2005-10-20 16:58:34 +00:00
|
|
|
class UserLock
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
Path fnUserLock;
|
|
|
|
AutoCloseFD fdUserLock;
|
|
|
|
|
2020-05-18 13:50:29 +00:00
|
|
|
bool isEnabled = false;
|
2006-12-07 11:27:32 +00:00
|
|
|
string user;
|
2020-05-18 13:50:29 +00:00
|
|
|
uid_t uid = 0;
|
|
|
|
gid_t gid = 0;
|
2015-07-01 12:56:34 +00:00
|
|
|
std::vector<gid_t> supplementaryGIDs;
|
2012-07-27 13:59:18 +00:00
|
|
|
|
2005-10-20 16:58:34 +00:00
|
|
|
public:
|
2017-01-25 11:45:38 +00:00
|
|
|
UserLock();
|
2005-10-20 16:58:34 +00:00
|
|
|
|
2006-12-07 16:33:31 +00:00
|
|
|
void kill();
|
|
|
|
|
2006-12-07 11:27:32 +00:00
|
|
|
string getUser() { return user; }
|
2016-06-03 13:45:11 +00:00
|
|
|
uid_t getUID() { assert(uid); return uid; }
|
|
|
|
uid_t getGID() { assert(gid); return gid; }
|
2015-07-01 12:56:34 +00:00
|
|
|
std::vector<gid_t> getSupplementaryGIDs() { return supplementaryGIDs; }
|
2006-12-07 00:16:07 +00:00
|
|
|
|
2020-05-08 09:22:39 +00:00
|
|
|
bool findFreeUser();
|
|
|
|
|
2020-05-14 14:00:54 +00:00
|
|
|
bool enabled() { return isEnabled; }
|
2012-07-27 13:59:18 +00:00
|
|
|
|
2005-10-20 16:58:34 +00:00
|
|
|
};
|
|
|
|
|
2006-09-04 21:06:23 +00:00
|
|
|
}
|