From 3cd0394caaee67343bd1a58091b0df193ddb631b Mon Sep 17 00:00:00 2001
From: "Rob Swindell (on Debian Linux)" <rob@synchro.net>
Date: Wed, 2 Apr 2025 18:59:21 -0700
Subject: [PATCH] More Rlogin xtrn-menu options (in modopts.ini [logon]
 section):

rlogin_xtrn_logon set to false to skip the normal logon screens for Rlogin.
rlogin_xtrn_logoff set to false (default) to immediately hangup, true to
prompt the user if they truly wish to logoff, and "full" to prompt and if
affirmed, go through the full logoff procedure (dislpay files and events,
etc.).
---
 exec/logon.js | 131 +++++++++++++++++++++++++++-----------------------
 1 file changed, 71 insertions(+), 60 deletions(-)

diff --git a/exec/logon.js b/exec/logon.js
index 6b90cd5196..776f6e9b8b 100644
--- a/exec/logon.js
+++ b/exec/logon.js
@@ -138,73 +138,74 @@ if(user.security.exemptions&UFLAG_H)
 /******************************
 * Replaces the 2.1 Logon stuff
 ******************************/
+if (!(bbs.sys_status&SS_RLOGIN) || options.rlogin_xtrn_logon !== false) {
+	if(options.fast_logon !== true || !(bbs.sys_status&SS_FASTLOGON)
+		|| !user.compare_ars(options.fast_logon_requirements)) {
+
+		// Logon screens
+
+		// Print successively numbered logon screens (logon, logon1, logon2, etc.)
+		var highest_printed_logon_screen=-1;
+		for(var i=0;;i++) {
+			var fname="logon";
+			if(i)
+				fname+=i;
+			if(!bbs.menu_exists(fname)) {
+				if(i>1)
+					break;
+				continue;
+			}
+			bbs.menu(fname);
+			highest_printed_logon_screen = i;
+		}
 
-if(options.fast_logon !== true || !(bbs.sys_status&SS_FASTLOGON)
-	|| !user.compare_ars(options.fast_logon_requirements)) {
+		// Print logon screens based on security level
+		if(user.security.level > highest_printed_logon_screen
+			&& bbs.menu_exists("logon" + user.security.level))
+			bbs.menu("logon" + user.security.level);
 
-	// Logon screens
+		// Print one of text/menu/random*.*, picked at random
+		// e.g. random1.asc, random2.asc, random3.asc, etc.
+		bbs.menu("random*");
 
-	// Print successively numbered logon screens (logon, logon1, logon2, etc.)
-	var highest_printed_logon_screen=-1;
-	for(var i=0;;i++) {
-		var fname="logon";
-		if(i)
-			fname+=i;
-		if(!bbs.menu_exists(fname)) {
-			if(i>1)
-				break;
-			continue;
-		}
-		bbs.menu(fname);
-		highest_printed_logon_screen = i;
+		console.clear(LIGHTGRAY);
+		bbs.user_event(EVENT_LOGON);
 	}
 
-	// Print logon screens based on security level
-	if(user.security.level > highest_printed_logon_screen
-		&& bbs.menu_exists("logon" + user.security.level))
-		bbs.menu("logon" + user.security.level);
-
-	// Print one of text/menu/random*.*, picked at random
-	// e.g. random1.asc, random2.asc, random3.asc, etc.
-	bbs.menu("random*");
+	if(user.security.level==99				/* Sysop logging on */
+		&& !system.matchuser("guest")		/* Guest account does not yet exist */
+		&& bbs.mods.userprops.get("logon", "makeguest", true) /* Sysop has not asked to stop this question */
+		) {
+		if(console.yesno("\x01?Create Guest/Anonymous user account (highly recommended)"))
+			load("makeguest.js");
+		else if(!console.yesno("Ask again later")) {
+			bbs.mods.userprops.set("logon", "makeguest", false);
+			console.crlf();
+		}
+	}
 
+	// Last few callers
+	console.aborted=false;
 	console.clear(LIGHTGRAY);
-	bbs.user_event(EVENT_LOGON);
-}
-
-if(user.security.level==99				/* Sysop logging on */
-	&& !system.matchuser("guest")		/* Guest account does not yet exist */
-	&& bbs.mods.userprops.get("logon", "makeguest", true) /* Sysop has not asked to stop this question */
-	) {
-	if(console.yesno("\x01?Create Guest/Anonymous user account (highly recommended)"))
-		load("makeguest.js");
-	else if(!console.yesno("Ask again later")) {
-		bbs.mods.userprops.set("logon", "makeguest", false);
-		console.crlf();
+	if(options.show_logon_list === true)
+		bbs.exec("?logonlist -l");
+	if(bbs.node_status != NODE_QUIET && ((system.settings&SYS_SYSSTAT) || !user.is_sysop))
+		bbs.mods.logonlist_lib.add();
+
+	// Auto-message
+	const auto_msg = system.data_dir + "msgs/auto.msg"
+	if(file_size(auto_msg)>0) {
+		console.printfile(auto_msg,P_NOATCODES|P_WORDWRAP);
+	}
+	console.crlf();
+
+	if(options.show_avatar && console.term_supports(USER_ANSI)) {
+		if(options.draw_avatar_above || options.draw_avatar_right)
+			bbs.mods.avatar_lib.draw(user.number, /* name: */null, /* netaddr: */null, options.draw_avatar_above, options.draw_avatar_right);
+		else
+			bbs.mods.avatar_lib.show(user.number);
+		console.attributes = 7;	// Clear the background attribute
 	}
-}
-
-// Last few callers
-console.aborted=false;
-console.clear(LIGHTGRAY);
-if(options.show_logon_list === true)
-	bbs.exec("?logonlist -l");
-if(bbs.node_status != NODE_QUIET && ((system.settings&SYS_SYSSTAT) || !user.is_sysop))
-	bbs.mods.logonlist_lib.add();
-
-// Auto-message
-const auto_msg = system.data_dir + "msgs/auto.msg"
-if(file_size(auto_msg)>0) {
-	console.printfile(auto_msg,P_NOATCODES|P_WORDWRAP);
-}
-console.crlf();
-
-if(options.show_avatar && console.term_supports(USER_ANSI)) {
-	if(options.draw_avatar_above || options.draw_avatar_right)
-		bbs.mods.avatar_lib.draw(user.number, /* name: */null, /* netaddr: */null, options.draw_avatar_above, options.draw_avatar_right);
-	else
-		bbs.mods.avatar_lib.show(user.number);
-	console.attributes = 7;	// Clear the background attribute
 }
 
 // Set rlogin_xtrn_menu=true in [logon] section of ctrl/modopts.ini
@@ -214,7 +215,17 @@ if(options.rlogin_xtrn_menu
 	var xtrn_sec;
 	if (console.terminal.indexOf("xtrn_sec=") === 0)
 		xtrn_sec = console.terminal.substring(9);
-	bbs.xtrn_sec(xtrn_sec);
+	while(bbs.online && !js.terminated) {
+		bbs.xtrn_sec(xtrn_sec);
+		if (!options.rlogin_xtrn_logoff)
+			break;
+		if (options.rlogin_xtrn_logoff == "full")
+			bbs.logoff(/* prompt: */true);
+		else {
+			if (console.yesno(bbs.text("LogOffQ")))
+				break;
+		}
+	}
 	bbs.hangup();
 } else if(!(user.security.restrictions&UFLAG_G)
 	&& console.term_supports(USER_ANSI) 
-- 
GitLab