summaryrefslogtreecommitdiff
path: root/usr.bin/telnet
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/telnet')
-rw-r--r--usr.bin/telnet/Makefile8
-rw-r--r--usr.bin/telnet/authenc.c6
-rw-r--r--usr.bin/telnet/externs.h8
-rw-r--r--usr.bin/telnet/main.c79
4 files changed, 74 insertions, 27 deletions
diff --git a/usr.bin/telnet/Makefile b/usr.bin/telnet/Makefile
index 4e2da93249b..4012819879d 100644
--- a/usr.bin/telnet/Makefile
+++ b/usr.bin/telnet/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.10 2000/10/10 15:41:09 millert Exp $
+# $OpenBSD: Makefile,v 1.11 2001/05/25 10:24:25 hin Exp $
#
# Copyright (c) 1990 The Regents of the University of California.
# All rights reserved.
@@ -52,4 +52,10 @@ LDADD+= -lkrb -ldes
DPADD+= ${LIBDES} ${LIBKRB}
.endif
+.if (${KERBEROS5:L} == "yes")
+CFLAGS+=-DENCRYPTION -DAUTHENTICATION -DKRB5
+LDADD+= -lkrb5
+DPADD+= ${LIBKRB5}
+.endif
+
.include <bsd.prog.mk>
diff --git a/usr.bin/telnet/authenc.c b/usr.bin/telnet/authenc.c
index 26100e47ff8..ba86eea4416 100644
--- a/usr.bin/telnet/authenc.c
+++ b/usr.bin/telnet/authenc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: authenc.c,v 1.3 1998/03/12 04:57:27 art Exp $ */
+/* $OpenBSD: authenc.c,v 1.4 2001/05/25 10:24:25 hin Exp $ */
/* $NetBSD: authenc.c,v 1.5 1996/02/28 21:03:52 thorpej Exp $ */
/*-
@@ -39,7 +39,7 @@
#if defined(AUTHENTICATION) || defined(ENCRYPTION)
int
-net_write(str, len)
+telnet_net_write(str, len)
unsigned char *str;
int len;
{
@@ -71,7 +71,7 @@ telnet_spin()
char *
telnet_getenv(val)
- char *val;
+ const char *val;
{
return((char *)env_getvalue((unsigned char *)val));
}
diff --git a/usr.bin/telnet/externs.h b/usr.bin/telnet/externs.h
index d635a879b48..7fa38ce9b36 100644
--- a/usr.bin/telnet/externs.h
+++ b/usr.bin/telnet/externs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: externs.h,v 1.5 2001/01/22 11:03:38 fgsch Exp $ */
+/* $OpenBSD: externs.h,v 1.6 2001/05/25 10:24:25 hin Exp $ */
/* $KTH: externs.h,v 1.16 1997/11/29 02:28:35 joda Exp $ */
/*
@@ -188,7 +188,7 @@ extern jmp_buf
int net_write(unsigned char *str, int len);
void net_encrypt(void);
int telnet_spin(void);
-char *telnet_getenv(char *val);
+char *telnet_getenv(const char *val);
char *telnet_gets(char *prompt, char *result, int length, int echo);
#endif
@@ -287,7 +287,7 @@ void xmitEC(void);
void Dump (char, unsigned char *, int);
void printoption (char *, int, int);
-void printsub (char, unsigned char *, int);
+void printsub (int, unsigned char *, int);
void sendnaws (void);
void setconnmode (int);
void setcommandmode (void);
@@ -357,7 +357,7 @@ void SetNetTrace(char *file);
void Dump(char direction, unsigned char *buffer, int length);
void printoption(char *direction, int cmd, int option);
void optionstatus(void);
-void printsub(char direction, unsigned char *pointer, int length);
+void printsub(int direction, unsigned char *pointer, int length);
void EmptyTerminal(void);
void SetForExit(void);
void Exit(int returnCode);
diff --git a/usr.bin/telnet/main.c b/usr.bin/telnet/main.c
index 9d43904cdde..d85101e03a8 100644
--- a/usr.bin/telnet/main.c
+++ b/usr.bin/telnet/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.10 2001/01/21 22:46:37 aaron Exp $ */
+/* $OpenBSD: main.c,v 1.11 2001/05/25 10:24:25 hin Exp $ */
/* $NetBSD: main.c,v 1.5 1996/02/28 21:04:05 thorpej Exp $ */
/*
@@ -47,14 +47,22 @@ static char copyright[] =
#define OPTS_FORWARD_CREDS 0x00000002
#define OPTS_FORWARDABLE_CREDS 0x00000001
-#if KRB5
+#ifdef KRB5
#define FORWARD
+/* XXX ugly hack to setup dns-proxy stuff */
+#define Authenticator asn1_Authenticator
+#include <kerberosV/krb5.h>
#endif
#ifdef KRB4
#include <kerberosIV/krb.h>
#endif
+#ifdef FORWARD
+int forward_flags;
+static int default_forward=0;
+#endif
+
/*
* Initialize variables.
*/
@@ -103,6 +111,43 @@ usage()
exit(1);
}
+
+#ifdef KRB5
+static void
+krb5_init(void)
+{
+ krb5_context context;
+ krb5_error_code ret;
+
+ ret = krb5_init_context(&context);
+ if (ret)
+ return;
+
+#if defined(AUTHENTICATION) && defined(KRB5) && defined(FORWARD)
+ if (krb5_config_get_bool (context, NULL,
+ "libdefaults", "forward", NULL)) {
+ forward_flags |= OPTS_FORWARD_CREDS;
+ default_forward=1;
+ }
+ if (krb5_config_get_bool (context, NULL,
+ "libdefaults", "forwardable", NULL)) {
+ forward_flags |= OPTS_FORWARDABLE_CREDS;
+ default_forward=1;
+ }
+#endif
+#ifdef ENCRYPTION
+ if (krb5_config_get_bool (context, NULL,
+ "libdefaults", "encrypt", NULL)) {
+ encrypt_auto(1);
+ decrypt_auto(1);
+ EncryptVerbose(1);
+ }
+#endif
+
+ krb5_free_context(context);
+}
+#endif
+
/*
* main. Parse arguments, invoke the protocol or command parser.
*/
@@ -120,6 +165,10 @@ main(argc, argv)
extern int forward_flags;
#endif /* FORWARD */
+#ifdef KRB5
+ krb5_init();
+#endif
+
tninit(); /* Clear out things */
TerminalSaveState();
@@ -203,7 +252,8 @@ main(argc, argv)
break;
case 'f':
#if defined(AUTHENTICATION) && defined(KRB5) && defined(FORWARD)
- if (forward_flags & OPTS_FORWARD_CREDS) {
+ if ((forward_flags & OPTS_FORWARD_CREDS) &&
+ !default_forward) {
fprintf(stderr,
"%s: Only one of -f and -F allowed.\n",
prompt);
@@ -218,7 +268,8 @@ main(argc, argv)
break;
case 'F':
#if defined(AUTHENTICATION) && defined(KRB5) && defined(FORWARD)
- if (forward_flags & OPTS_FORWARD_CREDS) {
+ if ((forward_flags & OPTS_FORWARD_CREDS) &&
+ !default_forward) {
fprintf(stderr,
"%s: Only one of -f and -F allowed.\n",
prompt);
@@ -300,26 +351,16 @@ main(argc, argv)
}
}
-#ifdef KRB4
- {
- char realm[REALM_SZ];
-
- if (krb_get_lrealm(realm, 0) != KSUCCESS) {
-#if defined(AUTHENTICATION)
- auth_disable_name("KERBEROS_V4");
-#endif
- } else if (autologin == -1) {
+ if (autologin == -1) {
#if defined(AUTHENTICATION)
- autologin = 1;
+ autologin = 1;
#endif
#if defined(ENCRYPTION)
- encrypt_auto(1);
- decrypt_auto(1);
+ encrypt_auto(1);
+ decrypt_auto(1);
#endif
- }
}
-#endif /* KRB4 */
-
+
if (autologin == -1)
autologin = (rlogin == _POSIX_VDISABLE) ? 0 : 1;