privilege: normalize the end of the generated sudoers file - #1448
Merged
Conversation
This was referenced Aug 10, 2026
The generated sudoers file ended with a trailing blank line, and every policy entry appended its own "\n" regardless of whether it produced any content. Entries yielding an empty sudoers section therefore emitted a stray newline, and the file always finished with one blank line more than needed. Collect the non-empty sections and join them with a single blank line separator instead, so sections stay visually separated but the file ends with exactly one newline. The golden files are updated accordingly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
denisonbarbosa
force-pushed
the
split/privilege-sudoers
branch
from
August 10, 2026 14:21
27955b8 to
62aceee
Compare
There was a problem hiding this comment.
Pull request overview
Normalizes generated sudoers formatting while preserving blank-line separation between policy sections.
Changes:
- Collects non-empty sudoers sections and joins them consistently.
- Adds formatting coverage and updates affected golden files.
Reviewed changes
Copilot reviewed 33 out of 33 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
internal/policies/privilege/privilege.go |
Normalizes sudoers section spacing and final newline. |
internal/policies/privilege/privilege_test.go |
Tests section separation and trailing newline behavior. |
internal/policies/testdata/TestApplyPolicies/golden/succeed/etc/sudoers.d/99-adsys-privilege-enforcement |
Updates normalized golden output. |
internal/policies/testdata/TestApplyPolicies/golden/succeed_if_checking_for_backend_online_status_returns_an_error/etc/sudoers.d/99-adsys-privilege-enforcement |
Updates normalized golden output. |
internal/policies/privilege/testdata/TestApplyPolicy/golden/set_client_user_admins/sudoers.d/99-adsys-privilege-enforcement |
Updates normalized golden output. |
internal/policies/privilege/testdata/TestApplyPolicy/golden/set_client_multiple_users_admins/sudoers.d/99-adsys-privilege-enforcement |
Updates normalized golden output. |
internal/policies/privilege/testdata/TestApplyPolicy/golden/set_client_mixed_with_users_and_group_admins/sudoers.d/99-adsys-privilege-enforcement |
Updates normalized golden output. |
internal/policies/privilege/testdata/TestApplyPolicy/golden/set_client_group_admins/sudoers.d/99-adsys-privilege-enforcement |
Updates normalized golden output. |
internal/policies/privilege/testdata/TestApplyPolicy/golden/overwrite_existing_sudoers_file/sudoers.d/99-adsys-privilege-enforcement |
Updates normalized golden output. |
internal/policies/privilege/testdata/TestApplyPolicy/golden/overwrite_existing_polkit_file/sudoers.d/99-adsys-privilege-enforcement |
Updates normalized golden output. |
internal/policies/privilege/testdata/TestApplyPolicy/golden/don't_overwrite_other_existing_files/sudoers.d/99-adsys-privilege-enforcement |
Updates normalized golden output. |
internal/policies/privilege/testdata/TestApplyPolicy/golden/disallow_local_admins/sudoers.d/99-adsys-privilege-enforcement |
Updates normalized golden output. |
internal/policies/privilege/testdata/TestApplyPolicy/golden/disallow_local_admins_with_previous_local_admin_conf_and_set_client_admins/sudoers.d/99-adsys-privilege-enforcement |
Updates normalized golden output. |
internal/policies/privilege/testdata/TestApplyPolicy/golden/disallow_local_admins_and_set_client_admins/sudoers.d/99-adsys-privilege-enforcement |
Updates normalized golden output. |
internal/policies/privilege/testdata/TestApplyPolicy/golden/create_on_new_polkit_version_and_remove_old_file/sudoers.d/99-adsys-privilege-enforcement |
Updates normalized golden output. |
internal/policies/privilege/testdata/TestApplyPolicy/golden/assume_old_polkit_if_cant_read_system_reserved_path/sudoers.d/99-adsys-privilege-enforcement |
Updates normalized golden output. |
internal/policies/privilege/testdata/TestApplyPolicy/golden/allow_local_admins_without_previous_local_admin_conf_and_set_client_admins/sudoers.d/99-adsys-privilege-enforcement |
Updates normalized golden output. |
internal/policies/privilege/testdata/TestApplyPolicy/golden/allow_local_admins_with_previous_local_admin_conf_and_set_client_admins/sudoers.d/99-adsys-privilege-enforcement |
Updates normalized golden output. |
internal/policies/privilege/testdata/TestApplyPolicy/golden/allow_local_admins_with_previous_local_admin_conf_(with_adsys_file)_and_set_client_admins/sudoers.d/99-adsys-privilege-enforcement |
Updates normalized golden output. |
internal/policies/privilege/testdata/TestApplyPolicy/golden/allow_local_admins_with_previous_local_admin_conf_(simple)_and_set_client_admins/sudoers.d/99-adsys-privilege-enforcement |
Updates normalized golden output. |
cmd/adsysd/integration_tests/testdata/TestPolicyUpdate/golden/refresh_with_one_dangling_symlink_ignores_the_respective_user/sudoers.d/99-adsys-privilege-enforcement |
Updates integration golden output. |
cmd/adsysd/integration_tests/testdata/TestPolicyUpdate/golden/refresh_with_no_user_connected_updates_machines/sudoers.d/99-adsys-privilege-enforcement |
Updates integration golden output. |
cmd/adsysd/integration_tests/testdata/TestPolicyUpdate/golden/refresh_some_connected/sudoers.d/99-adsys-privilege-enforcement |
Updates integration golden output. |
cmd/adsysd/integration_tests/testdata/TestPolicyUpdate/golden/refresh_all_connected/sudoers.d/99-adsys-privilege-enforcement |
Updates integration golden output. |
cmd/adsysd/integration_tests/testdata/TestPolicyUpdate/golden/machine,_update_old_data/sudoers.d/99-adsys-privilege-enforcement |
Updates integration golden output. |
cmd/adsysd/integration_tests/testdata/TestPolicyUpdate/golden/machine,_first_time/sudoers.d/99-adsys-privilege-enforcement |
Updates integration golden output. |
cmd/adsysd/integration_tests/testdata/TestPolicyUpdate/golden/machine,_first_time_with_winbind_backend/sudoers.d/99-adsys-privilege-enforcement |
Updates integration golden output. |
cmd/adsysd/integration_tests/testdata/TestPolicyUpdate/golden/host_is_offline,_regenerate_machine_from_old_data/sudoers.d/99-adsys-privilege-enforcement |
Updates integration golden output. |
cmd/adsysd/integration_tests/testdata/TestPolicyUpdate/golden/host_is_offline,_mach_gpos_cache_is_cleared,_with_policies_cache/sudoers.d/99-adsys-privilege-enforcement |
Updates integration golden output. |
cmd/adsysd/integration_tests/testdata/TestPolicyUpdate/golden/host_is_offline,_get_machine_from_cache_(no_update)/sudoers.d/99-adsys-privilege-enforcement |
Updates integration golden output. |
cmd/adsysd/integration_tests/testdata/TestPolicyUpdate/golden/does_not_error_when_d-bus_proxy_object_is_not_available/sudoers.d/99-adsys-privilege-enforcement |
Updates integration golden output. |
cmd/adsysd/integration_tests/testdata/TestPolicyUpdate/golden/does_not_error_when_certmonger_or_cepces_is_not_available/sudoers.d/99-adsys-privilege-enforcement |
Updates integration golden output. |
cmd/adsysd/integration_tests/testdata/TestPolicyUpdate/golden/already_up_to_date/sudoers.d/99-adsys-privilege-enforcement |
Updates integration golden output. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
adombeck
approved these changes
Aug 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Split out of #1401 as an unrelated drive-by fix, so it can be reviewed and land on its own.
The generated sudoers file ended with a trailing blank line, and every policy entry appended its own
\nwhether or not it produced content. Entries yielding an empty sudoers section emitted a stray newline, and the file always finished with one blank line more than needed.Sections are now collected and joined with a single blank-line separator, so they stay visually separated but the file ends with exactly one newline. Golden files updated accordingly.
Independent of the certificate work — no dependency on the rest of the stack.