blob: a73283722bc579357733f74f6018474a9705a42e [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 Drewry2f54b6a2011-09-16 13:45:31 -050013static const char *kFdEnvVar = "__MINIJAIL_FD";
Ben Chan541c7e52011-08-26 14:55:53 -070014static const char *kLdPreloadEnvVar = "LD_PRELOAD";
Elly Jonescd7a9042011-07-22 13:56:51 -040015
Will Drewry32ac9f52011-08-18 21:36:27 -050016#define MINIJAIL_MAX_SECCOMP_FILTER_LINE 512
17
Will Drewryf89aef52011-09-16 16:48:57 -050018struct minijail;
Will Drewry2ddaad02011-09-16 11:36:08 -050019/* minijail_size returns the size of |j| if marshalled.
20 * 0 is returned on error.
21 */
22extern size_t minijail_size(const struct minijail *j);
23/* minijail_marshal: serializes |j| to |buf|
24 * Writes |j| to |buf| such that it can be reparsed by the same
25 * library on the same architecture. This is meant to be used
26 * by minijail0.c and libminijailpreload.c. minijail flags that
27 * require minijail_run() will be excluded.
28 *
29 * The marshalled data is not robust to differences between the child
30 * and parent process (personality, etc).
31 *
32 * Returns 0 on success.
33 */
34extern int minijail_marshal(const struct minijail *j,
35 char *buf,
36 size_t available);
37/* minijail_unmarshal: initializes minijail |j| from |serialized|. */
38extern int minijail_unmarshal(struct minijail *j,
39 char *serialized,
40 size_t length);
Will Drewryfe4a3722011-09-16 14:50:50 -050041/* Using minijail_unmarshal, build |j| from |fd|. */
42extern int minijail_from_fd(int fd, struct minijail *j);
43/* Using minijail_marshal, sends |j| to |fd|. */
44extern int minijail_to_fd(struct minijail *j, int fd);
45/* minijail_preexec: strips |j| of all options handled by minijail_enter(). */
46extern void minijail_preexec(struct minijail *j);
Will Drewry2ddaad02011-09-16 11:36:08 -050047/* minijail_preenter: strips |j| of all options handled by minijail_run(). */
48extern void minijail_preenter(struct minijail *j);
49
Elly Jonescd7a9042011-07-22 13:56:51 -040050#endif /* !LIBMINIJAIL_PRIVATE_H */