-
Notifications
You must be signed in to change notification settings - Fork 680
many: reintroduce fdstore helpers #16784
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ZeyadYasser
merged 10 commits into
canonical:master
from
ZeyadYasser:add-fdstore-helpers-second-attempt
Jun 9, 2026
Merged
Changes from 6 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
3ad9149
many: reintroduce fdstore helpers
ZeyadYasser d8d83fb
systemd/fdstore: address review comments
ZeyadYasser f3f4c40
systemd/fdstore: add comment
ZeyadYasser c3febc7
systemd/fdstore: address review comments
ZeyadYasser 949d887
systemd/fdstore: address review comments
ZeyadYasser 6c74eb0
data/systemd: add service unit option to support fdstore
ZeyadYasser 76af8a9
systemd/fdstore: address review comments
ZeyadYasser 87d0a60
fixup! systemd/fdstore: address review comments
ZeyadYasser b65c133
fixup! systemd/fdstore: address review comments
ZeyadYasser 5059e41
fixup! systemd/fdstore: fix activation listeners cleanup
ZeyadYasser File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| // -*- Mode: Go; indent-tabs-mode: t -*- | ||
|
|
||
| /* | ||
| * Copyright (C) 2025 Canonical Ltd | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License version 3 as | ||
| * published by the Free Software Foundation. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| * | ||
| */ | ||
|
|
||
| package fdstore | ||
|
|
||
| import ( | ||
| "net" | ||
| "os" | ||
|
|
||
| "github.com/snapcore/snapd/testutil" | ||
| ) | ||
|
|
||
| func MockOsGetenv(f func(key string) string) (restore func()) { | ||
| return testutil.Mock(&osGetenv, f) | ||
| } | ||
|
|
||
| func MockOsUnsetenv(f func(key string) error) (restore func()) { | ||
| return testutil.Mock(&osUnsetenv, f) | ||
| } | ||
|
|
||
| func MockOsLookupEnv(f func(key string) (string, bool)) (restore func()) { | ||
| return testutil.Mock(&osLookupEnv, f) | ||
| } | ||
|
|
||
| func MockOsGetpid(f func() int) (restore func()) { | ||
| return testutil.Mock(&osGetpid, f) | ||
| } | ||
|
|
||
| func MockUnixCloseOnExec(f func(fd int)) (restore func()) { | ||
| return testutil.Mock(&unixCloseOnExec, f) | ||
| } | ||
|
|
||
| func MockUnixDup(f func(oldfd int) (fd int, err error)) (restore func()) { | ||
| return testutil.Mock(&unixDup, f) | ||
| } | ||
|
|
||
| func MockSdNotify(f func(notifyState string) error) (restore func()) { | ||
| return testutil.Mock(&sdNotify, f) | ||
| } | ||
|
|
||
| func MockSdNotifyWithFds(f func(notifyState string, files ...*os.File) error) (restore func()) { | ||
| return testutil.Mock(&sdNotifyWithFds, f) | ||
| } | ||
|
|
||
| func MockNetFileListener(f func(f *os.File) (ln net.Listener, err error)) (restore func()) { | ||
| return testutil.Mock(&netFileListener, f) | ||
| } | ||
|
|
||
| func MockOsFileClose(f func(*os.File) error) (restore func()) { | ||
| return testutil.Mock(&osFileClose, f) | ||
| } | ||
|
|
||
| func KnownFdNames() map[FdName]bool { | ||
| return knownFdNames | ||
| } | ||
|
|
||
| func Clear() { | ||
| fdstore = nil | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think systemd ignores what it does not know. So we could set it. But I would do it only if we it was tested. Maybe with a spread test even. Otherwise I would not even have it as a comment.