-
Notifications
You must be signed in to change notification settings - Fork 791
expand chronyd_specify_remote_server to be aligned with CIS #14241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jan-cerny
merged 4 commits into
ComplianceAsCode:master
from
vojtapolasek:improve_chronyd_specify_remote_servers
Dec 19, 2025
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
6c23929
expand the rule chronyd_specify_remote_server to cover more use cases
vojtapolasek ed69eee
add tests
vojtapolasek cc4c67c
updating chronyd_specify_remote_server
Arden97 cd70d32
updating ansible remediation for chronyd_specify_remote_server
Arden97 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
104 changes: 95 additions & 9 deletions
104
linux_os/guide/services/ntp/chronyd_specify_remote_server/oval/shared.xml
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,20 @@ description: |- | |
| <tt>Chrony</tt> can be configured to be a client and/or a server. | ||
| Add or edit server or pool lines to <tt>{{{ chrony_conf_path }}}</tt> as appropriate: | ||
| <pre>server <remote-server></pre> | ||
| Alternatively, server or pool directives can be specified in files included via | ||
| <tt>sourcedir</tt> or <tt>confdir</tt> directives in <tt>{{{ chrony_conf_path }}}</tt>. | ||
| When using <tt>sourcedir</tt>, create <tt>.sources</tt> files in the specified directory: | ||
| <pre># In {{{ chrony_conf_path }}}: | ||
| sourcedir /etc/chrony/sources.d | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that the remediations namely Ansible remediation should be improved so that they would remove problematic items from files in sourcedir or confdir. |
||
|
|
||
| # In /etc/chrony/sources.d/ntp.sources: | ||
| server 0.pool.ntp.org</pre> | ||
| When using <tt>confdir</tt>, create <tt>.conf</tt> files in the specified directory: | ||
| <pre># In {{{ chrony_conf_path }}}: | ||
| confdir /etc/chrony/conf.d | ||
|
|
||
| # In /etc/chrony/conf.d/ntp-servers.conf: | ||
| pool 1.pool.ntp.org</pre> | ||
| Multiple servers may be configured. | ||
|
|
||
| rationale: |- | ||
|
|
@@ -38,5 +52,13 @@ references: | |
| ocil_clause: 'a remote time server is not configured' | ||
|
|
||
| ocil: |- | ||
| Run the following command and verify remote server is configured properly: | ||
| Verify that a remote time server is configured. First, check the main configuration file: | ||
| <pre># grep -E "^(server|pool)" {{{ chrony_conf_path }}}</pre> | ||
| If no server or pool directive is found, check for sourcedir or confdir directives: | ||
| <pre># grep -E "^(sourcedir|confdir)" {{{ chrony_conf_path }}}</pre> | ||
| For each sourcedir found, check <tt>.sources</tt> files in that directory: | ||
| <pre># grep -E "^(server|pool)" /path/to/sourcedir/*.sources</pre> | ||
| For each confdir found, check <tt>.conf</tt> files in that directory: | ||
| <pre># grep -E "^(server|pool)" /path/to/confdir/*.conf</pre> | ||
| At least one server or pool directive must be present in the main configuration file | ||
| or in files within directories specified by sourcedir or confdir directives. | ||
18 changes: 18 additions & 0 deletions
18
linux_os/guide/services/ntp/chronyd_specify_remote_server/tests/commented_sourcedir.fail.sh
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| #!/bin/bash | ||
| # packages = chrony | ||
| # platform = multi_platform_fedora,multi_platform_ol,multi_platform_rhel,multi_platform_almalinux,multi_platform_ubuntu | ||
|
|
||
| # Test: Commented sourcedir should be ignored - should fail | ||
| SOURCES_DIR="/etc/chrony/sources.d" | ||
| rm -rf /etc/chrony/conf.d | ||
| rm -rf $SOURCES_DIR | ||
|
|
||
| # Create main conf with commented sourcedir | ||
|
|
||
| cat > {{{ chrony_conf_path }}} << EOF | ||
| # sourcedir $SOURCES_DIR | ||
| EOF | ||
|
|
||
| # Create sources.d directory with server (should be ignored) | ||
| mkdir -p $SOURCES_DIR | ||
| echo "server 0.pool.ntp.org" > $SOURCES_DIR/ntp.sources |
17 changes: 17 additions & 0 deletions
17
linux_os/guide/services/ntp/chronyd_specify_remote_server/tests/confdir.pass.sh
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| #!/bin/bash | ||
| # packages = chrony | ||
| # platform = multi_platform_fedora,multi_platform_ol,multi_platform_rhel,multi_platform_almalinux,multi_platform_ubuntu | ||
|
|
||
| # Test: server directive in confdir .conf file | ||
| CONF_DIR="/etc/chrony/conf.d" | ||
| rm -rf $CONF_DIR | ||
| rm -rf /etc/chrony/sources.d | ||
|
|
||
| # Create main conf with confdir | ||
| cat > {{{ chrony_conf_path }}} << EOF | ||
| confdir $CONF_DIR | ||
| EOF | ||
|
|
||
| # Create conf.d directory and file | ||
| mkdir -p $CONF_DIR | ||
| echo "pool 1.pool.ntp.org" > $CONF_DIR/ntp-servers.conf |
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
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
17 changes: 17 additions & 0 deletions
17
linux_os/guide/services/ntp/chronyd_specify_remote_server/tests/empty_sourcedir_main.pass.sh
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| #!/bin/bash | ||
| # packages = chrony | ||
| # platform = multi_platform_fedora,multi_platform_ol,multi_platform_rhel,multi_platform_almalinux,multi_platform_ubuntu | ||
|
|
||
| # Test: Empty sourcedir but server in main conf - should pass | ||
| SOURCES_DIR="/etc/chrony/sources.d" | ||
| rm -rf /etc/chrony/conf.d | ||
| rm -rf $SOURCES_DIR | ||
|
|
||
| # Create main conf with server AND sourcedir | ||
| cat > {{{ chrony_conf_path }}} << EOF | ||
| server 0.pool.ntp.org | ||
| sourcedir $SOURCES_DIR | ||
| EOF | ||
|
|
||
| # Create empty sources.d directory | ||
| mkdir -p $SOURCES_DIR |
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This rule is a part of many profiles in many products. Do all of these profiles allow chrony to use sourcedir and confdir?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is a feature of Chrony. And it is supported for long time.