Skip to content

Snapshot automount (.zfs) still fails under chroot (OpenSSH ChrootDirectory) #8903

Description

@mattgarber

System information

Type Version/Name
Distribution Name Debian
Distribution Version 9.9 (Stretch)
Linux Kernel 4.9.0-9-amd64
Architecture amd64
ZFS Version 0.8.0-1
SPL Version 0.8.0-1

Describe the problem you're observing

When attempting to browse auto-mounting ZFS dataset snapshots (.zfs/snapshot directory) over a chrooted SFTP (OpenSSH’s ChrootDirectory directive), snapshot access fails with the following error:

WARNING: Unable to automount /.zfs/snapshot/2019-06-13T221233/tank/backups/test01@2019-06-13T221233: 512

Browsing snapshots in this manner works as intended if ChrootDirectory is not set (not a workable solution, due to needing to restrict SFTP client access to the filesystem), and also works correctly on FreeBSD (11.2-RELEASE, 12.0-RELEASE), presumably because of differing methods of auto-mounting snapshot access.

This appears to be extremely similar to #3778, and @behlendorf indicated various fixes landing in 0.6.x and 0.7.x, although perhaps it wasn’t fully resolved for all kinds of chroot? The error is clear, in that the mount operation is being called on the SFTP client’s view of the filesystem (where /tank/backups/test01 appears as /), even though it should be resolved outside of the chroot.

I first ran into this issue on Ubuntu 18.04, running distro-provided zfs/spl 0.7.5, although attempted this reproduction on Debian with the latest 0.8.0 release to see whether the #3778 discussion/fixes were landed after Ubuntu’s version.

Describe how to reproduce the problem

  1. Create a new dataset for hosting restricted client content, e.g. tank/backups/test01, mounted at /tank/backups/test01.

  2. Create some dummy files, and create a symlink at the top of the dataset, pointing to the hidden snapshots directory: ln -s .zfs/snapshot snapshots. (The symlink is only so that SFTP clients don’t have to explicitly view hidden files, it’s not a prerequisite for reproducing the issue!)

  3. Create a few snapshots of the dataset: zfs snapshot tank/backups/test01@one, zfs snapshot tank/backups/test01@two.

  4. Create a test user (e.g. test01) and configure OpenSSH to restrict access for that particular user, including ChrootDirectory, and restart sshd. E.g.:

Match User test01
	ChrootDirectory /tank/backups/test01
	ForceCommand internal-sftp -l INFO -u 022
	PasswordAuthentication yes
  1. Connect via SFTP as specified test user. Verify that dummy files and directories are successfully browsable.

  2. Change into the snapshots symlink (.zfs/snapshot), and verify that snapshots list is accurate. (The symlink is only so that SFTP clients don’t have to explicitly view hidden files, it’s not a prerequisite for reproducing the issue!)

  3. Attempt to enter one or more snapshot directories. No content will appear, and kernel log on host system will include one or more errors similar to above: WARNING: Unable to automount /.zfs/snapshot/one/tank/backups/test01@one: 512.

Include any warning/errors/backtraces from the system logs

[ 5061.371785] WARNING: Unable to automount /.zfs/snapshot/2019-06-13T221233/tank/backups/test01@2019-06-13T221233: 512
[ 5061.457781] WARNING: Unable to automount /.zfs/snapshot/2019-06-13T221233/tank/backups/test01@2019-06-13T221233: 512
[ 5061.464070] WARNING: Unable to automount /.zfs/snapshot/2019-06-13T221233/tank/backups/test01@2019-06-13T221233: 512
[ 5063.660823] WARNING: Unable to automount /.zfs/snapshot/2019-06-13T221233/tank/backups/test01@2019-06-13T221233: 512
[ 5063.747940] WARNING: Unable to automount /.zfs/snapshot/2019-06-13T221233/tank/backups/test01@2019-06-13T221233: 512
[ 5063.757878] WARNING: Unable to automount /.zfs/snapshot/2019-06-13T221233/tank/backups/test01@2019-06-13T221233: 512

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: DefectIncorrect behavior (e.g. crash, hang)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions