[Git][NTPsec/ntpsec][master] RLIMIT_MEMLOCK is BSD/Linux-only and not part of POSIX.1-2001

Eric S. Raymond gitlab at mg.gitlab.com
Thu Dec 15 10:08:13 UTC 2016


Eric S. Raymond pushed to branch master at NTPsec / ntpsec


Commits:
75c61f53 by Matt Selsky at 2016-12-15T01:03:50-05:00
RLIMIT_MEMLOCK is BSD/Linux-only and not part of POSIX.1-2001

Make sure that it exists before trying to use it

Partially fixes GitLab issue #207

- - - - -


2 changed files:

- ntpd/ntp_config.c
- ntpd/ntpd.c


Changes:

=====================================
ntpd/ntp_config.c
=====================================
--- a/ntpd/ntp_config.c
+++ b/ntpd/ntp_config.c
@@ -3690,9 +3690,11 @@ ntp_rlimit(
 #endif
 
 	switch (rl_what) {
+#ifdef RLIMIT_MEMLOCK
 	    case RLIMIT_MEMLOCK:
 		/* ignore - for backward compatibility only */
 		break;
+#endif /* RLIMIT_MEMLOCK */
 
 #ifdef RLIMIT_NOFILE
 	    case RLIMIT_NOFILE:


=====================================
ntpd/ntpd.c
=====================================
--- a/ntpd/ntpd.c
+++ b/ntpd/ntpd.c
@@ -767,9 +767,12 @@ ntpdmain(
 	{
 	    struct rlimit rlim;
 	    rlim.rlim_max = rlim.rlim_cur = RLIM_INFINITY;
+#ifdef RLIMIT_MEMLOCK
 	    if (setrlimit(RLIMIT_MEMLOCK, &rlim) < 0)
 		msyslog(LOG_WARNING, "setrlimit() failed: not locking into RAM");
-	    else if (mlockall(MCL_CURRENT|MCL_FUTURE) < 0)
+	    else
+#endif
+	    if (mlockall(MCL_CURRENT|MCL_FUTURE) < 0)
 		msyslog(LOG_WARNING, "mlockall() failed: not locking into RAM");
 	    else
 		msyslog(LOG_INFO, "successfully locked into RAM");



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/75c61f53f2a9d6e6db607f0171e9d9d5921cba23
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20161215/6de7ee4d/attachment.html>


More information about the vc mailing list