git: 9front

Download patch

ref: 4242219d656402c7c3e11fc4bb6e9c99deac272f
parent: 41295c96abedf9e7a57a1f9c5486620dc721914f
parent: 6a24a93edf69d1cfe4661935af291ca948421d65
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Tue Jan 5 22:59:40 EST 2016

merge

--- /dev/null
+++ b/sys/src/cmd/auth/lib/private.c
@@ -1,0 +1,28 @@
+#include <u.h>
+#include <libc.h>
+#include <bio.h>
+#include <authsrv.h>
+#include "authcmdlib.h"
+
+static char *pmsg = "Warning! %s can't protect itself from debugging: %r\n";
+static char *smsg = "Warning! %s can't turn off swapping: %r\n";
+
+/* don't allow other processes to debug us and steal keys */
+void
+private(void)
+{
+	int fd;
+	char buf[64];
+
+	snprint(buf, sizeof(buf), "#p/%d/ctl", getpid());
+	fd = open(buf, OWRITE);
+	if(fd < 0){
+		fprint(2, pmsg, argv0);
+		return;
+	}
+	if(fprint(fd, "private") < 0)
+		fprint(2, pmsg, argv0);
+	if(fprint(fd, "noswap") < 0)
+		fprint(2, smsg, argv0);
+	close(fd);
+}
--