summaryrefslogtreecommitdiff
path: root/sys/kern/kern_time.c
diff options
context:
space:
mode:
authorcheloha <cheloha@cvs.openbsd.org>2019-09-04 14:27:56 +0000
committercheloha <cheloha@cvs.openbsd.org>2019-09-04 14:27:56 +0000
commit6681649a730f668723a286f0514f80fe509c785f (patch)
tree0f14954e632b5e0cc84ab129417aa3a478947de4 /sys/kern/kern_time.c
parent3b7be44fbd14b7474c7c2ae42871c66de17ba46d (diff)
gettimeofday, settimeofday(2): limit timezone support
For gettimeofday(2), always copy out an empty timezone struct. For settimeofday(2), still copyin(9) the struct but ignore the contents. In gettimeofday(2)'s case we have not changed the original BSD semantics: the kernel only tracks UTC time without an offset for DST, so a zeroed timezone struct is the correct thing to return to the caller. Future work could move these out into libc as stubs for clock_gettime and clock_settime(2). But, definitely a "later" thing, given that we are in beta. Update the manpage to de-emphasize the timezone parameters for these syscalls. Discussed with tedu@, deraadt@, millert@, kettenis@, yasuoka@, jca@, and guenther@. Tested by job@. Ports input from jca@ and sthen@. Manpage input from jca@. ok jca@ deraadt@
Diffstat (limited to 'sys/kern/kern_time.c')
-rw-r--r--sys/kern/kern_time.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c
index 8f1197b7935..31934323f71 100644
--- a/sys/kern/kern_time.c
+++ b/sys/kern/kern_time.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_time.c,v 1.123 2019/08/03 22:53:45 cheloha Exp $ */
+/* $OpenBSD: kern_time.c,v 1.124 2019/09/04 14:27:55 cheloha Exp $ */
/* $NetBSD: kern_time.c,v 1.20 1996/02/18 11:57:06 fvdl Exp $ */
/*
@@ -323,6 +323,7 @@ sys_gettimeofday(struct proc *p, void *v, register_t *retval)
syscallarg(struct timezone *) tzp;
} */ *uap = v;
struct timeval atv;
+ static const struct timezone zerotz = { 0, 0 };
struct timeval *tp;
struct timezone *tzp;
int error = 0;
@@ -341,7 +342,7 @@ sys_gettimeofday(struct proc *p, void *v, register_t *retval)
#endif
}
if (tzp)
- error = copyout(&tz, tzp, sizeof (tz));
+ error = copyout(&zerotz, tzp, sizeof(zerotz));
return (error);
}
@@ -377,8 +378,7 @@ sys_settimeofday(struct proc *p, void *v, register_t *retval)
if ((error = settime(&ts)) != 0)
return (error);
}
- if (tzp)
- tz = atz;
+
return (0);
}