xref: /freebsd/share/man/man4/mac_ntpd.4 (revision fa9896e082a1046ff4fbc75fcba4d18d1f2efc19)
13496c981SIan Lepore.\" Copyright (c) 2018 Ian Lepore <ian@FreeBSD.org>
23496c981SIan Lepore.\"
33496c981SIan Lepore.\" Redistribution and use in source and binary forms, with or without
43496c981SIan Lepore.\" modification, are permitted provided that the following conditions
53496c981SIan Lepore.\" are met:
63496c981SIan Lepore.\" 1. Redistributions of source code must retain the above copyright
73496c981SIan Lepore.\"    notice, this list of conditions and the following disclaimer.
83496c981SIan Lepore.\" 2. Redistributions in binary form must reproduce the above copyright
93496c981SIan Lepore.\"    notice, this list of conditions and the following disclaimer in the
103496c981SIan Lepore.\"    documentation and/or other materials provided with the distribution.
113496c981SIan Lepore.\"
123496c981SIan Lepore.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
133496c981SIan Lepore.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
143496c981SIan Lepore.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
153496c981SIan Lepore.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
163496c981SIan Lepore.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
173496c981SIan Lepore.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
183496c981SIan Lepore.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
193496c981SIan Lepore.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
203496c981SIan Lepore.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
213496c981SIan Lepore.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
223496c981SIan Lepore.\" SUCH DAMAGE.
233496c981SIan Lepore.\"
24*9b0841aeSIan Lepore.Dd July 20, 2018
253496c981SIan Lepore.Dt MAC_NTPD 4
263496c981SIan Lepore.Os
273496c981SIan Lepore.Sh NAME
283496c981SIan Lepore.Nm mac_ntpd
293496c981SIan Lepore.Nd "policy allowing ntpd to run as non-root user"
303496c981SIan Lepore.Sh SYNOPSIS
313496c981SIan LeporeTo compile the ntpd policy into your kernel, place the following lines
323496c981SIan Leporein your kernel configuration file:
333496c981SIan Lepore.Bd -ragged -offset indent
343496c981SIan Lepore.Cd "options MAC"
353496c981SIan Lepore.Cd "options MAC_NTPD"
363496c981SIan Lepore.Ed
373496c981SIan Lepore.Pp
383496c981SIan LeporeAlternately, to load the ntpd policy module at boot time,
393496c981SIan Leporeplace the following line in your kernel configuration file:
403496c981SIan Lepore.Bd -ragged -offset indent
413496c981SIan Lepore.Cd "options MAC"
423496c981SIan Lepore.Ed
433496c981SIan Lepore.Pp
443496c981SIan Leporeand in
453496c981SIan Lepore.Xr loader.conf 5 :
46*9b0841aeSIan Lepore.Bd -literal -offset indent
47*9b0841aeSIan Leporemac_ntpd_load="YES"
48*9b0841aeSIan Lepore.Ed
493496c981SIan Lepore.Sh DESCRIPTION
503496c981SIan LeporeThe
513496c981SIan Lepore.Nm
523496c981SIan Leporepolicy grants any process running as user
533496c981SIan Lepore.Sq ntpd
543496c981SIan Lepore(uid 123) the privileges needed to manipulate
553496c981SIan Leporesystem time, and to (re-)bind to the privileged NTP port.
563496c981SIan Lepore.Pp
573496c981SIan LeporeWhen
583496c981SIan Lepore.Xr ntpd 8
593496c981SIan Leporeis started with
60*9b0841aeSIan Lepore.Sq Fl u Ar <user>[:group]
613496c981SIan Leporeon the command line, it performs all initializations requiring root
623496c981SIan Leporeprivileges, then drops root privileges by switching to the given user id.
633496c981SIan LeporeFrom that point on, the only privileges it requires are the ability
643496c981SIan Leporeto manipulate system time, and the ability to re-bind a UDP socket
653496c981SIan Leporeto the NTP port (port 123) after a network interface change.
66*9b0841aeSIan Lepore.Pp
67*9b0841aeSIan LeporeWith the
68*9b0841aeSIan Lepore.Nm
69*9b0841aeSIan Leporepolicy active, it may also be possible to start ntpd as a non-root user,
70*9b0841aeSIan Leporebecause the default ntpd options don't require any additional root
71*9b0841aeSIan Leporeprivileges beyond those granted by the policy.
723496c981SIan Lepore.Ss Privileges Granted
733496c981SIan LeporeThe exact set of kernel privileges granted to any process running
743496c981SIan Leporewith the configured uid is:
753496c981SIan Lepore.Bl -inset -compact -offset indent
76*9b0841aeSIan Lepore.It Dv PRIV_ADJTIME
77*9b0841aeSIan Lepore.It Dv PRIV_CLOCK_SETTIME
78*9b0841aeSIan Lepore.It Dv PRIV_NTP_ADJTIME
79*9b0841aeSIan Lepore.It Dv PRIV_NETINET_RESERVEDPORT
80*9b0841aeSIan Lepore.It Dv PRIV_NETINET_REUSEPORT
813496c981SIan Lepore.El
823496c981SIan Lepore.Ss Runtime Configuration
833496c981SIan LeporeThe following
843496c981SIan Lepore.Xr sysctl 8
853496c981SIan LeporeMIBs are available for fine-tuning this MAC policy.
863496c981SIan LeporeAll
873496c981SIan Lepore.Xr sysctl 8
883496c981SIan Leporevariables can also be set as
893496c981SIan Lepore.Xr loader 8
903496c981SIan Leporetunables in
913496c981SIan Lepore.Xr loader.conf 5 .
923496c981SIan Lepore.Bl -tag -width indent
933496c981SIan Lepore.It Va security.mac.ntpd.enabled
943496c981SIan LeporeEnable the
953496c981SIan Lepore.Nm
963496c981SIan Leporepolicy.
973496c981SIan Lepore(Default: 1).
983496c981SIan Lepore.It Va security.mac.ntpd.uid
993496c981SIan LeporeThe numeric uid of the ntpd user.
1003496c981SIan Lepore(Default: 123).
1013496c981SIan Lepore.El
1023496c981SIan Lepore.Sh SEE ALSO
1033496c981SIan Lepore.Xr mac 4 ,
1043496c981SIan Lepore.Xr ntpd 8
1053496c981SIan Lepore.Sh HISTORY
1063496c981SIan LeporeMAC first appeared in
1073496c981SIan Lepore.Fx 5.0
1083496c981SIan Leporeand
1093496c981SIan Lepore.Nm
1103496c981SIan Leporefirst appeared in
1113496c981SIan Lepore.Fx 12.0 .
112