summaryrefslogtreecommitdiff
path: root/src/core/socket.c
Commit message (Collapse)AuthorAgeFilesLines
* core: drop 'wants' parameter from unit_add_node_dependency()Franck Bui2019-10-281-1/+1
| | | | | Since Wants dependency is no more automagically added to swap and mount units, this parameter is no more used hence this patch drops it.
* basic/fs-util: change CHASE_OPEN flag into a separate output parameterZbigniew Jędrzejewski-Szmek2019-10-241-1/+1
| | | | | | | | | | | | | chase_symlinks() would return negative on error, and either a non-negative status or a non-negative fd when CHASE_OPEN was given. This made the interface quite complicated, because dependning on the flags used, we would get two different "types" of return object. Coverity was always confused by this, and flagged every use of chase_symlinks() without CHASE_OPEN as a resource leak (because it would this that an fd is returned). This patch uses a saparate output parameter, so there is no confusion. (I think it is OK to have functions which return either an error or an fd. It's only returning *either* an fd or a non-fd that is confusing.)
* core: adjust load functions for other unit types to be more like serviceZbigniew Jędrzejewski-Szmek2019-10-111-9/+8
| | | | | | | No functional change, just adjusting code to follow the same pattern everywhere. In particular, never call _verify() on an already loaded unit, but return early from the caller instead. This makes the code a bit easier to follow.
* core: turn unit_load_fragment_and_dropin_optional() into a flagZbigniew Jędrzejewski-Szmek2019-10-111-1/+1
| | | | | | | | | | unit_load_fragment_and_dropin() and unit_load_fragment_and_dropin_optional() are really the same, with one minor difference in behaviour. Let's drop the second function. "_optional" in the name suggests that it's the "dropin" part that is optional. (Which it is, but in this case, we mean the fragment to be optional.) I think the new version with a flag is easier to understand.
* cgroup: analyze: Report memory configurations that deviate from systemdChris Down2019-10-031-1/+1
| | | | | | This is the most basic consumer of the new systemd-vs-kernel checker, both acting as a reasonable standalone exerciser of the code, and also as a way for easy inspection of deviations from systemd internal state.
* core: add support for RestartKillSignal= to override signal used for restart ↵Zbigniew Jędrzejewski-Szmek2019-10-021-2/+11
| | | | | | | | jobs v2: - if RestartKillSignal= is not specified, fall back to KillSignal=. This is necessary to preserve backwards compatibility (and keep KillSignal= generally useful).
* Merge pull request #13439 from yuwata/core-support-systemctl-clean-moreZbigniew Jędrzejewski-Szmek2019-09-131-6/+89
|\ | | | | core: support systemctl clean more
| * core/socket: support "systemctl clean" for socket unitsYu Watanabe2019-08-281-6/+89
| |
* | core: make RuntimeDirectoryPreserve= works with non-service unitsYu Watanabe2019-08-231-1/+3
|/
* pid1: always log successfull process termination quietlyZbigniew Jędrzejewski-Szmek2019-08-221-1/+2
| | | | Fixes #13372.
* tree-wide: introduce strerror_safe()Yu Watanabe2019-07-051-1/+1
|
* codespell: fix spelling errorsBen Boeckel2019-04-291-2/+2
|
* tree-wide: port users over to use new ERRNO_IS_ACCEPT_AGAIN() callLennart Poettering2019-04-101-12/+14
|
* core: add new API for enqueing a job with returning the transaction dataLennart Poettering2019-03-271-2/+2
|
* core: reduce the number of stalled PIDs from the watched processes list when ↵Franck Bui2019-03-201-4/+3
| | | | | | | | | | | | | | | | | possible Some PIDs can remain in the watched list even though their processes have exited since a long time. It can easily happen if the main process of a forking service manages to spawn a child before the control process exits for example. However when a pid is about to be mapped to a unit by calling unit_watch_pid(), the caller usually knows if the pid should belong to this unit exclusively: if we just forked() off a child, then we can be sure that its PID is otherwise unused. In this case we take this opportunity to remove any stalled PIDs from the watched process list. If we learnt about a PID in any other form (for example via PID file, via searching, MAINPID= and so on), then we can't assume anything.
* core: rename unit_{start_limit|condition|assert}_test() to unit_test_xyz()Lennart Poettering2019-03-181-1/+1
| | | | | | | Just some renaming, no change in behaviour. Background: I'd like to add more functions unit_test_xyz() that test various things, hence let's streamline the naming a bit.
* core: support netns joining also for sockets created by .socket unitLennart Poettering2019-03-071-16/+61
| | | | | | | | | | Similar to the cgroup magic we nowadays do when listening to sockets, to assign them the right bpf programs, let's also do the same and join the specified netns in the child process. This allows people to listen in sockets in specific namespaces, or join multiple services and socket units together to live in the same namespace.
* core/socket: drop unnecessary assignment to 'r'Yu Watanabe2019-01-091-23/+15
| | | | | | Follow-up for e5417345289b477a70e7515c71551ad34f968a40. As suggested in #11352.
* core/socket: use macro to define log_address_error_errno()Yu Watanabe2019-01-091-10/+7
| | | | | | Then, it is not necessary to suppress warnings. Follow-up for ae05e1b6584eb8f48a4530f963fea2c42e891034.
* core/socket: logs address or path which fails to be initializedYu Watanabe2019-01-081-8/+19
| | | | Closes #11348.
* core/socket: use _cleanup_ attribute for closing fds on errorYu Watanabe2019-01-081-29/+28
|
* core/socket: use log_unit_*()Yu Watanabe2019-01-081-4/+4
|
* Merge pull request #10963 from poettering/bus-force-state-change-signalZbigniew Jędrzejewski-Szmek2018-12-061-0/+4
|\ | | | | force PropertiesChanged bus signal on all unit state changes
| * core: whenever we change state of a unit, force out PropertiesChanged bus signalLennart Poettering2018-12-011-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This allows clients to follow our internal state changes safely. Previously, quick state changes (for example, when we restart a unit due to Restart= after it quickly transitioned through DEAD/FAILED states) would be coalesced into one bus signal event, with this change there's the guarantee that all state changes after the unit was announced ones are reflected on th bus. Note we only do this kind of guaranteed flushing only for unit state changes, not for other unit property changes, where clients still have to expect coalescing. This is because the unit state is a very important, high-level concept. Fixes: #10185
* | Merge pull request #10920 from yuwata/hashmap-destructorLennart Poettering2018-12-031-9/+3
|\ \ | | | | | | hashmap: make hashmap_free() call destructors of key or value
| * | tree-wide: make hash_ops typesafeYu Watanabe2018-12-021-9/+3
| |/
* | util: rename socket_protocol_{from,to}_name() to ip_protocol_{from,to}_name()Yu Watanabe2018-12-021-2/+2
|/
* core: log a recognizable message when a unit succeeds, tooLennart Poettering2018-11-161-1/+3
| | | | | | We already are doing it on failure, let's do it on success, too. Fixes: #10265
* core: make log messages about unit processes exiting recognizableLennart Poettering2018-11-161-3/+5
|
* core: make log messages about units entering a 'failed' state recognizableLennart Poettering2018-11-161-1/+1
| | | | | Let's make this recognizable, and carry result information in a structure fashion.
* core: introduce exec_params_clear()Yu Watanabe2018-11-081-1/+1
| | | | | | Follow-up for 1ad6e8b302e87b6891a2bfc35ad397b0afe3d940. Fixes #10677.
* core: split environment block mantained by PID 1's Manager object in twoLennart Poettering2018-10-311-1/+3
| | | | | | | | | | | | | | | | | | | | | | | This splits the "environment" field of Manager into two: transient_environment and client_environment. The former is generated from configuration file, kernel cmdline, environment generators. The latter is the one the user can control with "systemctl set-environment" and similar. Both sets are merged transparently whenever needed. Separating the two sets has the benefit that we can safely flush out the former while keeping the latter during daemon reload cycles, so that env var settings from env generators or configuration files do not accumulate, but dynamic API changes are kept around. Note that this change is not entirely transparent to users: if the user first uses "set-environment" to override a transient variable, and then uses "unset-environment" to unset it again things will revert to the original transient variable now, while previously the variable was fully removed. This change in behaviour should not matter too much though I figure. Fixes: #9972
* core: rework serializationLennart Poettering2018-10-261-16/+18
| | | | | | | | | | | | | | | | | Let's be more careful with what we serialize: let's ensure we never serialize strings that are longer than LONG_LINE_MAX, so that we know we can read them back with read_line(…, LONG_LINE_MAX, …) safely. In order to implement this all serialization functions are move to serialize.[ch], and internally will do line size checks. We'd rather skip a serialization line (with a loud warning) than write an overly long line out. Of course, this is just a second level protection, after all the data we serialize shouldn't be this long in the first place. While we are at it also clean up logging: while serializing make sure to always log about errors immediately. Also, (void)ify all calls we don't expect errors in (or catch errors as part of the general fflush_and_check() at the end.
* tree-wide: use setsockopt_int() moreYu Watanabe2018-10-191-37/+42
|
* tree-wide: introduce setsockopt_int() helper and make use of it everywhereLennart Poettering2018-10-181-12/+18
| | | | | | As suggested by @heftig: https://github.com/systemd/systemd/commit/6d5e65f6454212cd400d0ebda34978a9f20cc26a#commitcomment-30938667
* Merge pull request #10412 from poettering/sockaddr-sun-pathYu Watanabe2018-10-171-12/+6
|\ | | | | various fixes related to struct sockaddr_un handling
| * tree-wide: add a single version of "static const int one = 1"Lennart Poettering2018-10-151-12/+6
| | | | | | | | | | | | | | | | | | | | All over the place we define local variables for the various sockopts that take a bool-like "int" value. Sometimes they are const, sometimes static, sometimes both, sometimes neither. Let's clean this up, introduce a common const variable "const_int_one" (as well as one matching "const_int_zero") and use it everywhere, all acorss the codebase.
* | tree-wide: CMP()ify all the thingsLennart Poettering2018-10-161-5/+1
|/ | | | Let's employ coccinelle to fix everything up automatically for us.
* Merge pull request #10094 from keszybz/wants-loadingLennart Poettering2018-10-051-3/+3
|\ | | | | Fix bogus fragment paths in units in .wants/.requires
| * pid1: drop unused path parameter to add_two_dependencies_by_name()Zbigniew Jędrzejewski-Szmek2018-09-151-2/+2
| |
| * pid1: drop now-unused path parameter to add_dependency_by_name()Zbigniew Jędrzejewski-Szmek2018-09-151-1/+1
| |
* | fs-util: make symlink_idempotent() optionally create relative linkYu Watanabe2018-09-241-2/+2
|/
* core/socket: fix memleak in the error paths in usbffs_dispatch_eps()Yu Watanabe2018-09-031-6/+14
|
* tree-wide: use DEFINE_TRIVIAL_REF_UNREF_FUNC() macro or friends where applicableYu Watanabe2018-08-271-20/+4
|
* Merge pull request #9783 from poettering/get-user-creds-flagsZbigniew Jędrzejewski-Szmek2018-08-211-2/+2
|\ | | | | beef up get_user_creds() a bit and other improvements
| * user-util: rework get_user_creds()Lennart Poettering2018-08-201-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Let's fold get_user_creds_clean() into get_user_creds(), and introduce a flags argument for it to select "clean" behaviour. This flags parameter also learns to other new flags: - USER_CREDS_SYNTHESIZE_FALLBACK: in this mode the user records for root/nobody are only synthesized as fallback. Normally, the synthesized records take precedence over what is in the user database. With this flag set this is reversed, and the user database takes precedence, and the synthesized records are only used if they are missing there. This flag should be set in cases where doing NSS is deemed safe, and where there's interest in knowing the correct shell, for example if the admin changed root's shell to zsh or suchlike. - USER_CREDS_ALLOW_MISSING: if set, and a UID/GID is specified by numeric value, and there's no user/group record for it accept it anyway. This allows us to fix #9767 This then also ports all users to set the most appropriate flags. Fixes: #9767 [zj: remove one isempty() call]
* | tree-wide: Convert compare_func's to use CMP() macro wherever possible.Filipe Brandenburger2018-08-061-4/+4
|/ | | | | | | | Looked for definitions of functions using the *_compare_func() suffix. Tested: - Unit tests passed (ninja -C build/ test) - Installed this build and booted with it.
* Merge pull request #9624 from poettering/service-state-flushZbigniew Jędrzejewski-Szmek2018-08-021-2/+1
|\ | | | | flush out ExecStatus structures when a new service cycle begins
| * core: properly reset all ExecStatus structures when entering a new unit cycleLennart Poettering2018-07-231-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Whenever a unit is started fresh we should flush out any runtime data from the previous cycle. We are pretty good at that already, but what so far we missed was the ExecStart=/ExecStop=/… command exit status data. Let's fix that, and properly flush out that stuff too. Consider this service: [Service] ExecStart=/bin/sleep infinity ExecStop=/bin/false When this service is started, then stopped and then started again "systemctl status" would show the ExecStop= results of the previous run along with the ExecStart= results of the current one, which is very confusing. With this patch this is corrected: the data is kept right until the moment the new service cycle starts, and then flushed out. Hence "systemctl status" in that case will only show the ExecStart= data, but no ExecStop= data, like it should be. This should fix part of the confusion of #9588
| * core: drop "argv" field from ExecParameter structureLennart Poettering2018-07-231-2/+0
| | | | | | | | | | | | | | | | We always initialize it from the same field in ExecCommand anyway, hence there's no point in passing it separately to exec_spawn(), after all we already pass the ExecCommand structure itself anyway. No change in behaviour.