shithub: drawterm-fdroid

Download patch

ref: 9f65f57c73f7c9d80a89ad43195ae4c2fcf9ffbe
parent: 600869ad4163b0bafed7ff9ebedefeee8fcc7116
author: glenda <glenda@9front.local>
date: Sun Jan 30 20:19:08 EST 2022

patch for -R and -C to not bind /mnt/term/root and /mnt/term/cmd

--- a/cpu.c
+++ b/cpu.c
@@ -243,7 +243,7 @@
 void
 usage(void)
 {
-	fprint(2, "usage: %s [-GBO] "
+	fprint(2, "usage: %s [-GBORC] "
 		"[-h host] [-u user] [-a authserver] [-s secstore] "
 		"[-e 'crypt hash'] [-k keypattern] "
 		"[-p] [-t timeout] "
@@ -260,8 +260,13 @@
 void
 cpumain(int argc, char **argv)
 {
-	char *s;
+	char *s, *root;
+	int bindcmd, bindroot;
 
+	bindroot = 1;
+	root = nil;
+	bindcmd = 1;
+
 	user = getenv("USER");
 	if((pass = getenv("PASS")) != nil)
 		remove("/env/PASS");
@@ -305,11 +310,8 @@
 		user = EARGF(usage());
 		break;
 	case 'r':
-		s = smprint("/root/%s", EARGF(usage()));
-		cleanname(s);
-		if(bind(s, "/root", MREPL) < 0)
-			panic("bind /root: %r");
-		free(s);
+		root = smprint("/root/%s", EARGF(usage()));
+		cleanname(root);
 		break;
 	case 'c':
 		cmd = estrdup(EARGF(usage()));
@@ -325,9 +327,28 @@
 			*/
 		geometry = EARGF(usage());
 		break;
+	case 'R':
+		bindroot = 0;
+		break;
+	case 'C':
+		bindcmd = 0;
+		break;
 	default:
 		usage();
 	}ARGEND;
+
+	if (bindcmd)
+		bind("#C", "/", MAFTER);
+
+	if (bindroot || (root != nil))
+		if(bind("#U", "/root", MREPL) < 0)
+			panic("bind #U: %r");
+
+	if (root != nil) {
+		if(bind(root, "/root", MREPL) < 0)
+			panic("bind /root: %r");
+		free(root);
+	}
 
 	if(argc != 0)
 		usage();
--- a/drawterm.1
+++ b/drawterm.1
@@ -6,7 +6,7 @@
 .SH SYNOPSIS
 .B drawterm
 [
-.B -GBO
+.B -GBORC
 ] [
 .B -h
 .I host
@@ -64,6 +64,22 @@
 .IR cpu (1)
 to connect to the cpu server rather than 
 .IR rcpu (1)\fR.
+
+.TP
+.B -R
+Do not bind terminal root at
+.I /mnt/term/root
+unless
+.B -r \fIroot
+is also specified.
+
+.TP
+.B -C
+Do not bind
+.I /mnt/term/cmd
+for
+.IR os (1)
+command.
 
 .TP
 .B -h \fIhost
--- a/main.c
+++ b/main.c
@@ -51,11 +51,8 @@
 		panic("bind #e: %r");
 	if(bind("#I", "/net", MBEFORE) < 0)
 		panic("bind #I: %r");
-	if(bind("#U", "/root", MREPL) < 0)
-		panic("bind #U: %r");
 	bind("#A", "/dev", MAFTER);
 	bind("#N", "/dev", MAFTER);
-	bind("#C", "/", MAFTER);
 
 	if(open("/dev/cons", OREAD) != 0)
 		panic("open0: %r");