changelog shortlog tags branches files raw gz bz2 help

Mercurial > hg > plan9front / changeset: merge

changeset 5040: 862c812ddbe5
parent 5038: 4ed957d50ccb
parent 5039: 1e556e8c1eb7
child 5042: 77f0501b5cc3
author: cinap_lenrek@felloff.net
date: Wed, 06 Jan 2016 03:59:40 +0100
files:
description: merge
     1.1new file mode 100644
     1.2--- /dev/null
     1.3+++ b/sys/src/cmd/auth/lib/private.c
     1.4@@ -0,0 +1,28 @@
     1.5+#include <u.h>
     1.6+#include <libc.h>
     1.7+#include <bio.h>
     1.8+#include <authsrv.h>
     1.9+#include "authcmdlib.h"
    1.10+
    1.11+static char *pmsg = "Warning! %s can't protect itself from debugging: %r\n";
    1.12+static char *smsg = "Warning! %s can't turn off swapping: %r\n";
    1.13+
    1.14+/* don't allow other processes to debug us and steal keys */
    1.15+void
    1.16+private(void)
    1.17+{
    1.18+	int fd;
    1.19+	char buf[64];
    1.20+
    1.21+	snprint(buf, sizeof(buf), "#p/%d/ctl", getpid());
    1.22+	fd = open(buf, OWRITE);
    1.23+	if(fd < 0){
    1.24+		fprint(2, pmsg, argv0);
    1.25+		return;
    1.26+	}
    1.27+	if(fprint(fd, "private") < 0)
    1.28+		fprint(2, pmsg, argv0);
    1.29+	if(fprint(fd, "noswap") < 0)
    1.30+		fprint(2, smsg, argv0);
    1.31+	close(fd);
    1.32+}