• TempleOS Enterprise Edition TempleOS Enterprise Edition
  • Информация о проекте
    • Информация о проекте
    • Активность
    • Метки
    • Участники
  • Репозиторий
    • Репозиторий
    • Файлы
    • Коммиты
    • Ветки
    • Теги
    • Участники
    • Диаграмма
    • Сравнение
  • Задачи 0
    • Задачи 0
    • Список
    • Доски
    • Спринты
  • Запросы на слияние 0
    • Запросы на слияние 0
  • CI/CD
    • CI/CD
    • Конвейеры
    • Задания
    • Расписания
  • Развертывания
    • Развертывания
    • Окружения
    • Релизы
  • Пакеты и реестры
    • Пакеты и реестры
    • Реестр пакетов
    • Реестр контейнеров
  • Мониторинг
    • Мониторинг
    • Инциденты
  • Аналитика
    • Аналитика
    • Поток ценности
    • CI/CD
    • Репозиторий
  • Wiki
    • Wiki
  • Сниппеты
    • Сниппеты
  • Активность
  • Диаграмма
  • Создать новую задачу
  • Задания
  • Коммиты
  • Доски с задачами
Свернуть панель
  • cia-foundation
  • TempleOS Enterprise Edition
  • Запросы на слияние
  • !5

Ntp: the Temple asks Jerusalem what time it is

  • Ревью изменений

  • Скачать
  • Почтовые патчи
  • Простое отличие
Слиты Жильцов Дмитрий Андреевич запросил слияние ntp в master Окт 04, 2026
  • Обзор 0
  • Коммиты 3
  • Конвейеры 0
  • Изменения 9

The Temple kept whatever time the hosting company's RTC said. Now it asks Jerusalem, and it asks only Israel.

How the time is kept

  • Now() = RTC − local_time_offset + sys_clock_adj (Kernel/KDate.HC).
  • sys_clock_adj lives in RAM only and is zero at every boot (KMain).
  • The CMOS is never written. A wrong answer from the wire, or a spoofed one from the CIA, dies with the next reboot instead of being burned into the clock. Terry's RTC stays Terry's.

Who is asked

Israeli servers only, nearest to Jerusalem first. The first one that answers wins:

  1. ntp.ac.il — National Physical Laboratory, Jerusalem, stratum 1, the atomic clocks of Israel Standard Time
  2. ntp.huji.ac.il — Hebrew University of Jerusalem
  3. ntp.tau.ac.il — Tel Aviv
  4. timeserver.iix.net.il — Israel Internet Exchange, Petah Tikva
  5. ntp.technion.ac.il — Haifa
  6. 1.il.pool.ntp.org — Israeli pool, these follow the Hebrew University
  7. il.pool.ntp.org — the rest of the Israeli pool

Each server gets four questions and the fastest round trip is believed. Answers that are not from a server, unsynchronized, a kiss of death, or from an address we did not ask are not believed. Glowies.

When

  • Once.HC runs Ntp at boot, after the network.
  • NtpDaemon asks again every 6 hours, silently.
  • At the command line: Ntp; asks now, NtpRep; says who answered and how far off the RTC was, sys_clock_adj=0; trusts the bare RTC again.

Found on the way: UDP sendto used port 0

UdpSocketSendto sent every datagram from source port 0. The answer went back to port 0, where nobody listens, and half the internet drops port 0 on sight. DNS and DHCP never noticed because they build their packets by hand. Now a datagram leaves from the bound port, and an unbound socket takes a free port above 49151 first.

How it was tested

QEMU, 256 MB, 1 vCPU, virtio-net, with the RTC set to 2020-01-01 (-rtc base=2020-01-01):

Step Seen
Boot 1.il.pool.ntp.org, stratum 2, rtt 106 ms, RTC off by 213201633.5 s
Now() 10/03/26 14:42:33, the host's UTC in the same second
Bare RTC (Now-sys_clock_adj) 01/01/20, CMOS untouched
sys_clock_adj=0; the Temple back in 2020
Ntp; again correct again
TaskRep; NtpDaemon running

Deploying

The kernel changed (KDate, KGlbls, KMain, KernelC.HH), so tools/update_vds.py HOST rebuilds it with BootHDIns('C'). If C: does not come back, pick D at the boot menu.

Known sins

  • From outside Israel ntp.ac.il does not resolve and the university servers stay silent, so the pool answered in the test. The boot console then shows a few DnsParseResponse: no suitable answer lines. On an Israeli VDS a server higher in the list should answer; NtpRep; will tell.
  • Good to the second: Now() reads the RTC, and the RTC knows no fractions.
  • Now() is UTC, as Terry meant it. Israel time on screen needs local_time_offset in ~/HomeLocalize.HC, by hand, twice a year, as Terry also meant it.
  • SNTP, no authentication. RAM only is the whole defense, and it is enough for a Temple.

Terry, forgive us. The Temple used to keep its own time. Now it asks Jerusalem, which is where the time of the Temple should come from.

Ответственный
Назначить
Проверяющие
Запросить ревью
Оценка трудозатрат
Исходная ветка: ntp