xref: /netbsd-src/share/man/man4/clockctl.4 (revision 404fbe5fb94ca1e054339640cabb2801ce52dd30)
1.\"	$NetBSD: clockctl.4,v 1.5 2008/04/30 13:10:53 martin Exp $
2.\"
3.\" Copyright (c) 2001 The NetBSD Foundation, Inc.
4.\" All rights reserved.
5.\"
6.\" This code is derived from software contributed to The NetBSD Foundation
7.\" by Emmanuel Dreyfus.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright
13.\"    notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\"    notice, this list of conditions and the following disclaimer in the
16.\"    documentation and/or other materials provided with the distribution.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28.\" POSSIBILITY OF SUCH DAMAGE.
29.\"
30.Dd October 20, 2001
31.Dt CLOCKCTL 4
32.Os
33.Sh NAME
34.Nm clockctl
35.Nd Clock subsystem user control
36.Sh SYNOPSIS
37.Cd pseudo-device clockctl
38.Sh DESCRIPTION
39The
40.Nm
41interface brings clock control to non-root users. Any user with write access
42to
43.Pa /dev/clockctl
44will be able to perform operations such as
45.Xr settimeofday 2 ,
46.Xr clock_settime 2 ,
47.Xr adjtime 2 ,
48or
49.Xr ntp_adjtime 2 ,
50which are normally restricted to the super-user. Using the
51.Nm
52pseudo-device, it is possible to run daemons such as
53.Xr ntpd 8
54as non-privileged users, thus reducing the security exposure if a
55compromise is found in such a daemon.
56.Pp
57The
58.Nm
59pseudo-device driver provides an
60.Xr ioctl 2
61call for each privileged clock-related system call. The system
62call stubs in C library will use the
63.Xr ioctl 2
64on
65.Pa /dev/clockctl
66if the special file is present and accessible, or will revert to the
67plain super-user-restricted system call if the special file is not accessible.
68.Pp
69The following
70.Xr ioctl 2
71calls are defined in
72.Aq Pa sys/clockctl.h :
73.Bl -tag -width CLOCKCTL
74.It Dv CLOCKCTL_SETTIMEOFDAY
75This will run the
76.Xr settimeofday 2
77system call. Argument should be a pointer to a
78.Va struct clockctl_settimeofday_args :
79.Bd -literal
80struct clockctl_settimeofday_args {
81    struct timeval tv;
82    struct timezone tzp;
83};
84.Ed
85.It Dv CLOCKCTL_CLOCK_SETTIME
86This will run the
87.Xr clock_settime 2
88system call. Argument should be a pointer to a
89.Va struct clockctl_clock_settime_args :
90.Bd -literal
91struct clockctl_clock_settime_args {
92    clockid_t clock_id;
93    struct timespec tp;
94};
95.Ed
96.It Dv CLOCKCTL_ADJTIME
97This will run the
98.Xr adjtime 2
99system call. Argument should be a pointer to a
100.Va struct clockctl_adjtime_args :
101.Bd -literal
102struct clockctl_adjtime_args {
103    struct timeval delta;
104    struct timeval olddelta;
105};
106.Ed
107.It Dv CLOCKCTL_NTP_ADJTIME
108This will run the
109.Xr ntp_adjtime 2
110system call. Argument should be a pointer to a
111.Va struct clockctl_ntp_adjtime_args :
112.Bd -literal
113struct clockctl_ntp_adjtime_args {
114    struct timex tp;
115};
116.Ed
117.El
118.Sh SEE ALSO
119.Xr adjtime 2 ,
120.Xr clock_settime 2 ,
121.Xr ioctl 2 ,
122.Xr settimeofday 2
123.Sh HISTORY
124.Nm
125appeared in
126.Nx 1.6 .
127