1*4b9c6d91SCole Faust /* libminijail-private.h 2*4b9c6d91SCole Faust * Copyright 2011 The ChromiumOS Authors 3*4b9c6d91SCole Faust * Use of this source code is governed by a BSD-style license that can be 4*4b9c6d91SCole Faust * found in the LICENSE file. 5*4b9c6d91SCole Faust * 6*4b9c6d91SCole Faust * Values shared between libminijailpreload and libminijail, but not visible to 7*4b9c6d91SCole Faust * the outside world. 8*4b9c6d91SCole Faust */ 9*4b9c6d91SCole Faust 10*4b9c6d91SCole Faust #ifndef LIBMINIJAIL_PRIVATE_H 11*4b9c6d91SCole Faust #define LIBMINIJAIL_PRIVATE_H 12*4b9c6d91SCole Faust 13*4b9c6d91SCole Faust #ifdef __cplusplus 14*4b9c6d91SCole Faust extern "C" { 15*4b9c6d91SCole Faust #endif 16*4b9c6d91SCole Faust 17*4b9c6d91SCole Faust /* Explicitly declare exported functions so that -fvisibility tricks 18*4b9c6d91SCole Faust * can be used for testing and minimal symbol leakage occurs. 19*4b9c6d91SCole Faust */ 20*4b9c6d91SCole Faust #define API __attribute__((__visibility__("default"))) 21*4b9c6d91SCole Faust 22*4b9c6d91SCole Faust static const char kFdEnvVar[] = "__MINIJAIL_FD"; 23*4b9c6d91SCole Faust static const char kLdPreloadEnvVar[] = "LD_PRELOAD"; 24*4b9c6d91SCole Faust static const char kSeccompPolicyPathEnvVar[] = "SECCOMP_POLICY_PATH"; 25*4b9c6d91SCole Faust 26*4b9c6d91SCole Faust struct minijail; 27*4b9c6d91SCole Faust 28*4b9c6d91SCole Faust /* minijail_size: returns the size (in bytes) of @j if marshalled 29*4b9c6d91SCole Faust * @j jail to compute size of 30*4b9c6d91SCole Faust * 31*4b9c6d91SCole Faust * Returns 0 on error. 32*4b9c6d91SCole Faust */ 33*4b9c6d91SCole Faust extern size_t minijail_size(const struct minijail *j); 34*4b9c6d91SCole Faust 35*4b9c6d91SCole Faust /* minijail_marshal: serializes @j to @buf 36*4b9c6d91SCole Faust * @j minijail to serialize 37*4b9c6d91SCole Faust * @buf buffer to serialize to 38*4b9c6d91SCole Faust * @size size of @buf 39*4b9c6d91SCole Faust * 40*4b9c6d91SCole Faust * Returns 0 on success. 41*4b9c6d91SCole Faust * 42*4b9c6d91SCole Faust * Writes |j| to |buf| such that it can be reparsed by the same 43*4b9c6d91SCole Faust * library on the same architecture. This is meant to be used 44*4b9c6d91SCole Faust * by minijail0.c and libminijailpreload.c. minijail flags that 45*4b9c6d91SCole Faust * require minijail_run() will be excluded. 46*4b9c6d91SCole Faust * 47*4b9c6d91SCole Faust * The marshalled data is not robust to differences between the child 48*4b9c6d91SCole Faust * and parent process (personality, etc). 49*4b9c6d91SCole Faust */ 50*4b9c6d91SCole Faust extern int minijail_marshal(const struct minijail *j, char *buf, size_t size); 51*4b9c6d91SCole Faust 52*4b9c6d91SCole Faust /* minijail_unmarshal: initializes @j from @serialized 53*4b9c6d91SCole Faust * @j minijail to initialize 54*4b9c6d91SCole Faust * @serialized serialized jail buffer 55*4b9c6d91SCole Faust * @length length of buffer 56*4b9c6d91SCole Faust * 57*4b9c6d91SCole Faust * Returns 0 on success. 58*4b9c6d91SCole Faust */ 59*4b9c6d91SCole Faust extern int minijail_unmarshal(struct minijail *j, char *serialized, 60*4b9c6d91SCole Faust size_t length); 61*4b9c6d91SCole Faust 62*4b9c6d91SCole Faust /* minijail_from_fd: builds @j from @fd 63*4b9c6d91SCole Faust * @j minijail to initialize 64*4b9c6d91SCole Faust * @fd fd to initialize from 65*4b9c6d91SCole Faust * 66*4b9c6d91SCole Faust * Returns 0 on success. 67*4b9c6d91SCole Faust */ 68*4b9c6d91SCole Faust extern int minijail_from_fd(int fd, struct minijail *j); 69*4b9c6d91SCole Faust 70*4b9c6d91SCole Faust /* minijail_to_fd: sends @j over @fd 71*4b9c6d91SCole Faust * @j minijail to send 72*4b9c6d91SCole Faust * @fd fd to send over 73*4b9c6d91SCole Faust * 74*4b9c6d91SCole Faust * Returns 0 on success, or a negative error code on error. 75*4b9c6d91SCole Faust */ 76*4b9c6d91SCole Faust extern int minijail_to_fd(struct minijail *j, int fd); 77*4b9c6d91SCole Faust 78*4b9c6d91SCole Faust /* minijail_preexec: strips @j of all options handled by minijail_enter() 79*4b9c6d91SCole Faust * @j jail to strip 80*4b9c6d91SCole Faust */ 81*4b9c6d91SCole Faust extern void minijail_preexec(struct minijail *j); 82*4b9c6d91SCole Faust 83*4b9c6d91SCole Faust /* minijail_preenter: strips @j of all options handled by minijail_run() 84*4b9c6d91SCole Faust * @j jail to strip 85*4b9c6d91SCole Faust */ 86*4b9c6d91SCole Faust extern void minijail_preenter(struct minijail *j); 87*4b9c6d91SCole Faust 88*4b9c6d91SCole Faust #ifdef __cplusplus 89*4b9c6d91SCole Faust }; /* extern "C" */ 90*4b9c6d91SCole Faust #endif 91*4b9c6d91SCole Faust 92*4b9c6d91SCole Faust #endif /* !LIBMINIJAIL_PRIVATE_H */ 93