Primary instance default mount to wrong folder
Describe the bug
When creating a primary instance, the default behavior is supposed to be that a default mount from the home folder /home/user to /home/ubuntu/Home, but in my setup the snap automatically mounts home/user/snap/multipass/****/, where the last folder is a number, instead of /home/user. The edge snap also suffers from the same error. The bug only happens in the snap, while the built version (edge) is free from the error.
To Reproduce How, and what happened?
- sudo snap install multipass
- multipass shell
Expected behavior That it mounts the home folder as expected. Logs
─[$] multipass shell
Launched: primary
Mounted '/home/user/snap/multipass/16067' into 'primary:Home'
Welcome to Ubuntu 24.04.3 LTS (GNU/Linux 6.8.0-87-generic x86_64)
Nov 20 15:30:56 thinkpad multipassd[756787]: Returning setting local.privileged-mounts=true
Nov 20 15:30:56 thinkpad multipassd[756787]: initializing mount /home/[email protected]/snap/multipass/16173 => /home/ubuntu/Home in 'primary'
Nov 20 15:30:56 thinkpad multipassd[756787]: Executing 'which snap'
Nov 20 15:30:56 thinkpad multipassd[756787]: Executing 'sudo snap list multipass-sshfs'
Nov 20 15:30:56 thinkpad multipassd[756787]: Executing '[ -e /snap ]'
Nov 20 15:30:56 thinkpad multipassd[756787]: Installing the multipass-sshfs snap in 'primary'
Nov 20 15:30:56 thinkpad multipassd[756787]: Executing 'sudo snap install multipass-sshfs'
Nov 20 15:31:13 thinkpad multipassd[756787]: process program '/snap/multipass/16173/bin/sshfs_server'
Nov 20 15:31:13 thinkpad multipassd[756787]: process arguments '10.250.12.175, 22, ubuntu, /home/[email protected]/snap/multipass/16173, /home/ubuntu/Home, 1706264238:-1,, 1706264238:-1,, 3'
Nov 20 15:31:13 thinkpad multipassd[756787]: Applied AppArmor policy: multipass.primary.3a2af002.sshfs_server
Nov 20 15:31:13 thinkpad multipassd[756787]: QMP: {"timestamp": {"seconds": 1763649070, "microseconds": 328987}, "event": "RTC_CHANGE", "data": {"offset": 0, "qom-path": "/machine/unattached/device[4]/rtc"}}
Nov 20 15:31:13 thinkpad multipassd[756787]: [757509] started: /snap/multipass/16173/bin/sshfs_server 10.250.12.175 22 ubuntu /home/[email protected]/snap/multipass/16173 /home/ubuntu/Home 1706264238:-1, 1706264238:-1, 3
Nov 20 15:31:13 thinkpad sshfs_server[757509]: /build/multipass/parts/multipass/src/src/sshfs_mount/sshfs_mount.cpp:130 make_sftp_server(source = /home/[email protected]/snap/multipass/16173, target = /home/ubuntu/Home, …):
Nov 20 15:31:13 thinkpad sshfs_server[757509]: Executing 'snap run multipass-sshfs.env'
Nov 20 15:31:14 thinkpad sshfs_server[757509]: Executing 'sudo env LD_LIBRARY_PATH=/snap/multipass-sshfs/145/lib /snap/multipass-sshfs/145/bin/sshfs -V'
Nov 20 15:31:14 thinkpad sshfs_server[757509]: Executing 'sudo /bin/bash -c 'P="/home/ubuntu/Home"; while [ ! -d "$P/" ]; do P="${P%/*}"; done; echo $P/''
Nov 20 15:31:14 thinkpad sshfs_server[757509]: Executing 'id -u'
Nov 20 15:31:14 thinkpad sshfs_server[757509]: /build/multipass/parts/multipass/src/src/sshfs_mount/sshfs_mount.cpp:141 make_sftp_server(): `id -u` = 1000
Nov 20 15:31:14 thinkpad sshfs_server[757509]: Executing 'id -g'
Nov 20 15:31:14 thinkpad sshfs_server[757509]: /build/multipass/parts/multipass/src/src/sshfs_mount/sshfs_mount.cpp:145 make_sftp_server(): `id -g` = 1000
Nov 20 15:31:14 thinkpad sshfs_server[757509]: Executing 'sudo /bin/bash -c 'cd "/home/ubuntu/" && mkdir -p "Home"''
Nov 20 15:31:14 thinkpad sshfs_server[757509]: Executing 'sudo /bin/bash -c 'cd "/home/ubuntu/" && chown -R 1000:1000 "Home"''
Nov 20 15:31:14 thinkpad sshfs_server[757509]: Executing 'sudo env LD_LIBRARY_PATH=/snap/multipass-sshfs/145/lib /snap/multipass-sshfs/145/bin/sshfs -o slave -o transform_symlinks -o allow_other -o Compression=no -o dir_cache=no :"/home/[email protected]/snap/multipass/16173" "/home/ubuntu/Home"'
Nov 20 15:31:15 thinkpad multipassd[756787]: Saved file `/var/snap/multipass/common/data/multipassd/multipassd-vm-instances.json` successfully in attempt #1
Additional info
- OS: Ubuntu 24.04.3
- CPU architecture or model: amd64
- 1.16.1 snap, 1.17.0-dev
Additional context I am using authd and other autoinstalled software that may be causing this issue.
Could not reproduce here, FWIW. What does echo $HOME say for you?
And echo $SNAP_REAL_HOME?
This is where we get the user's home: https://github.com/canonical/multipass/blob/43b8b9af177c3090ab6565e5154a687b7853b012/src/client/cli/cmd/launch.cpp#L138-L150
$HOME says what it should: /home/user. $SNAP_REAL_HOME if run from outside echos nothing, but within the snap it also echos /home/user. The error does not happen in the built version, so I am expecting it is some sort of interaction between the authd installation and the snap. Usage of the primary instance may be low, but as more people use authd we may see an increase of reports on this issue.
WDYT?
PD: Snap connections seem to be fine.
Puzzling. You're saying that those vars have the right values in snap run --shell multipass, right? Not sure what mechanism could be causing Multipass to see something else.
Correct 👍