Skip to content

Conversation

@larsewi
Copy link
Contributor

@larsewi larsewi commented Nov 4, 2025

  • Added test for overriding default directory create mode
  • Skip remaining string comparisons after successful match
  • Added override_default_directory_create_mode to body agent control
  • Replaced hardcoded directory create mode with DEFAULTMODE

@larsewi larsewi force-pushed the perms branch 2 times, most recently from c8aa2ca to 294f7ec Compare November 4, 2025 15:10
@larsewi
Copy link
Contributor Author

larsewi commented Nov 4, 2025

@cf-bottom Jenkins please :)

@cf-bottom
Copy link

@larsewi larsewi marked this pull request as ready for review November 5, 2025 08:26
@larsewi
Copy link
Contributor Author

larsewi commented Nov 5, 2025

Build Status
Skipped Debian 13 ARM because it is not happy

Ticket: CFE-4590, ENT-13239
Signed-off-by: Lars Erik Wik <[email protected]>
Allow overriding the default 0700 permissions when `cf-agent` creates
parent directories during file promise repairs.

The new attribute `default_directory_create_mode` in body agent control
enables users to specify custom permissions (e.g., 0755) for
automatically created directories, avoiding the need for explicit perms
promises on each parent directory when deeper paths are required.

This addresses cases where files need broader access permissions but
their auto-created parent directories would otherwise default to 0700,
making the files inaccessible despite having correct permissions.

Example usage:
```
body agent control {
    default_directory_create_mode => "0755";
}
```

Ticket: CFE-4590, ENT-13239
Changelog: Title
Signed-off-by: Lars Erik Wik <[email protected]>
Copy link
Contributor

@craigcomstock craigcomstock left a comment

Choose a reason for hiding this comment

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

looks good.

{
Log(LOG_LEVEL_VERBOSE, "SET select_end_match_eof %s", (char *) value);
EvalContextSetSelectEndMatchEof(ctx, BooleanFromString(value));
continue;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why? I don't understand the context or the reason for the change and what the change does.

I noticed around line 1141 there is another block that doesn't continue I wonder if this whole block of code needs to be audited for correct logic?

if (strcmp(cp->lval, CFA_CONTROLBODY[AGENT_CONTROL_ALLCLASSESREPORT].lval) == 0)

Copy link
Contributor Author

@larsewi larsewi Nov 7, 2025

Choose a reason for hiding this comment

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

We are checking if the string matches any of the possible attributes. Once we find a match, we don't need to check if it matches the remaining attributes, because we know implicitly that they will not match.

There is no change in behavior, just less CPU cycles wasted.

Copy link
Member

Choose a reason for hiding this comment

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

Feels like i am just showing what i dont know about the code

but, @larsewi your description there made me wonder if this would be affected:

body common control
{
   default_directory_create_mode => "000";
   default_directory_create_mode => "770";
}

It's a silly example, but in some policies the same attribtue is set differently in different contexts and multiple contexts might apply.

I just wanted to be sure that not continuing to check for the attribute will not affect this (in the above simple example, expect the last one to win).

@larsewi
Copy link
Contributor Author

larsewi commented Nov 7, 2025

@cf-bottom Jenkins please :)

@larsewi larsewi requested a review from olehermanse November 7, 2025 15:04
@cf-bottom
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

5 participants