Open
Conversation
This is a stepping stone to a linux port
markjdb
reviewed
Nov 8, 2023
Owner
markjdb
left a comment
There was a problem hiding this comment.
Thanks, this looks like a good start. My comments are mostly about reducing code duplication.
|
|
||
| // Starting with linux unfriendly code (pdfork) | ||
| // ?? errno? | ||
| if ((pid = pdfork(&pd, PD_CLOEXEC)) < 0) |
Owner
There was a problem hiding this comment.
pdfork() is roughly equivalent to fork()+pidfd_open() on Linux, I believe.
| if (firstdot) | ||
| *firstdot = '\0'; | ||
| } | ||
| #endif |
Owner
There was a problem hiding this comment.
You should be able to do something like
#define cap_getnameinfo(channel, ...) getnameinfo(__VA_ARGS__)
in the non-capsicum case, and then everything ought to work without any code duplication.
| goto cleanup; | ||
| #endif | ||
|
|
||
| // Loop here until service is stopped |
Owner
There was a problem hiding this comment.
Please use C-style comments, just to keep things consistent.
| const char *, const char *, const char *); | ||
| int netdump_cap_herald(struct cap_channel *, int *, struct sockaddr_in *, | ||
| uint32_t *, char **); | ||
|
|
| if (error != 0 && *nsd >= 0) | ||
| (void)close(*nsd); | ||
| return (error); | ||
| } |
Owner
There was a problem hiding this comment.
It should be possible to avoid duplication with cap_herald.c by refactoring the code a bit:
- change netdump_cap_herald() to call herald_command() directly when capsicum is not configured,
- refactor herald_command() to avoid using nvlists directly, instead just using C out-parameters or a structure or something.
I believe you could also use libnv on Linux: https://github.com/fudosecurity/nvlist
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.
This is a stepping stone to a linux port
I have tested dumping from a OneFS node and reading the core from an internal kgdb container. Please let me know what testing you would like to see performed.