Skip to content

CFE-4621: tests/files: Check owner on created files with content#5995

Merged
larsewi merged 1 commit into
cfengine:masterfrom
btriller:files-create-content-owner
Jan 4, 2026
Merged

CFE-4621: tests/files: Check owner on created files with content#5995
larsewi merged 1 commit into
cfengine:masterfrom
btriller:files-create-content-owner

Conversation

@btriller

Copy link
Copy Markdown
Contributor

Check that promised files created without create attribute have owner promised on creation.

@btriller

Copy link
Copy Markdown
Contributor Author

... what is already fixed in master

body common control
{
}

bundle agent __main__
{
  vars:
    "owner" string => 'sys';
    "files"  slist => { 'content' };

  files:
    "/tmp/$(files)" delete => tidy;

    "/tmp/content"
      perms   => mo("644", $(owner)),
      content => "";

  reports:
    "CFEngine version: $(sys.cf_version)";
    "OK: $(files) has owner $(with)==$(owner)"
      with   => nth(getuserinfo(filestat("/tmp/$(files)", "uid")), "username"),
      if     => strcmp($(owner), $(with));

    "FAIL: $(files) has owner $(with)!=$(owner)"
      with   => nth(getuserinfo(filestat("/tmp/$(files)", "uid")), "username"),
      unless => strcmp($(owner), $(with));
}

body delete tidy
{
      dirlinks => "delete";
      rmdirs   => "true";
}

body perms mo(mode,user)
{
      owners => { "$(user)" };
      mode   => "$(mode)";
      rxdirs => "false";
}
    info: Deleted file '/tmp/content'
    info: Created file '/tmp/content', mode 0644
    info: Owner of '/tmp/content' was 0, set to 3
R: CFEngine version: 3.27.0a.3c1612d7d
R: OK: content has owner sys==sys

but not in 3.24.3

sudo cf-agent -KIf ./blub.cf
    info: Deleted file '/tmp/content'
    info: Created file '/tmp/content', mode 0644
R: CFEngine version: 3.24.3
R: FAIL: content has owner root!=sys

@btriller btriller changed the title tests/files: Check owner on created files with content CFE-4621: tests/files: Check owner on created files with content Dec 13, 2025
@larsewi

larsewi commented Dec 15, 2025

Copy link
Copy Markdown
Contributor

@cf-bottom Jenkins please :)

@cf-bottom

Copy link
Copy Markdown

@larsewi

larsewi commented Dec 18, 2025

Copy link
Copy Markdown
Contributor

Thanks for submitting the PR @btriller 🚀 We will get back to it shortly

@larsewi

larsewi commented Dec 19, 2025

Copy link
Copy Markdown
Contributor

@cf-bottom Jenkins please :)

@cf-bottom

Copy link
Copy Markdown

@larsewi larsewi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check that promised files created without create attribute have owner
promised on creation.
@btriller btriller force-pushed the files-create-content-owner branch from 45a988c to f866786 Compare December 19, 2025 15:04
@btriller btriller requested a review from larsewi December 19, 2025 19:10
@larsewi

larsewi commented Jan 2, 2026

Copy link
Copy Markdown
Contributor

@cf-bottom Jenkins please :)

@cf-bottom

Copy link
Copy Markdown

@larsewi larsewi merged commit 9d6ea6b into cfengine:master Jan 4, 2026
46 of 49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants