Module Name: src
Committed By: kre
Date: Tue Oct 29 13:10:10 UTC 2024
Modified Files:
src/libexec/telnetd: state.c sys_term.c telnetd.c
Log Message:
PR bin/58787 telnetd - handle auto authentication better
Apparently from FreeBSD via RVP -- but FreeBSD deleted telnetd
more than 2 years ago, so I assume instead from
https://github.com/cschuber/freebsd-telnet/tree/main/contrib/telnet
To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/libexec/telnetd/state.c
cvs rdiff -u -r1.49 -r1.50 src/libexec/telnetd/sys_term.c
cvs rdiff -u -r1.59 -r1.60 src/libexec/telnetd/telnetd.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/libexec/telnetd/state.c
diff -u src/libexec/telnetd/state.c:1.34 src/libexec/telnetd/state.c:1.35
--- src/libexec/telnetd/state.c:1.34 Sat Feb 10 09:21:52 2024
+++ src/libexec/telnetd/state.c Tue Oct 29 13:10:10 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: state.c,v 1.34 2024/02/10 09:21:52 andvar Exp $ */
+/* $NetBSD: state.c,v 1.35 2024/10/29 13:10:10 kre Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)state.c 8.5 (Berkeley) 5/30/95";
#else
-__RCSID("$NetBSD: state.c,v 1.34 2024/02/10 09:21:52 andvar Exp $");
+__RCSID("$NetBSD: state.c,v 1.35 2024/10/29 13:10:10 kre Exp $");
#endif
#endif /* not lint */
@@ -549,8 +549,10 @@ willoption(int option)
#ifdef AUTHENTICATION
case TELOPT_AUTHENTICATION:
- func = auth_request;
- changeok++;
+ if (auth_level >= 0) {
+ func = auth_request;
+ changeok++;
+ }
break;
#endif
Index: src/libexec/telnetd/sys_term.c
diff -u src/libexec/telnetd/sys_term.c:1.49 src/libexec/telnetd/sys_term.c:1.50
--- src/libexec/telnetd/sys_term.c:1.49 Thu Aug 15 01:15:21 2019
+++ src/libexec/telnetd/sys_term.c Tue Oct 29 13:10:10 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: sys_term.c,v 1.49 2019/08/15 01:15:21 kamil Exp $ */
+/* $NetBSD: sys_term.c,v 1.50 2024/10/29 13:10:10 kre Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)sys_term.c 8.4+1 (Berkeley) 5/30/95";
#else
-__RCSID("$NetBSD: sys_term.c,v 1.49 2019/08/15 01:15:21 kamil Exp $");
+__RCSID("$NetBSD: sys_term.c,v 1.50 2024/10/29 13:10:10 kre Exp $");
#endif
#endif /* not lint */
@@ -583,6 +583,10 @@ start_login(char *host, int autologin, c
const char *loginprog = NULL;
extern struct sockaddr_storage from;
char buf[sizeof(from) * 4 + 1];
+ char *user;
+
+ user = getenv("USER");
+ user = (user != NULL) ? strdup(user) : NULL;
scrub_env();
@@ -634,9 +638,9 @@ start_login(char *host, int autologin, c
argv = addarg(argv, name);
} else
#endif
- if (getenv("USER")) {
+ if (user != NULL) {
argv = addarg(argv, "--");
- argv = addarg(argv, getenv("USER"));
+ argv = addarg(argv, user);
/*
* Assume that login will set the USER variable
* correctly. For SysV systems, this means that
Index: src/libexec/telnetd/telnetd.c
diff -u src/libexec/telnetd/telnetd.c:1.59 src/libexec/telnetd/telnetd.c:1.60
--- src/libexec/telnetd/telnetd.c:1.59 Thu Sep 21 14:00:34 2023
+++ src/libexec/telnetd/telnetd.c Tue Oct 29 13:10:10 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: telnetd.c,v 1.59 2023/09/21 14:00:34 shm Exp $ */
+/* $NetBSD: telnetd.c,v 1.60 2024/10/29 13:10:10 kre Exp $ */
/*
* Copyright (C) 1997 and 1998 WIDE Project.
@@ -65,7 +65,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 19
#if 0
static char sccsid[] = "@(#)telnetd.c 8.4 (Berkeley) 5/30/95";
#else
-__RCSID("$NetBSD: telnetd.c,v 1.59 2023/09/21 14:00:34 shm Exp $");
+__RCSID("$NetBSD: telnetd.c,v 1.60 2024/10/29 13:10:10 kre Exp $");
#endif
#endif /* not lint */
@@ -242,7 +242,7 @@ main(int argc, char *argv[])
#ifdef ENCRYPTION
case 'e':
if (strcmp(optarg, "debug") == 0) {
- encrypt_debug_mode = 1;
+ EncryptDebug(1);
break;
}
usage();
@@ -493,11 +493,13 @@ getterminaltype(char *name, size_t l)
/*
* Handle the Authentication option before we do anything else.
*/
- send_do(TELOPT_AUTHENTICATION, 1);
- while (his_will_wont_is_changing(TELOPT_AUTHENTICATION))
- ttloop();
- if (his_state_is_will(TELOPT_AUTHENTICATION)) {
- retval = auth_wait(name, l);
+ if (auth_level >= 0) {
+ send_do(TELOPT_AUTHENTICATION, 1);
+ while (his_will_wont_is_changing(TELOPT_AUTHENTICATION))
+ ttloop();
+ if (his_state_is_will(TELOPT_AUTHENTICATION)) {
+ retval = auth_wait(name, l);
+ }
}
#endif