summaryrefslogtreecommitdiffstats
path: root/src/shared/install.h (follow)
Commit message (Collapse)AuthorAgeFilesLines
* shared/install: use FOREACH_ARRAY for install_changes_have_modificationMike Yuan2024-05-011-3/+3
|
* various: use strdup_to() in various obvious casesZbigniew Jędrzejewski-Szmek2024-03-201-1/+1
| | | | | strdup_to() returns 0 on success and here we convert obvious blocks which either return -ENOMEM or 0.
* core,install: generalize install error handlingMike Yuan2024-03-061-1/+8
|
* install: optionally return discovered unit file path in unit_file_exists()Lennart Poettering2024-01-111-1/+5
|
* unit-file: support UpheldBy= in [Install] settings (adding Upholds= depsMike Yuan2023-05-151-0/+1
| | | | | | from .upholds/) Closes #26896
* preset: Add ignore directiveDaan De Meyer2023-04-141-1/+13
| | | | | | The ignore directive specifies to not do anything with the given unit and leave existing configuration intact. This allows distributions to gradually adopt preset files by shipping a ignore * preset file.
* tree-wide: rename cleanup functionDavid Tardon2023-04-141-1/+1
| | | | ... with accordance to the current coding style.
* install: drop unused functionDavid Tardon2023-04-121-1/+1
|
* install: define hash_ops for UnitFileListDavid Tardon2023-03-281-0/+1
|
* basic: add RuntimeScope enumLennart Poettering2023-03-101-17/+17
| | | | | | | | | | | | In various tools and services we have a per-system and per-user concept. So far we sometimes used a boolean indicating whether we are in system mode, or a reversed boolean indicating whether we are in user mode, or the LookupScope enum used by the lookup path logic. Let's address that, in introduce a common enum for this, we can use all across the board. This is mostly just search/replace, no actual code changes.
* shared|install: Use InstallChangeType consistentlyCristian Rodríguez2022-11-121-2/+2
| | | | gcc 13 -Wenum-int-mismatch, enabled by default, reminds us enum ! = int
* shared/install: make install_changes_add propagate passed-in errno valueZbigniew Jędrzejewski-Szmek2022-10-241-1/+1
| | | | | | | | | | | The function was written to only return an error from internal allocation failures, because when using it to create a bus message, we want to distinguish a failed operation from an allocation error when sending the reply. But it turns out that the only caller that makes this distinction checks that the passed-in errno value ('type') is not negative beforehand. So we can make the function pass 'type' value through, which makes most of the callers nicer. No functional change.
* install: include full type name in special UnitFilePresetMode valuesLennart Poettering2022-10-141-2/+2
| | | | | | Typically the _MAX and _INVALID special enum values use the full type as prefix, even if the actual values of the enum might not. Let's follow this rule here too.
* install: make InstallChange enum type a proper typeLennart Poettering2022-10-141-10/+13
| | | | | | | We can just make this an enum, as long as we ensure it has enough range, which we can do by adding -ERRNO_MAX as one possible value (at least on GNU C). We already do that at multiple other places, so let's do this here too.
* shared/install: print warning when unmasking unit with cmdline maskZbigniew Jędrzejewski-Szmek2022-10-131-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | 'systemctl unmask foo' will try to remove the symlink to /dev/null under /etc/. But the unit may also be masked by a symlink under /run/generator, in particular the one created by systemd-debug-generator based on systemd.mask=foo on the kernel commandline. The unmask call cannot anything about this: even if it removed the symlink from /run/generator, it'll be recreated on the next daemon-reload. Thus, we can only warn about it. Initially, I wanted to check if 'systemctl.mask' is defined on the kernel command-line, but that's not effective, because such mask symlinks can be created by other generators based on other conditions. Checking for runtime mask is "dumber", but is more robust because it doesn't assume who created the mask and why. The handling of InstallInfo is the copied from install_info_symlink_wants(). It's pretty ugly, this whole code should be rewritten from scratch. The message is printed, but the whole operation is still "successful". This keep backwards compatibility: people might call unmask to remove filesystem masks even if there's still a cmdline param in place. We allow 'systemctl mask' to create such a mask, so 'unmask' should be able to remove it. Fixes #22689.
* shared/install: rename 'UnitFileInstallInfo' to 'InstallInfo'Zbigniew Jędrzejewski-Szmek2022-10-131-3/+3
| | | | | | | - shorter is better - name now matches the defining-file name I was also considering UnitInstallInfo. Can change if people prefer that.
* shared/install: rename 'unit_file_change_type' to 'install_change' + followupsZbigniew Jędrzejewski-Szmek2022-10-131-13/+15
| | | | | | We had an anonymous enum with values called UNIT_FILE_…, which could easily be confused with UNIT_FILE_… from UnitFileFlags enum. This commit renames the enum values and also the variables which refer to them.
* shared/install: rename UnitFileInstallInfo.type to .install_modeZbigniew Jędrzejewski-Szmek2022-10-131-1/+1
|
* shared/install: rename 'unit file type' to 'install mode'Zbigniew Jędrzejewski-Szmek2022-10-131-9/+9
| | | | | git grep -l -nwi 'UnitFileType|UNIT_FILE_TYPE' | \ xargs sed -r -i 's/UnitFileType/InstallMode/g; s/UNIT_FILE_TYPE/INSTALL_MODE/g; s/unit_file_type/install_mode/g'
* shared/install: rename UnitFileChange to InstallChangeZbigniew Jędrzejewski-Szmek2022-10-131-19/+19
| | | | | It's shorter and more generic. The struct can contain info about changes to unit files, but also symlinks and errors.
* shared/install: rename 'files' param to 'names'Zbigniew Jędrzejewski-Szmek2022-10-131-8/+8
| | | | | … or 'name_or_path' or 'names_or_paths' as appropriate. Those functions are generally called with unit names as arguments.
* Rename UnitFileScope to LookupScopeZbigniew Jędrzejewski-Szmek2022-03-291-17/+18
| | | | | | | | | As suggested in https://github.com/systemd/systemd/pull/22649/commits/8b3ad3983f5440eef812b34e5ed862ca59fdf7f7#r837345892 The define is generalized and moved to path-lookup.h, where it seems to fit better. This allows a recursive include to be removed and in general makes things simpler.
* shared/install: split UNIT_FILE_SYMLINK into two statesZbigniew Jędrzejewski-Szmek2022-03-291-1/+2
| | | | | | The two states are distinguished, but are treated everywhere identically, so there is no difference in behaviour except for slighlty different log output.
* shared/install: fix reenable on linked unit filesZbigniew Jędrzejewski-Szmek2022-03-291-1/+1
|
* shared/install: propagate errors about invalid aliases and such tooZbigniew Jędrzejewski-Szmek2022-03-291-1/+6
| | | | | | | If an invalid arg appears in [Install] Alias=, WantedBy=, RequiredBy=, we'd warn in the logs, but not propagate this information to the caller, and in particular not over dbus. But if we call "systemctl enable" on a unit, and the config if invalid, this information is quite important.
* tree-wide: make specifier expansion --root= awareLennart Poettering2021-06-241-0/+1
| | | | | | | | | | | | | | | | | | | | | | This fixes repart's, systemctl's, sysusers' and tmpfiles' specifier expansion to honour the root dir specified with --root=. This is relevant for specifiers such as %m, %o, … which are directly sourced from files on disk. This doesn't try to be overly smart: specifiers referring to runtime concepts (i.e. boot ID, architecture, hostname) rather than files on the medium are left as is. There's certainly a point to be made that they should fail in case --root= is specified, but I am not entirely convinced about that, and it's certainly something we can look into later if there's reason to. I wondered for a while how to hook this up best, but given that quite a large number of specifiers resolve to data from files on disks, and most of our tools needs this, I ultimately decided to make the root dir a first class parameter to specifier_printf(). Replaces: #16187 Fixes: #16183
* shared/install: ignore enablement of template units w/o instance when presettingZbigniew Jędrzejewski-Szmek2021-06-101-4/+5
| | | | | | | | | | | | | When we have a unit which cannot be enabled: # foo@.service: ... [Install] WantedBy=foo.target # there is no instance, so we don't know what to enable we should throw an error when invoked directly with 'enable', but not when doing 'preset' or 'preset-all'. Fixes #19856.
* shared/install: ignore failures for auxiliary filesZbigniew Jędrzejewski-Szmek2021-06-091-0/+1
| | | | | | If Also= fails, warn, but otherwise ignore the failure. Fixes #19407.
* install: warn if WantedBy targets don't existJan Synacek2021-04-231-0/+1
| | | | | | | | | | Currently, if [Install] section contains WantedBy=target that doesn't exist, systemd creates the symlinks anyway. That is just user-unfriendly. Let's be nice and warn about installing non-existent targets. Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1835351. Replaces: #15834
* install: include OS headers before our own definitionLennart Poettering2021-03-041-2/+2
| | | | | Doesn't matter much, but matches more our usual coding style where our definition are done after all headers provided by the OS are included.
* install: make UnitFileChangeType enum anonymousLennart Poettering2021-02-171-11/+11
| | | | | | | | | | We almost never use the named enum type, in almost all cases we use "int" instead, since we overload it with negative errnos. To simplify things, let's use "int" really everywhere. Moreover, let's rename the fields for this enum to "type_or_errno", to make the overloading clear. And let's ad some assertions that things are in the right range.
* shared: use -EINVAL for _UNIT_FILE_CHANGE_TYPE_INVALIDBenjamin Robin2021-02-161-1/+1
| | | | Follow-up of #11484
* tree-wide: use -EINVAL for enum invalid valuesZbigniew Jędrzejewski-Szmek2021-02-101-2/+2
| | | | | | | | | As suggested in https://github.com/systemd/systemd/pull/11484#issuecomment-775288617. This does not touch anything exposed in src/systemd. Changing the defines there would be a compatibility break. Note that tests are broken after this commit. They will be fixed in the next one.
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-091-1/+1
|
* core: add [Enable|Disable]UnitFilesWithFlags DBUS methodsLuca Boccassi2020-09-041-3/+5
| | | | | | | | | | | | | | The new methods work as the unflavoured ones, but takes flags as a single uint64_t DBUS parameters instead of different booleans, so that it can be extended without breaking backward compatibility. Add new flag to allow adding/removing symlinks in [/etc|/run]/systemd/system.attached so that portable services configuration files can be self-contained in those directories, without affecting the system services directories. Use the new methods and flags from portablectl --enable. Useful in case /etc is read-only, with only the portable services directories being mounted read-write.
* install: fix wrong data typefangxiuning2020-07-101-1/+1
|
* shared/install: optionally cache the preset listZbigniew Jędrzejewski-Szmek2020-05-051-1/+10
| | | | | | | | | | When doing list-unit-files with --root, we would re-read the preset list for every unit. This uses a cache to only do it once. The time for list-unit-files goes down by about ~30%. unit_file_query_preset() is also called from src/core/. This patch does not touch that path, since the saving there are smaller, since preset status is only read on demand over dbus, and caching would be more complicated.
* shared/install: rework alias check and add testZbigniew Jędrzejewski-Szmek2020-01-101-1/+1
| | | | | | | | | | | | This mostly reuses existing checkers used by pid1, so handling of aliases should be consistent. Hopefully, with the test it'll be clearer what it happening. Support for .wants/.requires "aliases" is restored. Those are still used in the wild quite a bit, so we need to support them. See https://github.com/systemd/systemd/pull/13119 for a discussion of aliases with an instance that point to a different template: this is allowed.
* shared/install: split out alias verification functionZbigniew Jędrzejewski-Szmek2019-12-191-0/+2
| | | | No functional change.
* Create src/shared/unit-file.[ch] for unit-file related opsZbigniew Jędrzejewski-Szmek2019-07-191-30/+0
| | | | | So far we put such functinos in install.[ch], but that is tied too closely to enable/disable. Let's start moving things to a place with a better name.
* tree-wide: remove Lennart's copyright linesLennart Poettering2018-06-141-4/+0
| | | | | | | | | | | These lines are generally out-of-date, incomplete and unnecessary. With SPDX and git repository much more accurate and fine grained information about licensing and authorship is available, hence let's drop the per-file copyright notice. Of course, removing copyright lines of others is problematic, hence this commit only removes my own lines and leaves all others untouched. It might be nicer if sooner or later those could go away too, making git the only and accurate source of authorship information.
* tree-wide: drop 'This file is part of systemd' blurbLennart Poettering2018-06-141-2/+0
| | | | | | | | | | | | | | | | This part of the copyright blurb stems from the GPL use recommendations: https://www.gnu.org/licenses/gpl-howto.en.html The concept appears to originate in times where version control was per file, instead of per tree, and was a way to glue the files together. Ultimately, we nowadays don't live in that world anymore, and this information is entirely useless anyway, as people are very welcome to copy these files into any projects they like, and they shouldn't have to change bits that are part of our copyright header for that. hence, let's just get rid of this old cruft, and shorten our codebase a bit.
* tree-wide: unify how we define bit mak enumsLennart Poettering2018-06-121-3/+3
| | | | | | Let's always write "1 << 0", "1 << 1" and so on, except where we need more than 31 flag bits, where we write "UINT64(1) << 0", and so on to force 64bit values.
* install: export unit_file_lookup_state()Lennart Poettering2018-05-241-0/+6
|
* tree-wide: be more careful with the type of array sizesLennart Poettering2018-04-271-16/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously we were a bit sloppy with the index and size types of arrays, we'd regularly use unsigned. While I don't think this ever resulted in real issues I think we should be more careful there and follow a stricter regime: unless there's a strong reason not to use size_t for array sizes and indexes, size_t it should be. Any allocations we do ultimately will use size_t anyway, and converting forth and back between unsigned and size_t will always be a source of problems. Note that on 32bit machines "unsigned" and "size_t" are equivalent, and on 64bit machines our arrays shouldn't grow that large anyway, and if they do we have a problem, however that kind of overly large allocation we have protections for usually, but for overflows we do not have that so much, hence let's add it. So yeah, it's a story of the current code being already "good enough", but I think some extra type hygiene is better. This patch tries to be comprehensive, but it probably isn't and I missed a few cases. But I guess we can cover that later as we notice it. Among smaller fixes, this changes: 1. strv_length()' return type becomes size_t 2. the unit file changes array size becomes size_t 3. DNS answer and query array sizes become size_t Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=76745
* install: minor enum beautificationsLennart Poettering2018-04-121-4/+4
|
* tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek2018-04-061-13/+0
| | | | | | | | | | Files which are installed as-is (any .service and other unit files, .conf files, .policy files, etc), are left as is. My assumption is that SPDX identifiers are not yet that well known, so it's better to retain the extended header to avoid any doubt. I also kept any copyright lines. We can probably remove them, but it'd nice to obtain explicit acks from all involved authors before doing that.
* Add SPDX license identifiers to source files under the LGPLZbigniew Jędrzejewski-Szmek2017-11-191-0/+1
| | | | | This follows what the kernel is doing, c.f. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
* install: move and rename to lowercase two functionsZbigniew Jędrzejewski-Szmek2017-09-211-14/+0
| | | | No reason to make them look like macros.
* shared, systemctl: teach is-enabled to show installation targetsJan Synacek2016-10-241-0/+1
| | | | | | | | | | | | | It may be desired by users to know what targets a particular service is installed into. Improve user friendliness by teaching the is-enabled command to show such information when used with --full. This patch makes use of the newly added UnitFileFlags and adds UNIT_FILE_DRY_RUN flag into it. Since the API had already been modified, it's now easy to add the new dry-run feature for other commands as well. As a next step, --dry-run could be added to systemctl, which in turn might pave the way for a long requested dry-run feature when running systemctl start.