Skip to content

multipass exec yields unexpected result when command invoked uses sudo #3933

@jnsgruk

Description

@jnsgruk

Describe the bug
If I run a command with multipass exec that involves sudo, the SUDO_ environemnt variables inside the machine are not as I would expect

To Reproduce

multipass exec juju-dev -- sudo env | grep SUDO_
SUDO_COMMAND=/usr/bin/env
SUDO_USER=root
SUDO_UID=0
SUDO_GID=0

Expected behavior
I would expect the SUDO_USER to be set to ubuntu, SUDO_UID to 1000, etc. If multipass shell is used, that is the case:

multipass shell juju-dev

ubuntu@juju-dev:~$ sudo env | grep SUDO_
SUDO_COMMAND=/usr/bin/env
SUDO_USER=ubuntu
SUDO_UID=1000
SUDO_GID=1000

Logs
Please provide logs from the daemon, see accessing logs on where to find them on your platform.

Additional info

  • OS: Ubuntu 24.10
  • CPU architecture or model: amd64
  • multipass version: 1.15.0
  • multipass info:
multipass info
Name:           juju-dev
State:          Running
Snapshots:      0
IPv4:           10.61.201.101
                10.77.151.1
                10.1.0.60
Release:        Ubuntu 24.04.1 LTS
Image hash:     28d2f9df3ac0 (Ubuntu 24.04 LTS)
CPU(s):         2
Load:           1.06 1.09 0.83
Disk usage:     11.4GiB out of 48.4GiB
Memory usage:   2.2GiB out of 3.8GiB
Mounts:         /home/jon => /home/ubuntu/jon
                    UID map: 1000:default
                    GID map: 1000:default
  • multipass get local.driver: qemu

Additional context

First reported here: canonical/concierge#37
cc @omar-selo

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions