aboutsummaryrefslogtreecommitdiff
path: root/sbin/adjkerntz/adjkerntz.c
diff options
context:
space:
mode:
authorEugene Grosbein <eugen@FreeBSD.org>2022-06-21 18:29:08 +0000
committerEugene Grosbein <eugen@FreeBSD.org>2022-06-21 18:32:54 +0000
commit048ce0876f5421f70a6d348479bdeacdd8472bed (patch)
tree9b463fa294e01c58faf4a7bb522fc9c2efb43c56 /sbin/adjkerntz/adjkerntz.c
parentb4bdc8f9253d9db46f598f17cc546c2fe0f8038d (diff)
downloadsrc-048ce0876f5421f70a6d348479bdeacdd8472bed.tar.gz
src-048ce0876f5421f70a6d348479bdeacdd8472bed.zip
adjkerntz(8): detect extra jailed invokation to keep logs clean
It may happen that "adjkerntz -a" called from jailed root crontab. In that case it spams logs with a line: sysctl(set: "machdep.wall_cmos_clock"): Operation not permitted Be silent in that case. MFC after: 1 month
Diffstat (limited to 'sbin/adjkerntz/adjkerntz.c')
-rw-r--r--sbin/adjkerntz/adjkerntz.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/sbin/adjkerntz/adjkerntz.c b/sbin/adjkerntz/adjkerntz.c
index e6cadcf7f189..2fde545ebf32 100644
--- a/sbin/adjkerntz/adjkerntz.c
+++ b/sbin/adjkerntz/adjkerntz.c
@@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$");
* with Garrett Wollman and Bruce Evans fixes.
*
*/
+#include <errno.h>
#include <stdio.h>
#include <signal.h>
#include <stdlib.h>
@@ -159,6 +160,12 @@ again:
len = sizeof(kern_offset);
if (sysctlbyname("machdep.adjkerntz", &kern_offset, &len, NULL, 0) == -1) {
+ if (errno == EPERM && !init && geteuid() == 0)
+ /*
+ * Surplus call from jailed root crontab.
+ * Avoid spamming logs.
+ */
+ return 1;
syslog(LOG_ERR, "sysctl(\"machdep.adjkerntz\"): %m");
return 1;
}