From fe081dbbfc4993b69d6d5c8cebb3708bf22e2bbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dag-Erling=20Sm=C3=B8rgrav?= Date: Thu, 15 Aug 2013 16:00:41 +0000 Subject: [PATCH] Unfortunately, Linux doesn't have MAP_NOCORE. git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@696 185d5e19-27fe-0310-9dcf-9bff6b9f3609 --- lib/liboath/oath_key_alloc.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/liboath/oath_key_alloc.c b/lib/liboath/oath_key_alloc.c index 7385732..b725fb2 100644 --- a/lib/liboath/oath_key_alloc.c +++ b/lib/liboath/oath_key_alloc.c @@ -53,9 +53,14 @@ struct oath_key * oath_key_alloc(void) { struct oath_key *key; + int prot, flags; - if ((key = mmap(NULL, sizeof *key, PROT_READ|PROT_WRITE, - MAP_ANON|MAP_NOCORE, -1, 0)) == NULL) { + prot = PROT_READ|PROT_WRITE; + flags = MAP_ANON; +#ifdef MAP_NOCORE + flags |= MAP_NOCORE; +#endif + if ((key = mmap(NULL, sizeof *key, prot, flags, -1, 0)) == NULL) { memset(key, 0, sizeof *key); key->mapped = 1; if (mlock(key, sizeof *key) == 0)