BSD 4_4_Lite1 release
[unix-history] / usr / src / usr.bin / telnet / main.c
index a5a3245..ce22840 100644 (file)
@@ -38,7 +38,7 @@ static char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)main.c     8.1 (Berkeley) 6/6/93";
+static char sccsid[] = "@(#)main.c     8.2 (Berkeley) 12/15/93";
 #endif /* not lint */
 
 #include <sys/types.h>
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -47,6 +47,15 @@ static char sccsid[] = "@(#)main.c   8.1 (Berkeley) 6/6/93";
 #include "externs.h"
 #include "defines.h"
 
 #include "externs.h"
 #include "defines.h"
 
+/* 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 0
+#define FORWARD
+#endif
+
 /*
  * Initialize variables.
  */
 /*
  * Initialize variables.
  */
@@ -73,7 +82,7 @@ usage()
            prompt,
 #ifdef AUTHENTICATION
            "[-8] [-E] [-K] [-L] [-S tos] [-X atype] [-a] [-c] [-d] [-e char]",
            prompt,
 #ifdef AUTHENTICATION
            "[-8] [-E] [-K] [-L] [-S tos] [-X atype] [-a] [-c] [-d] [-e char]",
-           "\n\t[-k realm] [-l user] [-n tracefile] ",
+           "\n\t[-k realm] [-l user] [-f/-F] [-n tracefile] ",
 #else
            "[-8] [-E] [-L] [-S tos] [-a] [-c] [-d] [-e char] [-l user]",
            "\n\t[-n tracefile]",
 #else
            "[-8] [-E] [-L] [-S tos] [-a] [-c] [-d] [-e char] [-l user]",
            "\n\t[-n tracefile]",
@@ -109,6 +118,9 @@ main(argc, argv)
        extern int optind;
        int ch;
        char *user, *strrchr();
        extern int optind;
        int ch;
        char *user, *strrchr();
+#ifdef FORWARD
+       extern int forward_flags;
+#endif /* FORWARD */
 
        tninit();               /* Clear out things */
 #if    defined(CRAY) && !defined(__STDC__)
 
        tninit();               /* Clear out things */
 #if    defined(CRAY) && !defined(__STDC__)
@@ -127,7 +139,7 @@ main(argc, argv)
        rlogin = (strncmp(prompt, "rlog", 4) == 0) ? '~' : _POSIX_VDISABLE;
        autologin = -1;
 
        rlogin = (strncmp(prompt, "rlog", 4) == 0) ? '~' : _POSIX_VDISABLE;
        autologin = -1;
 
-       while ((ch = getopt(argc, argv, "8EKLS:X:acde:k:l:n:rt:x")) != EOF) {
+       while ((ch = getopt(argc, argv, "8EKLS:X:acde:fFk:l:n:rt:x")) != EOF) {
                switch(ch) {
                case '8':
                        eight = 3;      /* binary output and input */
                switch(ch) {
                case '8':
                        eight = 3;      /* binary output and input */
@@ -177,6 +189,37 @@ main(argc, argv)
                case 'e':
                        set_escape_char(optarg);
                        break;
                case 'e':
                        set_escape_char(optarg);
                        break;
+               case 'f':
+#if defined(AUTHENTICATION) && defined(KRB5) && defined(FORWARD)
+                       if (forward_flags & OPTS_FORWARD_CREDS) {
+                           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':
+#if defined(AUTHENTICATION) && defined(KRB5) && defined(FORWARD)
+                       if (forward_flags & OPTS_FORWARD_CREDS) {
+                           fprintf(stderr, 
+                                   "%s: Only one of -f and -F allowed.\n",
+                                   prompt);
+                           usage();
+                       }
+                       forward_flags |= OPTS_FORWARD_CREDS;
+                       forward_flags |= OPTS_FORWARDABLE_CREDS;
+#else
+                       fprintf(stderr,
+                        "%s: Warning: -F ignored, no Kerberos V5 support.\n", 
+                               prompt);
+#endif
+                       break;
                case 'k':
 #if defined(AUTHENTICATION) && defined(KRB4)
                    {
                case 'k':
 #if defined(AUTHENTICATION) && defined(KRB4)
                    {