shithub: riscv

Download patch

ref: 55a0abdd439964793a5ebceb23776d162a0436d2
parent: 90a08cf1fda8eaf4afe98f74a7572fb36b7ef369
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Mon Apr 4 18:25:08 EDT 2022

auth/as: fix wrong filesystem permissions due to wrong factotum being attached

to change user, have to (re-)mount factotum under the new user,
so it can authenticate us under the correct user for the filesystems.

--- a/sys/src/cmd/auth/as.c
+++ b/sys/src/cmd/auth/as.c
@@ -38,6 +38,22 @@
 	sysfatal("exec: %s: %r", a[0]);
 }
 
+int
+mountfactotum(void)
+{
+	int fd;
+
+	/* get a link to factotum as new user */
+	fd = open("/srv/factotum", ORDWR);
+	if(fd < 0)
+		return -1;
+	if(mount(fd, -1, "/mnt", MREPL, "") == -1){
+		close(fd);
+		return -1;
+	}
+	return 0;
+}
+
 void
 main(int argc, char *argv[])
 {
@@ -57,6 +73,10 @@
 
 	if(becomeuser(argv[0]) < 0)
 		sysfatal("can't change uid for %s: %r", argv[0]);
+
+	if(mountfactotum() < 0)
+		sysfatal("can't mount factotum for uid for %s: %r", argv[0]);
+
 	if(newns(argv[0], namespace) < 0)
 		sysfatal("can't build namespace: %r");