Skip to content
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

Add non capsicum build option #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vthyng
Copy link

@vthyng vthyng commented Nov 8, 2023

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.

This is a stepping stone to a linux port
Copy link
Owner

@markjdb markjdb left a comment

Choose a reason for hiding this comment

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

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)
Copy link
Owner

Choose a reason for hiding this comment

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

pdfork() is roughly equivalent to fork()+pidfd_open() on Linux, I believe.

if (firstdot)
*firstdot = '\0';
}
#endif
Copy link
Owner

Choose a reason for hiding this comment

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

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.


// Loop here until service is stopped
Copy link
Owner

Choose a reason for hiding this comment

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

Please use C-style comments, just to keep things consistent.

@@ -33,11 +33,19 @@
struct cap_channel;
struct sockaddr_in;

#ifdef WITH_CAPSICUM
int netdump_cap_handler(struct cap_channel *, const char *, const char *,
const char *, const char *, const char *);
int netdump_cap_herald(struct cap_channel *, int *, struct sockaddr_in *,
uint32_t *, char **);

Copy link
Owner

Choose a reason for hiding this comment

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

Extra newline here.

if (error != 0 && *nsd >= 0)
(void)close(*nsd);
return (error);
}
Copy link
Owner

Choose a reason for hiding this comment

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants