aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/lock.hh
blob: 8fbb67ddc812e418b2d504a76819d0100dc321c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#pragma once

#include "sync.hh"
#include "types.hh"
#include "util.hh"

namespace nix {

class UserLock
{
private:
    Path fnUserLock;
    AutoCloseFD fdUserLock;

    bool isEnabled = false;
    string user;
    uid_t uid = 0;
    gid_t gid = 0;
    std::vector<gid_t> supplementaryGIDs;

public:
    UserLock();

    void kill();

    string getUser() { return user; }
    uid_t getUID() { assert(uid); return uid; }
    uid_t getGID() { assert(gid); return gid; }
    std::vector<gid_t> getSupplementaryGIDs() { return supplementaryGIDs; }

    bool findFreeUser();

    bool enabled() { return isEnabled; }

};

}