summaryrefslogtreecommitdiffstats
path: root/src/shared/install.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* tree-wide: use path_simplify_alloc() moreYu Watanabe2023-10-071-5/+3
|
* Merge pull request #29193 from keszybz/path-util-adjustmentDaan De Meyer2023-09-291-14/+7
|\ | | | | Make unit mangling follow paths
| * tree-wide: add path_simplify_alloc() and use itZbigniew Jędrzejewski-Szmek2023-09-221-14/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | path_simplify_full()/path_simplify() are changed to allow a NULL path, for which a NULL is returned. Generally, callers have already asserted before that the argument is nonnull. This way path_simplify_full()/path_simplify() and path_simplify_alloc() behave consistently. In sd-device.c, logging in device_set_syspath() is intentionally dropped: other branches don't log. In mount-tool.c, logging in parse_argv() is changed to log the user-specified value, not the simplified string. In an error message, we should show the actual argument we got, not some transformed version.
* | treewide: split commandline into command lineJoerg Behrmann2023-09-201-1/+1
|/
* install: Drop install_info_may_process() from unit_file_get_default()Daan De Meyer2023-08-181-3/+0
| | | | | | This currently makes unit_file_get_default() fail if the default target is transient which shouldn't make us fail to get the default unit.
* Drop split-usr and unmerged-usr supportLuca Boccassi2023-07-281-5/+0
| | | | | | | | | | As previously announced, execute order 66: https://lists.freedesktop.org/archives/systemd-devel/2022-September/048352.html The meson options split-usr, rootlibdir and rootprefix become no-ops that print a warning if they are set to anything other than the default values. We can remove them in a future release.
* stat-util: rename files_same() → inode_same()Lennart Poettering2023-05-191-1/+1
| | | | | | | | | | | Let's be more accurate about what this function does: it checks whether the underlying reported inode is the same. Internally, this already uses a better named stat_inode_same() call, hence let's similarly name the wrapping function following the same logic. Similar for files_same_at() and path_equal_or_same_files(). No code changes, just some renaming.
* unit-file: support UpheldBy= in [Install] settings (adding Upholds= depsMike Yuan2023-05-151-5/+16
| | | | | | from .upholds/) Closes #26896
* preset: Add ignore directiveDaan De Meyer2023-04-141-12/+33
| | | | | | 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.
* Merge pull request #27266 from dtardon/take-structLuca Boccassi2023-04-141-2/+1
|\ | | | | Use TAKE_STRUCT() to copy and reset structs
| * tree-wide: use TAKE_STRUCTDavid Tardon2023-04-141-2/+1
| |
* | install: use FOREACH_ARRAYDavid Tardon2023-04-141-2/+2
| |
* | tree-wide: rename cleanup functionDavid Tardon2023-04-141-5/+5
| | | | | | | | ... with accordance to the current coding style.
* | install: fix memory leak if GREEDY_REALLOC() failsDavid Tardon2023-04-141-6/+11
|/
* install: rename functionDavid Tardon2023-04-121-4/+4
|
* install: drop unused functionDavid Tardon2023-04-121-4/+0
|
* install: define hash_ops for UnitFileListDavid Tardon2023-03-281-0/+8
|
* chase-symlinks: Rename chase_symlinks() to chase()Daan De Meyer2023-03-241-4/+4
| | | | | | | | | Chasing symlinks is a core function that's used in a lot of places so it deservers a less verbose names so let's rename it to chase() and chaseat(). We also slightly change the pattern used for the chaseat() helpers so we get chase_and_openat() and similar.
* basic: add RuntimeScope enumLennart Poettering2023-03-101-46/+46
| | | | | | | | | | | | 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.
* install: fail early if specifier expansion failedDavid Tardon2023-02-211-0/+2
| | | | | | | | | | | | | | | | | Before: systemd[1]: Assertion 'path' failed at src/shared/install.c:288, function install_changes_add(). Aborting. systemd[1]: Caught <ABRT> from our own process. systemd[1]: Caught <ABRT>, dumped core as pid 2525. systemd[1]: Freezing execution After: Failed to enable unit: Invalid specifier in user-%J.service Fixes #26467. Follow-up for: f5a0162
* treewide: fix a few typos in NEWS, docs and commentsDmitry V. Levin2023-02-151-1/+1
|
* pid1: fix segv triggered by status query (#26279)Robin Humble2023-02-011-1/+1
| | | | | | | | | | | | If any query makes it to the end of install_info_follow() then I think symlink_target is set to NULL. If that is followed by -EXDEV from unit_file_load_or_readlink(), then that causes basename(NULL) which segfaults pid 1. This is triggered by eg. "systemctl status crond" in RHEL9 if /etc/systemd/system/crond.service -> /ram/etc/systemd/system/crond.service -> /usr/lib/systemd/system/.crond.service.blah.blah -> /usr/lib/systemd/system/crond.service
* shared/install: rework an assert to appease gcc-13Zbigniew Jędrzejewski-Szmek2023-01-221-1/+2
| | | | | | With the previous form, gcc is confused and thinks that .type might be unset. Fixes #26118.
* shared/install: rework InstallChange to always have .path setZbigniew Jędrzejewski-Szmek2023-01-221-2/+6
| | | | | | | | | We would set .path in all cases except INSTALL_CHANGE_AUXILIARY_FAILED, where we would just just .source. This special case is just not worth it, because we can't easily assert that .path is set. Let's remove this special case to help the compiler know that .path is actually set. Avoids a warning with gcc-13.0.1-0.1.fc38.x86_64.
* systemctl: enable: overwrite broken alias symlinksMike Yuan2023-01-051-1/+9
| | | | | | | | When switching to an alternative alias provider, the previous one might have been uninstalled or so. It should be fine for us to overwrite them directly. Closes #23694
* tree-wide: use -EBADF for fd initializationZbigniew Jędrzejewski-Szmek2022-12-191-2/+2
| | | | | | | | | | | | | | | | -1 was used everywhere, but -EBADF or -EBADFD started being used in various places. Let's make things consistent in the new style. Note that there are two candidates: EBADF 9 Bad file descriptor EBADFD 77 File descriptor in bad state Since we're initializating the fd, we're just assigning a value that means "no fd yet", so it's just a bad file descriptor, and the first errno fits better. If instead we had a valid file descriptor that became invalid because of some operation or state change, the other errno would fit better. In some places, initialization is dropped if unnecessary.
* systemctl: warn if trying to disable a unit with no install infoMike Yuan2022-12-031-4/+17
| | | | | | | | | | | Trying to disable a unit with no install info is mostly useless, so adding a warning like we do for enable (with the new dbus method 'DisableUnitFilesWithFlagsAndInstallInfo()'). Note that it would still find and remove symlinks to the unit in /etc, regardless of whether it has install info or not, just like before. And if there are actually files to remove, we suppress the warning. Fixes #17689
* Rename def.h to constants.hZbigniew Jędrzejewski-Szmek2022-11-081-1/+1
| | | | | | The name "def.h" originates from before the rule of "no needless abbreviations" was established. Let's rename the file to clarify that it contains a collection of various semi-related constants.
* install: process all Wants= symlinks even if some of them failYu Watanabe2022-10-281-5/+11
| | | | | | Follow-up for 94e7298d309fef7710174def820e9d38e512a086. Fixes CID#1499992.
* systemctl,manager: refuse linking unit files underneath the search pathsZbigniew Jędrzejewski-Szmek2022-10-241-3/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | We treat symlinks to unit files outside of the search path differently from symlinks to unit files *in* the search path. The former are "linked" unit files, while the latter are enablement symlinks and such and will be removed when disabling the unit. The history of the check for in_search_path() is interesting: this condition was added already in the first version of the code in 830964834f330836b9d33752e83de09d4f38da87. Since the beginning, matching arguments would simply be ignored. I think this is dubious. The man page says: > Link a unit file that is *not* in the unit file search paths > into the unit file search path But for backwards-compat, let's continue to silently do nothing for files *in* the search path. The case of symlinks to unit files underneath the search path, but in some subdirectory, is less clear. We didn't check for this case, so it was implicitly allowed. But that's just an oversight, we don't want to allow people to create additional subhierarchies under our hierarchy. Let's check for this case and refuse. Closes #24605.
* shared/install: check that install_changes_add() didn't fail on successZbigniew Jędrzejewski-Szmek2022-10-241-19/+41
| | | | | | | This adds a check for an allocation error for the calls to install_changes_add() where we're plannig to return success from the call. In cases where we're returning failure, it doesn't matter as much: the operation will fail anyway, and if the allocation fails, we'll just get a less descriptive error message.
* shared/install: add forgotten calls to install_changes_add()Zbigniew Jędrzejewski-Szmek2022-10-241-25/+24
| | | | | | | | | The machinery to report a good error message only works if the error was registered with install_changes_add() and a file name. Otherwise we only get a generic "Op failed: %m" message. In some places -EINVAL is replaced by -EUCLEAN, so that we get the proper error message.
* shared/install: make install_changes_add propagate passed-in errno valueZbigniew Jędrzejewski-Szmek2022-10-241-49/+31
| | | | | | | | | | | 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.
* Make comment about coordinating offline and online installation symmetricZbigniew Jędrzejewski-Szmek2022-10-201-0/+2
| | | | https://github.com/systemd/systemd/pull/24728#issuecomment-1260966910
* install: include full type name in special UnitFilePresetMode valuesLennart Poettering2022-10-141-3/+3
| | | | | | 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-25/+21
| | | | | | | 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-3/+29
| | | | | | | | | | | | | | | | | | | | | | | | | '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: use cleanup func for InstallInfo*Zbigniew Jędrzejewski-Szmek2022-10-131-50/+40
| | | | | In the next commit cleanup will be used in one more place. This change avoids proliferation of the open-coded cleanup calls.
* shared/install: rename 'UnitFileInstallInfo' to 'InstallInfo'Zbigniew Jędrzejewski-Szmek2022-10-131-45/+45
| | | | | | | - 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-47/+47
| | | | | | 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-29/+30
|
* shared/install: rename 'unit file type' to 'install mode'Zbigniew Jędrzejewski-Szmek2022-10-131-36/+36
| | | | | 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-71/+71
| | | | | 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-47/+50
| | | | | … or 'name_or_path' or 'names_or_paths' as appropriate. Those functions are generally called with unit names as arguments.
* tree-wide: port things dirname_malloc() → path_extract_directory()Lennart Poettering2022-08-231-21/+27
|
* tree-wide: allow ASCII fallback for → in logsDavid Tardon2022-06-281-1/+2
|
* Revert "shared/install: create relative symlinks for enablement and aliasing"Zbigniew Jędrzejewski-Szmek2022-05-051-9/+5
| | | | | | | | | | | This reverts commit d6c9411072901556176ac130f2ce71a33107aa93. I still think this is something that needs to be done, but we're hitting some unexplained failures, e.g. https://github.com/systemd/systemd/issues/22920. So let's revert this for now, so -rc2 can be released, with a plan to return to this after a release. Closes #22920.
* shared/install: use correct cleanup functionYu Watanabe2022-05-021-1/+1
| | | | Fixes #23250.
* shared/install: fix crash when reenable is called without --rootZbigniew Jędrzejewski-Szmek2022-04-151-1/+1
|
* tree-wide: add a space after if, switch, for, and whileYu Watanabe2022-04-011-1/+1
|