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.sh now accepts nullfs mounted files #737

Closed
wants to merge 1 commit into from

Conversation

nullobsi
Copy link

It is sometimes desirable to nullfs mount a single file into a jail, like resolv.conf, hosts, or otherwise. However, using a MOUNT in a Bastillefile with a file mount currently throws an error. The script needs a small adaptation to accept files.

@bmac2
Copy link
Collaborator

bmac2 commented Dec 8, 2024

PR and reason makes sense. We need to test this one and then merge if no issues.
@yaazkal @cedwards

@bmac2
Copy link
Collaborator

bmac2 commented Dec 17, 2024

@tschettervictor can you test this one also so we can make sure it is good

@tschettervictor
Copy link
Collaborator

tschettervictor commented Dec 22, 2024

So the flow here seems to be this.

If the host path is a directory or a file, then it is acceptable.

I had an issue mounting the file though. This was because the mount command expects the file to be present or it will fail to mount.

I would change the command to the following.

    ## Create mount point if it does not exist
    if [ -d "${_hostpath}" ] && [ ! -d "${_fullpath}" ]; then
        mkdir -p "${_fullpath}" || error_exit "Failed to create mount point inside jail."
    elif [ -f "${_hostpath}" ] && [ ! -f "${_fullpath}" ]; then
        mkdir -p "$( dirname ${_fullpath} )" || error_exit "Failed to create mount point inside jail."
        touch "${_fullpath}" || error_exit "Failed to create mount point inside jail."
    fi

This will

  1. Create a directory if the specified path is actually a directory.
  2. Simply touch and create the file at the mount point if the specified path is a file and doesn't exist.

The above worked fine for me. @nullobsi

@tschettervictor
Copy link
Collaborator

tschettervictor commented Dec 22, 2024

I've updated my last comment.

This will ensure that if the file you are trying to mount is not present inside the jail, it will first be created, and also, if there are directories missing in the files path, they will also be created.

Tests are passing with that block.

@tschettervictor
Copy link
Collaborator

Only things you are missing is inside the "umount" command. That check also needs to be changed from "-d" to "-e"

@tschettervictor
Copy link
Collaborator

Hmmm. There are actually way more bugs in the mound and unmount that I first realized.
If you don't mind, I'm going to open another PR addressing them.

I'll include this one to allow file mounting also.

@bmac2
Copy link
Collaborator

bmac2 commented Dec 28, 2024

@tschettervictor should this one be closed since you opened another PR to address this along with the other mount errors?

@tschettervictor
Copy link
Collaborator

I believe so. My PR fixes this along with a number of other bugs I found.

@bmac2
Copy link
Collaborator

bmac2 commented Dec 31, 2024

fixed in #778

@bmac2 bmac2 closed this Dec 31, 2024
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.

3 participants