diff options
-rw-r--r-- | lib/libc/sys/adjtime.2 | 9 | ||||
-rw-r--r-- | sys/kern/kern_time.c | 9 |
2 files changed, 14 insertions, 4 deletions
diff --git a/lib/libc/sys/adjtime.2 b/lib/libc/sys/adjtime.2 index a2c953bb3a9..a214c30796f 100644 --- a/lib/libc/sys/adjtime.2 +++ b/lib/libc/sys/adjtime.2 @@ -1,4 +1,4 @@ -.\" $OpenBSD: adjtime.2,v 1.13 2003/06/02 20:18:38 millert Exp $ +.\" $OpenBSD: adjtime.2,v 1.14 2006/06/04 18:47:33 otto Exp $ .\" $NetBSD: adjtime.2,v 1.5 1995/10/12 15:40:44 jtc Exp $ .\" .\" Copyright (c) 1980, 1991, 1993 @@ -61,6 +61,9 @@ may not be finished when .Fn adjtime is called again. If +.Fa delta +is null, no adjustment is done. +If .Fa olddelta is non-null, the structure pointed to will contain, upon return, the number of microseconds still to be corrected from the earlier call. @@ -70,9 +73,9 @@ of computers in a local area network. Such time servers would slow down the clocks of some machines and speed up the clocks of others to bring them to the average network time. .Pp -The call +Only the superuser may adjust the time using the .Fn adjtime -is restricted to the superuser. +function. .Sh RETURN VALUES A return value of 0 indicates that the call succeeded. A return value of \-1 indicates that an error occurred, and in this diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c index c8f2fa62e31..7bffe722027 100644 --- a/sys/kern/kern_time.c +++ b/sys/kern/kern_time.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_time.c,v 1.54 2006/01/20 07:53:48 tedu Exp $ */ +/* $OpenBSD: kern_time.c,v 1.55 2006/06/04 18:47:33 otto Exp $ */ /* $NetBSD: kern_time.c,v 1.20 1996/02/18 11:57:06 fvdl Exp $ */ /* @@ -385,6 +385,12 @@ sys_adjtime(struct proc *p, void *v, register_t *retval) long ndelta, ntickdelta, odelta; int s, error; + if (!SCARG(uap, delta)) { + s = splclock(); + odelta = timedelta; + splx(s); + goto out; + } if ((error = suser(p, 0))) return (error); if ((error = copyin((void *)SCARG(uap, delta), (void *)&atv, @@ -432,6 +438,7 @@ sys_adjtime(struct proc *p, void *v, register_t *retval) tickdelta = ntickdelta; splx(s); +out: if (SCARG(uap, olddelta)) { atv.tv_sec = odelta / 1000000; atv.tv_usec = odelta % 1000000; |