aboutsummaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)AuthorFiles
2019-06-03Finish the env re-implementationSergey Poznyakoff2
* NEWS: Document the "env" statement and the PIES_MASTER_PID environment variable. Version 1.3.91 * configure.ac: Version 1.3.91 * doc/pies.texi: Document the new "env" statement syntax. Provide instructions on how to convert legacy "env" statement to the new form. * lib/envop.c (environ_unset): Take reference value as argument. If supplied, unset the variable only if its value matches the reference one. * lib/envop.h (environ_unset): Change proto. * src/pies.c (parse_legacy_env): Minor changes. (_cb_env_unset): Allow to specify value. * src/progman.c (run_command): Define PIES_MASTER_PID. * tests/env.at: Check the legacy env syntax. * tests/envop.at: Additional checks.
2019-06-02Speed up tests.Sergey Poznyakoff2
Presence of the ~/.netrc file can slow down execution because of eventual DNS calls in hostcmp. Provide an option to disable netrc parsing and use it in tests. * src/piesctl-cl.opt: New option: --no-netrc. * doc/pies.texi: Document --no-netrc * src/piesctl.c (shttp_connect): Don't read ~/.netrc if given --no-netrc. * tests/env.at: Pass --no-netrc to piesctl. * tests/respawn.at: Likewise. * tests/shell.at: Likewise. * tests/shutdown.at: Likewise. * tests/startup.at: Likewise.
2019-06-02Rewrite the testsuiteSergey Poznyakoff1
The aim is to run pies in foreground if possible. Limit execution time using external wrapper. * src/pies.c: (_cb_redir): Consistently return 1 on errors. * tests/aux/sleepexit: New file. * tests/aux/startcheck: New file. * tests/aux/touchfile: Change arguments. * tests/aux/respawn: Rewrite. * tests/lines.c: New noinst program. * tests/to.c: New noinst program. * tests/.gitignore: Add new programs. * tests/Makefile.am: Update. * tests/env.at: Use to to avoid hanging forever. Add missing popdef. * tests/redirect.at: Use echo as component program. * tests/respawn.at: Run pies in foreground. Use to to limit execution time. * tests/shell.at: Likewise. * tests/shutdown.at: Likewise. * tests/startup.at: Likewise. * tests/ret-exec.at: Use sleepexit as component program. * tests/ret-notify.at: Likewise.
2019-06-02New configuration statement for manipulating the environment.Sergey Poznyakoff5
The "env" statement is now a compound statement. It can contain four substatements: "clear" to clear the environment, "keep" to retain certain variable while clearing it, "set" to set a variable, and "unset" to unset a variable or variables. Both "keep" and "unset" can take globbing pattern as their argument, in which case they affect all variable matching that pattern. The value part in the "set" statement is subject to variable expansion, e.g. set "MANPATH=$MANPATH${MANPATH:+:}/usr/local/man" The support for the old one-line syntax of "env" is retained for backward compatibility. This commit also fixes redirection to a file: new data are appended to the file, instead of overwriting it. * lib/Makefile.am: Add new files. * lib/envop.c: New file. * lib/envop.h: New file. * lib/wildmatch.c: New file. * src/comp.c (component_free): Update. * src/pies.c (argv_free): New function. (parse_legacy_env): New function. (_cb_env): Remove. (cb_env_section_parser): New function. (cb_env_keywords): New keywords for the "env" block statement: clear, keep, set, unset. (component_keywords): New compount statement: env. Old usage retained for backward compatibility. * src/pies.h: Include "envop.h" (component)<env>: Remove. <envop>: New field. * src/prog.h (prog)<env>: New field. * src/progman.c (redirect_to_file): Position to the end of file. (DEBUG_ENVIRON): Remove macro. (debug_environ): New function. (environ_setup): Remove. (prog_sockenv): Use environ_set to modify local copy of environment. (prog_start_prologue): Use environ_create + envop_exec to create and modify the environment. (prog_execute): Set environment to prog-local copy. * tests/.gitignore: Build envtest * tests/Makefile.am: Add new tests. * tests/testsuite.at: Add environment tests. * tests/envop.at: New file. * tests/envtest.c: New file. * tests/env.at: New file. * tests/redirect.at: Check first two lines of the output file.
2019-05-31Provide an option to run commands via sh -cSergey Poznyakoff3
The new flag "shell" instructs pies to run the command marked with it as '/bin/sh -c $command'. Alternative shell can be supplied ising the 'program' statement. This is useful if the command line uses shell-specific features (command or variable expansion, redirection, pipes, etc.) This commit also fixes a bug in the 'env' statement handling: a single argument with embedded whitespaces was undergoing word splitting and thus incorrectly handled as multiple arguments. * NEWS: Document changes. * doc/pies.texi: Likewise. * src/comp.c (component_free): Free command. (component_finish): Split command into argv/argc as directed by the CF_SHELL flag. * src/pies.c (_cb_command): Remove. Functionality moved to component_finish(). (_cb_env): Bugfix. Don't split arguments. * src/pies.h (CF_SHELL): New flag. (component) <command>: New member. * tests/Makefile.am: Add new tests. * tests/testsuite.at: Add new tests. * tests/aux/respawn: Change default timeout to 1 second. * tests/respawn.at: Minor change. * tests/shell.at: New test.
2019-05-28Permit stdout redirection for startup and shutdown components.Sergey Poznyakoff1
* src/progman.c (register_prog0): Preserve comp->redir[RETR_OUT].type for exec, startup, and shutdown components.
2019-05-24Implement shutdown componentsSergey Poznyakoff2
* src/pies.h: Update comment. * src/progman.c (register_prog0): Register shutdown components in disabled state. (program_shutdown): New function. (progman_stop): Call program_shutdown. * tests/shutdown.at: New test. * tests/Makefile.am: Add new test. * tests/testsuite.at: Likewise. * tests/aux/startup: Rename to tests/aux/touchfile * tests/startup.at: Reflect the change.
2019-05-24Don't remove finished startup components. Just mark them with status_finished.Sergey Poznyakoff5
* src/ctl.c (pies_comp_mode_str): Add pies_comp_startup and pies_comp_shutdown. * src/piesctl.c (mode_trans): Likewise. * src/progman.c (progman_startup_phase): Test the status of pies_comp_startup components. (progman_waiting_p): Test status instead of pid>0 to select running components. (progman_cleanup): Set status of the finished startup component to status_finished, instead of removing it. * src/comp.c (loaded): Remove unused variable. (component_config_commit): Remove special handling for pies_comp_startup.
2019-05-24Initial implementation of "startup" components.Sergey Poznyakoff5
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 Poznyakoff26
2019-05-23Revise dependency handling. Correctly display cyclic dependencies.Sergey Poznyakoff3
* 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.
2019-05-20Upgrade grecsSergey Poznyakoff4
2019-05-17Provide an option to disable SysV init mode.Sergey Poznyakoff2
This is useful if pies is run as a entrypoint process in a docker container.
2019-05-17Fix coredump in components_dump_depmapSergey Poznyakoff1
Coredump was triggered by detected cyclic dependency.
2019-02-10Minor fixSergey Poznyakoff1
* src/Makefile.am (install-data-hook): Add missing DESTDIR (Reported by Rafael Fontenelle).
2019-02-10Fix typosSergey Poznyakoff1
Spotted by Rafael Fontenelle.
2018-05-20BugfixSergey Poznyakoff1
* src/pies.c (setsigvhan): Fix setting signals
2017-01-02Happy GNU YearSergey Poznyakoff26
2016-08-20Fix environment modification codeSergey Poznyakoff1
Port fixes from GNU rush
2016-07-16Merge branch 'master' of ssh://git.gnu.org.ua/gitroot/piesSergey Poznyakoff2
2016-07-16Don't concatenate adjacent strings in configuration files.Sergey Poznyakoff2
* grecs: Upgrade. * src/pies.h: Fix include paths. * src/piesctl.c: Likewise. * NEWS: Document changes. * doc/pies.texi: Likewise.
2016-04-07Remove duplicate includesSergey Poznyakoff2
2016-03-19Add testsuteSergey Poznyakoff1
2016-03-19BugfixesSergey Poznyakoff2
* src/pies.c (main): Issue the start-up message after eventual changing to background and the corresponding reconfiguration of diagnostic output channel. * src/piesctl.c (parse_condition_to_uri, com_id): Fix checking for arguments.
2016-03-19Fix some compilation issues on SolarisSergey Poznyakoff4
* configure.ac: Check for libnsl * src/pies.c (string_to_syslog_facility): LOG_AUTHPRIV and LOG_FTP may be undefined. * src/piesctl.c (EX_NOTFOUND): Rename to EX_PIES_NOTFOUND. (com_list): Use default_cond. * src/sysvinit.c (console_stty): Make sure CBAUDEX is defined. * src/utmp.c (fill_utmp): Declare locals right before using them.
2016-03-07Improve docsSergey Poznyakoff1
* doc/pies.texi: Document piesctl and identity providers. * src/piesctl.c: Fix reference to the docs.
2016-03-07Fix pies -ESergey Poznyakoff1
* src/pies.c (main): Fix syntax type comparison.
2016-03-06Reimplement the telinit legacy interface.Sergey Poznyakoff6
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-03-05ACL reference statements.Sergey Poznyakoff3
All ACL keywords can be used in simple statement as well as in block form. As simple statements, they take a name of an already defined named ACL. E.g.: defacl forbid { deny any; } component foo { list-acl forbid; } This commit also fixes some eventual double-frees. * doc/pies.texi: Update. * src/acl.c (pies_acl)<refcnt>: New member. (pies_acl_use): New function. (pies_acl_create): Initialize refcnt. (pies_acl_destroy): New function. (pies_acl_free): Rewrite as a wrapper over pies_acl_destroy. (_parse_sub_acl): Call pies_acl_use when installing a named ACL. (_acl_common_section_parser): Handle grecs_callback_set_value. * src/acl.h (pies_acl_destroy) (pies_acl_use): New function. * src/comp.c (component_free): Free acl.
2016-03-05Use pies_schedule_action instead of assigning action directly.Sergey Poznyakoff1
2016-03-02BugfixesSergey Poznyakoff2
* src/comp.c (component_verify): Fix stdout redirection check. * src/meta1parse.c (meta1_translate_node): Skip simple statements. (meta1_translate_node): Allocate comp->dir * doc/pies.texi: Use @example instead of @smallexample
2016-03-02Configurable pathname of the emergency shellSergey Poznyakoff2
* configure.ac (EMERGENCY_SHELL): New arg_var. * src/Makefile.am (AM_CPPFLAGS): Define EMERGENCY_SHELL. * src/sysvinit.c (emergency_shell): Initialize with the value of EMERGENCY_SHELL.
2016-03-01BugfixSergey Poznyakoff1
* src/sysvinit.c (sysvinit_environ_hint): Fix dimensions.
2016-02-28Synchronize changes in runlevel with configuration reloadsSergey Poznyakoff5
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-28Minor changeSergey Poznyakoff1
2016-02-26Minor fixSergey Poznyakoff1
2016-02-26piesctl: minor formatting changeSergey Poznyakoff1
2016-02-26Improve previous commit.Sergey Poznyakoff1
* comp.c (mark_prog): Instead of calling progman_gc, terminate the prog if it is a deactivated listener.
2016-02-26Fix reconfiguration codeSergey Poznyakoff1
* src/comp.c (component_config_commit): Run progman_gc right after mark stage, to ensure any eventual listener components are properly closed before being reopened by progman_create_sockets
2016-02-26Enable the use of redirectors in init modeSergey Poznyakoff1
2016-02-25Minor fixSergey Poznyakoff1
2016-02-25Implement "telinit environ" ctl commandSergey Poznyakoff5
* 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-24Improve parsing and handling of stop, start, and restart ctl commands.Sergey Poznyakoff2
* src/ctl.c (pcond_active): New type. (pcond_eval): Handle pcond_active. (pcond_conv): New op: active. (pcond_conv_find): Skip array elements with NULL term value. (object_to_cond): Permit empty argument if no handler function is defined. (fun_stop): Work on all prog types. (fun_start): Work only on components. (fun_restart): Work only on running components. * src/piesctl.c (cmdline_parser_state): New member: command. (pcond_parse_unary): Handle "active" keyword. (parse_condition): Change signature. (parse_condition_to_uri): Likewise. (default_cond): New function, (com_stop, com_start, com_restart): If no arguments supplied, assume default condition "type component". (ctlcom_t): Change signature. All uses changed. (main): Pass a pointer to cmdline_parser_state to the command handler.
2016-02-24Changes in prog structureSergey Poznyakoff6
* src/prog.h (prog): Remove .facility. Use facility from the component. (active,wait,stop): Move from union into the main struct. All uses changed.
2016-02-24Cleanup initialization codeSergey Poznyakoff2
* src/cmdline.opt (parse_options): Change signature. Handle sysvinit case. * src/pies.c (set_conf_file_names): Handle sysvinit case. (main): Move some parts of sysvinit-specific initialization to set_conf_file_names.
2016-02-24Remove spurious informational message on startupSergey Poznyakoff3
2016-02-24Minor stylistic changeSergey Poznyakoff5
2016-02-23BugfixesSergey Poznyakoff4
* 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 Poznyakoff13
* 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 Poznyakoff3
* src/inetd-bi.c (tcpmux): Use component_foreach to handle help requests. * src/progman.c (progman_iterate_comp): Removed. * src/pies.h: Likewise.

Return to:

Send suggestions and report system problems to the System administrator.