Date: Mon, 1 Mar 2010 02:15:41 +0300 From: Subbsd <subbsd@gmail.com> To: freebsd-current@freebsd.org Subject: check for jailed environment for adjkerntz Message-ID: <8237b2241002281515q5e953a48l4ac8a981fed407ab@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
jail with "complete" type have standard crontab a file of tasks. However not all standard task are adapted for work in jail an environment. For example adjkerntz which generates adjkerntz [46733]: sysctl (set: "machdep.wall_cmos_clock"): Operation not permitted I suggest to give adjkerntz concept about jail in which to it it is not necessary to work: --- adjkerntz.c-orig 2010-03-01 01:53:01.000000000 +0300 +++ adjkerntz.c 2010-03-01 02:03:45.000000000 +0300 @@ -80,7 +80,7 @@ struct tm local; struct timeval tv, *stv; struct timezone tz, *stz; - int kern_offset, wall_clock, disrtcset; + int kern_offset, wall_clock, disrtcset, jailed; size_t len; /* Avoid time_t here, can be unsigned long or worse */ long offset, localsec, diff; @@ -118,6 +118,16 @@ if (init) sleep_mode = True; + len = sizeof(jailed); + if (sysctlbyname("security.jail.jailed", &jailed, &len, NULL, 0) == -1) { + syslog(LOG_ERR, "sysctl(\"security.jail.jailed\"): %m"); + return 1; + } + if (jailed!=0) { + //not for jail + return 1; + } + sigemptyset(&mask); sigemptyset(&emask); sigaddset(&mask, SIGTERM);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?8237b2241002281515q5e953a48l4ac8a981fed407ab>