write_files recursively sets ownership to root:root, ignores owner directive.

Bug #1745978 reported by Chris Glass
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cloud-init
New
Undecided
Unassigned

Bug Description

The "write_files" cloud init directive tramples on folder permissions while ignoring the "owner" directive, resulting in wrong ownership of "root:root" being set all along the file path.

Provider: LXD (maybe/probably others too)

Cloud-init version:
17.1-46-g7acc9e68-0ubuntu1~16.04.1

Sample cloud config:

#cloud-config
write_files:
- content: |
    Example content.
  path: /home/ubuntu/example
  owner: ubuntu:ubuntu
  permissions: '0600'

Expected behavior:

A "/home/ubuntu/example" file is created, with "ubuntu:ubuntu" as owner and a permission of 600. Permissions of the parent /home/ubuntu folder do not change.

What actually happens:

A "/home/ubuntu/example" file is created, with an owner of "root:root" and a permission of 600.
The "/home/ubuntu" folder now *also* has "root:root" as owner, resulting in a non-writable home for the "ubuntu" user.

The permissions should:

1) Honor the chosen user:group pair
2) Only set permission on parent folders if they do not already exist.

Revision history for this message
Chris Glass (tribaal) wrote :

/var/log/cloud-init.log -> https://paste.ubuntu.com/26483428/

(notice the python stacktrace)

/var/log/cloud-init-output.log -> https://paste.ubuntu.com/26483440/

description: updated
Revision history for this message
Chris Glass (tribaal) wrote :

This bug might be a duplicate of 1486113, although 1486113 fails to capture "changing the parent directory's permissions"

Revision history for this message
Mohammad Bhuyan (mohammad-bhuyan) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.