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