1 /*
2  * Copyright (C) Igor Sysoev
3  * Copyright (C) NGINX, Inc.
4  */
5 
6 #ifndef _NXT_CLONE_H_INCLUDED_
7 #define _NXT_CLONE_H_INCLUDED_
8 
9 
10 #if (NXT_HAVE_CLONE_NEWUSER)
11 
12 typedef struct {
13     nxt_int_t                   container;
14     nxt_int_t                   host;
15     nxt_int_t                   size;
16 } nxt_clone_map_entry_t;
17 
18 typedef struct {
19     nxt_uint_t                  size;
20     nxt_clone_map_entry_t       *map;
21 } nxt_clone_credential_map_t;
22 
23 #endif
24 
25 typedef struct {
26     nxt_int_t                   flags;
27 
28 #if (NXT_HAVE_CLONE_NEWUSER)
29     nxt_clone_credential_map_t  uidmap;
30     nxt_clone_credential_map_t  gidmap;
31 #endif
32 
33 } nxt_clone_t;
34 
35 
36 pid_t nxt_clone(nxt_int_t flags);
37 
38 
39 #define nxt_is_clone_flag_set(flags, test)                                    \
40     ((flags & CLONE_##test) == CLONE_##test)
41 
42 
43 #if (NXT_HAVE_CLONE_NEWUSER)
44 
45 NXT_EXPORT nxt_int_t nxt_clone_credential_map(nxt_task_t *task, pid_t pid,
46     nxt_credential_t *creds, nxt_clone_t *clone);
47 NXT_EXPORT nxt_int_t nxt_clone_vldt_credential_uidmap(nxt_task_t *task,
48     nxt_clone_credential_map_t *map, nxt_credential_t *creds);
49 NXT_EXPORT nxt_int_t nxt_clone_vldt_credential_gidmap(nxt_task_t *task,
50     nxt_clone_credential_map_t *map, nxt_credential_t *creds);
51 
52 #endif
53 
54 
55 #endif /* _NXT_CLONE_H_INCLUDED_ */
56