Skip to content

write_files silently fails to set special bits (setuid/setgid/sticky) in permissions #6225

@azrdev

Description

@azrdev

Bug report

Trying to create a file with special permission bits set using the write_files module raises no error, the correct permissions are printed to the log, but are never set on the file.

Asked this on IRC and got confirmation from @blackboxsw (thanks!)

Steps to reproduce the problem

# user-data
write_files:
  - path: /usr/local/bin/deploy
    content: "#!/bin/sh"
    owner: root:root
    permissions: '4111'

Logs to /var/log/cloud-init.log a line similar to Writing to /usr/local/bin/deploy - wb: [4111] 379 bytes, that is it contains the desired mode 4111

But the file afterwards has permissions 111 (setuid bit cleared).

Environment details

  • Cloud-init version: 21.1-7.el8
  • Operating System Distribution: Rocky Linux
  • Cloud provider, platform or installer type: Openstack

cloud-init logs

2025-05-15 08:44:56,491 - util.py[DEBUG]: Writing to /usr/local/sbin/vault-deploy-certificates - wb: [4111] 379 bytes

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions