git: 9front

Download patch

ref: 94d1d7e1ee4fd628a793278bd11107241f3600c8
parent: 3e7c58449888e2800045e2f19a726252f8966d38
author: glenda <glenda@9front.local>
date: Sun Aug 7 05:11:25 EDT 2022

rcpu: show error when we auth but don't connect

When a user isn't allowed to log into a file server, we
used to silently dump the user back to the console,
reporting that the command succeeded.

We should give the user an error when they fail to log in,
and we should exit unsuccessfully.

This status is communicated by setting up a sentinel env
var, and clearning it just before we execute the user
command.

--- a/rc/bin/rcpu
+++ b/rc/bin/rcpu
@@ -23,6 +23,7 @@
 	if(test -d /mnt/term/mnt/cpunote) {
 		rfork e
 		mainproc=$apid
+		rm -f /mnt/term/env/rfailed
 		{cat; echo -n hangup} </mnt/term/mnt/cpunote/data >/proc/$mainproc/notepg &
 		noteproc=$apid
 		wait $mainproc
@@ -33,6 +34,7 @@
 
 fn client {
 	echo -n >/env/rstatus
+	echo -n 'lost connection' > /env/rfailed
 	rfork n
 	bind '#|' /mnt/cpunote || exit
 	</fd/0 exec $exportfs -r / &
@@ -44,6 +46,10 @@
 		while(~ $status interrupted) {
 			echo -n interrupt
 			wait
+		}
+		if(test -e /env/rfailed){
+			>[1=2] echo lost connection
+			exit 'disconnected'
 		}
 		status=`{cat /env/rstatus}
 		exit $"status
--