diff options
| author | cinap_lenrek <cinap_lenrek@felloff.net> | 2016-01-06 03:59:40 +0100 |
|---|---|---|
| committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2016-01-06 03:59:40 +0100 |
| commit | cd747191012d0420ac631340d962da1f80cef0a5 (patch) | |
| tree | 75fb2e8636b2028f62f930be2a34cfa6fc033767 | |
| parent | 3735cc9bc3a44b53d0c639493f21cf4d29be1136 (diff) | |
| parent | 4cf801b8537276103a09d44dad31f637164916e7 (diff) | |
| download | plan9front-cd747191012d0420ac631340d962da1f80cef0a5.tar.xz | |
merge
| -rw-r--r-- | sys/src/cmd/auth/lib/private.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/sys/src/cmd/auth/lib/private.c b/sys/src/cmd/auth/lib/private.c new file mode 100644 index 000000000..392842c0d --- /dev/null +++ b/sys/src/cmd/auth/lib/private.c @@ -0,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); +} |
