-
Notifications
You must be signed in to change notification settings - Fork 148
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
Fix alignment when listing jails with more than one IP address #691
Conversation
When a VNET jail has more than IP address configured on its primary interface, invoking "bastille list -a" will now display all addresses vertically aligned.
Thanks, I personally prefer the space instead of the extra characters for the first two columns. Now, does this support printing the published ports corresponding to each IP? does this support different hostname per IP? Regards |
@vrachnis I really need the steps you went through to add a second ip to a vnet jail. I have googled, read the jail.conf manual and can not figure out how to set a second ip to a vnet jail. |
when I run your list with a normal jail with multiple ip root@fbsd:/usr/local/share/bastille # bastille list -a |
apologies for missing the previous comments here. I just found the notification emails.
I've added the second IPs using rc.conf, and specifically using the config from carp(4):
That said, I just tried and I was able to create a jail with standard aliases (and no carp):
This generates the following output (using the patch from this PR):
Note that those are only applicable to vnet jails. For standard jails, the IPs are defined in jail.conf using commas as you said. I could also port this multiline behaviour to non-vnet output if you'd like me to.
Correct. I didn't like the complexity of the logic if I tried to use the extra bracket characters, so I didn't submit that. The only reason I mentioned it is that if the reviewers preferred it, I could bring that in.
That's a very good question. I've never used
Not really. The hostname logic is still the same; that is to say list.sh pulls the |
Regarding the rdr elements, I think it's not meant to work with vnet jails using the current implementation. Trying to add a new redirection gives me an error:
If I try to see the pf rule that it generated, I get this:
With the key line being:
This generates Looking at pf.conf(5), it seems that the
I believe that because of this VNET check, we end up having an empty JAIL_IP, which then goes on to break this and this rule. So coming back to the original question:
No, it does not. That's because rdr doesn't work for vnet jails, and this patch only affects the output when vnet is enabled. When vnet is disabled, the IP list is pulled from jail.cof. As long as there are no new lines in the IP list, the new logic is disabled and uses the existing output format Thinking out loud (because I don't have a v6 set of addresses from my ISP to test with), the JAIL_IP variable could still be multiline for non-vnet jails if IPv6 and IPv4 addresses are assigned at the same time. That would trigger the if statement to use the new logic, and that wouldn't show the published ports any differently than what we already do. However, considering that rdr.sh adds the same rules for the v4 and the v6 address, that is (probably) not a bad thing and better than having new line characters in the middle of the IP list for the jail? |
tested with vnet jails with multiple ip addresses, works as advertised. |
When a VNET jail has more than IP address configured on its primary interface, invoking
bastille list -a
will now display all addresses vertically aligned. This is to address a misalignment issue where the fields following the ip addresses were no longer in the same line as the jail name.For instance:
With this change, all additional IPs for a given jail are aligned vertically, and the fields following the IP (ports, hostname, release, path) are all in the same line as the jail name:
Considerations
Grouping of IPs
Initially I attempted to use line-drawing characters to visualize the fact that all addresses belong to the same jail:
While the result was making it clear to the user where the extra line comes from, the implementation became unnecessarily complex. More importantly, it meant that if anyone parses the output of
bastille list -a
in their script, would have to account for the fact that the "primary" IP address would be in either the third or fourth field of the line.This highlights the fact that with this, the first and second/third/etc addresses will still be on different fields. The first address will be on field number 3, while the following addresses will be on field number 1. I could potentially modify the output to put some dummy characters in the first two columns, although I'm not sure that I like the result. Let me know if something like the following is preferable.
Dependencies
No new dependencies were introduced.