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 | |
Jorge Lucangeli Obes | a67bd6a | 2016-08-19 15:33:48 -0400 | [diff] [blame] | 13 | #ifdef __cplusplus |
| 14 | extern "C" { |
| 15 | #endif |
| 16 | |
Will Drewry | 6ac9112 | 2011-10-21 16:38:58 -0500 | [diff] [blame] | 17 | /* Explicitly declare exported functions so that -fvisibility tricks |
| 18 | * can be used for testing and minimal symbol leakage occurs. |
| 19 | */ |
Mike Frysinger | d9ef07c | 2018-05-30 16:51:36 -0400 | [diff] [blame] | 20 | #define API __attribute__((__visibility__("default"))) |
Will Drewry | 6ac9112 | 2011-10-21 16:38:58 -0500 | [diff] [blame] | 21 | |
Will Drewry | 2f54b6a | 2011-09-16 13:45:31 -0500 | [diff] [blame] | 22 | static const char *kFdEnvVar = "__MINIJAIL_FD"; |
Ben Chan | 541c7e5 | 2011-08-26 14:55:53 -0700 | [diff] [blame] | 23 | static const char *kLdPreloadEnvVar = "LD_PRELOAD"; |
Elly Jones | cd7a904 | 2011-07-22 13:56:51 -0400 | [diff] [blame] | 24 | |
Will Drewry | f89aef5 | 2011-09-16 16:48:57 -0500 | [diff] [blame] | 25 | struct minijail; |
Elly Jones | e1749eb | 2011-10-07 13:54:59 -0400 | [diff] [blame] | 26 | |
| 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 Drewry | 2ddaad0 | 2011-09-16 11:36:08 -0500 | [diff] [blame] | 31 | */ |
| 32 | extern size_t minijail_size(const struct minijail *j); |
Elly Jones | e1749eb | 2011-10-07 13:54:59 -0400 | [diff] [blame] | 33 | |
| 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 Drewry | 2ddaad0 | 2011-09-16 11:36:08 -0500 | [diff] [blame] | 41 | * 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 Drewry | 2ddaad0 | 2011-09-16 11:36:08 -0500 | [diff] [blame] | 48 | */ |
| 49 | extern int minijail_marshal(const struct minijail *j, |
| 50 | char *buf, |
Elly Jones | e1749eb | 2011-10-07 13:54:59 -0400 | [diff] [blame] | 51 | 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 Drewry | 2ddaad0 | 2011-09-16 11:36:08 -0500 | [diff] [blame] | 60 | extern int minijail_unmarshal(struct minijail *j, |
| 61 | char *serialized, |
| 62 | size_t length); |
Elly Jones | e1749eb | 2011-10-07 13:54:59 -0400 | [diff] [blame] | 63 | |
| 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 Drewry | fe4a372 | 2011-09-16 14:50:50 -0500 | [diff] [blame] | 70 | extern int minijail_from_fd(int fd, struct minijail *j); |
Elly Jones | e1749eb | 2011-10-07 13:54:59 -0400 | [diff] [blame] | 71 | |
| 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 Drewry | fe4a372 | 2011-09-16 14:50:50 -0500 | [diff] [blame] | 78 | extern int minijail_to_fd(struct minijail *j, int fd); |
Elly Jones | e1749eb | 2011-10-07 13:54:59 -0400 | [diff] [blame] | 79 | |
| 80 | /* minijail_preexec: strips @j of all options handled by minijail_enter() |
| 81 | * @j jail to strip |
| 82 | */ |
Will Drewry | fe4a372 | 2011-09-16 14:50:50 -0500 | [diff] [blame] | 83 | extern void minijail_preexec(struct minijail *j); |
Elly Jones | e1749eb | 2011-10-07 13:54:59 -0400 | [diff] [blame] | 84 | |
| 85 | /* minijail_preenter: strips @j of all options handled by minijail_run() |
| 86 | * @j jail to strip |
| 87 | */ |
Will Drewry | 2ddaad0 | 2011-09-16 11:36:08 -0500 | [diff] [blame] | 88 | extern void minijail_preenter(struct minijail *j); |
| 89 | |
Jorge Lucangeli Obes | a67bd6a | 2016-08-19 15:33:48 -0400 | [diff] [blame] | 90 | #ifdef __cplusplus |
| 91 | }; /* extern "C" */ |
| 92 | #endif |
| 93 | |
Elly Jones | cd7a904 | 2011-07-22 13:56:51 -0400 | [diff] [blame] | 94 | #endif /* !LIBMINIJAIL_PRIVATE_H */ |