Add -j <jail> flag to route(8) to allow route to perform actions in
a Jail.
Details
Diff Detail
- Repository
- rG FreeBSD src repository
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
Thank you for working on this! Conceptually it LGTM, please see a comment on the implementation part.
sbin/route/route.c | ||
---|---|---|
237 | I'd rather save the parameter here and explicitly call some jail_attach wrapper later. This will help keep argument parsing and business logic split, hopefully maintaining the same level of readability |
@melifaro Thank you so much for reviewing and the suggestion! I have moved the jail attach bit out and added the missed Makefile changes. (oops)
sbin/route/route.c | ||
---|---|---|
238 | Do we need usejail at all? |
It reads to me like initialising jail_name to NULL and replacing if (usejail) with if (jail_name != NULL) would make the usejail variable superfluous. Splitting a pointer and its validity into two variables like this (jail_name and usejail) introduces the potential for contradiction if only one of the two is updated. If this split is required for something I would like to see them stored together in a struct { char *, bool } instead of destructured into two variables.
sbin/route/route.c | ||
---|---|---|
238 | It reads to me like initialising jail_name to NULL and replacing if (usejail) with if (jail_name != NULL) would make the usejail variable superfluous. Splitting a pointer and its validity into two variables like this (jail_name and usejail) introduces the potential for contradiction if only one of the two is updated. If this split is required for something I would like to see them stored together in a struct { char *, bool } instead of destructured into two variables. |
The jail_name variable must be initialised to NULL. This should be done through an explicit char * jail_name = NULL; in line 101 of route.c.
You're correct. Looking at just the diff again I assumed it was allocated on the stack instead of in the bss section.