blob: 62d26257974a284349f964b8086bdeca489ec66b [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
Will Drewry6ac91122011-10-21 16:38:58 -050013/* Explicitly declare exported functions so that -fvisibility tricks
14 * can be used for testing and minimal symbol leakage occurs.
15 */
16#define API __attribute__ ((visibility("default")))
17
Will Drewry2f54b6a2011-09-16 13:45:31 -050018static const char *kFdEnvVar = "__MINIJAIL_FD";
Ben Chan541c7e52011-08-26 14:55:53 -070019static const char *kLdPreloadEnvVar = "LD_PRELOAD";
Elly Jonescd7a9042011-07-22 13:56:51 -040020
Will Drewry32ac9f52011-08-18 21:36:27 -050021#define MINIJAIL_MAX_SECCOMP_FILTER_LINE 512
22
Will Drewryf89aef52011-09-16 16:48:57 -050023struct minijail;
Elly Jonese1749eb2011-10-07 13:54:59 -040024
25/* minijail_size: returns the size (in bytes) of @j if marshalled
26 * @j jail to compute size of
27 *
28 * Returns 0 on error.
Will Drewry2ddaad02011-09-16 11:36:08 -050029 */
30extern size_t minijail_size(const struct minijail *j);
Elly Jonese1749eb2011-10-07 13:54:59 -040031
32/* minijail_marshal: serializes @j to @buf
33 * @j minijail to serialize
34 * @buf buffer to serialize to
35 * @size size of @buf
36 *
37 * Returns 0 on success.
38 *
Will Drewry2ddaad02011-09-16 11:36:08 -050039 * Writes |j| to |buf| such that it can be reparsed by the same
40 * library on the same architecture. This is meant to be used
41 * by minijail0.c and libminijailpreload.c. minijail flags that
42 * require minijail_run() will be excluded.
43 *
44 * The marshalled data is not robust to differences between the child
45 * and parent process (personality, etc).
Will Drewry2ddaad02011-09-16 11:36:08 -050046 */
47extern int minijail_marshal(const struct minijail *j,
48 char *buf,
Elly Jonese1749eb2011-10-07 13:54:59 -040049 size_t size);
50
51/* minijail_unmarshal: initializes @j from @serialized
52 * @j minijail to initialize
53 * @serialized serialized jail buffer
54 * @length length of buffer
55 *
56 * Returns 0 on success.
57 */
Will Drewry2ddaad02011-09-16 11:36:08 -050058extern int minijail_unmarshal(struct minijail *j,
59 char *serialized,
60 size_t length);
Elly Jonese1749eb2011-10-07 13:54:59 -040061
62/* minijail_from_fd: builds @j from @fd
63 * @j minijail to initialize
64 * @fd fd to initialize from
65 *
66 * Returns 0 on success.
67 */
Will Drewryfe4a3722011-09-16 14:50:50 -050068extern int minijail_from_fd(int fd, struct minijail *j);
Elly Jonese1749eb2011-10-07 13:54:59 -040069
70/* minijail_to_fd: sends @j over @fd
71 * @j minijail to send
72 * @fd fd to send over
73 *
74 * Returns 0 on success.
75 */
Will Drewryfe4a3722011-09-16 14:50:50 -050076extern int minijail_to_fd(struct minijail *j, int fd);
Elly Jonese1749eb2011-10-07 13:54:59 -040077
78/* minijail_preexec: strips @j of all options handled by minijail_enter()
79 * @j jail to strip
80 */
Will Drewryfe4a3722011-09-16 14:50:50 -050081extern void minijail_preexec(struct minijail *j);
Elly Jonese1749eb2011-10-07 13:54:59 -040082
83/* minijail_preenter: strips @j of all options handled by minijail_run()
84 * @j jail to strip
85 */
Will Drewry2ddaad02011-09-16 11:36:08 -050086extern void minijail_preenter(struct minijail *j);
87
Elly Jonescd7a9042011-07-22 13:56:51 -040088#endif /* !LIBMINIJAIL_PRIVATE_H */