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 13#ifdef __cplusplus 14extern "C" { 15#endif 16 17/* Explicitly declare exported functions so that -fvisibility tricks 18 * can be used for testing and minimal symbol leakage occurs. 19 */ 20#define API __attribute__ ((visibility("default"))) 21 22static const char *kFdEnvVar = "__MINIJAIL_FD"; 23static const char *kLdPreloadEnvVar = "LD_PRELOAD"; 24 25struct minijail; 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. 31 */ 32extern size_t minijail_size(const struct minijail *j); 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 * 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). 48 */ 49extern int minijail_marshal(const struct minijail *j, 50 char *buf, 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 */ 60extern int minijail_unmarshal(struct minijail *j, 61 char *serialized, 62 size_t length); 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 */ 70extern int minijail_from_fd(int fd, struct minijail *j); 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 */ 78extern int minijail_to_fd(struct minijail *j, int fd); 79 80/* minijail_preexec: strips @j of all options handled by minijail_enter() 81 * @j jail to strip 82 */ 83extern void minijail_preexec(struct minijail *j); 84 85/* minijail_preenter: strips @j of all options handled by minijail_run() 86 * @j jail to strip 87 */ 88extern void minijail_preenter(struct minijail *j); 89 90#ifdef __cplusplus 91}; /* extern "C" */ 92#endif 93 94#endif /* !LIBMINIJAIL_PRIVATE_H */ 95