• 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                         uint32_t systemd_cgroup:1;
 40                 };
 41                 uint32_t flags;
 42         };
 43         char *name;
 44         char *hostname;
 45         char *pidfile;
 46         char *idmap_offset;
 47         char *consolesocket;
 48         char *envfile;
 49         struct blobmsg_list mount;
 50         struct blobmsg_list setns;
 51         int argc;
 52 };
 53 
 54 typedef enum instance_watchdog {
 55         INSTANCE_WATCHDOG_MODE_DISABLED,
 56         INSTANCE_WATCHDOG_MODE_PASSIVE,
 57         INSTANCE_WATCHDOG_MODE_ACTIVE,
 58         __INSTANCE_WATCHDOG_MODE_MAX,
 59 } instance_watchdog_mode_t;
 60 
 61 struct watchdog {
 62         bool self_managed;
 63         instance_watchdog_mode_t mode;
 64         uint32_t freq;
 65         struct uloop_timeout timeout;
 66 };
 67 
 68 struct service_instance {
 69         struct vlist_node node;
 70         struct service *srv;
 71         const char *name;
 72 
 73         int8_t nice;
 74         bool valid;
 75 
 76         char *user;
 77         uid_t uid;
 78         gid_t pw_gid;
 79         char *group;
 80         gid_t gr_gid;
 81 
 82         bool has_cgroup;
 83         bool halt;
 84         bool restart;
 85         bool respawn;
 86         int respawn_count;
 87         int reload_signal;
 88         struct timespec start;
 89         struct timespec stop;
 90 
 91         bool trace;
 92         bool has_jail;
 93         bool require_jail;
 94         bool immediately;
 95         bool no_new_privs;
 96         struct jail jail;
 97         char *seccomp;
 98         char *seccomp_mode;
 99         char *seccomp_log;
100         char *capabilities;
101         char *pidfile;
102         char *extroot;
103         char *overlaydir;
104         char *tmpoverlaysize;
105         char *bundle;
106         int syslog_facility;
107         int exit_code;
108         uint64_t incarnation;
109 
110         uint32_t term_timeout;
111         uint32_t respawn_timeout;
112         uint32_t respawn_threshold;
113         uint32_t respawn_retry;
114 
115         struct blob_attr *config;
116         struct uloop_process proc;
117         int proc_pidfd;
118         struct uloop_timeout timeout;
119         struct uloop_timeout cgroup_timeout;
120         struct uloop_fd cgroup_events;
121         int stdio_fd[3];
122         int notify_fd;
123         struct ustream_fd _stdout;
124         struct ustream_fd _stderr;
125         struct ustream_fd console;
126         struct ustream_fd console_client;
127 
128         struct blob_attr *command;
129         struct blob_attr *trigger;
130         struct blobmsg_list env;
131         struct blob_attr *data_blob;
132         struct blobmsg_list data;
133         struct blobmsg_list netdev;
134         struct blobmsg_list file;
135         struct blobmsg_list limits;
136         struct blobmsg_list errors;
137 
138         struct watchdog watchdog;
139 };
140 
141 void instance_start(struct service_instance *in);
142 int instance_signal(struct service_instance *in, int sig);
143 void instance_stop(struct service_instance *in, bool halt);
144 void instance_update(struct service_instance *in, struct service_instance *in_new);
145 void instance_init(struct service_instance *in, struct service *s, struct blob_attr *config);
146 void instance_stdio_set(struct service_instance *in, int *fds);
147 void instance_notify_set(struct service_instance *in, int *fd);
148 void instance_free(struct service_instance *in);
149 void instance_dump(struct blob_buf *b, struct service_instance *in, int debug);
150 void service_event_instance_exit(const char *type, struct service_instance *in);
151 
152 #endif
153 

This page was automatically generated by LXR 0.3.1.  •  OpenWrt