summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_clone.h
blob: e89fd82d4a60740fadf924caf0c57937557a55ec (plain) (blame)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
 * Copyright (C) Igor Sysoev
 * Copyright (C) NGINX, Inc.
 */

#ifndef _NXT_CLONE_H_INCLUDED_
#define _NXT_CLONE_H_INCLUDED_


#if (NXT_HAVE_CLONE_NEWUSER)

typedef struct {
    nxt_int_t                   container;
    nxt_int_t                   host;
    nxt_int_t                   size;
} nxt_clone_map_entry_t;

typedef struct {
    nxt_uint_t                  size;
    nxt_clone_map_entry_t       *map;
} nxt_clone_credential_map_t;

#endif

typedef struct {
    nxt_int_t                   flags;

#if (NXT_HAVE_CLONE_NEWUSER)
    nxt_clone_credential_map_t  uidmap;
    nxt_clone_credential_map_t  gidmap;
#endif

} nxt_clone_t;


pid_t nxt_clone(nxt_int_t flags);


#define nxt_is_clone_flag_set(flags, test)                                    \
    ((flags & CLONE_##test) == CLONE_##test)


#if (NXT_HAVE_CLONE_NEWUSER)

#define NXT_CLONE_MNT(flags)                                                  \
    ((flags & CLONE_NEWNS) == CLONE_NEWNS)

NXT_EXPORT nxt_int_t nxt_clone_credential_map(nxt_task_t *task, pid_t pid,
    nxt_credential_t *creds, nxt_clone_t *clone);
NXT_EXPORT nxt_int_t nxt_clone_vldt_credential_uidmap(nxt_task_t *task,
    nxt_clone_credential_map_t *map, nxt_credential_t *creds);
NXT_EXPORT nxt_int_t nxt_clone_vldt_credential_gidmap(nxt_task_t *task,
    nxt_clone_credential_map_t *map, nxt_credential_t *creds);

#endif


#endif /* _NXT_CLONE_H_INCLUDED_ */