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

Mount/Umount fixes and improvements #778

Merged
merged 15 commits into from
Dec 31, 2024

Conversation

tschettervictor
Copy link
Collaborator

@tschettervictor tschettervictor commented Dec 24, 2024

This PR fixes a bunch of bugs found in mount and umount, and adds the ability to mount files as well as directories.

It also included the "set_target" function, as well as a new "error_continue" function that is always called inside loops to continue to the next jail if an error occurs in the event of "ALL" as a target.

To test

  1. Mount and unmount directory. Make sure to mount and unmount when they are already mounted to test if it will return that they are already mounted/unmounted
  2. Do the above with files also
  3. Do the above with directories have spaces in them, making sure to enclose in quotes and use backslashes for the spaces like "bastille mount jail "/my/test\ directory\ here" /mnt/jail/path" or even (not recommended) "bastille mount jail "/my/test\ directory\ here" "/mnt/jail/path\ with\ space""

Make sure that when you retry the mount/umount commands, that it returns the correct error saying that 1. it has been already mounted, 2. the mount doesn't exist

#737

@bmac2
Copy link
Collaborator

bmac2 commented Dec 26, 2024

steps to test this please.

@tschettervictor
Copy link
Collaborator Author

Mount a file or folder into a jail, then unmount it.
Try it with a folder and with a file.

It should work.

I was finding that at times it would enter the mount multiple times into the fstab file. So
I moved the grep block to the first thing it does.

Also, this allows to mount files like so "bastille mount jail /etc/rc.conf mnt/etc.conf" or "bastille mount jail /etc/rc.conf /mnt/etc.conf" with or without the leading slash. This PR will trim make sure there are no // in the path.

You can also mount bastille mount jail /etc/rc.conf mnt" and it will simply mount at /mnt/etc.rc.conf

The old way had bugs like

  1. Of the file was not present it couldn't mount.
  2. It would overwrite if a file was present, where this PR takes care of that by erroring if a file is already there

@tschettervictor tschettervictor changed the title Mount/Umount fixes Mount/Umount fixes and improvements Dec 27, 2024
@bmac2
Copy link
Collaborator

bmac2 commented Dec 31, 2024

tested working

@bmac2 bmac2 merged commit 4365082 into BastilleBSD:master Dec 31, 2024
1 check passed
@tschettervictor tschettervictor deleted the mount-fixes branch December 31, 2024 22:09
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