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
This commit is contained in:
Johan Danielsson
2002-08-28 20:57:40 +00:00
parent 8ffc68bb79
commit a0f0bbfa08

View File

@@ -40,11 +40,6 @@ static char *copyright[] = {
#include "telnet_locl.h" #include "telnet_locl.h"
RCSID("$Id$"); 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 #if KRB5
#define FORWARD #define FORWARD
#endif #endif
@@ -91,9 +86,30 @@ usage(void)
#ifdef FORWARD #ifdef FORWARD
extern int forward_flags; int forward_option = 0; /* forward flags set from command line */
static int default_forward=0;
#endif /* FORWARD */ #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 #ifdef KRB5
/* XXX ugly hack to setup dns-proxy stuff */ /* XXX ugly hack to setup dns-proxy stuff */
@@ -112,13 +128,11 @@ krb5_init(void)
#if defined(AUTHENTICATION) && defined(KRB5) && defined(FORWARD) #if defined(AUTHENTICATION) && defined(KRB5) && defined(FORWARD)
if (krb5_config_get_bool (context, NULL, if (krb5_config_get_bool (context, NULL,
"libdefaults", "forward", NULL)) { "libdefaults", "forward", NULL)) {
forward_flags |= OPTS_FORWARD_CREDS; forward(1);
default_forward=1;
} }
if (krb5_config_get_bool (context, NULL, if (krb5_config_get_bool (context, NULL,
"libdefaults", "forwardable", NULL)) { "libdefaults", "forwardable", NULL)) {
forward_flags |= OPTS_FORWARDABLE_CREDS; forwardable(1);
default_forward=1;
} }
#endif #endif
#ifdef ENCRYPTION #ifdef ENCRYPTION
@@ -240,36 +254,20 @@ main(int argc, char **argv)
set_escape_char(optarg); set_escape_char(optarg);
break; break;
case 'f': 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 'F':
case 'G':
#if defined(AUTHENTICATION) && defined(KRB5) && defined(FORWARD) #if defined(AUTHENTICATION) && defined(KRB5) && defined(FORWARD)
if ((forward_flags & OPTS_FORWARD_CREDS) && if (forward_option) {
!default_forward) {
fprintf(stderr, fprintf(stderr,
"%s: Only one of -f and -F allowed.\n", "%s: Only one of -f, -F and -G allowed.\n",
prompt); prompt);
usage(); usage();
} }
forward_flags |= OPTS_FORWARD_CREDS; forward_option = ch;
forward_flags |= OPTS_FORWARDABLE_CREDS;
#else #else
fprintf(stderr, fprintf(stderr,
"%s: Warning: -F ignored, no Kerberos V5 support.\n", "%s: Warning: -%c ignored, no Kerberos V5 support.\n",
prompt); prompt, ch);
#endif #endif
break; break;
case 'k': case 'k':
@@ -307,16 +305,6 @@ main(int argc, char **argv)
fprintf(stderr, fprintf(stderr,
"%s: Warning: -x ignored, no ENCRYPT support.\n", "%s: Warning: -x ignored, no ENCRYPT support.\n",
prompt); 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 #endif
break; break;