-
Notifications
You must be signed in to change notification settings - Fork 142
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
rename: adjust all mount points #666
Open
gahr
wants to merge
1
commit into
BastilleBSD:master
Choose a base branch
from
gahr:adjust-all-mount-points
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1
−18
Open
Changes from all commits
Commits
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 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
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.
Why are you removing all these lines?
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 don't have much familiarity with this code, I just fixed it to fit my use case, so let's go through it.
My proposal is to change occurrences of
${bastille_jailsdir}/${TARGET}
into${bastille_jailsdir}/${NEWNAME}
in the fstab file. I think this is hardly debatable: we are renaming the jail${TARGET}
into the jail${NEWNAME}
, so all mount points that were pointing to the former now need to point to the latter.So why did I remove all other lines? I think the old code was trying to match a particular mount point into fstab, namely, the
..../root/.bastille
mountpoint. The original bug is that it left all other custom mount points alone, unrenamed.So, my take is to sed them all, which makes the rest of the code useless.
The linprocfs/linsysfs special case should also be covered, although I don't understand why the leading dot in the string matched in
sed -i '' "s|.${bastille_jailsdir}/${TARGET}/|${bastille_jailsdir}/${NEWNAME}/|" "${FSTAB_CONFIG}"
.Hope this helps clarify.
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.
Yes I see what you mean.
However, what happens if a jail is named the same as a directory in the path specified?
Say you have a directory mounted into a jail named test, and the jail is also named test?
What do you think would be the best way to solve this?
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.
This is actually a problem for the whole of the bastille project. Rename.sh and clone.sh use the approach you do to rename fstab and jail.conf files.
I suppose we could document that you should try to never name your jails in a similar manner as your directories.
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.
How would that match
${bastille_jailsdir}/${TARGET}
or${bastille_jailsdir}/${NEWNAME}
? You'd have to have a path, say, /usr/local/bastille/jails/foo underbastlle_jailsdir
, so your mount point could be:In this case, yes, my approach would rename both TARGET to NEW, while probably you only want to rename the first.
I'd say it's still safer than what we're doing now...
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.
It looks like the only place it's called is here. I'm good with this change, unless @cedwards has a good reason to retain the original code.
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.
@tschettervictor did you test this code on your system also??
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.
Still working on that...
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.
My testing confirms that the old code does not rename the mount points at all.
However, I would keep the old code.
In the "clone.sh" function this line
sed -i '' "s|${bastille_jailsdir}/${TARGET}/root/|${bastille_jailsdir}/${NEWNAME}/root/|" "${FSTAB_CONFIG}"
is added, which is not present in the "rename.sh"
I would argue that we should just make the "rename" code identical to the "clone" code as they attempt to do the exact same thing.
The current code does in fact change the RELEASE mount point, but does not touch any other custom mount points.
Here is the code from the "clone.sh"
I would just add the last line here to the rename function, but keep the old code in place just in case.
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.
At the same time, the original code was trying to do something as simple as rename the entire RELEASE fstab, when it is far easier to just rename all occurrences of the old jail to the new jail.
Unless @cedwards was trying to do something specific with it...