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.\" 243496c981SIan Lepore.\" $FreeBSD$ 253496c981SIan Lepore.\" 26*9b0841aeSIan Lepore.Dd July 20, 2018 273496c981SIan Lepore.Dt MAC_NTPD 4 283496c981SIan Lepore.Os 293496c981SIan Lepore.Sh NAME 303496c981SIan Lepore.Nm mac_ntpd 313496c981SIan Lepore.Nd "policy allowing ntpd to run as non-root user" 323496c981SIan Lepore.Sh SYNOPSIS 333496c981SIan LeporeTo compile the ntpd policy into your kernel, place the following lines 343496c981SIan Leporein your kernel configuration file: 353496c981SIan Lepore.Bd -ragged -offset indent 363496c981SIan Lepore.Cd "options MAC" 373496c981SIan Lepore.Cd "options MAC_NTPD" 383496c981SIan Lepore.Ed 393496c981SIan Lepore.Pp 403496c981SIan LeporeAlternately, to load the ntpd policy module at boot time, 413496c981SIan Leporeplace the following line in your kernel configuration file: 423496c981SIan Lepore.Bd -ragged -offset indent 433496c981SIan Lepore.Cd "options MAC" 443496c981SIan Lepore.Ed 453496c981SIan Lepore.Pp 463496c981SIan Leporeand in 473496c981SIan Lepore.Xr loader.conf 5 : 48*9b0841aeSIan Lepore.Bd -literal -offset indent 49*9b0841aeSIan Leporemac_ntpd_load="YES" 50*9b0841aeSIan Lepore.Ed 513496c981SIan Lepore.Sh DESCRIPTION 523496c981SIan LeporeThe 533496c981SIan Lepore.Nm 543496c981SIan Leporepolicy grants any process running as user 553496c981SIan Lepore.Sq ntpd 563496c981SIan Lepore(uid 123) the privileges needed to manipulate 573496c981SIan Leporesystem time, and to (re-)bind to the privileged NTP port. 583496c981SIan Lepore.Pp 593496c981SIan LeporeWhen 603496c981SIan Lepore.Xr ntpd 8 613496c981SIan Leporeis started with 62*9b0841aeSIan Lepore.Sq Fl u Ar <user>[:group] 633496c981SIan Leporeon the command line, it performs all initializations requiring root 643496c981SIan Leporeprivileges, then drops root privileges by switching to the given user id. 653496c981SIan LeporeFrom that point on, the only privileges it requires are the ability 663496c981SIan Leporeto manipulate system time, and the ability to re-bind a UDP socket 673496c981SIan Leporeto the NTP port (port 123) after a network interface change. 68*9b0841aeSIan Lepore.Pp 69*9b0841aeSIan LeporeWith the 70*9b0841aeSIan Lepore.Nm 71*9b0841aeSIan Leporepolicy active, it may also be possible to start ntpd as a non-root user, 72*9b0841aeSIan Leporebecause the default ntpd options don't require any additional root 73*9b0841aeSIan Leporeprivileges beyond those granted by the policy. 743496c981SIan Lepore.Pp 753496c981SIan Lepore.Ss Privileges Granted 763496c981SIan LeporeThe exact set of kernel privileges granted to any process running 773496c981SIan Leporewith the configured uid is: 783496c981SIan Lepore.Bl -inset -compact -offset indent 79*9b0841aeSIan Lepore.It Dv PRIV_ADJTIME 80*9b0841aeSIan Lepore.It Dv PRIV_CLOCK_SETTIME 81*9b0841aeSIan Lepore.It Dv PRIV_NTP_ADJTIME 82*9b0841aeSIan Lepore.It Dv PRIV_NETINET_RESERVEDPORT 83*9b0841aeSIan Lepore.It Dv PRIV_NETINET_REUSEPORT 843496c981SIan Lepore.El 853496c981SIan Lepore.Pp 863496c981SIan Lepore.Ss Runtime Configuration 873496c981SIan LeporeThe following 883496c981SIan Lepore.Xr sysctl 8 893496c981SIan LeporeMIBs are available for fine-tuning this MAC policy. 903496c981SIan LeporeAll 913496c981SIan Lepore.Xr sysctl 8 923496c981SIan Leporevariables can also be set as 933496c981SIan Lepore.Xr loader 8 943496c981SIan Leporetunables in 953496c981SIan Lepore.Xr loader.conf 5 . 963496c981SIan Lepore.Bl -tag -width indent 973496c981SIan Lepore.It Va security.mac.ntpd.enabled 983496c981SIan LeporeEnable the 993496c981SIan Lepore.Nm 1003496c981SIan Leporepolicy. 1013496c981SIan Lepore(Default: 1). 1023496c981SIan Lepore.It Va security.mac.ntpd.uid 1033496c981SIan LeporeThe numeric uid of the ntpd user. 1043496c981SIan Lepore(Default: 123). 1053496c981SIan Lepore.El 1063496c981SIan Lepore.Sh SEE ALSO 1073496c981SIan Lepore.Xr mac 4 , 1083496c981SIan Lepore.Xr ntpd 8 1093496c981SIan Lepore.Sh HISTORY 1103496c981SIan LeporeMAC first appeared in 1113496c981SIan Lepore.Fx 5.0 1123496c981SIan Leporeand 1133496c981SIan Lepore.Nm 1143496c981SIan Leporefirst appeared in 1153496c981SIan Lepore.Fx 12.0 . 116