Skip to content

Refusing linking files underneath our hierarchy, improve error messages - #25080

Merged
yuwata merged 6 commits into
systemd:mainfrom
keszybz:search-paths
Oct 24, 2022
Merged

yuwata merged 6 commits into
systemd:mainfrom
keszybz:search-paths

Conversation

@keszybz

@keszybz keszybz commented Oct 20, 2022

Copy link
Copy Markdown
Member

No description provided.

@bluca bluca added the ci-fails/needs-rework 🔥 Please rework this, the CI noticed an issue with the PR label Oct 20, 2022
@keszybz keszybz removed the ci-fails/needs-rework 🔥 Please rework this, the CI noticed an issue with the PR label Oct 20, 2022
@keszybz

keszybz commented Oct 20, 2022

Copy link
Copy Markdown
Member Author

I missed a spot. Should be OK now.

Comment thread src/shared/install.c Resolved
Comment thread src/shared/install.c Resolved
@bluca

bluca commented Oct 20, 2022

Copy link
Copy Markdown
Member

should go into NEWS - it was a broken case, but it is a small behavior change

@keszybz keszybz added good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed and removed good-to-merge/with-minor-suggestions labels Oct 20, 2022
@keszybz

keszybz commented Oct 20, 2022

Copy link
Copy Markdown
Member Author

Updated with the two suggestions.

Comment thread src/shared/install.c Resolved
Comment thread src/shared/install.c Resolved
Comment thread src/core/dbus-manager.c Outdated
/* When making changes here, make sure to also change install_changes_dump() in install.c. */

switch (changes[i].type) {
switch (changes[i].change_or_error) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are reverting f8662fe with that. At the very least, say so.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

f8662fe actually reverts (part of) 1308f72. Frankly, I didn't look at the history, and thought that I dropped the rename from that pull request somehow, as it underwent a lot of review and reworks, and I ended up dropping at least one patch. But as I wrote in #25002, this is getting into bikeshed territory so I'll drop this commit instead.

@poettering poettering added reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks and removed good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed labels Oct 20, 2022
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.
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.
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.
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
8309648. 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 systemd#24605.
We said "search path" and "search paths" in the same sentence…
@keszybz

keszybz commented Oct 24, 2022

Copy link
Copy Markdown
Member Author

The two comments are addressed, restoring the green label.

@keszybz keszybz removed the reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks label Oct 24, 2022
@keszybz keszybz added the good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed label Oct 24, 2022
@yuwata
yuwata merged commit 8207ec4 into systemd:main Oct 24, 2022
@keszybz
keszybz deleted the search-paths branch October 24, 2022 18:28
@keszybz keszybz removed the good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed label Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

systemctl link should refuse when target is inside systemd own's hierarchy

4 participants