From 88189cd37e490ab9c99c014fc44132efceaa8868 Mon Sep 17 00:00:00 2001 From: cheloha Date: Wed, 21 Aug 2019 20:44:10 +0000 Subject: sysctl(2): add kern.utc_offset: successor to the DST/TIMEZONE options(4) The DST and TIMEZONE options(4) are incompatible with KARL, so we need some other way to compensate for an RTC running with a known offset. Enter kern.utc_offset, an offset in minutes East of UTC. TIMEZONE has always been minutes West, but this is inconsistent with how everyone else talks about timezones, hence the flip. TIMEZONE has the advantage of being compiled into the binary. Our new sysctl(2) has no such luck, so it needs to be set as early as possible in boot, from sysctl.conf(5), so we can correct the kernel clock from the RTC's local time to UTC before daemons like ntpd(8) and cron(8) start. To encourage this, kern.utc_offset is made immutable after the securelevel(7) is raised to 1. Prompted by yasuoka@. Discussed with deraadt@, kettenis@, yasuoka@. Additional testing by yasuoka@. ok deraadt@, yasuoka@ --- sys/conf/param.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sys/conf/param.c') diff --git a/sys/conf/param.c b/sys/conf/param.c index 0fc9b496694..4d9f32841d8 100644 --- a/sys/conf/param.c +++ b/sys/conf/param.c @@ -1,4 +1,4 @@ -/* $OpenBSD: param.c,v 1.43 2019/08/02 02:17:35 cheloha Exp $ */ +/* $OpenBSD: param.c,v 1.44 2019/08/21 20:44:09 cheloha Exp $ */ /* $NetBSD: param.c,v 1.16 1996/03/12 03:08:40 mrg Exp $ */ /* @@ -83,6 +83,7 @@ int tick = 1000000 / HZ; int tick_nsec = 1000000000 / HZ; int tickadj = 240000 / (60 * HZ); /* can adjust 240ms in 60s */ struct timezone tz __attribute__ ((section(".data"))) = { TIMEZONE, DST }; +int utc_offset = 0; #define NPROCESS (30 + 16 * MAXUSERS) #define NTEXT (80 + NPROCESS / 8) /* actually the object cache */ #define NVNODE (NPROCESS * 2 + NTEXT + 100) -- cgit v1.2.3