Snap application cannot be run as snap_daemon user out of the box
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
snapd |
New
|
Undecided
|
Unassigned |
Bug Description
The MySQL charm uses the charmed-mysql snap (https:/
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:/
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-
```
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-
```
import subprocess
user = "snap_daemon"
group = "snap_daemon"
command = "/snap/
env = {}
process = subprocess.run(
command,
user=user,
group=group,
capture_
text=True,
env=env,
encoding=
)
print("stdout: ", process.stdout)
print("stderr: ", process.stderr)
```