Skip to content

Exclude user nfsnobody when checking home directories#8426

Merged
ggbecker merged 2 commits intoComplianceAsCode:stabilization-v0.1.61from
mildas:home_dir_exclude_nfsnobody
Mar 25, 2022
Merged

Exclude user nfsnobody when checking home directories#8426
ggbecker merged 2 commits intoComplianceAsCode:stabilization-v0.1.61from
mildas:home_dir_exclude_nfsnobody

Conversation

@mildas
Copy link
Copy Markdown
Contributor

@mildas mildas commented Mar 25, 2022

Description:

Filter user nfsnobody on RHEL7 systems.

Rationale:

Similar to #8393 fix

Fixes #8419

@mildas mildas requested a review from yuumasato March 25, 2022 12:33
@github-actions
Copy link
Copy Markdown

Start a new ephemeral environment with changes proposed in this pull request:

Open in Gitpod

@yuumasato yuumasato self-assigned this Mar 25, 2022

{{%- if product == 'rhel7' %}}
<unix:password_state id="state_file_permissions_home_files_permissions_nfsnobody" version="1">
<unix:username datatype="string" operation="equals">nfsnobody</unix:username>
Copy link
Copy Markdown
Member

@ggbecker ggbecker Mar 25, 2022

Choose a reason for hiding this comment

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

Suggested change
<unix:username datatype="string" operation="equals">nfsnobody</unix:username>
<unix:username datatype="string" operation="pattern match">^(nobody|nfsnobody)$</unix:username>

Can't we do something like this and remove the nobody from line 13 and make this filter applicable to all products?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nfsnobody shouldn't be expected to be a regular user even in other platforms, even though it should be technically possible

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We can, but I didn't want other products to have more users excluded than necessary.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hmm, maybe it is fine then.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

What is the conclusion? Should add nobody there or not?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's do the following:

Line 13:
<unix:username datatype="string" operation="pattern match">.*</unix:username>

Then we keep the filter exclude for all platforms but we assign the list of users to a jinja variable (example) according to the product, for example:

rhel7 and ol7 - "nobody|nfsnobody"
other products - "nobody"

then

Suggested change
<unix:username datatype="string" operation="equals">nfsnobody</unix:username>
<unix:username datatype="string" operation="pattern match">^({{{ user_list }}})$</unix:username>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Apply the above to all rules including rules from: #8393

Copy link
Copy Markdown
Member

@yuumasato yuumasato Mar 25, 2022

Choose a reason for hiding this comment

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

rhel7 and ol7 - "nobody|nfsnobody"
other products - "nobody"

I think we need achors in the regex, like:
^(nobody|nfsnobody)$

Otherwise a user named Anobody would be excluded.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ahh, I see the anchors in the xml now, :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Where to define the variable with user list? I don't think rule.yml is a good place as it would be basically redundant.

@yuumasato yuumasato assigned ggbecker and unassigned yuumasato Mar 25, 2022
@mildas
Copy link
Copy Markdown
Contributor Author

mildas commented Mar 25, 2022

I've put the variable to shared/macros-oval.jinja because I see it related only to OVAL check.

@mildas mildas force-pushed the home_dir_exclude_nfsnobody branch from 6d34767 to 256614f Compare March 25, 2022 16:07
@mildas mildas force-pushed the home_dir_exclude_nfsnobody branch from 256614f to 0370567 Compare March 25, 2022 16:08
@ggbecker ggbecker merged commit 49e6ad9 into ComplianceAsCode:stabilization-v0.1.61 Mar 25, 2022
@yuumasato yuumasato added this to the 0.1.61 milestone Mar 25, 2022
@yuumasato yuumasato added the bugfix Fixes to reported bugs. label Mar 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Fixes to reported bugs.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants