git: 9front

Download patch

ref: 97ac522016276e3464888b8585fb60ff9a1ffd53
parent: 3cf7c67be1e0ccf88788a895d89dafc773824755
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;
--