openbsd-ports/security/gnupg/patches/patch-util_secmem_c

41 lines
1.1 KiB
Plaintext
Raw Normal View History

2014-10-13 19:21:16 +00:00
$OpenBSD: patch-util_secmem_c,v 1.5 2014/10/13 19:21:16 sthen Exp $
--- util/secmem.c.orig Thu Dec 20 12:22:28 2012
+++ util/secmem.c Sun Dec 30 23:27:38 2012
2014-10-13 19:21:16 +00:00
@@ -36,6 +36,8 @@
#include <sys/lock.h>
#endif
#endif
+#include <sys/sysctl.h>
+#include <uvm/uvm_swap_encrypt.h>
#include "types.h"
#include "memory.h"
2014-10-13 19:21:16 +00:00
@@ -91,11 +93,23 @@ static int suspend_warning;
static void
print_warn(void)
{
- if (!no_warning)
+ int mib[3], swapencrypt = 0;
+ size_t len;
+
+ mib[0] = CTL_VM;
+ mib[1] = VM_SWAPENCRYPT;
+ mib[2] = SWPENC_ENABLE;
+
+ len = sizeof(swapencrypt);
+
+ if (sysctl(mib, 3, &swapencrypt, &len, NULL, 0) == -1)
+ log_info("WARNING: Can't receive vm.swapencrypt.enable sysctl value\n");
+
+ if (!no_warning && !swapencrypt)
{
- log_info(_("WARNING: using insecure memory!\n"));
- log_info(_("please see http://www.gnupg.org/documentation/faqs.html"
- " for more information\n"));
+ log_info("WARNING: Using insecure memory!\n");
+ log_info("Please enable swap encryption via"
+ " 'sysctl vm.swapencrypt.enable=1'.\n");
}
}