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