Repository navigation
Refusing linking files underneath our hierarchy, improve error messages - #25080
Merged
Merged
Conversation
Member
Author
|
I missed a spot. Should be OK now. |
bluca
reviewed
Oct 20, 2022
bluca
reviewed
Oct 20, 2022
bluca
approved these changes
Oct 20, 2022
Member
|
should go into NEWS - it was a broken case, but it is a small behavior change |
Member
Author
|
Updated with the two suggestions. |
poettering
reviewed
Oct 20, 2022
poettering
reviewed
Oct 20, 2022
poettering
reviewed
Oct 20, 2022
| /* 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) { |
Member
There was a problem hiding this comment.
you are reverting f8662fe with that. At the very least, say so.
Member
Author
There was a problem hiding this comment.
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.
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…
Member
Author
|
The two comments are addressed, restoring the green label. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.