sys: add OpenBSD support

Add OpenBSD support, including pledge(2) support by implementing
SYS_EnableSystemCallFilter().

This commit depends on the addition of AdjustFreq() privops and the
addtion of invoking SYS_EnableSystemCallFilter() from PRV_StartHelper().

Only system call filter levels on/off' are supported. Setting level
to 0 disables the filter and setting it to 1 enables it.

Update the documentation to reflect that OpenBSD supports:
- the SCHED_FIFO real-time scheduler (option -P)
- locking chronyd into memory (option -m)
- reload sample history of servers and ref clocks (option -r)
- forking into two process when run as non-root user (option -u)
- maxdrift/maxslewrate of 100000.
This commit is contained in:
Thomas Kupper
2026-02-04 22:09:09 +01:00
committed by Miroslav Lichvar
parent 9a57ef8dbf
commit 4ddc6b334d
9 changed files with 425 additions and 44 deletions

11
sys.c
View File

@@ -42,6 +42,9 @@
#elif defined(NETBSD) || defined(FREEBSD)
#include "sys_netbsd.h"
#include "sys_posix.h"
#elif defined(OPENBSD)
#include "sys_openbsd.h"
#include "sys_posix.h"
#elif defined(MACOSX)
#include "sys_macosx.h"
#endif
@@ -66,6 +69,8 @@ SYS_Initialise(int clock_control)
SYS_Solaris_Initialise();
#elif defined(NETBSD) || defined(FREEBSD)
SYS_NetBSD_Initialise();
#elif defined(OPENBSD)
SYS_OpenBSD_Initialise();
#elif defined(MACOSX)
SYS_MacOSX_Initialise();
#else
@@ -88,6 +93,8 @@ SYS_Finalise(void)
SYS_Solaris_Finalise();
#elif defined(NETBSD) || defined(FREEBSD)
SYS_NetBSD_Finalise();
#elif defined(OPENBSD)
SYS_OpenBSD_Finalise();
#elif defined(MACOSX)
SYS_MacOSX_Finalise();
#else
@@ -105,6 +112,8 @@ void SYS_DropRoot(uid_t uid, gid_t gid, SYS_ProcessContext context)
SYS_Solaris_DropRoot(uid, gid, context);
#elif (defined(NETBSD) || defined(FREEBSD)) && defined(FEAT_PRIVDROP)
SYS_NetBSD_DropRoot(uid, gid, context, !null_driver);
#elif defined(OPENBSD) && defined(FEAT_PRIVDROP)
SYS_OpenBSD_DropRoot(uid, gid, context, !null_driver);
#elif defined(MACOSX) && defined(FEAT_PRIVDROP)
SYS_MacOSX_DropRoot(uid, gid, context);
#else
@@ -118,6 +127,8 @@ void SYS_EnableSystemCallFilter(int level, SYS_ProcessContext context)
{
#if defined(LINUX) && defined(FEAT_SCFILTER)
SYS_Linux_EnableSystemCallFilter(level, context);
#elif defined(OPENBSD) && defined(FEAT_SCFILTER)
SYS_OpenBSD_EnableSystemCallFilter(level, context);
#else
LOG_FATAL("system call filter not supported");
#endif