ntp-4.2.6p2-mlock.patch 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. diff -up ntp-4.2.6p2/html/ntpd.html.mlock ntp-4.2.6p2/html/ntpd.html
  2. --- ntp-4.2.6p2/html/ntpd.html.mlock 2010-07-12 16:36:09.000000000 +0200
  3. +++ ntp-4.2.6p2/html/ntpd.html 2010-07-12 16:36:09.000000000 +0200
  4. @@ -32,7 +32,7 @@
  5. </ul>
  6. <hr>
  7. <h4 id="synop">Synopsis</h4>
  8. - <tt>ntpd [ -46aAbdDgLnNqx ] [ -c <i>conffile</i> ] [ -f <i>driftfile</i> ] [ -i <i>jaildir</i> ] [ -I <i>iface</i> ] [ -k <i>keyfile</i> ] [ -l <i>logfile</i> ] [ -p <i>pidfile</i> ] [ -P <i>priority</i> ] [ -r <i>broadcastdelay</i> ] [ -s <i>statsdir</i> ] [ -t <i>key</i> ] [ -u <i>user</i>[:<i>group</i>] ] [ -U <i>interface_update_interval</i> ] [ -v <i>variable</i> ] [ -V <i>variable</i> ]</tt>
  9. + <tt>ntpd [ -46aAbdDgLmnNqx ] [ -c <i>conffile</i> ] [ -f <i>driftfile</i> ] [ -i <i>jaildir</i> ] [ -I <i>iface</i> ] [ -k <i>keyfile</i> ] [ -l <i>logfile</i> ] [ -p <i>pidfile</i> ] [ -P <i>priority</i> ] [ -r <i>broadcastdelay</i> ] [ -s <i>statsdir</i> ] [ -t <i>key</i> ] [ -u <i>user</i>[:<i>group</i>] ] [ -U <i>interface_update_interval</i> ] [ -v <i>variable</i> ] [ -V <i>variable</i> ]</tt>
  10. <h4 id="descr">Description</h4>
  11. <p>The <tt>ntpd</tt> program is an operating system daemon that synchronises the system clock with remote NTP&nbsp;time servers or local reference clocks. It is a complete implementation of the Network Time Protocol (NTP) version 4, but also retains compatibility with version 3, as defined by RFC-1305, and version 1 and 2, as defined by RFC-1059 and RFC-1119, respectively. The program can operate in any of several modes, as described on the <a href="assoc.html">Association Management</a> page, and with both symmetric key and public key cryptography, as described on the <a href="manyopt.html">Authentication Options</a> page.</p>
  12. <p>The <tt>ntpd</tt> program ordinarily requires a configuration file as desccribe on the Configuration Commands and Options collection above. However a client can discover remote servers and configure them automatically. This makes it possible to deploy a fleet of workstations without specifying configuration details specific to the local environment. Further details are on the <a href="manyopt.html">Automatic Server Discovery</a> page.</p>
  13. @@ -123,6 +123,8 @@
  14. <dd>Do not listen to virtual interfaces, defined as those with names containing a colon. This option is deprecated. Please consider using the configuration file <a href="miscopt.html#interface">interface</a> command, which is more versatile.</dd>
  15. <dt><tt>-M</tt></dt>
  16. <dd>Raise scheduler precision to its maximum (1 msec) using timeBeginPeriod. (Windows only)</dd>
  17. + <dt><tt>-m</tt>
  18. + <dd>Lock memory.
  19. <dt><tt>-n</tt></dt>
  20. <dd>Don't fork.</dd>
  21. <dt><tt>-N</tt></dt>
  22. diff -up ntp-4.2.6p2/ntpd/ntpd-opts.c.mlock ntp-4.2.6p2/ntpd/ntpd-opts.c
  23. --- ntp-4.2.6p2/ntpd/ntpd-opts.c.mlock 2010-07-09 04:23:28.000000000 +0200
  24. +++ ntp-4.2.6p2/ntpd/ntpd-opts.c 2010-07-12 16:36:09.000000000 +0200
  25. @@ -284,6 +284,15 @@ tSCC zNice_Name[] = "ni
  26. #define NICE_FLAGS (OPTST_DISABLED)
  27. /*
  28. + * Mlock option description:
  29. + */
  30. +tSCC zMlockText[] =
  31. + "Lock memory";
  32. +tSCC zMlock_NAME[] = "MLOCK";
  33. +tSCC zMlock_Name[] = "mlock";
  34. +#define MLOCK_FLAGS (OPTST_DISABLED)
  35. +
  36. +/*
  37. * Pidfile option description:
  38. */
  39. tSCC zPidfileText[] =
  40. @@ -911,6 +920,18 @@ static tOptDesc optDesc[ OPTION_CT ] = {
  41. /* desc, NAME, name */ zPccfreqText, zPccfreq_NAME, zPccfreq_Name,
  42. /* disablement strs */ NULL, NULL },
  43. + { /* entry idx, value */ 32, VALUE_OPT_MLOCK,
  44. + /* equiv idx, value */ 32, VALUE_OPT_MLOCK,
  45. + /* equivalenced to */ NO_EQUIVALENT,
  46. + /* min, max, act ct */ 0, 1, 0,
  47. + /* opt state flags */ MLOCK_FLAGS, 0,
  48. + /* last opt argumnt */ { NULL },
  49. + /* arg list/cookie */ NULL,
  50. + /* must/cannot opts */ NULL, NULL,
  51. + /* option proc */ NULL,
  52. + /* desc, NAME, name */ zMlockText, zMlock_NAME, zMlock_Name,
  53. + /* disablement strs */ NULL, NULL },
  54. +
  55. { /* entry idx, value */ INDEX_OPT_VERSION, VALUE_OPT_VERSION,
  56. /* equiv idx value */ NO_EQUIVALENT, 0,
  57. /* equivalenced to */ NO_EQUIVALENT,
  58. @@ -1005,7 +1026,7 @@ tOptions ntpdOptions = {
  59. NO_EQUIVALENT, /* '-#' option index */
  60. NO_EQUIVALENT /* index of default opt */
  61. },
  62. - 35 /* full option count */, 32 /* user option count */,
  63. + 36 /* full option count */, 33 /* user option count */,
  64. ntpd_full_usage, ntpd_short_usage,
  65. NULL, NULL
  66. };
  67. diff -up ntp-4.2.6p2/ntpd/ntpd-opts.h.mlock ntp-4.2.6p2/ntpd/ntpd-opts.h
  68. --- ntp-4.2.6p2/ntpd/ntpd-opts.h.mlock 2010-07-09 04:23:28.000000000 +0200
  69. +++ ntp-4.2.6p2/ntpd/ntpd-opts.h 2010-07-12 16:36:09.000000000 +0200
  70. @@ -84,12 +84,13 @@ typedef enum {
  71. INDEX_OPT_SLEW = 29,
  72. INDEX_OPT_USEPCC = 30,
  73. INDEX_OPT_PCCFREQ = 31,
  74. - INDEX_OPT_VERSION = 32,
  75. - INDEX_OPT_HELP = 33,
  76. - INDEX_OPT_MORE_HELP = 34
  77. + INDEX_OPT_MLOCK = 32,
  78. + INDEX_OPT_VERSION = 33,
  79. + INDEX_OPT_HELP = 34,
  80. + INDEX_OPT_MORE_HELP = 35
  81. } teOptIndex;
  82. -#define OPTION_CT 35
  83. +#define OPTION_CT 36
  84. #define NTPD_VERSION "4.2.6p2"
  85. #define NTPD_FULL_VERSION "ntpd - NTP daemon program - Ver. 4.2.6p2"
  86. @@ -182,6 +183,10 @@ typedef enum {
  87. # warning undefining MODIFYMMTIMER due to option name conflict
  88. # undef MODIFYMMTIMER
  89. # endif
  90. +# ifdef MLOCK
  91. +# warning undefining MLOCK due to option name conflict
  92. +# undef MLOCK
  93. +# endif
  94. # ifdef NOFORK
  95. # warning undefining NOFORK due to option name conflict
  96. # undef NOFORK
  97. @@ -263,6 +268,7 @@ typedef enum {
  98. # undef LOGFILE
  99. # undef NOVIRTUALIPS
  100. # undef MODIFYMMTIMER
  101. +# undef MLOCK
  102. # undef NOFORK
  103. # undef NICE
  104. # undef PIDFILE
  105. @@ -301,6 +307,7 @@ typedef enum {
  106. #define VALUE_OPT_LOGFILE 'l'
  107. #define VALUE_OPT_NOVIRTUALIPS 'L'
  108. #define VALUE_OPT_MODIFYMMTIMER 'M'
  109. +#define VALUE_OPT_MLOCK 'm'
  110. #define VALUE_OPT_NOFORK 'n'
  111. #define VALUE_OPT_NICE 'N'
  112. #define VALUE_OPT_PIDFILE 'p'
  113. diff -up ntp-4.2.6p2/ntpd/ntpd.c.mlock ntp-4.2.6p2/ntpd/ntpd.c
  114. --- ntp-4.2.6p2/ntpd/ntpd.c.mlock 2010-07-12 16:36:09.000000000 +0200
  115. +++ ntp-4.2.6p2/ntpd/ntpd.c 2010-07-12 16:36:09.000000000 +0200
  116. @@ -722,7 +722,8 @@ ntpdmain(
  117. }
  118. #endif
  119. -#if defined(HAVE_MLOCKALL) && defined(MCL_CURRENT) && defined(MCL_FUTURE)
  120. +#if defined(MCL_CURRENT) && defined(MCL_FUTURE)
  121. + if (HAVE_OPT( MLOCK )) {
  122. # ifdef HAVE_SETRLIMIT
  123. /*
  124. * Set the stack limit to something smaller, so that we don't lock a lot
  125. @@ -748,7 +749,7 @@ ntpdmain(
  126. * fail if we drop root privlege. To be useful the value
  127. * has to be larger than the largest ntpd resident set size.
  128. */
  129. - rl.rlim_cur = rl.rlim_max = 32*1024*1024;
  130. + rl.rlim_cur = rl.rlim_max = 64*1024*1024;
  131. if (setrlimit(RLIMIT_MEMLOCK, &rl) == -1) {
  132. msyslog(LOG_ERR, "Cannot set RLIMIT_MEMLOCK: %m");
  133. }
  134. @@ -760,6 +761,7 @@ ntpdmain(
  135. */
  136. if (mlockall(MCL_CURRENT|MCL_FUTURE) < 0)
  137. msyslog(LOG_ERR, "mlockall(): %m");
  138. + }
  139. #else /* not (HAVE_MLOCKALL && MCL_CURRENT && MCL_FUTURE) */
  140. # ifdef HAVE_PLOCK
  141. # ifdef PROCLOCK