]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
More updates for bug 2817. Harlan Stenn.
authorHarlan Stenn <stenn@ntp.org>
Wed, 23 Sep 2015 10:29:51 +0000 (10:29 +0000)
committerHarlan Stenn <stenn@ntp.org>
Wed, 23 Sep 2015 10:29:51 +0000 (10:29 +0000)
bk: 56027f1fgGkzsvTYQwbdPldH6_FsDg

12 files changed:
ChangeLog
html/miscopt.html
include/ntp_config.h
ntpd/invoke-ntp.conf.texi
ntpd/ntp.conf.5man
ntpd/ntp.conf.5mdoc
ntpd/ntp.conf.def
ntpd/ntp.conf.man.in
ntpd/ntp.conf.mdoc.in
ntpd/ntp_config.c
ntpd/ntpd.c
sntp/m4/ntp_rlimit.m4

index b5c2197edeb769cfafab72d739bb03696247931c..8b955ec6b3c47e4d8ecb34735d3cad8b6aeb217a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -118,6 +118,7 @@ fixed formatting. Tomasz Flendrich
 * Fix progname definition in unity runner scripts.  Harlan Stenn.
 * Clean trailing whitespace in tests/ntpd/Makefile.am.  Harlan Stenn.
 * Update the patch for bug 2817.  Harlan Stenn.
+* More updates for bug 2817.  Harlan Stenn.
 ---
 (4.2.8p3) 2015/06/29 Released by Harlan Stenn <stenn@ntp.org>
 
index ac32419df08a8dd48bbdda9db4cef13d773d832e..c6190222bf96b36bdb2632be9a817f7b38686df6 100644 (file)
@@ -11,7 +11,7 @@
 <img src="pic/boom3.gif" alt="gif" align="left"><a href="http://www.eecis.udel.edu/~mills/pictures.html">from <i>Pogo</i>, Walt Kelly</a>
 <p>We have three, now looking for more.</p>
 <p>Last update:
-  <!-- #BeginDate format:En2m -->29-Jun-2015  05:56<!-- #EndDate -->
+  <!-- #BeginDate format:En2m -->23-Sep-2015  10:20<!-- #EndDate -->
     UTC</p>
 <br clear="left">
 <h4>Related Links</h4>
   <dd>
     <dl>
       <dt><tt>memlock <i>Nmegabytes</i></tt></dt>
-      <dd>Specify the number of megabytes of memory that can be allocated.  Probably only available under Linux, this option is useful when dropping root (the <tt>-i</tt> option).   The default is 32  megabytes. Setting this to zero will prevent any attemp to lock memory.</dd>
+      <dd>Specify the number of megabytes of memory that should be allocated and locked.  Probably only available under Linux, this option may be useful when dropping root (the <tt>-i</tt> option).  The default is 32 megabytes on non-Linux machines, and -1 under Linux.  -1 means "do not lock the process into memory".  0 means "lock whatever memory the process wants into memory".</dd>
       <dt><tt>stacksize <i>N4kPages</i></tt></dt>
       <dd>Specifies the maximum size of the process stack on systems with the <tt>mlockall()</tt> function. Defaults to 50 4k pages (200 4k pages in OpenBSD).</dd>
       <dt><tt>filenum <i>Nfiledescriptors</i></tt></dt>
index a74cd552b85dd5e8fd4b6f34f77597777409a2ed..bd8f595d94f30d7f671d01f398f2f1ab4c8bccf5 100644 (file)
@@ -46,8 +46,8 @@
 extern int     cmdline_server_count;
 extern char ** cmdline_servers;
 
-/* set to zero if admin doesn't want memory locked */
-extern int     do_memlock;
+/* set to zero if we're not locking memory */
+extern int     cur_memlock;
 
 typedef struct int_range_tag {
        int     first;
index 8c8a8a6d27f82ef14999b7cd0794377a48903593..c1df1693bc3f1a65c17b3848279812cc75bb189c 100644 (file)
@@ -6,7 +6,7 @@
 #
 # EDIT THIS FILE WITH CAUTION  (invoke-ntp.conf.texi)
 #
-# It has been AutoGen-ed  July 26, 2015 at 06:23:38 AM by AutoGen 5.18.5
+# It has been AutoGen-ed  September 23, 2015 at 10:15:09 AM by AutoGen 5.18.5
 # From the definitions    ntp.conf.def
 # and the template file   agtexi-file.tpl
 @end ignore
@@ -1837,7 +1837,7 @@ re-associate accordingly.
 Some administrators prefer to avoid running
 @code{ntpd(1ntpdmdoc)}
 continuously and run either
-@code{ntpdate(8)}
+@code{sntp(1sntpmdoc)}
 or
 @code{ntpd(1ntpdmdoc)}
 @code{-q}
@@ -2578,12 +2578,15 @@ pulses will not be suppressed.
 @item @code{rlimit} @code{[@code{memlock} @kbd{Nmegabytes} | @code{stacksize} @kbd{N4kPages} @code{filenum} @kbd{Nfiledescriptors}]}
 @table @asis
 @item @code{memlock} @kbd{Nmegabytes}
-Specify the number of megabytes of memory that can be allocated.
-Probably only available under Linux, this option is useful
+Specify the number of megabytes of memory that should be
+allocated and locked.
+Probably only available under Linux, this option may be useful
 when dropping root (the
 @code{-i}
 option).
-The default is 32 megabytes. Setting this to zero will prevent any attemp to lock memory.
+The default is 32 megabytes on non-Linux machines, and -1 under Linux.
+-1 means "do not lock the process into memory".
+0 means "lock whatever memory the process wants into memory".
 @item @code{stacksize} @kbd{N4kPages}
 Specifies the maximum size of the process stack on systems with the
 @code{mlockall()}
index a57a27dbde0559dd7f894d043fdefb920dbc336d..350f09dc18ecd86636c6558c3ee2c1e1b39caf41 100644 (file)
 .ds B-Font B
 .ds I-Font I
 .ds R-Font R
-.TH ntp.conf 5man "26 Jul 2015" "4.2.8p3" "File Formats"
+.TH ntp.conf 5man "23 Sep 2015" "4.2.8p3" "File Formats"
 .\"
 .\" EDIT THIS FILE WITH CAUTION (in-mem file)
 .\"
-.\" It has been AutoGen-ed July 26, 2015 at 06:23:41 AM by AutoGen 5.18.5
+.\" It has been AutoGen-ed September 23, 2015 at 10:22:45 AM by AutoGen 5.18.5
 .\" From the definitions ntp.conf.def
 .\" and the template file agman-cmd.tpl
 .SH NAME
@@ -2080,7 +2080,7 @@ re-associate accordingly.
 Some administrators prefer to avoid running
 \fCntpd\f[]\fR(1ntpdmdoc)\f[]
 continuously and run either
-\fCntpdate\f[]\fR(8)\f[]
+\fCsntp\f[]\fR(1sntpmdoc)\f[]
 or
 \fCntpd\f[]\fR(1ntpdmdoc)\f[]
 \f\*[B-Font]\-q\f[]
@@ -2897,12 +2897,15 @@ pulses will not be suppressed.
 .RS
 .TP 7
 .NOP \f\*[B-Font]memlock\f[] \f\*[I-Font]Nmegabytes\f[]
-Specify the number of megabytes of memory that can be allocated.
-Probably only available under Linux, this option is useful
+Specify the number of megabytes of memory that should be
+allocated and locked.
+Probably only available under Linux, this option may be useful
 when dropping root (the
 \f\*[B-Font]\-i\f[]
 option).
-The default is 32 megabytes. Setting this to zero will prevent any attemp to lock memory.
+The default is 32 megabytes on non-Linux machines, and \-1 under Linux.
+-1 means "do not lock the process into memory".
+0 means "lock whatever memory the process wants into memory".
 .TP 7
 .NOP \f\*[B-Font]stacksize\f[] \f\*[I-Font]N4kPages\f[]
 Specifies the maximum size of the process stack on systems with the
index 7cd5513a1cfc0359ff5dca90d3aba81e5b2e09a9..a5b250d1b42385c2166740cbd880301064653289 100644 (file)
@@ -1,9 +1,9 @@
-.Dd July 26 2015
+.Dd September 23 2015
 .Dt NTP_CONF 5mdoc File Formats
 .Os
 .\"  EDIT THIS FILE WITH CAUTION  (ntp.mdoc)
 .\"
-.\"  It has been AutoGen-ed  July 26, 2015 at 06:23:35 AM by AutoGen 5.18.5
+.\"  It has been AutoGen-ed  September 23, 2015 at 10:15:06 AM by AutoGen 5.18.5
 .\"  From the definitions    ntp.conf.def
 .\"  and the template file   agmdoc-cmd.tpl
 .Sh NAME
@@ -1903,7 +1903,7 @@ re\-associate accordingly.
 Some administrators prefer to avoid running
 .Xr ntpd 1ntpdmdoc
 continuously and run either
-.Xr ntpdate 8
+.Xr sntp 1sntpmdoc
 or
 .Xr ntpd 1ntpdmdoc
 .Fl q
@@ -2725,12 +2725,15 @@ pulses will not be suppressed.
 .Xc
 .Bl -tag -width indent
 .It Cm memlock Ar Nmegabytes
-Specify the number of megabytes of memory that can be allocated.
-Probably only available under Linux, this option is useful
+Specify the number of megabytes of memory that should be
+allocated and locked.
+Probably only available under Linux, this option may be useful
 when dropping root (the
 .Fl i
 option).
-The default is 32 megabytes. Setting this to zero will prevent any attemp to lock memory.
+The default is 32 megabytes on non\-Linux machines, and \-1 under Linux.
+-1 means "do not lock the process into memory".
+0 means "lock whatever memory the process wants into memory".
 .It Cm stacksize Ar N4kPages
 Specifies the maximum size of the process stack on systems with the
 .Fn mlockall
index 9aeb211b48047e1bada990de59747d92f50b5c43..43835bc7632ecb2ac3def88c3375aff065430326 100644 (file)
@@ -2727,12 +2727,15 @@ pulses will not be suppressed.
 .Xc
 .Bl -tag -width indent
 .It Cm memlock Ar Nmegabytes
-Specify the number of megabytes of memory that can be allocated.
-Probably only available under Linux, this option is useful
+Specify the number of megabytes of memory that should be
+allocated and locked.
+Probably only available under Linux, this option may be useful
 when dropping root (the
 .Fl i
 option).
-The default is 32 megabytes. Setting this to zero will prevent any attemp to lock memory.
+The default is 32 megabytes on non-Linux machines, and -1 under Linux.
+-1 means "do not lock the process into memory".
+0 means "lock whatever memory the process wants into memory".
 .It Cm stacksize Ar N4kPages
 Specifies the maximum size of the process stack on systems with the
 .Fn mlockall
index 9db0c59e0d2ea632e3541d079252eb435b0b6d78..b9468e3440b81768c578903a22a02da93b190924 100644 (file)
 .ds B-Font B
 .ds I-Font I
 .ds R-Font R
-.TH ntp.conf 5 "26 Jul 2015" "4.2.8p3" "File Formats"
+.TH ntp.conf 5 "23 Sep 2015" "4.2.8p3" "File Formats"
 .\"
 .\" EDIT THIS FILE WITH CAUTION (in-mem file)
 .\"
-.\" It has been AutoGen-ed July 26, 2015 at 06:23:41 AM by AutoGen 5.18.5
+.\" It has been AutoGen-ed September 23, 2015 at 10:22:45 AM by AutoGen 5.18.5
 .\" From the definitions ntp.conf.def
 .\" and the template file agman-cmd.tpl
 .SH NAME
@@ -2080,7 +2080,7 @@ re-associate accordingly.
 Some administrators prefer to avoid running
 \fCntpd\f[]\fR(@NTPD_MS@)\f[]
 continuously and run either
-\fCntpdate\f[]\fR(8)\f[]
+\fCsntp\f[]\fR(@SNTP_MS@)\f[]
 or
 \fCntpd\f[]\fR(@NTPD_MS@)\f[]
 \f\*[B-Font]\-q\f[]
@@ -2897,12 +2897,15 @@ pulses will not be suppressed.
 .RS
 .TP 7
 .NOP \f\*[B-Font]memlock\f[] \f\*[I-Font]Nmegabytes\f[]
-Specify the number of megabytes of memory that can be allocated.
-Probably only available under Linux, this option is useful
+Specify the number of megabytes of memory that should be
+allocated and locked.
+Probably only available under Linux, this option may be useful
 when dropping root (the
 \f\*[B-Font]\-i\f[]
 option).
-The default is 32 megabytes. Setting this to zero will prevent any attemp to lock memory.
+The default is 32 megabytes on non-Linux machines, and \-1 under Linux.
+-1 means "do not lock the process into memory".
+0 means "lock whatever memory the process wants into memory".
 .TP 7
 .NOP \f\*[B-Font]stacksize\f[] \f\*[I-Font]N4kPages\f[]
 Specifies the maximum size of the process stack on systems with the
index b1dbd80502cb101be2fa54c305f2f2562019fe6a..b6f648fb88d28fd699d7f84cbba280f40cce2d1c 100644 (file)
@@ -1,9 +1,9 @@
-.Dd July 26 2015
+.Dd September 23 2015
 .Dt NTP_CONF 5 File Formats
 .Os
 .\"  EDIT THIS FILE WITH CAUTION  (ntp.mdoc)
 .\"
-.\"  It has been AutoGen-ed  July 26, 2015 at 06:23:35 AM by AutoGen 5.18.5
+.\"  It has been AutoGen-ed  September 23, 2015 at 10:15:06 AM by AutoGen 5.18.5
 .\"  From the definitions    ntp.conf.def
 .\"  and the template file   agmdoc-cmd.tpl
 .Sh NAME
@@ -1903,7 +1903,7 @@ re\-associate accordingly.
 Some administrators prefer to avoid running
 .Xr ntpd @NTPD_MS@
 continuously and run either
-.Xr ntpdate 8
+.Xr sntp @SNTP_MS@
 or
 .Xr ntpd @NTPD_MS@
 .Fl q
@@ -2725,12 +2725,15 @@ pulses will not be suppressed.
 .Xc
 .Bl -tag -width indent
 .It Cm memlock Ar Nmegabytes
-Specify the number of megabytes of memory that can be allocated.
-Probably only available under Linux, this option is useful
+Specify the number of megabytes of memory that should be
+allocated and locked.
+Probably only available under Linux, this option may be useful
 when dropping root (the
 .Fl i
 option).
-The default is 32 megabytes. Setting this to zero will prevent any attemp to lock memory.
+The default is 32 megabytes on non\-Linux machines, and \-1 under Linux.
+-1 means "do not lock the process into memory".
+0 means "lock whatever memory the process wants into memory".
 .It Cm stacksize Ar N4kPages
 Specifies the maximum size of the process stack on systems with the
 .Fn mlockall
index 197900f62b208d0ecc37b4f6ac8cae991da4a6b4..85a8265f88d7e3c31faf493e4b2e17deb0eb9664 100644 (file)
 #include "ntp_parser.h"
 #include "ntpd-opts.h"
 
+/* Bug 2817 */
+#if defined(HAVE_SYS_MMAN_H)
+# include <sys/mman.h>
+#endif
 
 /* list of servers from command line for config_peers() */
 int    cmdline_server_count;
 char **        cmdline_servers;
 
-/* set to zero if admin doesn't want memory locked */
-int    do_memlock = 1;
+/* Current state of memory locking:
+ * -1: default
+ *  0: memory locking disabled
+ *  1: Memory locking enabled
+ */
+int    cur_memlock = -1;
 
 /*
  * "logconfig" building blocks
@@ -2613,18 +2621,32 @@ config_rlimit(
                        break;
 
                case T_Memlock:
-                       if (rlimit_av->value.i != 0) {
+                       /* What if we HAVE_OPT(SAVECONFIGQUIT) ? */
+                       if (rlimit_av->value.i == -1) {
+                               if (cur_memlock != 0) {
+                                       if (-1 == munlockall()) {
+                                               msyslog(LOG_ERR, "munlockall() failed: %m");
+                                       }
+                               }
+                               cur_memlock = 0;
+                       } else if (rlimit_av->value.i >= 0) {
 #if defined(RLIMIT_MEMLOCK)
+                               if (cur_memlock != 1) {
+                                       if (-1 == mlockall(MCL_CURRENT|MCL_FUTURE)) {
+                                               msyslog(LOG_ERR, "mlockall() failed: %m");
+                                       }
+                               }
                                ntp_rlimit(RLIMIT_MEMLOCK,
                                           (rlim_t)(rlimit_av->value.i * 1024 * 1024),
                                           1024 * 1024,
                                           "MB");
+                               cur_memlock = 1;
 #else
                                /* STDERR as well would be fine... */
                                msyslog(LOG_WARNING, "'rlimit memlock' specified but is not available on this system.");
 #endif /* RLIMIT_MEMLOCK */
                        } else {
-                               do_memlock = 0;
+                               msyslog(LOG_WARNING, "'rlimit memlock' value of %d is unexpected!", rlimit_av->value.i);
                        }
                        break;
 
index 6c4fcc2e6839cbc0250042937b29513e3d9f5ff0..2604f64645d127215a7f6ed2940c3c5ff172b212 100644 (file)
@@ -785,7 +785,7 @@ ntpdmain(
         */
        getconfig(argc, argv);
 
-       if (do_memlock) {
+       if (-1 == cur_memlock && -1 != DFLT_RLIMIT_MEMLOCK) {
 # if defined(HAVE_MLOCKALL)
                /*
                 * lock the process into memory
index 3be1adefc7da7bd91199b09814345cf4b32626f6..48d26dd3c69f152d4752b00c74e13a552f4e02b6 100644 (file)
@@ -31,7 +31,7 @@ case "$ntp_cv_rlimit_memlock" in
     AC_SUBST([HAVE_RLIMIT_MEMLOCK])
     case "$host" in
      *-*-*linux*)
-       ntp_dflt_rlimit_memlock="0"  ;;
+       ntp_dflt_rlimit_memlock="-1"  ;;
      *) ntp_dflt_rlimit_memlock="32" ;;
     esac
     HAVE_RLIMIT_MEMLOCK=" memlock $ntp_dflt_rlimit_memlock"  ;;
@@ -103,7 +103,7 @@ AC_ARG_WITH(
     [memlock],
     [AS_HELP_STRING(
        [--with-memlock],
-       [? =32 (0 on linux) megabytes]
+       [? =32 (-1 on linux) megabytes]
     )],
     [ans=$withval],
     [ans=yes]