• source navigation  • diff markup  • identifier search  • freetext search  • 

Sources/procd/service/instance.h

  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         bool procfs;
 28         bool sysfs;
 29         bool ubus;
 30         bool log;
 31         bool ronly;
 32         bool netns;
 33         bool userns;
 34         bool cgroupsns;
 35         bool console;
 36         char *name;
 37         char *hostname;
 38         char *pidfile;
 39         struct blobmsg_list mount;
 40         struct blobmsg_list setns;
 41         int argc;
 42 };
 43 
 44 typedef enum instance_watchdog {
 45         INSTANCE_WATCHDOG_MODE_DISABLED,
 46         INSTANCE_WATCHDOG_MODE_PASSIVE,
 47         INSTANCE_WATCHDOG_MODE_ACTIVE,
 48         __INSTANCE_WATCHDOG_MODE_MAX,
 49 } instance_watchdog_mode_t;
 50 
 51 struct watchdog {
 52         instance_watchdog_mode_t mode;
 53         uint32_t freq;
 54         struct uloop_timeout timeout;
 55 };
 56 
 57 struct service_instance {
 58         struct vlist_node node;
 59         struct service *srv;
 60         const char *name;
 61 
 62         int8_t nice;
 63         bool valid;
 64 
 65         char *user;
 66         uid_t uid;
 67         gid_t pw_gid;
 68         char *group;
 69         gid_t gr_gid;
 70 
 71         bool halt;
 72         bool restart;
 73         bool respawn;
 74         int respawn_count;
 75         int reload_signal;
 76         struct timespec start;
 77 
 78         bool trace;
 79         bool has_jail;
 80         bool require_jail;
 81         bool immediately;
 82         bool no_new_privs;
 83         struct jail jail;
 84         char *seccomp;
 85         char *capabilities;
 86         char *pidfile;
 87         char *extroot;
 88         char *overlaydir;
 89         char *tmpoverlaysize;
 90         char *bundle;
 91         int syslog_facility;
 92         int exit_code;
 93 
 94         uint32_t term_timeout;
 95         uint32_t respawn_timeout;
 96         uint32_t respawn_threshold;
 97         uint32_t respawn_retry;
 98 
 99         struct blob_attr *config;
100         struct uloop_process proc;
101         struct uloop_timeout timeout;
102         struct ustream_fd _stdout;
103         struct ustream_fd _stderr;
104         struct ustream_fd console;
105         struct ustream_fd console_client;
106 
107         struct blob_attr *command;
108         struct blob_attr *trigger;
109         struct blobmsg_list env;
110         struct blobmsg_list data;
111         struct blobmsg_list netdev;
112         struct blobmsg_list file;
113         struct blobmsg_list limits;
114         struct blobmsg_list errors;
115 
116         struct watchdog watchdog;
117 };
118 
119 void instance_start(struct service_instance *in);
120 void instance_stop(struct service_instance *in, bool halt);
121 void instance_update(struct service_instance *in, struct service_instance *in_new);
122 void instance_init(struct service_instance *in, struct service *s, struct blob_attr *config);
123 void instance_free(struct service_instance *in);
124 void instance_dump(struct blob_buf *b, struct service_instance *in, int debug);
125 
126 #endif
127 

This page was automatically generated by LXR 0.3.1.  •  OpenWrt