Skip to content

Conversation

@btriller
Copy link
Contributor

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

@btriller
Copy link
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
Copy link
Contributor

larsewi commented Dec 15, 2025

@cf-bottom Jenkins please :)

@cf-bottom
Copy link

@larsewi
Copy link
Contributor

larsewi commented Dec 18, 2025

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

@larsewi
Copy link
Contributor

larsewi commented Dec 19, 2025

@cf-bottom Jenkins please :)

@cf-bottom
Copy link

Copy link
Contributor

@larsewi larsewi left a comment

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
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