this using unveil(2), but ignore errors if /var/log doesn't exist. We
want to be able to set the time if the system is damanged or /var is
not mounted yet.
We also need to unveil everything for reading since we still allow
arbitrary locations of zone info files. Hopefully that will go away
soon.
OK deraadt
-/* $OpenBSD: date.c,v 1.57 2021/08/11 13:41:48 schwarze Exp $ */
+/* $OpenBSD: date.c,v 1.58 2022/09/19 15:36:20 florian Exp $ */
/* $NetBSD: date.c,v 1.11 1995/09/07 06:21:05 jtc Exp $ */
/*
time_t now;
int yearset = 0;
+ if (unveil("/", "r") == -1)
+ err(1, "unveil /");
+ /* Let us set the time even if logwtmp would fail. */
+ unveil("/var/log/wtmp", "w");
if (pledge("stdio settime rpath wpath", NULL) == -1)
err(1, "pledge");