shithub: riscv

Download patch

ref: 56768a36df13d7703c5fce283fff2dbb5c0094da
parent: 8dec598474aacb3e9016a79eea43796842ae4af5
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Fri Dec 23 09:58:39 EST 2022

auth/factotum: access /proc instead of #p for private()

--- a/sys/src/cmd/auth/factotum/fs.c
+++ b/sys/src/cmd/auth/factotum/fs.c
@@ -179,18 +179,17 @@
 	exits(nil);
 }
 
-char *pmsg = "Warning! %s can't protect itself from debugging: %r\n";
-char *smsg = "Warning! %s can't turn off swapping: %r\n";
-
 /* don't allow other processes to debug us and steal keys */
 static void
 private(void)
 {
 	int fd;
-	char buf[64];
+	char buf[32];
+	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";
 
-	snprint(buf, sizeof(buf), "#p/%d/ctl", getpid());
-	fd = open(buf, OWRITE);
+	snprint(buf, sizeof(buf), "/proc/%d/ctl", getpid());
+	fd = open(buf, OWRITE|OCEXEC);
 	if(fd < 0){
 		fprint(2, pmsg, argv0);
 		return;
--- a/sys/src/cmd/auth/lib/private.c
+++ b/sys/src/cmd/auth/lib/private.c
@@ -4,18 +4,17 @@
 #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];
+	char buf[32];
+	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";
 
-	snprint(buf, sizeof(buf), "#p/%d/ctl", getpid());
-	fd = open(buf, OWRITE);
+	snprint(buf, sizeof(buf), "/proc/%d/ctl", getpid());
+	fd = open(buf, OWRITE|OCEXEC);
 	if(fd < 0){
 		fprint(2, pmsg, argv0);
 		return;