aboutsummaryrefslogtreecommitdiff
path: root/src/pies.h
AgeCommit message (Collapse)AuthorFiles
2019-05-24Initial implementation of "startup" components.Sergey Poznyakoff1
These are components that are run at program startup. Starting other components is delayed until all startup components terminate. This is similar to SysV "bootwait" components. Upon termination, startup components are removed from the configuration. They are not renewed upon configuratuion reload. * src/comp.c (comp_array_remove): Remove from the depmap as well. (component_ref_decr): Use comp_array_remove for active components and plain component_free for inactive ones. (component_build_depmap): Use comp_array_remove. (component_config_commit): Special handling for pies_comp_startup components. * src/pies.c (modetab): New component modes: "startup" and "shutdown". (main): Run program_init_startup. * src/pies.h (pies_comp_mode): New modes: pies_comp_startup and pies_comp_shutdown. (program_init_startup): New proto. * src/progman.c (progman_waiting_p): Return 1 if a startup component is still running. (program_init_startup): New function. (progman_cleanup): Handle pies_comp_startup termination. * src/socket.c (switch_eids): Avoid unnecessary calls to setegid and seteuid. * tests/atlocal.in (auxdir): New variable. * tests/mailer: Move to tests/aux/ * tests/respawn: Move to tests/aux/ * tests/retcode: Move to tests/aux/ * tests/aux/startup: New auxiliary program. * tests/redirect.at: Start components from $auxdir. * tests/respawn.at: Likewise. * tests/ret-exec.at: Likewise. * tests/ret-notify.at: Likewise. * tests/startup.at: New file. * tests/testsuite.at: Include startup.at * tests/Makefile.am: Add new tests.
2019-05-23Update copyright yearsSergey Poznyakoff1
2019-05-23Revise dependency handling. Correctly display cyclic dependencies.Sergey Poznyakoff1
* src/comp.c (component_log_dep): Remove. (report_cyclic_dependency): New function. (comp_array_remove): New function. (component_build_depmap): Remove erroneous components both from the component table and dependency map. (components_dump_depmap): Avoid trailing whitespace in the output. * src/depmap.c (depmap_clear_all): Remove. (depmap_remove): New function. * src/pies.h (CF_REMOVE): New flag. (depmap_clear_all): Remove prototype. (depmap_remove): New prototype. * tests/Makefile.am: Add new test. * tests/atlocal.in (trimws): New function. * tests/cyclic.at: New test. * tests/testsuite.at: Include new test.
2017-01-02Happy GNU YearSergey Poznyakoff1
2016-07-16Don't concatenate adjacent strings in configuration files.Sergey Poznyakoff1
* grecs: Upgrade. * src/pies.h: Fix include paths. * src/piesctl.c: Likewise. * NEWS: Document changes. * doc/pies.texi: Likewise.
2016-03-06Reimplement the telinit legacy interface.Sergey Poznyakoff1
pies -T is now fully compatible with the legacy telinit command * src/telinit.opt: New file. * src/Makefile.am: Add telinit.opt * src/cmdline.opt (-T): Remove explicit variable. Rest of command line is processed specially. * src/pies.h (telinit): Change prototype. * src/sysvinit.c (telinit): Rewrite. * src/.gitignore: Update. * doc/pies.texi: Document telinit.
2016-02-28Synchronize changes in runlevel with configuration reloadsSergey Poznyakoff1
State transition algorithm used this far could cause spurious component wakeups in some cases. Consider the following scenario: being in runlevel N, the configuration is changed so that a component X is added at runlevel N. Then a change to runlevel N+1 is initiated. What happens then is that X is woken up (still being in runlevel N) and terminated shortly afterwards, upon entering runlevel N+1. To avoid this, configuration must be reloaded after runlevel changes. * src/ctl.c (res_runlevel): Don't initiate ACTION_RELOAD after setting the runlevel. * src/pies.c (main): Begin main event loop with call to pies_pause. * src/pies.h (pies_set_hook): New proto. (inittrans): Remove proto. * src/socket.c (pies_set_hook): New function. (pies_pause): Call pies_pause_hook if defined. * src/sysvinit.c (inittrans): Change to static. If transition was initiated by user (e.g. by invoking telinit), schedule ACTION_RELOAD. (sysvinit_begin): Set inittrans as pies_hook
2016-02-25Implement "telinit environ" ctl commandSergey Poznyakoff1
* src/ctl.c: New endpoint "environ" * src/pies.h (sysvinit_envlocate) (sysvinit_envdelete) (sysvinit_envupdate): New protos. * src/piesctl.c: New subcommand "telinit environ". * src/sysvinit.c (sysvinit_envlocate) (sysvinit_envdelete) (sysvinit_envupdate): New functions. (sysvinit_begin): Create allocated copies of instance and pies_master_argv to avoid them being rewritten by calls to mf_proctitle_format
2016-02-24Remove spurious informational message on startupSergey Poznyakoff1
2016-02-23BugfixesSergey Poznyakoff1
* lib/addrfmt.c: Include limits.h * src/ctl.c (fun_stop,fun_start): Ignore non-component progs. * src/pies.c (request_restart_components): Fix piesctl invocation. * src/pies.h (PIES_CHLD_RESCHEDULE_ALARM): New flag. (progman_wait_until): Remove. (progman_recompute_alarm): New proto. * src/progman.c (recompute_alarm): Remove. All uses raise PIES_CHLD_RESCHEDULE_ALARM instead. (progman_wake_sleeping): Handle status_stopping components independently on their activity flag. (prog_stop_all, progman_wait_until): Remove. (progman_stop): Rewrite using mark+sweep approach.
2016-02-23Improve loggingSergey Poznyakoff1
* po/POTFILES.in: Add missing source files. * grecs: Upgrade. * src/diag.c (pies_diag_printer): New function. (logfuncall): New function. * src/pies.h: Add new prototypes. * src/pies.c (main): Initialize grecs_print_diag_fun * src/acl.c: Uniformly use double-quotes in messages. Use logfuncall where applicable. * src/comp.c: Likewise. * src/ctl.c: Likewise. * src/inetd-bi.c: Likewise. * src/inetd.c: Likewise. * src/limits.c: Likewise. * src/piesctl.c: Likewise. * src/progman.c: Likewise. * src/socket.c: Likewise. * src/sysvinit.c: Likewise.
2016-02-22Get rid of progman_iterate_compSergey Poznyakoff1
* src/inetd-bi.c (tcpmux): Use component_foreach to handle help requests. * src/progman.c (progman_iterate_comp): Removed. * src/pies.h: Likewise.
2016-02-22Provide a default single-user entry in init modeSergey Poznyakoff1
This complements 6aac230c. The entry is created unless a component for runlevel S already exists. * src/comp.c (component_foreach): New function. * src/pies.h: Likewise. * src/sysvinit.c (inittab_parse): Provide default S entry unless one is already defined.
2016-02-21Provide fall-back entry in init modeSergey Poznyakoff1
* src/sysvinit.c (inittab_parse): Provide default entry if inittab cannot be read or if it defined no components. * src/comp.c (component_list_is_empty): New function. * src/pies.c (pies_read_config): Always return 0 in init mode. (main): Use LOG_DAEMON in init mode. * src/pies.h (component_list_is_empty): New proto.
2016-02-20Improve control interfaceSergey Poznyakoff1
This commit implements the following operations on the new /conf endpoints: GET /conf/runtime - List configuration PUT /conf/runtime - Reload configuration POST /conf/runtime - Post new configuration GET /conf/files - List configuration files DELETE /conf/files - Delete some or all configuration files from the list POST /conf/files - Install new configuration file Piesctl supports the following new commands: piesctl config reload piesctl config file clear piesctl config file add SYNTAX NAME piesctl config file del[ete] NAME [NAME...] piesctl config file list * src/ctl.c (res_conf): New function. (restab): New endpoint /conf * src/pies.c (config_file_add): Set free_entry. (config_file_remove, config_file_remove_all) (config_file_list_serialize): New functions. (pies_config_parse): Bail out if tree processing fails. (pies_reload): Remove unused function. (main): Redo ACTION_RELOAD handling. Handle ACTION_COMMIT. * src/pies.h (ACTION_COMMIT): New action. (config_file_remove, config_file_remove_all) (config_file_list_serialize) (pies_read_config, progman_gc): New protos. * src/piesctl.c (cmdline_parser_state): New struct (next_token, peek_token): Take ptr to cmdline_parser_state as argument. (parse_error, require_token, assert_eol) (piesctl_format): New functions. (parse_condition_to_uri): Rewrite using piesctl_format. New subcommand: config. Improve help output.
2016-02-19Revamp program termination after reconfiguring.Sergey Poznyakoff1
* src/pies.h (PIES_CHLD_GC): New op. (progman_stop_tag): Remove proto. * src/pies.c (main): Handle PIES_CHLD_GC: stop all programs marked for termination. * src/comp.c (component_config_commit): Mark leftover components for termination, instead of waiting for them to terminate. * src/sysvinit.c (runlevel_setup_prog): Skip prog if its active status didn't change. Mark inactivated progs for termination. (sysvinit_runlevel_setup): Schedule PIES_CHLD_GC. (inittrans): Don't wait for programs to terminate. That will be done in the main loop. * src/prog.h (prog)<stop>: New boolean member. * src/progman.c (progman_cleanup) (progman_stop_component): Clear the stop flag. (progman_gc): New function. (progman_stop_tag): Remove.
2016-02-18Improve loggingSergey Poznyakoff1
* src/diag.c: Rewrite. (vdiagmsg,diagmsg): New functions. * src/pies.c (main): Set DIAG_REOPEN_LOG for init process. * src/pies.h (DIAG_REOPEN_LOG): New flag (DIAG_TO_MASK,DIAG_ALL): New constants. (diagmsg): New proto. * src/sysvinit.c: Add log messages in important transition points (inittrans): Reinitialize logging to syslog upon transition to normal mode.
2016-02-15Implement emergency shell.Sergey Poznyakoff1
* src/pies.c (main): Move init-specific command line handling to sysvinit_parse_argv. * src/pies.h (dfl_level): Remove extern. (sysvinit_parse_argv): New proto. * src/sysvinit.c (sysvinit_parse_argv): New function. (sysvinit_begin): Start emergency shell, if requested.
2016-02-14Fix handling of wait componentsSergey Poznyakoff1
* src/pies.h (PIES_COMP_WAIT): Remove. (PIES_COMP_MASK): Save one bit. (PIES_CHLD_NONE, PIES_CHLD_CLEANUP) (PIES_CHLD_WAKEUP): New constants. (pies_schedule_children): New proto. (sysvinit_runlevel_setup): Change signature. * src/pies.c (children_cleanup, got_alarm): Merge into single static variable children_op. All uses updated. (pies_schedule_children): New function. (sig_handler): Update (main): Don't call ctl_open for init process. It is done by inittrans after transition from boot to normal state. Update to use pies_schedule_children. * src/prog.h (IS_ACTIVE_COMPONENT): New macro. * src/progman.c (prog_start): Don't modify prog->v.p.wait. (progman_wake_sleeping): Start usual components only after all "wait" components have terminated. (progman_cleanup): If a "wait" component has terminated, request PIES_CHLD_WAKEUP. * src/sysvinit.c (enstate) <wait>: Remove. (enablecomp): Update. (runlevel_setup_prog): Set prog->v.p.wait. (sysvinit_runlevel_setup): Take only one parameter. (inittrans): Remove "wait" and the related mess. Call ctl_open after transition boot -> normal.
2016-02-13Stop disabled components when switching runlevels.Sergey Poznyakoff1
* src/prog.h (status_enabled, status_disabled): Remove. (status_stopped, status_running): New modes. All uses updated. * src/comp.c (component_finish): Disable ondemand component by default. * src/ctl.c (json_object_set_bool): New function. (pies_status_str): Update. (prog_serialize): Set "disabled" attribute. (fun_stop, fun_start): Use CF_DISABLED flag. (res_runlevel): Schedule ACTION_RELOAD. * src/pies.h (json_object_set_bool): New proto. * src/piesctl.c (status_trans): Reflect changes in modes. (print_comp): Check the "disabled" attribute. * src/progman.c (register_prog0) (prog_open_socket,prog_start,prog_stop) (progman_wake_sleeping) (prog_start_prerequisites) (react, progman_cleanup) (progman_stop_component): Update. (no_children_left): Fix. * src/sysvinit.c (enablecomp): Make CF_DISABLED flag persist for ondemand components. (runlevel_setup_prog): Use CF_DISABLED flag. (inittrans): Stop inactivated processes. * doc/pies.texi: Update.
2016-02-13Implement on-demaind components; implement control socket telinit interface.Sergey Poznyakoff1
* src/pies.h: Include json.h (sysvinit_report, sysvinit_set_runlevel) (json_object_set_string, json_object_set_number): New protos. * src/ctl.c (ctlio_resource)<predicate>: New member. (restab): New endpoint: runlevel. Available only if run as pid 1. (find_resource): If predicate is not NULL, call it to confirm that the endpoint is available. * src/piesctl.c: New subcommand "telinit". * src/sysvinit.c (sysvinit_set_runlevel): New function. (sysvinit_fifo_handler): Implement on-demaind components.
2016-02-12Improve progman API (progman_foreach and progman_stop_component).Sergey Poznyakoff1
* src/progman.c (progman_foreach): Allow filter to remove its prog argument from the list. Return integer (result of the call to filter, that returned non-zero). All uses changed. (progman_running_count): Remove. (progman_stop_component): Take a pointer to pointer. Pass it to destroy_prog when needed. All uses changed. * src/comp.c (prog_is_leftover): New function. (cb_terminate_prog): Use prog_is_leftover. Don't raise CF_DISABLED flag, as prog will have been destroyed by progman_stop_component. (cb_kill_prog): Use prog_is_leftover. * src/ctl.c (fun_stop): Check if prog still exists after the call to progman_stop_component. * src/pies.h (progman_running_count): Removed. * src/prog.h (progman_foreach): Return int. (progman_stop_component): Change signature.
2016-01-31Fix runlevel switching; handle powerfail commands.Sergey Poznyakoff1
* src/ctl.c (prog_serialize): List runlevels. * src/pies.c (main): Set got_alarm after reloading configuration. Handle ACTION_POWER. * src/pies.h (ACTION_POWER): New constant. (progman_running_p): Rename to progman_waiting_p. All uses changed. (sysvinit_power): New proto. (POWER_STAT_FILE): New define. (POWER_STAT_FAIL,POWER_STAT_LOW,POWER_STAT_OK): New constants. * src/prog.h (prog) <idx>: Remove. (prog) <wait>: New member. * src/progman.c (prog_lookup_by_idx): Remove. (progman_waiting_p): Return 1 only if there is at least one prog with v.p.wait set. (prog_start): Initialize v.p.wait for sysvinit components. (progman_start): Don't do anything if waiting for components from the previous runlevel. (progman_wake_sleeping): Likewise. (progman_cleanup): Assume expect_term if waiting for components from the previous runlevel. Clear v.p.wait on exited progs. * src/sysvinit.c (sysvinit_fifo_handler): Don't call progman_stop when handling runlevel changes. Handle INIT_CMD_POWERFAIL, INIT_CMD_POWERFAILNOW, and INIT_CMD_POWEROK. (sysvinit_sigtrans): Handle SIGPWR. (is_comp_wait): Rewrite. (power_stat_file): New variable. (sysvinit_power): New function.
2016-01-21Cleanup: redo configuration file handling and dependency tracking.Sergey Poznyakoff1
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.
2016-01-08Uniformly use grecs memory management functions.Sergey Poznyakoff1
* gnulib.modules: Remove unneded modules. * ident/ident.h: Remove xalloc.h, include errno.h * ident/ident.c: Use standard allocation functions instead of x* * ident/pam.c: Remove. * ident/provider.c: Remove. * ident/system.c: Remove. * src/meta.c: Remove. * src/Makefile.am: Remove meta.c * src/progman.c: Use grecs_* allocation functions instead of x*. (notify): Use wordsplit to expand variables within message. Rename variables: program-name to program_name; canonical-program-name to canonical_program_name. * doc/pies.texi: Update. * src/depmap.c: Use grecs_* allocation functions instead of x*. (depmap_end): New function. * src/diag.c (logmsg_vprintf): Use grecs_txtacc instead of obstack. * src/pies.h (depmap_end): New proto. Remove unused includes. * src/acl.c: Use grecs_* allocation functions instead of x*. * src/ctl.c: Likewise. * src/inetd.c: Likewise. * src/limits.c: Likewise. * src/meta1gram.y: Likewise. * src/meta1lex.l: Likewise. * src/pies.c: Likewise. * src/socket.c: Likewise. * src/sysvinit.c: Likewise. * src/userprivs.c: Likewise.
2016-01-08Enable control socket when run as init process.Sergey Poznyakoff1
* configure.ac (DEFAULT_CONTROL_URL): Rename to DEFAULT_PIES_CONTROL_URL. Change default value. (DEFAULT_INIT_CONTROL_URL): New subst variable. * lib/libpies.h (pies_basic_url_create): New prototype. * lib/url.c (pies_basic_url_create): New function (renamed from pies_url_create). (pies_url_create): Expand variable references in the input string. * src/Makefile.am (AM_CPPFLAGS): Pass DEFAULT_INIT_CONTROL_URL * src/ctl.c (pies_control_url) (ctl_open): Don't exit on errors, return -1 instead. * src/pies.c (default_control_url): New variable. (config_parse): Create default socket url. (pies_control_url): New macro (main): Set environment variable PIES_INSTANCE. Try to open control socket in init process mode as well. * src/pies.h (default_control_url): New extern. (ctl_open): Change prototype. (pies_control_url): Remove. * src/piesctl-cl.opt (parse_options): Set environment variable PIES_INSTANCE. * src/piesctl.c (parse_config): Use pies_url_create and DEFAULT_PIES_CONTROL_URL when falling back to the default socket.
2016-01-05Include argv in the output of ctl id command.Sergey Poznyakoff1
* ctl.c (res_instance): Include "argv" in the return json. Use pies_master_argv[0] to report binary path. * pies.c (pies_master_argv,pies_master_argc): New globals. (main): Initialize them. Refuse to restart unless argv[0] begins with a slash. * pies.h (pies_master_argv,pies_master_argc): New globals. * piesctl.c (com_id): Rewrite output formatting.
2016-01-05Minor changes.Sergey Poznyakoff1
* src/ctl.c (ctlio_authenticate): Configurable realm name. (ctlio_do_command): Check the Accept header. * src/inetd.c (inetd_conf_file): Change line_no type. * src/pies.c (control_keywords): New keyword: realm. * src/pies.h (control) <realm>: New member.
2016-01-03Minor changesSergey Poznyakoff1
* configure.ac: Version 1.2.92 * src/ctl.c (ctlio_finalize_reply): Don't close connection on errors. * src/pies.h (PIES_PRINTFLIKE): New macro. (logmsg, logmsg_printf): Mark as printflike.
2016-01-02Switch to new control interface.Sergey Poznyakoff1
Old control options (--status, --restart-components) rewritten using piesctl. SIGUSR1 and SIGUSR2 no longer handled. * lib/arraymember.c (array_index): New function. * lib/libpies.h: Likewise. * src/cmdline.opt: Fix copyright years. * src/piesctl-cl.opt: Likewise. * src/ctl.c (ctlio_do_command): Implement restart. (pies_control_url): New function. (eval_env): rename json to result. New member cond. Restore pcond_ functions. (json_to_pcond): New function. (res_programs): Conditional selection of programs to list. Implement restart. * src/pies.c (ctlfile, statfile): Remove. (pies_keywords): Mark control-file and stat-file as inactive. (default_sigv): Remove SIGUSR1 and SIGUSR2 (pies_check_status): Don't send SIGUSR2. (stop_components): Remove. (request_restart_components): Rewrite as a wrapper. Call piesctl to do the job. (list_components): New function. * src/pies.h (ACTION_COMPRELOAD) (ACTION_DUMPSTATS): Remove. All callers changed. (progman_dump_stats): Remove. * src/piesctl.c (shttp_request_send): Don't initialize conn->req; the caller is responsible for that. (parse_condition, json_to_string) (parse_condition_to_uri): New functions. (com_list): Read conditional expression from the command line. (com_restart): Implement. * src/progman.c (progman_dump_stats): Remove.
2015-12-31Command-line control interface.Sergey Poznyakoff1
* configure.ac (DEFAULT_CONTROL_URL): New subst variable. * grecs: Upgrade. * ident/pam.c (overwrite_and_free): Free ptr. * lib/Makefile.am: Add new sources. * src/addrfmt.c: Move to lib/addrfmt.c * lib/grecsasrt.c: New file. * lib/grecsasrt.h: New file. * lib/mkfilename.c: New file. * lib/netrc.c: New file. * lib/pp.c: New file. * lib/split3.c: New file. * src/url.c: Move from lib/url.c (pies_url_free_user, pies_url_free_passwd): New finctions. * lib/libpies.h (strsplit3): New proto. (pies_url_create, pies_url_destroy) (pies_url_get_arg, pies_url_copy) (pies_url_free_user, pies_url_free_passwd) (netrc_scan) (pp_add_option, pp_command_line, mkfilename) (sockaddr_to_str, sockaddr_to_astr): New protos * src/Makefile.am (bin_PROGRAMS): New program: piesctl (pies_SOURCES): Remove addrfmt.c and url.c. (noinst_HEADERS, BUILT_SOURCES): Add piesctl-cl.h * src/cmdline.opt: Use pp_* function family to build preprocessor command line. * src/ctl.c (http_header_hash): Use case-insensitive hashing. (ctlio_finalize_reply): Don't close connection after sending 401 response. (input): Remove ws and wsflags. All uses changed. (input_append): Use strsplit3 to parse the request line. * src/pies.c: Use pp_* function family to build preprocessor command line. Move assert_, mkfilename and _cb+_url functions into libpies. * src/pies.h (pies_sockaddr_storage): Move to libpies.h * src/piesctl.c: New file. * src/piesctl-cl.opt: New file.
2015-12-20Bugfixes in init modeSergey Poznyakoff1
* src/ctl.c (ctl_open): Add missing return. * src/pies.c (config_parse): Return if tree is null. (main) [INIT_EMU]: Print more info. Override default init_fifo. Don't use syslog and control socket if running as init process. * src/pies.h (init_fifo): New extern. * src/progman.c (open_redirector): Return -1 if running as init process. (prog_start): Always initialize redir[]. * src/sysvinit.c (init_fifo): New variable. Use it instead if the INIT_FIFO macro. (inittrans): Call create_fifo once, when transiting from boot to normal state.
2015-12-17Implement user privilegesSergey Poznyakoff1
* src/pies.h (component): New members: list_acl and adm_acl. (control): Removed id_acl. New members: adm_acl and usr_acl. * src/pies.c (component_keywords): New keywords list-acl and admin-acl. Removed identity-acl. * ident/ident.c (pies_identity_user_name): New function. * ident/identity.h (pies_identity_user_name): New proto. * src/ctl.c (CTL_USER_STATE,CTL_ADMIN_STATE): New states. (cmdtab): Mark administrative commands as valid in CTL_ADMIN_STATE (ctlio_create): Assume CTL_ADMIN_STATE in the absense of identity providers. (auth_data): New struct. (cmd_auth): Select appropriate state depending on the user permissions. (list_matches): New function. (eval_env): Keep the list of selected progs. (count_prog): Removed. (selector): New function. (cmd_list): Rewrite to take into account access rights. (cmd_start,cmd_stop) (cmd_restart): Only allowed for users with administrative privileges.
2015-12-16Minor fixes.Sergey Poznyakoff1
* grecs: Upgrade. * lib/parsetime.c: Fix senseless compiler warnings. * src/acl.c: Fix docstrings. * src/meta1gram.y (yyerror): Change argument * src/meta1lex.l: Add flex options * src/pies.h (meta1error): Change signature. * src/progman.c (prog_lookup_by_socket): Remove. * src/sysvinit.c (sysvinit_stop_filter): Remove.
2015-12-16Implement authentication on control socket.Sergey Poznyakoff1
* Makefile.am (SUBDIRS): Add src. * configure.ac: Check for crypt.h and PAM Build ident/Makefile * grecs: Update. * ident/Makefile.am: New file. * ident/ident.c: New file. * ident/ident.h: New file. * ident/identity.h: New file. * ident/pam.c: New file. * ident/provider.c: New file. * ident/system.c: New file. * lib/Makefile.am: Add arraymember.c * lib/arraymember.c: New file. * lib/libpies.h (is_array_member): New proto. * src/Makefile.am (LDADD): Add libident.a and @PAM_LIBS@ * src/acl.c (acl_entry): Remove groups. Add new members: names and name_match. (pies_acl_create): Deep copy the locus. Set free_entry function for the list. (pies_acl_free): Free locus. (_parse_from): Set free_entry function for the list. (_parse_group): Parse the "user" construct. (parse_acl_line): Deep copy the locus. Allow for null value. (acl_keywords): Update docstrings. (_acl_check): Rewrite identity checks. * src/acl.h (acl_input)<user,groups>: Remove. <identity>: New member. (pies_acl_free): New proto. * src/ctl.c (identity): New global. (cmdtab): New command: auth (ctlio) <addr,addrlen>: New members. (ctlio_create): Start from authenticated state only if no identity_providers are configured. (cmd_auth): New function. (cmd_help): Print only commands that are available in the current state. (ctl_accept): Initialize io->addr and io->addrlen. * src/inetd-bi.c: Change call to check_acl * src/pies.c: Include identity.h (control_keywords): New statement "identity-acl" (pies_keywords): New statement "identity-provider" (config_init): Register identity mechanisms. (config_parse): New function. (config_help): Print help on identity-provider statements. (main): Use config_parse to parse grecs-style configurations. * src/pies.h: Include identity.h (check_acl): Change argument list. All callers changed. (control): Remove acl. Add conn_acl and id_acl instead. * src/progman.c (check_acl): Change argument list. Take identity as the 3rd argument.
2015-11-05New ctl commands: start, stop, restart, reboot, shutdown.Sergey Poznyakoff1
* src/ctl.c (CTL_ACTION_STATE): New state. (cmdtab): Add new commands: start, stop, restart, reboot, shutdown. (ctlio)<action>: New member. (ctlio_create): Initialize action. (list_prog): List scheduled wakeup time for sleeping components. (cmd_start,cmd_stop) (cmd_restart,cmd_reboot,cmd_shutdown): New functions. (ctlwr): Handle CTL_ACTION_STATE. * src/pies.c (pies_schedule_action): New function. (stop_components): Use progman_stop_tag(). * src/pies.h (pies_schedule_action, progman_stop_tag): New protos. (progman_stop_component): Remove. * src/prog.h (progman_locate, progman_stop_component): New protos. * src/progman.c (progman_locate): New function. (progman_cleanup): Set status depending on the CF_DISABLED bit. (progman_stop_component): Take struct prog* as argument. (progman_stop_tag): New function.
2015-10-31Implement list control command.Sergey Poznyakoff1
* src/ctl.c: Implement list. * src/prog.h (IS_COMPONENT): New macro (from progman.c) * src/progman.c: Move IS_COMPONENT to src/prog.h * src/socket.c (create_socket): Clear uid, gid and umaskval for inet sockets.
2015-10-30Introduce control connection.Sergey Poznyakoff1
* src/ctl.c: New file. * src/Makefile.am (pies_SOURCES): Add ctl.c * src/pies.c: New configuration statement "control" * src/pies.h (instance, ctl_url): New externs. (register_socket): Change signature. (update_socket,ctl_open): New protos. * src/socket.c (listenset): Remove. (fdset): New static. (sockinst)<handler>: Array of three pointers: handlers for read, write, and exception, correspondingly. (find_socket_handler): Remove. (register_socket): Take three function pointers as arguments. Update corresponding elements of fdset. (update_socket): New function. (pies_pause): Handle all three I/O operations. (deregister_socket) (register_program_socket) (disable_socket,enable_socket): Reflect the changes. * src/sysvinit.c (create_fifo): Update call to register_socket.
2015-01-21New component flag: nullinputSergey Poznyakoff1
* NEWS: Update. * doc/pies.texi: Document nullinput flag. * src/pies.c (str_to_cf): New flag: nullinput * src/pies.h (CF_NULLINPUT): New flag. * src/progman.c (prog_start): If CF_NULLINPUT flag is set, redirect /dev/null to the stdin
2014-06-09Implement ctrlaltdel and kbrequest processes.Sergey Poznyakoff1
* src/sysdep.c: New file. * src/Makefile.am (pies_SOURCES): Add sysdep.c * src/pies.c (ACTION_*): Move to pies.h (sig_handler): Call sysvinit_sigtrans, return immediately if it handles the signal. (setsigvhan): New function. (add_extra_sigv): New function. (signal_setup): Rewrite. (main): Handle ACTION_CTRLALTDEL and ACTION_KBREQUEST. * src/pies.h (PIES_COMP_DEFAULT) (PIES_COMP_WAIT,PIES_COMP_MASK): New defines. (pies_action): New enum, add new actions: ACTION_CTRLALTDEL and ACTION_KBREQUEST. (setsigvhan, add_extra_sigv) (sysvinit_sigtrans,sysvinit_runlevel_setup) (sysvinit_sysdep_begin): New protos. (sysvinit_request) <pad>: Rename to data. * src/sysvinit.c (enablecomp): Change meaning of the data pointer. (sysvinit_runlevel_setup): Change signature. Remove static qualifier. All uses changed. (sysvinit_setenv): New static. (sysvinit_fifo_handler): Handle INIT_CMD_SETENV. (sysvinit_sigtrans): New function. (sysvinit_begin): Set up new signals. Call sysvinit_sysdep_begin.
2013-01-07Add function for parsing /etc/inittab.Sergey Poznyakoff1
* src/limits.c (free_limits): New function. * src/pies.c (config_syntax): Move to pies.h (config_syntax_tab): New type "inittab" (free_action,component_free): New functions. (component_finish): Call component_free to discard the failed component. (main): In sysvinit mode, default to reading two configuration files: /etc/inittab and /etc/pies.init. Don't exit on configuration errors in this mode. * src/pies.h (str_to_config_syntax) (add_config,free_redirector) (component_free,free_limits) (inittab_parse): New protos. * src/progman.c (free_redirector): New function. * src/sysvinit.c (inittab_parse): New function.
2013-01-07Fix sysvinit execution environment, simplify boot state system.Sergey Poznyakoff1
* src/pies.c (_cb_runlevels): Bugfix. (set_console_dev): Move to sysvinit.c * src/pies.h (progman_sysvinit_enable): Remove proto. (console_open, telinit): New protos. (sysvinit_environ_hint): New extern. * src/prog.h (prog_stop): New proto. * src/progman.c (env_concat): Bugfix. (env_concat): In sysvinit mode, apply sysvinit_environ_hint to the environment. (console_open, console_stty): Move to sysvinit.c * src/sysvinit.c (boot_state): Simplify state set. (getinitdefault, askrunlevel): New functions. (sysvinit_runlevel_setup): New function. (enablecomp): Change signature to match progman_foreach API. (sysvinit_begin): Prepare console, become a session leader, prepare environment. (inittrans): Call sysvinit_runlevel_setup * src/socket.c (calc_fd_max): Fix return type. * src/acl.c (acl_copy): Remove unused variable.
2013-01-06Update copyright years.Sergey Poznyakoff1
2013-01-06Fix runlevel transition algorithm, implement SysV-style fifo interface.Sergey Poznyakoff1
* src/prog.h: New file. * src/Makefile.am: Add new file. * src/cmdline.opt: New option --telinit (-T). * src/diag.c (vlogmsg): In sysvin it mode, write directly to the console. Close it when finished. * src/pies.c (_cb_initdefault, _cb_runlevels): Use is_valid_runlevel to check if the specified runlevels are ok. (main): In sysvinit mode, reset action to ACTION_CONT. * src/pies.h (progman_filter): New proto. (progman_accept,register_socket): Change signature. (deregister_socket): New proto. (register_program_socket): New proto. * src/progman.c: Move constant and adatatype definitions to prog.h (prog_stop): Remove static qualifier. (console_open): Likewise. (progman_accept): Use new socket API. (progman_stop): Correctly handle timeouts. (progman_foreach): New function. * src/socket.c: Register all sockets along with their handlers in a doubly-linked list. (sockinst): New struct. (register_socket,deregister_socket): New functions. (register_program_socket): New function. (pies_pause): Traverse the list to find which fd has changed. Use its registered handler to handle the event. * src/sysvinit.c: Include prog.h (is_valid_runlevel): New function. (sysvinit_fifo_handler,check_fifo): New static functions. (inittrans): Fix transition algorithm. (telinit): New function.
2013-01-05Write utmp/wtmp records in sysvinit mode.Sergey Poznyakoff1
* configure.ac: Check for utmp.h, utmpx.h * src/utmp.c: New file. * src/Makefile.am: Add utmp.c * src/pies.h (sysvinit_acct): New proto. * src/progman.c (prog_start, progman_cleanup): Call sysvinit_acct. * src/sysvinit.c (inittrans): Call sysvinit_acct. Set proctitle.
2013-01-04Fix sysvinit transition logic.Sergey Poznyakoff1
* src/pies.c (main): Call sysvinit_begin to initialize sysvinit subsystem. In the main loop, force wakeup if inittrans returns 1. * src/pies.h (is_sysvinit): Rewrite macro. (progman_sysvinit_enable): New proto. (inittrans): Change return type. * src/progman.c (progman_sysvinit_enable): New function. (progman_running_p): Additional debugging. (prog_start): Special handling for sysvinit components. Remove calls to runlevel_match * src/sysvinit.c (runlevel_match): Remove function. (sysvinit_begin): New function. (inittrans): Return boolean value indicating whether a transition has been made. Call progman_sysvinit_enable to change the status of sysvinit components as appropriate.
2013-01-04Implement runlevel transitions.Sergey Poznyakoff1
* src/sysvinit.c: New file. * src/Makefile.am: Add new file. * src/pies.c (initdefault, dfl_level): Move to sysvinit.c (modetab): Add new modes. (inittrans): Move to sysvinit.c * src/pies.h (is_sysvinit): New macro. (dfl_level): New extern. (runlevel_match, inittrans, is_comp_wait): New protos. * src/progman.c (progman_running_p): Take into account only components. Use is_comp_wait to determine if the component should be waited for. (prog_start): Run sysvinit components only when started as init process. (runlevel_match): Move to sysvinit.c (prog_start_prerequisites): Return immediately if the component is disabled.
2013-01-04Initial support for running as init process.Sergey Poznyakoff1
* 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) <once>: New keyword. (component_keywords)<runlevels,initdefault>: New keywords. (main): Initial support for init(8) mode. * src/pies.h (pies_comp_mode) <pies_comp_exec_once>: New constant. (component)<runlevels>: New member. (init_process,console_device,initdefault): New externs. * src/progman.c (prog_status)<status_finished>: New status. (prog)<runlevels>: 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.
2011-10-23Switch to the latest Grecs.Sergey Poznyakoff1
* Makefile.am (ChangeLog): Use git2chg.awk to build it. * NEWS: Update. * bootstrap.conf (gnulib_modules): Grecs does not depend on gnulib any more. * configure.ac: Version 1.2.90. Define GRECS_HOST_PROJECT_INCLUDES, remove grecs Makefiles from AC_CONFIG_FILES: it is now done by GRECS_SETUP itself. * gnulib.modules (gitlog-to-changelog,argp): Remove. (configmake): New module. * grecs: Update to a52ab6c6. * lib/libpies.h: Remove redefinitions of _() and N_(). * src/Makefile.am: Update for the recent grecs. * src/acl.c: Rewrite using Grecs support for lists and symtabs. * src/acl.h: Likewise. * src/diag.c: Likewise. * src/inetd.c: Likewise. * src/meta1gram.y: Likewise. * src/meta1lex.h: Likewise. * src/meta1lex.l: Likewise. * src/pies.c: Likewise. * src/pies.h: Likewise. * src/progman.c: Likewise. * src/userprivs.c: Likewise.
2010-01-02Update copyright years.Sergey Poznyakoff1
Happy GNU Year!

Return to:

Send suggestions and report system problems to the System administrator.