Skip to content

NTP sync loop in oc-bootstrap is missing trailing &, blocks boot and leaves clock at 1970-01-01 #100

Description

@pdscomp

Summary

The NTP sync loop in /etc/init.d/oc-bootstrap is missing a trailing &, so it runs synchronously inside the boot() function. This blocks the rest of the boot sequence and, because ntpdate retries every 5 seconds until success, can leave the printer with an unset clock (showing 1970-01-01) and potentially other boot-time services never started.

Where the bug is

File: oc-patches/services/bootstrap-oc/oc-bootstrap in the cc-fw-tools-canvas repo (the currently active CC1 OpenCentauri patch tree).

Current code (lines 84–90):

        # Synchronize time to NTP, and every 24 hours!
        sh -c 'while true; do
            until /usr/sbin/ntpdate pool.ntp.org; do
                sleep 5
            done
            sleep 86400
        done'

The final done' has no &, so the whole sh -c subprocess is foregrounded. The surrounding /etc/init.d/oc-bootstrap boot() function cannot return until the sh -c exits, and the sh -c only exits if ntpdate succeeds once and then the inner while true eventually terminates — which it never does because it loops forever every 24 hours.

In practice, the visible symptom is the system clock staying at 1970-01-01, which breaks file/print history timestamps, logs, and anything else relying on real time.

Reported by

Impact

  • Clock is not synchronized at boot, so timestamps stay at 1970-01-01.
  • Any code after the NTP block in oc-bootstrap (inside the if [ -f /kip/etc/entware_release ] branch) may never execute, because the function never returns.
  • File/print history shows '--' or 1970 dates (already reported by davidt_1 in the same channel).

Suggested fix

Add & to background the NTP sync loop, matching other backgrounded loops in the same file (e.g. mount_usb_daemon &, udhcpc ... &, updatedb loop with &):

        # Synchronize time to NTP, and every 24 hours!
        sh -c 'while true; do
            until /usr/sbin/ntpdate pool.ntp.org; do
                sleep 5
            done
            sleep 86400
        done' &

Optionally also consider:

  • Adding a small initial sleep or a network-readiness check before the first ntpdate attempt, so the retry loop isn't hammering pool.ntp.org during the first few seconds of boot.
  • Logging ntpdate output to /tmp or syslog for diagnostics.

Related issues

  • The file/print history timestamp issues reported in #patched-fw may be downstream of this bug.

Verification steps

  1. Build a firmware image with the fix.
  2. Flash to a CC1.
  3. Boot with no existing NTP sync.
  4. Check date shortly after boot — should be current, not 1970-01-01.
  5. Check that the rest of oc-bootstrap completed (e.g. SSH/Entware services are up, mount_usb_daemon is running).
  6. Verify /usr/sbin/ntpdate is still retrying in the background by inspecting ps.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions