Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions core/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ COPY --from=download-binaries \
/usr/bin/blueos_startup_update.py \
/usr/bin/blueos-recorder \
/usr/bin/bridges \
/usr/bin/chronyc \
/usr/bin/chronyd \
/usr/bin/disktest \
/usr/bin/linux2rest \
/usr/bin/machineid-cli \
Expand Down
1 change: 1 addition & 0 deletions core/start-blueos-core
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ SERVICES=(
'beacon',250,0,0,0,"$SERVICES_PATH/beacon/main.py"
'bridget',0,0,0,0,"nice -19 $RUN_AS_REGULAR_USER_BEGIN $SERVICES_PATH/bridget/main.py $RUN_AS_REGULAR_USER_END"
'commander',250,0,0,0,"$SERVICES_PATH/commander/main.py"
'chronyd',0,0,0,0,"chronyd -d -f $TOOLS_PATH/chrony/chrony.conf"
'nmea_injector',250,0,0,0,"nice -19 $SERVICES_PATH/nmea_injector/main.py"
'helper',250,0,0,0,"$BLUEOS_PYTHON_BIN_SECONDARY $SERVICES_PATH/helper/main.py"
'iperf3',250,0,0,0," iperf3 --server --port 5201"
Expand Down
62 changes: 62 additions & 0 deletions core/tools/chrony/bootstrap.sh
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"
32 changes: 32 additions & 0 deletions core/tools/chrony/chrony.conf
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
Comment on lines +15 to +16

Copy link
Copy Markdown

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 allow ranges 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 like 192.168.2.0/24 plus 192.168.0.0/16.


# 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
1 change: 1 addition & 0 deletions core/tools/install-static-binaries.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ set -e
TOOLS=(
blueos_startup_update
bridges
chrony
disktest
linux2rest
machineid
Expand Down
1 change: 1 addition & 0 deletions core/tools/install-system-tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ set -e

TOOLS=(
ardupilot_tools
chrony
filebrowser
logviewer
scripts
Expand Down