-
Notifications
You must be signed in to change notification settings - Fork 142
Timekeeper: Install chronyd as BlueOS tool #3980
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
Draft
juliusz-t
wants to merge
1
commit into
bluerobotics:master
Choose a base branch
from
juliusz-nosun:timekeeper
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
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
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 |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -e | ||
|
|
||
| VERSION="4.8" | ||
| SHA256="33ea8eb2a4daeaa506e8fcafd5d6d89027ed6f2f0609645c6f149b560d301706" | ||
| PROJECT_NAME="chrony" | ||
| SOURCE_URL="https://chrony-project.org/releases/$PROJECT_NAME-$VERSION.tar.gz" | ||
|
|
||
| echo "Installing project $PROJECT_NAME version $VERSION" | ||
|
|
||
| if [ -z "$RUNNING_IN_CI" ]; then | ||
| mkdir -p /run/chrony | ||
| echo "Finished configuring $PROJECT_NAME" | ||
| exit 0 | ||
| fi | ||
|
|
||
| if [ -n "$VIRTUAL_ENV" ]; then | ||
| BIN_DIR="$VIRTUAL_ENV/bin" | ||
| else | ||
| BIN_DIR="/usr/bin" | ||
| fi | ||
| mkdir -p "$BIN_DIR" | ||
|
|
||
| TMP_DIR="$(mktemp -d)" | ||
| trap 'rm -rf "$TMP_DIR"' EXIT | ||
|
|
||
| ARCHIVE="$TMP_DIR/$PROJECT_NAME-$VERSION.tar.gz" | ||
| wget -q "$SOURCE_URL" -O "$ARCHIVE" | ||
| printf "%s %s\n" "$SHA256" "$ARCHIVE" | sha256sum -c - | ||
|
|
||
| tar -xzf "$ARCHIVE" -C "$TMP_DIR" | ||
| cd "$TMP_DIR/$PROJECT_NAME-$VERSION" | ||
|
|
||
| LDFLAGS="${LDFLAGS:-} -static" ./configure \ | ||
| --prefix=/usr \ | ||
| --bindir=/usr/bin \ | ||
| --sbindir=/usr/bin \ | ||
| --sysconfdir=/etc \ | ||
| --localstatedir=/var \ | ||
| --chronyrundir=/run/chrony \ | ||
| --chronyvardir=/usr/blueos/userdata/chrony \ | ||
| --disable-nts \ | ||
| --disable-privdrop \ | ||
| --disable-readline \ | ||
| --disable-sechash \ | ||
| --with-chronyc-user=root \ | ||
| --with-user=root \ | ||
| --without-libcap \ | ||
| --without-seccomp | ||
|
|
||
| make -j"$(nproc)" chronyd chronyc | ||
| strip chronyd chronyc | ||
| install -m 0755 chronyd "$BIN_DIR/chronyd" | ||
| install -m 0755 chronyc "$BIN_DIR/chronyc" | ||
|
|
||
| if command -v file >/dev/null 2>&1; then | ||
| echo "Installed binary type: $(file "$BIN_DIR/chronyd")" | ||
| echo "Installed binary type: $(file "$BIN_DIR/chronyc")" | ||
| fi | ||
|
|
||
| echo "Finished installing $PROJECT_NAME" |
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,32 @@ | ||
| # BlueOS chrony configuration. | ||
| # | ||
| # chronyd is started by start-blueos-core and disciplines the shared system clock | ||
| # (the container shares the host's clock). Other services can inspect and extend | ||
| # this at runtime via chronyc. | ||
|
|
||
| # Default upstream sources, used whenever the vehicle can reach them (topside / | ||
| # internet). `iburst` speeds up the initial sync. Services can add more sources | ||
| # at runtime. | ||
| pool pool.ntp.org iburst | ||
|
|
||
| # Serve NTP to devices on the vehicle network. Restrict to typical BlueOS subnets. | ||
| # TODO(chrony): drive these from settings / detected interfaces. | ||
| allow 192.168.2.0/24 | ||
| allow 192.168.0.0/16 | ||
| allow 10.0.0.0/8 | ||
|
|
||
| # Even with no upstream source, act as a stratum-10 server so vehicle-network | ||
| # clients can still synchronize to a single, consistent on-board clock. | ||
| local stratum 10 | ||
|
|
||
| # Record the rate at which the system clock gains/loses time to speed up sync | ||
| # after a restart. | ||
| driftfile /usr/blueos/userdata/chrony/chrony.drift | ||
|
|
||
| # Step the clock (instead of slewing) only during the first few updates after | ||
| # start-up, when the offset is larger than 1 second. Afterwards, only slew, to | ||
| # avoid time jumps while the system is running. | ||
| makestep 1.0 3 | ||
|
|
||
| # Save/restore clock from the RTC if one is present (no-op otherwise). | ||
| rtcsync | ||
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 |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ set -e | |
| TOOLS=( | ||
| blueos_startup_update | ||
| bridges | ||
| chrony | ||
| disktest | ||
| linux2rest | ||
| machineid | ||
|
|
||
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 |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ set -e | |
|
|
||
| TOOLS=( | ||
| ardupilot_tools | ||
| chrony | ||
| filebrowser | ||
| logviewer | ||
| scripts | ||
|
|
||
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.
🚨 issue (security): Broad NTP "allow" ranges may expose the time service more widely than intended
These broad
allowranges expose NTP to most private networks reachable from the container. In deployments where those ranges include non-vehicle devices, this could serve time to unintended clients and increase attack surface. Please narrow the ranges to the specific subnets you expect (or make them configurable) and avoid redundant overlaps like192.168.2.0/24plus192.168.0.0/16.