1 /* 2 * Copyright (C) 2013 Felix Fietkau <nbd@openwrt.org> 3 * Copyright (C) 2013 John Crispin <blogic@openwrt.org> 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU Lesser General Public License version 2.1 7 * as published by the Free Software Foundation 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 */ 14 15 #ifndef __PROCD_INSTANCE_H 16 #define __PROCD_INSTANCE_H 17 18 #include <libubox/vlist.h> 19 #include <libubox/uloop.h> 20 #include <libubox/ustream.h> 21 #include "../utils/utils.h" 22 23 #define RESPAWN_ERROR (5 * 60) 24 #define SIGNALLED_OFFSET 128 25 26 struct jail { 27 union { 28 struct { 29 uint32_t procfs:1; 30 uint32_t sysfs:1; 31 uint32_t ubus:1; 32 uint32_t udebug:1; 33 uint32_t log:1; 34 uint32_t ronly:1; 35 uint32_t netns:1; 36 uint32_t userns:1; 37 uint32_t cgroupsns:1; 38 uint32_t console:1; 39 }; 40 uint32_t flags; 41 }; 42 char *name; 43 char *hostname; 44 char *pidfile; 45 struct blobmsg_list mount; 46 struct blobmsg_list setns; 47 int argc; 48 }; 49 50 typedef enum instance_watchdog { 51 INSTANCE_WATCHDOG_MODE_DISABLED, 52 INSTANCE_WATCHDOG_MODE_PASSIVE, 53 INSTANCE_WATCHDOG_MODE_ACTIVE, 54 __INSTANCE_WATCHDOG_MODE_MAX, 55 } instance_watchdog_mode_t; 56 57 struct watchdog { 58 bool self_managed; 59 instance_watchdog_mode_t mode; 60 uint32_t freq; 61 struct uloop_timeout timeout; 62 }; 63 64 struct service_instance { 65 struct vlist_node node; 66 struct service *srv; 67 const char *name; 68 69 int8_t nice; 70 bool valid; 71 72 char *user; 73 uid_t uid; 74 gid_t pw_gid; 75 char *group; 76 gid_t gr_gid; 77 78 bool halt; 79 bool restart; 80 bool respawn; 81 int respawn_count; 82 int reload_signal; 83 struct timespec start; 84 85 bool trace; 86 bool has_jail; 87 bool require_jail; 88 bool immediately; 89 bool no_new_privs; 90 struct jail jail; 91 char *seccomp; 92 char *capabilities; 93 char *pidfile; 94 char *extroot; 95 char *overlaydir; 96 char *tmpoverlaysize; 97 char *bundle; 98 int syslog_facility; 99 int exit_code; 100 101 uint32_t term_timeout; 102 uint32_t respawn_timeout; 103 uint32_t respawn_threshold; 104 uint32_t respawn_retry; 105 106 struct blob_attr *config; 107 struct uloop_process proc; 108 struct uloop_timeout timeout; 109 struct ustream_fd _stdout; 110 struct ustream_fd _stderr; 111 struct ustream_fd console; 112 struct ustream_fd console_client; 113 114 struct blob_attr *command; 115 struct blob_attr *trigger; 116 struct blobmsg_list env; 117 struct blob_attr *data_blob; 118 struct blobmsg_list data; 119 struct blobmsg_list netdev; 120 struct blobmsg_list file; 121 struct blobmsg_list limits; 122 struct blobmsg_list errors; 123 124 struct watchdog watchdog; 125 }; 126 127 void instance_start(struct service_instance *in); 128 void instance_stop(struct service_instance *in, bool halt); 129 void instance_update(struct service_instance *in, struct service_instance *in_new); 130 void instance_init(struct service_instance *in, struct service *s, struct blob_attr *config); 131 void instance_free(struct service_instance *in); 132 void instance_dump(struct blob_buf *b, struct service_instance *in, int debug); 133 134 #endif 135
This page was automatically generated by LXR 0.3.1. • OpenWrt