From cf14c349fad774e477a80d1c5e6572f21f17ced1 Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Sun, 30 Dec 2012 15:36:56 +0200 Subject: Initial support for running as init process. * grecs: Upgrade. * lib/Makefile.am: Use AM_CPPFLAGS instead of INCLUDES. * src/Makefile.am: Likewise. * src/acl.c: Update grecs_keyword definitions. * src/inetd.c (inetd_conf_file): Bugfix. The ws structure could be free'd prior to initialization. * src/pies.c: Update grecs_keyword definitions. (init_process,initdefault,dfl_level): New globals. (modetab) : New keyword. (component_keywords): New keywords. (main): Initial support for init(8) mode. * src/pies.h (pies_comp_mode) : New constant. (component): New member. (init_process,console_device,initdefault): New externs. * src/progman.c (prog_status): New status. (prog): New member. (progman_running_p): New function. (prog_start): Special handling for init process mode. (progman_start): Likewise. Take into account runlevels. (progman_dump_stats): New flag 'f' for status_finished. --- src/pies.h | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) (limited to 'src/pies.h') diff --git a/src/pies.h b/src/pies.h index 73b0583..9b3ae9d 100644 --- a/src/pies.h +++ b/src/pies.h @@ -122,6 +122,9 @@ struct pies_privs enum pies_comp_mode { + /* + ** Pies native component types. + */ /* Execute the component, no sockets are opened. This is the default Pies mode. */ pies_comp_exec, @@ -137,7 +140,47 @@ enum pies_comp_mode /* Open a socket, start a component, and pass the socket fd to the component via the UNIX domain socket. Corresponds to `start_action = pass' in MeTA1. */ - pies_comp_pass_fd + pies_comp_pass_fd, + + /* + ** Init-style components + */ + + /* Start the process when the specified runlevel is entered and wait + for its termination */ + pies_comp_wait, + /* Execute the component once, when the specified runlevel is entered */ + pies_comp_once, + /* Execute the component during system boot. Ignore runlevel settings. */ + pies_comp_boot, + /* Execute the component during system boot and wait for it to terminate. + Ignore runlevel settings. */ + pies_comp_bootwait, + /* Execute the component when the power goes down. */ + pies_comp_powerfail, + /* Execute the component when the power goes down. Wait for it to + terminate. */ + pies_comp_powerwait, + /* Execute the component when the power is restored. Wait for it to + terminate. */ + pies_comp_powerokwait, + /* Execute the process when SIGINT is delivered, i.e. someone has + pressed the Ctrl+Alt+Del combination. */ + pies_comp_ctrlaltdel, + /* Execute the component when a specified ondemand runlevel is called */ + pies_comp_ondemand, + /* Execute the component on the system boot. */ + pies_comp_sysinit, + /* Execute the component when running on the UPS and pies is informed that + the UPS battery is almost empty. */ + pies_comp_powerfailnow, + /* Execute the component a signal from the keyboard handler arrives, + indicating that a special key combination was pressed on the console + keyboard. */ + pies_comp_kbrequest, + + /* Restart the component wherever it terminates */ + pies_comp_respawn = pies_comp_exec, }; #define CF_DISABLED 0x001 /* The componenet is disabled */ @@ -176,6 +219,9 @@ struct component mode_t umask; /* Umask to install before starting */ limits_record_t limits; /* System limits */ + /* For exec (init) components */ + char *runlevels; + /* For inetd components */ size_t max_rate; /* Maximum number of invocations per minute */ size_t max_ip_connections; /* Max. number of connections per IP address */ @@ -225,7 +271,12 @@ extern char **mailer_argv; extern size_t default_max_rate; extern char *qotdfile; +extern int init_process; +extern char *console_device; +extern int initdefault; + 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); -- cgit v1.2.1