blob: 926559f33d61584edb5e796f3cf6f4bcff2fbc34 [file] [log] [blame]
Elly Jonescd7a9042011-07-22 13:56:51 -04001/* libminijail-private.h
2 * Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file.
5 *
6 * Values shared between libminijailpreload and libminijail, but not visible to
7 * the outside world.
8 */
9
10#ifndef LIBMINIJAIL_PRIVATE_H
11#define LIBMINIJAIL_PRIVATE_H
12
Jorge Lucangeli Obesa67bd6a2016-08-19 15:33:48 -040013#ifdef __cplusplus
14extern "C" {
15#endif
16
Will Drewry6ac91122011-10-21 16:38:58 -050017/* Explicitly declare exported functions so that -fvisibility tricks
18 * can be used for testing and minimal symbol leakage occurs.
19 */
20#define API __attribute__ ((visibility("default")))
21
Will Drewry2f54b6a2011-09-16 13:45:31 -050022static const char *kFdEnvVar = "__MINIJAIL_FD";
Ben Chan541c7e52011-08-26 14:55:53 -070023static const char *kLdPreloadEnvVar = "LD_PRELOAD";
Elly Jonescd7a9042011-07-22 13:56:51 -040024
Will Drewryf89aef52011-09-16 16:48:57 -050025struct minijail;
Elly Jonese1749eb2011-10-07 13:54:59 -040026
27/* minijail_size: returns the size (in bytes) of @j if marshalled
28 * @j jail to compute size of
29 *
30 * Returns 0 on error.
Will Drewry2ddaad02011-09-16 11:36:08 -050031 */
32extern size_t minijail_size(const struct minijail *j);
Elly Jonese1749eb2011-10-07 13:54:59 -040033
34/* minijail_marshal: serializes @j to @buf
35 * @j minijail to serialize
36 * @buf buffer to serialize to
37 * @size size of @buf
38 *
39 * Returns 0 on success.
40 *
Will Drewry2ddaad02011-09-16 11:36:08 -050041 * Writes |j| to |buf| such that it can be reparsed by the same
42 * library on the same architecture. This is meant to be used
43 * by minijail0.c and libminijailpreload.c. minijail flags that
44 * require minijail_run() will be excluded.
45 *
46 * The marshalled data is not robust to differences between the child
47 * and parent process (personality, etc).
Will Drewry2ddaad02011-09-16 11:36:08 -050048 */
49extern int minijail_marshal(const struct minijail *j,
50 char *buf,
Elly Jonese1749eb2011-10-07 13:54:59 -040051 size_t size);
52
53/* minijail_unmarshal: initializes @j from @serialized
54 * @j minijail to initialize
55 * @serialized serialized jail buffer
56 * @length length of buffer
57 *
58 * Returns 0 on success.
59 */
Will Drewry2ddaad02011-09-16 11:36:08 -050060extern int minijail_unmarshal(struct minijail *j,
61 char *serialized,
62 size_t length);
Elly Jonese1749eb2011-10-07 13:54:59 -040063
64/* minijail_from_fd: builds @j from @fd
65 * @j minijail to initialize
66 * @fd fd to initialize from
67 *
68 * Returns 0 on success.
69 */
Will Drewryfe4a3722011-09-16 14:50:50 -050070extern int minijail_from_fd(int fd, struct minijail *j);
Elly Jonese1749eb2011-10-07 13:54:59 -040071
72/* minijail_to_fd: sends @j over @fd
73 * @j minijail to send
74 * @fd fd to send over
75 *
76 * Returns 0 on success.
77 */
Will Drewryfe4a3722011-09-16 14:50:50 -050078extern int minijail_to_fd(struct minijail *j, int fd);
Elly Jonese1749eb2011-10-07 13:54:59 -040079
80/* minijail_preexec: strips @j of all options handled by minijail_enter()
81 * @j jail to strip
82 */
Will Drewryfe4a3722011-09-16 14:50:50 -050083extern void minijail_preexec(struct minijail *j);
Elly Jonese1749eb2011-10-07 13:54:59 -040084
85/* minijail_preenter: strips @j of all options handled by minijail_run()
86 * @j jail to strip
87 */
Will Drewry2ddaad02011-09-16 11:36:08 -050088extern void minijail_preenter(struct minijail *j);
89
Jorge Lucangeli Obesa67bd6a2016-08-19 15:33:48 -040090#ifdef __cplusplus
91}; /* extern "C" */
92#endif
93
Elly Jonescd7a9042011-07-22 13:56:51 -040094#endif /* !LIBMINIJAIL_PRIVATE_H */