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