coreos / coreos/ignition

Add sugar for creating containing directories with specified ownership/perms

Open
#2,265 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

butane
Dominant language
Go
Stars
974
Forks
296
Avg merge
6d 14h
Merged PRs (30d)
9

Description

Created originally in Butane by @bgilbert: https://github.com/coreos/butane/issues/380


Ignition creates containing directories for files/dirs/links specified in the config, but it gives them default ownership/permissions rather than the ones specified for the file/dir/link. This ensures that containing directories have safe default ownership. It's still possible to override the parents' ownership/perms by explicitly specifying the containing directories in the directories section.

But it's not especially ergonomic. A deeply-nested file might need several containing directories, each of which needs to be spelled out explicitly. This makes sense for Ignition configs, which are intentionally low-level, but it'd be nice to have Butane sugar to avoid this.

The main issue here will be syntax. Butane doesn't know which directories already exist, and we can't override perms on every containing directory all the way up to the root. For example, if creating /home/builder/.config/systemd/user/default.target.wants/something.service, we might want to set ownership for builder/.config/systemd/user/default.target.wants but not /home. I don't think the ecosystem has a conventional syntax for this.

We could do something like this:

variant: fcos
version: 1.5.0-experimental
storage:
  files:
    - path: /home/builder/.config/systemd/user/default.target.wants/something.service
      user:
        name: builder
      contents:
        inline: invalid
  directories:
    - path: /home/builder/.config/systemd/user/default.target.wants
      base: /home
      user:
        name: builder

That has the disadvantages of being verbose and difficult to understand.

We could merge the "parent directories" fields into the files/directories/links sections, but we can't reuse a file mode as a directory mode, so we might want another field or so:

variant: fcos
version: 1.5.0-experimental
storage:
  files:
    - path: /home/builder/.config/systemd/user/default.target.wants/something.service
      user:
        name: builder
      contents:
        inline: invalid
      parents:
        base: /home
        mode: 0700

Discussion thread

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the linked Butane issue and the Fedora discussion thread, then inspect how Butane represents storage files, directories, and links. The issue names no files or tests; done requires an agreed syntax for parent-directory ownership and permissions plus implementation and coverage for the proposed behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.