From a0f0bbfa08e79ebc62de656212c1715ec856a753 Mon Sep 17 00:00:00 2001 From: Johan Danielsson Date: Wed, 28 Aug 2002 20:57:40 +0000 Subject: [PATCH] only register what forwarding options are asked for when parsing command line, we have to set the actual flags later after we have read .telnetrc git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@11289 ec53bebd-3082-4978-b11e-865c3cabbd6b --- appl/telnet/telnet/main.c | 74 ++++++++++++++++----------------------- 1 file changed, 31 insertions(+), 43 deletions(-) diff --git a/appl/telnet/telnet/main.c b/appl/telnet/telnet/main.c index ef4b3700e..e7c0a5c96 100644 --- a/appl/telnet/telnet/main.c +++ b/appl/telnet/telnet/main.c @@ -40,11 +40,6 @@ static char *copyright[] = { #include "telnet_locl.h" RCSID("$Id$"); -/* These values need to be the same as defined in libtelnet/kerberos5.c */ -/* Either define them in both places, or put in some common header file. */ -#define OPTS_FORWARD_CREDS 0x00000002 -#define OPTS_FORWARDABLE_CREDS 0x00000001 - #if KRB5 #define FORWARD #endif @@ -91,9 +86,30 @@ usage(void) #ifdef FORWARD -extern int forward_flags; -static int default_forward=0; +int forward_option = 0; /* forward flags set from command line */ #endif /* FORWARD */ +void +set_forward_options(void) +{ +#ifdef FORWARD + switch(forward_option) { + case 'f': + forward(1); + forwardable(0); + break; + case 'F': + forward(1); + forwardable(1); + break; + case 'G': + forward(0); + forwardable(0); + break; + default: + break; + } +#endif +} #ifdef KRB5 /* XXX ugly hack to setup dns-proxy stuff */ @@ -112,13 +128,11 @@ krb5_init(void) #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; + forward(1); } if (krb5_config_get_bool (context, NULL, "libdefaults", "forwardable", NULL)) { - forward_flags |= OPTS_FORWARDABLE_CREDS; - default_forward=1; + forwardable(1); } #endif #ifdef ENCRYPTION @@ -240,36 +254,20 @@ main(int argc, char **argv) set_escape_char(optarg); break; case 'f': -#if defined(AUTHENTICATION) && defined(KRB5) && defined(FORWARD) - if ((forward_flags & OPTS_FORWARD_CREDS) && - !default_forward) { - fprintf(stderr, - "%s: Only one of -f and -F allowed.\n", - prompt); - usage(); - } - forward_flags |= OPTS_FORWARD_CREDS; -#else - fprintf(stderr, - "%s: Warning: -f ignored, no Kerberos V5 support.\n", - prompt); -#endif - break; case 'F': + case 'G': #if defined(AUTHENTICATION) && defined(KRB5) && defined(FORWARD) - if ((forward_flags & OPTS_FORWARD_CREDS) && - !default_forward) { + if (forward_option) { fprintf(stderr, - "%s: Only one of -f and -F allowed.\n", + "%s: Only one of -f, -F and -G allowed.\n", prompt); usage(); } - forward_flags |= OPTS_FORWARD_CREDS; - forward_flags |= OPTS_FORWARDABLE_CREDS; + forward_option = ch; #else fprintf(stderr, - "%s: Warning: -F ignored, no Kerberos V5 support.\n", - prompt); + "%s: Warning: -%c ignored, no Kerberos V5 support.\n", + prompt, ch); #endif break; case 'k': @@ -309,16 +307,6 @@ main(int argc, char **argv) prompt); #endif break; - case 'G': -#if defined(AUTHENTICATION) && defined(KRB5) && defined(FORWARD) - forward_flags ^= OPTS_FORWARD_CREDS; - forward_flags ^= OPTS_FORWARDABLE_CREDS; -#else - fprintf(stderr, - "%s: Warning: -G ignored, no Kerberos V5 support.\n", - prompt); -#endif - break; case '?': default: