The home directory for the snap_daemon user is `/nonexistent` by default, and we run into the following error when we try to invoke the charmed-mysql.xtrabackup binary with the snap_daemon user in python using subprocess:
```
cmd_run.go:1046: WARNING: cannot create user data directory: cannot create snap home dir: mkdir /nonexistent: permission denied
cmd_run.go:1046: WARNING: cannot create user data directory: cannot create snap home dir: mkdir /nonexistent: permission denied
Sorry, home directories outside of /home are not currently supported.
See https://forum.snapcraft.io/t/11209 for details.
Sorry, home directories outside of /home are not currently supported.
```
The python code that tries to execute charmed-mysql.xtrabackup binary as the snap_daemon user is:
```
import subprocess
user = "snap_daemon"
group = "snap_daemon"
command = "charmed-mysql.xtrabackup --help".split()
env = {}
The MySQL charm uses the charmed-mysql snap (https:/ /github. com/canonical/ charmed- mysql-snap). This snap contains all the binaries required to run a MySQL charm (e.g. mysql-server, mysql-shell, xtrabackup, etc) installed from apt packages. The charmed-mysql snap has a daemon (https:/ /github. com/canonical/ charmed- mysql-snap/ blob/8. 0/edge/ snap/snapcraft. yaml#L54- L60) to run mysqld, which is run as the snap_daemon user (https:/ /github. com/canonical/ charmed- mysql-snap/ blob/8. 0/edge/ snap/local/ start-mysqld. sh#L3-L4).
Since mysqld is run as snap_daemon, the MySQL data files are owned by the snap_daemon user. Thus, when the charm runs an application binary (e.g. xtrabackup - https:/ /github. com/canonical/ charmed- mysql-snap/ blob/8. 0/edge/ snap/snapcraft. yaml#L100- L105), it must be run as snap_daemon to have access to the data files.
The home directory for the snap_daemon user is `/nonexistent` by default, and we run into the following error when we try to invoke the charmed- mysql.xtrabacku p binary with the snap_daemon user in python using subprocess:
``` /forum. snapcraft. io/t/11209 for details.
cmd_run.go:1046: WARNING: cannot create user data directory: cannot create snap home dir: mkdir /nonexistent: permission denied
cmd_run.go:1046: WARNING: cannot create user data directory: cannot create snap home dir: mkdir /nonexistent: permission denied
Sorry, home directories outside of /home are not currently supported.
See https:/
Sorry, home directories outside of /home are not currently supported.
```
The python code that tries to execute charmed- mysql.xtrabacku p binary as the snap_daemon user is:
```
import subprocess
user = "snap_daemon" mysql.xtrabacku p --help".split()
group = "snap_daemon"
command = "charmed-
env = {}
process = subprocess.run( output= True, "utf-8" ,
command,
user=user,
group=group,
capture_
text=True,
env=env,
encoding=
)
print("stdout: ", process.stdout)
print("stderr: ", process.stderr)
```