Skip to content

Inconsistent template file permissions for containers and VMs #19055

Description

@jonathan-conder

Please confirm

  • I have searched existing issues to check if an issue already exists for the bug I encountered.

Distribution

Ubuntu

Distribution version

24.04

Output of snap list --all lxd core20 core22 core24 core26 snapd

Name    Version      Rev    Tracking       Publisher   Notes
core22  20260410     2437   latest/stable  canonical✓  base,disabled
core22  20260824     2955   latest/stable  canonical✓  base
core24  20260317     1587   latest/stable  canonical✓  base,disabled
core24  20260410     1643   latest/stable  canonical✓  base
core26  20260531     409    latest/stable  canonical✓  base,disabled
core26  20260629     462    latest/stable  canonical✓  base
lxd     6.9-ab8fad2  40424  6/stable       canonical✓  -
snapd   2.76.2       27710  latest/stable  canonical✓  snapd,disabled
snapd   2.76.3       27738  latest/stable  canonical✓  snapd

System info

n/a

Instance log

n/a

Expected behavior

When copying an instance, the file mode of when: copy templates should not depend on whether the instance is a container or a VM.

Actual behavior

When copying a VM, all templated files are reset to 0644. When copying a container, the files retain their original mode.

Steps to reproduce

Run this script:

set -e

lxc init ubuntu:24.04 c1
lxc init --vm ubuntu:24.04 v1

for t in c1 v1; do
    lxc config template create $t probe.tpl
    echo templated | lxc config template edit $t probe.tpl
    lxc config metadata show $t \
        | yq '.templates."/etc/probe" = {"when": ["create", "copy"], "template": "probe.tpl"}' \
        | lxc config metadata edit $t

    lxc start $t
    until lxc exec $t -- systemctl is-system-running --wait 2>/dev/null; do sleep 1; done
    lxc exec $t -- chmod 0600 /etc/probe
    echo "$t:   $(lxc exec $t -- stat -c %a /etc/probe)"

    lxc stop $t
    u=${t/1/2}
    lxc copy $t $u
    lxc start $u
    until lxc exec $u -- true 2>/dev/null; do sleep 1; done
    echo "$u:   $(lxc exec $u -- stat -c %a /etc/probe)"
done

Current output:

Creating c1
Creating v1
Failed to connect to bus: No such file or directory
running
c1:   600
c2:   600
running
v1:   600
v2:   644

Ideal output:

Creating c1
Creating v1
Failed to connect to bus: No such file or directory
running
c1:   600
c2:   600
running
v1:   600
v2:   600

Information to attach

  • Any relevant kernel output (dmesg)
  • Instance configuration (lxc config show <instance> --expanded)
  • Main daemon log (at /var/log/lxd/lxd.log or /var/snap/lxd/common/lxd/logs/lxd.log)
  • If a lxc command fails, output of the command with --debug
  • Output of the daemon with --debug (or use lxc monitor while reproducing the issue)

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

    No labels
    No labels

    Type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions