Elly Jones | cd7a904 | 2011-07-22 13:56:51 -0400 | [diff] [blame] | 1 | /* 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 Drewry | 2f54b6a | 2011-09-16 13:45:31 -0500 | [diff] [blame] | 13 | static const char *kFdEnvVar = "__MINIJAIL_FD"; |
Ben Chan | 541c7e5 | 2011-08-26 14:55:53 -0700 | [diff] [blame] | 14 | static const char *kLdPreloadEnvVar = "LD_PRELOAD"; |
Elly Jones | cd7a904 | 2011-07-22 13:56:51 -0400 | [diff] [blame] | 15 | |
Will Drewry | 32ac9f5 | 2011-08-18 21:36:27 -0500 | [diff] [blame] | 16 | #define MINIJAIL_MAX_SECCOMP_FILTER_LINE 512 |
| 17 | |
Will Drewry | f89aef5 | 2011-09-16 16:48:57 -0500 | [diff] [blame] | 18 | struct minijail; |
Elly Jones | e1749eb | 2011-10-07 13:54:59 -0400 | [diff] [blame] | 19 | |
| 20 | /* minijail_size: returns the size (in bytes) of @j if marshalled |
| 21 | * @j jail to compute size of |
| 22 | * |
| 23 | * Returns 0 on error. |
Will Drewry | 2ddaad0 | 2011-09-16 11:36:08 -0500 | [diff] [blame] | 24 | */ |
| 25 | extern size_t minijail_size(const struct minijail *j); |
Elly Jones | e1749eb | 2011-10-07 13:54:59 -0400 | [diff] [blame] | 26 | |
| 27 | /* minijail_marshal: serializes @j to @buf |
| 28 | * @j minijail to serialize |
| 29 | * @buf buffer to serialize to |
| 30 | * @size size of @buf |
| 31 | * |
| 32 | * Returns 0 on success. |
| 33 | * |
Will Drewry | 2ddaad0 | 2011-09-16 11:36:08 -0500 | [diff] [blame] | 34 | * Writes |j| to |buf| such that it can be reparsed by the same |
| 35 | * library on the same architecture. This is meant to be used |
| 36 | * by minijail0.c and libminijailpreload.c. minijail flags that |
| 37 | * require minijail_run() will be excluded. |
| 38 | * |
| 39 | * The marshalled data is not robust to differences between the child |
| 40 | * and parent process (personality, etc). |
Will Drewry | 2ddaad0 | 2011-09-16 11:36:08 -0500 | [diff] [blame] | 41 | */ |
| 42 | extern int minijail_marshal(const struct minijail *j, |
| 43 | char *buf, |
Elly Jones | e1749eb | 2011-10-07 13:54:59 -0400 | [diff] [blame] | 44 | size_t size); |
| 45 | |
| 46 | /* minijail_unmarshal: initializes @j from @serialized |
| 47 | * @j minijail to initialize |
| 48 | * @serialized serialized jail buffer |
| 49 | * @length length of buffer |
| 50 | * |
| 51 | * Returns 0 on success. |
| 52 | */ |
Will Drewry | 2ddaad0 | 2011-09-16 11:36:08 -0500 | [diff] [blame] | 53 | extern int minijail_unmarshal(struct minijail *j, |
| 54 | char *serialized, |
| 55 | size_t length); |
Elly Jones | e1749eb | 2011-10-07 13:54:59 -0400 | [diff] [blame] | 56 | |
| 57 | /* minijail_from_fd: builds @j from @fd |
| 58 | * @j minijail to initialize |
| 59 | * @fd fd to initialize from |
| 60 | * |
| 61 | * Returns 0 on success. |
| 62 | */ |
Will Drewry | fe4a372 | 2011-09-16 14:50:50 -0500 | [diff] [blame] | 63 | extern int minijail_from_fd(int fd, struct minijail *j); |
Elly Jones | e1749eb | 2011-10-07 13:54:59 -0400 | [diff] [blame] | 64 | |
| 65 | /* minijail_to_fd: sends @j over @fd |
| 66 | * @j minijail to send |
| 67 | * @fd fd to send over |
| 68 | * |
| 69 | * Returns 0 on success. |
| 70 | */ |
Will Drewry | fe4a372 | 2011-09-16 14:50:50 -0500 | [diff] [blame] | 71 | extern int minijail_to_fd(struct minijail *j, int fd); |
Elly Jones | e1749eb | 2011-10-07 13:54:59 -0400 | [diff] [blame] | 72 | |
| 73 | /* minijail_preexec: strips @j of all options handled by minijail_enter() |
| 74 | * @j jail to strip |
| 75 | */ |
Will Drewry | fe4a372 | 2011-09-16 14:50:50 -0500 | [diff] [blame] | 76 | extern void minijail_preexec(struct minijail *j); |
Elly Jones | e1749eb | 2011-10-07 13:54:59 -0400 | [diff] [blame] | 77 | |
| 78 | /* minijail_preenter: strips @j of all options handled by minijail_run() |
| 79 | * @j jail to strip |
| 80 | */ |
Will Drewry | 2ddaad0 | 2011-09-16 11:36:08 -0500 | [diff] [blame] | 81 | extern void minijail_preenter(struct minijail *j); |
| 82 | |
Elly Jones | cd7a904 | 2011-07-22 13:56:51 -0400 | [diff] [blame] | 83 | #endif /* !LIBMINIJAIL_PRIVATE_H */ |