• 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         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         instance_watchdog_mode_t mode;
 59         uint32_t freq;
 60         struct uloop_timeout timeout;
 61 };
 62 
 63 struct service_instance {
 64         struct vlist_node node;
 65         struct service *srv;
 66         const char *name;
 67 
 68         int8_t nice;
 69         bool valid;
 70 
 71         char *user;
 72         uid_t uid;
 73         gid_t pw_gid;
 74         char *group;
 75         gid_t gr_gid;
 76 
 77         bool halt;
 78         bool restart;
 79         bool respawn;
 80         int respawn_count;
 81         int reload_signal;
 82         struct timespec start;
 83 
 84         bool trace;
 85         bool has_jail;
 86         bool require_jail;
 87         bool immediately;
 88         bool no_new_privs;
 89         struct jail jail;
 90         char *seccomp;
 91         char *capabilities;
 92         char *pidfile;
 93         char *extroot;
 94         char *overlaydir;
 95         char *tmpoverlaysize;
 96         char *bundle;
 97         int syslog_facility;
 98         int exit_code;
 99 
100         uint32_t term_timeout;
101         uint32_t respawn_timeout;
102         uint32_t respawn_threshold;
103         uint32_t respawn_retry;
104 
105         struct blob_attr *config;
106         struct uloop_process proc;
107         struct uloop_timeout timeout;
108         struct ustream_fd _stdout;
109         struct ustream_fd _stderr;
110         struct ustream_fd console;
111         struct ustream_fd console_client;
112 
113         struct blob_attr *command;
114         struct blob_attr *trigger;
115         struct blobmsg_list env;
116         struct blobmsg_list data;
117         struct blobmsg_list netdev;
118         struct blobmsg_list file;
119         struct blobmsg_list limits;
120         struct blobmsg_list errors;
121 
122         struct watchdog watchdog;
123 };
124 
125 void instance_start(struct service_instance *in);
126 void instance_stop(struct service_instance *in, bool halt);
127 void instance_update(struct service_instance *in, struct service_instance *in_new);
128 void instance_init(struct service_instance *in, struct service *s, struct blob_attr *config);
129 void instance_free(struct service_instance *in);
130 void instance_dump(struct blob_buf *b, struct service_instance *in, int debug);
131 
132 #endif
133 

This page was automatically generated by LXR 0.3.1.  •  OpenWrt