Module Name:    src
Committed By:   pgoyette
Date:           Mon Dec  7 23:20:57 UTC 2015

Modified Files:
        src/lib/libc/sys: adjtime.2 clock_settime.2 gettimeofday.2
            ntp_adjtime.2

Log Message:
Update to match reality.  For these functions, we still try the system
call first, and only fall back to /dev/clockctl if the system call
fails.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/lib/libc/sys/adjtime.2
cvs rdiff -u -r1.22 -r1.23 src/lib/libc/sys/clock_settime.2
cvs rdiff -u -r1.27 -r1.28 src/lib/libc/sys/gettimeofday.2
cvs rdiff -u -r1.10 -r1.11 src/lib/libc/sys/ntp_adjtime.2

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/sys/adjtime.2
diff -u src/lib/libc/sys/adjtime.2:1.20 src/lib/libc/sys/adjtime.2:1.21
--- src/lib/libc/sys/adjtime.2:1.20	Thu May 13 10:20:57 2004
+++ src/lib/libc/sys/adjtime.2	Mon Dec  7 23:20:57 2015
@@ -1,4 +1,4 @@
-.\"	$NetBSD: adjtime.2,v 1.20 2004/05/13 10:20:57 wiz Exp $
+.\"	$NetBSD: adjtime.2,v 1.21 2015/12/07 23:20:57 pgoyette Exp $
 .\"
 .\" Copyright (c) 1980, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\"     @(#)adjtime.2	8.1 (Berkeley) 6/4/93
 .\"
-.Dd June 4, 1993
+.Dd December 8, 2015
 .Dt ADJTIME 2
 .Os
 .Sh NAME
@@ -77,19 +77,20 @@ 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
-If the calling user is not the super user, then the
+If the calling user is not the super user, the
+.Fn adjtime
+system call will fail, and the
 .Fn adjtime
 function in the standard C library will try to use the
 .Xr clockctl 4
-device if present, thus making possible for non privileged users to
+device if present, thus making it possible for non privileged users to
 adjust the system time.
 If
 .Xr clockctl 4
 is not present or not accessible, then
 .Fn adjtime
-reverts to the
-.Fn adjtime
-system call, which is restricted to the super user.
+returns
+.Er EPERM .
 .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

Index: src/lib/libc/sys/clock_settime.2
diff -u src/lib/libc/sys/clock_settime.2:1.22 src/lib/libc/sys/clock_settime.2:1.23
--- src/lib/libc/sys/clock_settime.2:1.22	Fri Mar 28 15:35:55 2014
+++ src/lib/libc/sys/clock_settime.2	Mon Dec  7 23:20:57 2015
@@ -1,4 +1,4 @@
-.\" $NetBSD: clock_settime.2,v 1.22 2014/03/28 15:35:55 wiz Exp $
+.\" $NetBSD: clock_settime.2,v 1.23 2015/12/07 23:20:57 pgoyette Exp $
 .\"
 .\" Copyright (c) 1999 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd February 11, 1999
+.Dd December 8, 2016
 .Dt CLOCK_SETTIME 2
 .Os
 .Sh NAME
@@ -119,19 +119,20 @@ of
 identifies a clock that increments when the CPU is running in user
 or kernel mode on behalf of the calling process.
 .Pp
-If the calling user is not the super-user, then the
+If the calling user is not the super-user, the
+.Fn clock_settime
+system call will fail, and the
 .Fn clock_settime
 function in the standard C library will try to use the
 .Xr clockctl 4
-device if present, thus making possible for non privileged users to
+device if present, thus making it possible for non privileged users to
 set the system time.
 If
 .Xr clockctl 4
 is not present or not accessible, then
 .Fn clock_settime
-reverts to the
-.Fn clock_settime
-system call, which is restricted to the super user.
+returns
+.Er EPERM .
 .Sh RETURN VALUES
 A value of 0 is returned on success.
 Otherwise, a value of \-1 is returned and

Index: src/lib/libc/sys/gettimeofday.2
diff -u src/lib/libc/sys/gettimeofday.2:1.27 src/lib/libc/sys/gettimeofday.2:1.28
--- src/lib/libc/sys/gettimeofday.2:1.27	Tue May 18 07:14:18 2010
+++ src/lib/libc/sys/gettimeofday.2	Mon Dec  7 23:20:57 2015
@@ -1,4 +1,4 @@
-.\"	$NetBSD: gettimeofday.2,v 1.27 2010/05/18 07:14:18 jruoho Exp $
+.\"	$NetBSD: gettimeofday.2,v 1.28 2015/12/07 23:20:57 pgoyette Exp $
 .\"
 .\" Copyright (c) 1980, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\"     @(#)gettimeofday.2	8.2 (Berkeley) 5/26/95
 .\"
-.Dd May 18, 2010
+.Dd December 8, 2016
 .Dt GETTIMEOFDAY 2
 .Os
 .Sh NAME
@@ -98,19 +98,21 @@ and
 .Fn gettimeofday
 will always return zeroes.
 .Pp
-If the calling user is not the super-user, then the
+The
+.Fn settimeofday
+system call is available only for the super-user.
+If the calling user is not the super-user, the system call will fail, and the
 .Fn settimeofday
 function in the standard C library will try to use the
 .Xr clockctl 4
-device if present, thus making possible for non privileged users to
+device if present, thus making it possible for non privileged users to
 set the system time.
 If
 .Xr clockctl 4
 is not present or not accessible, then
 .Fn settimeofday
-reverts to the
-.Fn settimeofday
-system call, which is restricted to the super user.
+returns
+.Er EPERM .
 .\" XXX uncomment when/if this is put into place!
 .\" If the system is running in secure mode (see
 .\" .Xr init 8 ),

Index: src/lib/libc/sys/ntp_adjtime.2
diff -u src/lib/libc/sys/ntp_adjtime.2:1.10 src/lib/libc/sys/ntp_adjtime.2:1.11
--- src/lib/libc/sys/ntp_adjtime.2:1.10	Mon May 18 09:28:51 2009
+++ src/lib/libc/sys/ntp_adjtime.2	Mon Dec  7 23:20:57 2015
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ntp_adjtime.2,v 1.10 2009/05/18 09:28:51 wiz Exp $
+.\"	$NetBSD: ntp_adjtime.2,v 1.11 2015/12/07 23:20:57 pgoyette Exp $
 .\"
 .\" Copyright (c) 2001 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd October 22, 2007
+.Dd December 8, 2015
 .Dt NTP_ADJTIME 2
 .Os
 .Sh NAME
@@ -55,6 +55,21 @@ The
 .Fn ntp_adjtime
 function is used by the NTP daemon to adjust the system clock to an
 externally derived time.
+The
+.Fn ntp_adjtime
+system call is available only for the super user.
+If the system call fails, the
+.Fn ntp_adjtime
+function in the standard C library will try to use the
+.Xr clockctl 4 device if present, thus making it possible for the NTP
+daemon to run as a non-privileged user.
+If
+.X4 clockctl 4
+is not present,
+.Fn ntp_adjtime
+returns
+.Er EPERM .
+.Pp
 The time offset and related variables which are set by
 .Fn ntp_adjtime
 are used by

Reply via email to