path: root/src/pies.h
diff options
authorSergey Poznyakoff <gray@gnu.org>2016-01-21 08:31:31 +0200
committerSergey Poznyakoff <gray@gnu.org>2016-01-21 08:31:31 +0200
commit0c930fc6d3fde82e800c685ec1df92ddfa23fe09 (patch)
tree1494ff68c9006d3e1a9d6ab5b3b2a5e2f66a47ca /src/pies.h
parent2040ea870ae411472a73d0bee49fb7c4a774ad93 (diff)
Cleanup: redo configuration file handling and dependency tracking.
Implement clean configuration reload on SIGHUP. Use SIGUSR1 to restart the program (previously initiated by SIGHUP). * src/Makefile.am (pies_SOURCES): Add comp.c * src/comp.c: New file. * src/acl.c (pies_acl_free): Don't coredump on NULL arg. (_parse_from): Set cmp function for the sockaddr list. (_acl_common_section_parser): Set cmp function for the ACL (pies_acl_cmp): New function. * src/acl.h (pies_acl_cmp): New proto. * src/cmdline.opt: Remove option --dump-prereq. Add options --trace-prereq and --trace-depend. * src/ctl.c: Use prog_tag to access tag of struct prog. * src/depmap.c (depmap_clear) (depmap_clear_all): New functions. * src/inetd.c (inetd_conf_file): Don't register prog right away. This is done later in component_config_commit. (inetd_parse_conf): Rename to inetd_config_parse. * src/limits.c (limits_cmp): New function. * src/pies.c (config_file): Replace with struct config_syntax. (str_to_config_syntax): Return a pointer to struct config_syntax. (add_config): Rename to config_file_add. (config_file_add_type): New function. (return_code_keywords, create_action): Change handling of actions. (return_code_section_parser): Likewise. (component_verify, component_create) (component_free, component_finish): Move to comp.c (config_parse): Remove. (pies_config_parse): New function. (pies_read_config,pies_reload): New function. (pies_reload): Rename to request_reload. (pies_status): Rename to request_status. (pies_stop): Rename to request_stop. (main): Change configuration file handling. SIGHUP reloads configuration, instead of restarting the program. (default_sigv,sig_handler): Handle SIGUSR1. * src/pies.h (component): New members: prev, next, listidx, arridx, ref_count, prog. Remove act_head, act_tail, act_temp. Add new prototypes. * src/prog.h (prog): Remove tag and prereq. * src/progman.c (prog_tag): New function. (destroy_prog): Update component reference count. (register_redir): Likewise. (register_prog0): Take one argument. Update component reference count. (register_prog): Update comp->prog (prog_rebuild_prerequisites): Remove. (component_fixup_depend): Remove. (fixup_prerequisites,rebuild_prerequisites) (print_dep,progman_dump_prereq) (progman_dump_depmap,progman_build_depmap): Remove. (prog_start_prerequisites): Scan depmap to find prerequisites. (prog_stop_dependents): Likewise. (progman_wait): Remove. (progman_wait_until): New function. (progman_stop): Rewrite using progman_wait_until. (react): Rewrite using grecs_list * src/sysvinit.c: Use prog_tag when needed. * src/userprivs.c (pies_privs_cmp, pies_privs_free): New functions. * grecs: Update. * lib/safe_strcmp.c: New file. * lib/Makefile.am: Add safe_strcmp.c * lib/libpies.h (safe_strcmp): New proto.
Diffstat (limited to 'src/pies.h')
1 files changed, 46 insertions, 11 deletions
diff --git a/src/pies.h b/src/pies.h
index e0d24d2..ad8e8ee 100644
--- a/src/pies.h
+++ b/src/pies.h
@@ -95,13 +95,12 @@ enum return_action
#define STATUS_SIG_BIT 0x80000000
#define STATUS_CODE(c) ((c) & ~STATUS_SIG_BIT)
struct action
- struct action *next;
size_t nstat;
unsigned *status;
enum return_action act; /* Action to take when the component terminates */
char *addr; /* Addresses to notify about it. */
char *message; /* Notification mail. */
char *command; /* Execute this command */
@@ -199,14 +198,22 @@ enum pies_comp_mode
#define CF_SIGGROUP 0x100 /* Send signals to the process group */
#define CF_NULLINPUT 0x200 /* Provide null input stream */
+struct prog;
struct component
+ struct component *prev, *next; /* Components form doubly-linked list. */
+ int listidx; /* Index of the list. */
+ size_t arridx; /* Index of this component. */
+ size_t ref_count; /* Reference count. */
+ struct prog *prog; /* Prog associated with this component. */
enum pies_comp_mode mode;
char *tag; /* Entry tag (for diagnostics purposes) */
char *program; /* Program name */
size_t argc; /* Number of command line arguments */
char **argv; /* Program command line */
char **env; /* Program environment */
@@ -214,13 +221,13 @@ struct component
struct grecs_list *prereq; /* Prerequisites */
struct grecs_list *depend; /* Dependency targets */
int flags; /* CF_ bitmask */
size_t max_instances; /* Maximum number of simultaneously running
instances */
char *rmfile; /* Try to remove this file before starting */
- struct pies_privs privs; /* UID/GIDS+groups to run under */
+ struct pies_privs privs; /* UID/GIDS+groups to run as */
mode_t umask; /* Umask to install before starting */
limits_record_t limits; /* System limits */
/* For exec (init) components */
char *runlevels;
@@ -246,25 +253,25 @@ struct component
char *max_ip_connections_message;
/* Redirectors: */
int facility; /* Syslog facility. */
struct redirector redir[2]; /* Repeaters for stdout and stderr */
/* Actions to execute on various exit codes: */
- struct action *act_head, *act_tail;
- struct action act_temp; /* Auxiliary object used during configuration */
+ struct grecs_list *act_list;
/* ACLs for control interface */
pies_acl_t list_acl; /* List access control list */
pies_acl_t adm_acl; /* Administrative ACL (stop, start, etc.) */
#define is_sysvinit(cp) ((cp)->mode >= pies_mark_sysvinit || (cp)->runlevels)
enum pies_action {
extern char *instance;
extern char *log_tag;
@@ -286,41 +293,44 @@ extern int initdefault;
extern int dfl_level;
extern size_t pies_master_argc;
extern char **pies_master_argv;
extern char *default_control_url[2];
-enum config_syntax
+enum config_syntax_type
-int str_to_config_syntax (const char *str, enum config_syntax *psynt);
-void add_config (enum config_syntax syntax, const char *name);
+struct config_syntax;
+struct config_syntax *str_to_config_syntax (const char *str);
+void config_file_add (struct config_syntax *syntax, const char *name);
+void config_file_add_type (enum config_syntax_type syntax, const char *name);
void free_redirector (struct redirector *rp);
void pies_schedule_action (int act);
+void free_action (struct action *act);
void register_prog (struct component *comp);
int progman_running_p (void);
size_t progman_running_count (void);
void progman_start (void);
void progman_wake_sleeping (int);
void progman_stop (void);
void progman_cleanup (int expect_term);
void progman_filter (int (*filter) (struct component *, void *data),
void *data);
+int progman_wait_until (int (*cond) (void *), void *data);
void progman_stop_tag (const char *name);
-void progman_dump_prereq (void);
-void progman_dump_depmap (void);
int progman_accept (int socket, void *data);
-int progman_build_depmap (void);
void progman_create_sockets (void);
struct component *progman_lookup_component (const char *tag);
struct component *progman_lookup_tcpmux (const char *service,
const char *master);
void progman_run_comp (struct component *comp, int fd,
@@ -348,12 +358,17 @@ enum pies_depmap_direction
pies_depmap_t depmap_alloc (size_t count);
pies_depmap_t depmap_copy (pies_depmap_t dpm);
void depmap_set (pies_depmap_t dmap, size_t row, size_t col);
int depmap_isset (pies_depmap_t dmap, size_t row, size_t col);
+void depmap_clear (pies_depmap_t dmap, size_t row, size_t col);
+void depmap_clear_all (pies_depmap_t dmap, enum pies_depmap_direction dir,
+ size_t coord);
void depmap_tc (pies_depmap_t dmap);
size_t depmap_first (pies_depmap_t dmap, enum pies_depmap_direction dir,
size_t coord, pies_depmap_pos_t *ppos);
size_t depmap_next (pies_depmap_t dmap, pies_depmap_pos_t pos);
void depmap_end (pies_depmap_pos_t pos);
@@ -362,16 +377,31 @@ int assert_grecs_value_type (grecs_locus_t *locus,
int str_to_socket_type (const char *str, int *pret);
int socket_type_to_str (int socket_type, const char **pres);
struct component *component_create (const char *name);
void component_free (struct component *comp);
+void component_ref_incr (struct component *comp);
+void component_ref_decr (struct component *comp);
+void component_config_begin (void);
+void component_config_rollback (void);
+void component_config_commit (void);
+int component_is_active (struct component *comp);
void component_finish (struct component *comp, grecs_locus_t *locus);
struct grecs_keyword *find_component_keyword (const char *ident);
+void components_dump_depmap (void);
+void components_trace (char **argv, enum pies_depmap_direction dir);
+struct component *component_depmap_first (enum pies_depmap_direction dir,
+ size_t idx, pies_depmap_pos_t *ppos);
+struct component *component_depmap_next (pies_depmap_pos_t pos);
void pies_pause (void);
@@ -398,12 +428,13 @@ void disable_socket (int fd);
void enable_socket (int fd);
int parse_limits (limits_record_t *plrec, char *str, char **endp);
int set_limits (const char *name, limits_record_t lrec);
void free_limits (limits_record_t rec);
+int limits_cmp (limits_record_t a, limits_record_t b);
void meta1_parser_set_debug (void);
int meta1lex (void);
int meta1error (char const *s);
int meta1parse (void);
@@ -448,15 +479,19 @@ void debug_msg (const char *fmt, ...) PIES_PRINTFLIKE(1,2);
/* userprivs.c */
int switch_to_privs (uid_t uid, gid_t gid, struct grecs_list *retain_groups);
void pies_priv_setup (struct pies_privs *);
void pies_epriv_setup (struct pies_privs *);
+int pies_privs_cmp (struct pies_privs const *a, struct pies_privs const *b);
+void pies_privs_free (struct pies_privs *p);
/* inetd.c */
-int inetd_parse_conf (const char *file);
+int inetd_config_parse (const char *file);
/* inetd-bi.c */
struct inetd_builtin
const char *service;
int socktype;

Return to:

Send suggestions and report system problems to the System administrator.