| 398 | "do not perform possibly restrictive checks on settime(2) args"); |
| 399 | |
| 400 | int |
| 401 | kern_clock_settime(struct thread *td, clockid_t clock_id, struct timespec *ats) |
| 402 | { |
| 403 | struct timeval atv; |
| 404 | int error; |
| 405 | |
| 406 | if ((error = priv_check(td, PRIV_CLOCK_SETTIME)) != 0) |
| 407 | return (error); |
| 408 | if (clock_id != CLOCK_REALTIME) |
| 409 | return (EINVAL); |
| 410 | if (ats->tv_nsec < 0 || ats->tv_nsec >= 1000000000 || |
| 411 | ats->tv_sec < 0) |
| 412 | return (EINVAL); |
| 413 | if (!allow_insane_settime && |
| 414 | (ats->tv_sec > 8000ULL * 365 * 24 * 60 * 60 || |
| 415 | ats->tv_sec < utc_offset())) |
| 416 | return (EINVAL); |
| 417 | /* XXX Don't convert nsec->usec and back */ |
| 418 | TIMESPEC_TO_TIMEVAL(&atv, ats); |
| 419 | error = settime(td, &atv); |
| 420 | return (error); |
| 421 | } |
| 422 | |
| 423 | #ifndef _SYS_SYSPROTO_H_ |
| 424 | struct clock_getres_args { |
no test coverage detected