Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/telnet PR/45805: Borodin Oleg: telnet/telnetd with -...



details:   https://anonhg.NetBSD.org/src/rev/2a1f1b7ed9d8
branches:  trunk
changeset: 772620:2a1f1b7ed9d8
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Jan 09 16:08:55 2012 +0000

description:
PR/45805: Borodin Oleg: telnet/telnetd with -DAUTHENTICATION -DENCRYPTION
(rfc2941)
- Minimal diffs to separate MKCRYPTO from USE_KERBEROS

diffstat:

 usr.bin/telnet/Makefile    |   21 +++--
 usr.bin/telnet/authenc.c   |   10 +-
 usr.bin/telnet/commands.c  |  158 ++++++++++++++++++++++----------------------
 usr.bin/telnet/externs.h   |   30 ++++----
 usr.bin/telnet/main.c      |    7 +-
 usr.bin/telnet/sys_bsd.c   |    6 +-
 usr.bin/telnet/telnet.c    |   34 ++++----
 usr.bin/telnet/utilities.c |   47 ++++++------
 8 files changed, 160 insertions(+), 153 deletions(-)

diffs (truncated from 1004 to 300 lines):

diff -r 049f26107eed -r 2a1f1b7ed9d8 usr.bin/telnet/Makefile
--- a/usr.bin/telnet/Makefile   Mon Jan 09 16:04:45 2012 +0000
+++ b/usr.bin/telnet/Makefile   Mon Jan 09 16:08:55 2012 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.48 2011/10/05 10:48:54 roy Exp $
+#      $NetBSD: Makefile,v 1.49 2012/01/09 16:08:55 christos Exp $
 #
 # Copyright (c) 1990 The Regents of the University of California.
 # All rights reserved.
@@ -34,7 +34,7 @@
 #      from: @(#)Makefile      8.1 (Berkeley) 6/6/93
 #
 
-WARNS?=        1       # XXX -Wshadow etc.  fix asap
+WARNS?=        4       # XXX -Wshadow etc.  fix asap
 CWARNFLAGS.clang+=     -Wno-tautological-compare -Wno-format-security
 
 .include <bsd.own.mk>
@@ -64,19 +64,22 @@
 LIBTELNETDIR!= cd ${.CURDIR}/../../lib/libtelnet; ${PRINTOBJDIR}
 
 .if (${USE_KERBEROS} != "no")
-CPPFLAGS+=-DKRB5 -DFORWARD -DAUTHENTICATION -DENCRYPTION
-LDADD+= -lkrb5 -lasn1 -lcrypto -lcrypt
-DPADD+=        ${LIBKRB5} ${LIBASN1} ${LIBCRYPTO} ${LIBCRYPT}
+CPPFLAGS+=-DKRB5 -DFORWARD
+LDADD+= -lkrb5 -lasn1 -lcom_err -lroken
+DPADD+=        ${LIBKRB5} ${LIBASN1} ${LIBCOM_ERR} ${LIBROKEN}
+.endif
+
+.if (${MKCRYPTO} != "no")
+CPPFLAGS+=-DAUTHENTICATION -DENCRYPTION
+LDADD+= -ldes -lcrypto -lcrypt
+DPADD+=        ${LIBDES} ${LIBCRYPTO} ${LIBCRYPT}
+.endif
 
 .if (${USE_PAM} != "no")
 LDADD+= -lpam ${PAM_STATIC_LDADD}
 DPADD+=        ${LIBPAM} ${PAM_STATIC_DPADD}
 .endif
 
-LDADD+= -ldes -lcom_err -lroken
-DPADD+=        ${LIBDES} ${LIBCOM_ERR} ${LIBROKEN}
-.endif
-
 .if defined(HAVE_GCC) || defined(HAVE_PCC)
 .for f in commands telnet terminal utilities
 COPTS.${f}.c+=  -Wno-pointer-sign
diff -r 049f26107eed -r 2a1f1b7ed9d8 usr.bin/telnet/authenc.c
--- a/usr.bin/telnet/authenc.c  Mon Jan 09 16:04:45 2012 +0000
+++ b/usr.bin/telnet/authenc.c  Mon Jan 09 16:08:55 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: authenc.c,v 1.12 2003/08/07 11:16:07 agc Exp $ */
+/*     $NetBSD: authenc.c,v 1.13 2012/01/09 16:08:55 christos Exp $    */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)authenc.c  8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: authenc.c,v 1.12 2003/08/07 11:16:07 agc Exp $");
+__RCSID("$NetBSD: authenc.c,v 1.13 2012/01/09 16:08:55 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -87,7 +87,7 @@
 }
 
 char *
-telnet_gets(char *prompt, char *result, int length, int echo)
+telnet_gets(char *prmpt, char *result, int length, int echo)
 {
        extern int globalmode;
        int om = globalmode;
@@ -95,9 +95,9 @@
 
        TerminalNewMode(-1);
        if (echo) {
-               printf("%s", prompt);
+               printf("%s", prmpt);
                res = fgets(result, length, stdin);
-       } else if ((res = getpass(prompt)) != NULL) {
+       } else if ((res = getpass(prmpt)) != NULL) {
                strlcpy(result, res, length);
                res = result;
        }
diff -r 049f26107eed -r 2a1f1b7ed9d8 usr.bin/telnet/commands.c
--- a/usr.bin/telnet/commands.c Mon Jan 09 16:04:45 2012 +0000
+++ b/usr.bin/telnet/commands.c Mon Jan 09 16:08:55 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: commands.c,v 1.67 2006/12/18 14:18:40 christos Exp $   */
+/*     $NetBSD: commands.c,v 1.68 2012/01/09 16:08:55 christos Exp $   */
 
 /*
  * Copyright (C) 1997 and 1998 WIDE Project.
@@ -63,7 +63,7 @@
 #if 0
 static char sccsid[] = "@(#)commands.c 8.4 (Berkeley) 5/30/95";
 #else
-__RCSID("$NetBSD: commands.c,v 1.67 2006/12/18 14:18:40 christos Exp $");
+__RCSID("$NetBSD: commands.c,v 1.68 2012/01/09 16:08:55 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -109,8 +109,8 @@
 static char _hostname[MAXHOSTNAMELEN];
 
 typedef struct {
-       char    *name;          /* command name */
-       char    *help;          /* help string (NULL for no help) */
+       const char      *name;  /* command name */
+       const char      *help;  /* help string (NULL for no help) */
        int     (*handler)      /* routine which executes command */
                        (int, char *[]);
        int     needconnect;    /* Do we need to be connected to execute? */
@@ -123,7 +123,7 @@
 
 static void makeargv(void);
 static int special(char *);
-static char *control(cc_t);
+static const char *control(cc_t);
 static int sendcmd(int, char **);
 static int send_esc(char *);
 static int send_docmd(char *);
@@ -155,7 +155,7 @@
 static void slc_help(int);
 static struct slclist *getslc(char *);
 static int slccmd(int, char *[]);
-static struct env_lst *env_help(unsigned char *, unsigned char *);
+static struct env_lst *env_help(const unsigned char *, unsigned char *);
 static struct envlist *getenvcmd(char *);
 #ifdef AUTHENTICATION
 static int auth_help(char *);
@@ -175,12 +175,13 @@
 {
     char *cp, *cp2, c;
     char **argp = margv;
+    static char bang[] = "!";
 
     margc = 0;
     cp = line;
     if (*cp == '!') {          /* Special case shell escape */
        strlcpy(saveline, line, sizeof(saveline)); /* save for shell command */
-       *argp++ = "!";          /* No room in string to get this */
+       *argp++ = bang;         /* No room in string to get this */
        margc++;
        cp++;
     }
@@ -253,7 +254,7 @@
  * Construct a control character sequence
  * for a special character.
  */
-static char *
+static const char *
 control(cc_t c)
 {
        static char buf[5];
@@ -297,8 +298,8 @@
  */
 
 struct sendlist {
-    char       *name;          /* How user refers to it (case independent) */
-    char       *help;          /* Help information (0 ==> no help) */
+    const char *name;          /* How user refers to it (case independent) */
+    const char *help;          /* Help information (0 ==> no help) */
     int                needconnect;    /* Need to be connected */
     int                narg;           /* Number of arguments */
     int                (*handler)      /* Routine to perform (for special ops) */
@@ -334,7 +335,7 @@
     { "dont",  0,                                      0, 1, send_dontcmd, 3, 0 },
     { "will",  0,                                      0, 1, send_willcmd, 3, 0 },
     { "wont",  0,                                      0, 1, send_wontcmd, 3, 0 },
-    { 0 }
+    { .name = 0 }
 };
 
 #define        GETSEND(name) ((struct sendlist *) genget(name, (char **) Sendlist, \
@@ -450,7 +451,7 @@
 }
 
 int
-send_tncmd(void        (*func)(int, int), char *cmd, char *name)
+send_tncmd(void        (*func)(int, int), const char   *cmd, char *name)
 {
     const char **cpp;
     int val = 0;
@@ -475,7 +476,7 @@
        printf("\n");
        return 0;
     }
-    cpp = (const char **)genget(name, (char **)telopts, sizeof(char *));
+    cpp = (void *)genget(name, __UNCONST(telopts), sizeof(char *));
     if (Ambiguous(cpp)) {
        fprintf(stderr,"'%s': ambiguous argument ('send %s ?' for help).\n",
                                        name, cmd);
@@ -653,12 +654,12 @@
 #endif /* ENCRYPTION */
 
 struct togglelist {
-    char       *name;          /* name of toggle */
-    char       *help;          /* help message */
+    const char *name;          /* name of toggle */
+    const char *help;          /* help message */
     int                (*handler)      /* routine to do actual setting */
                        (int);
     int                *variable;
-    char       *actionexplanation;
+    const char *actionexplanation;
 };
 
 static struct togglelist Togglelist[] = {
@@ -741,7 +742,7 @@
            lclchars,
                &localchars,
                    "recognize certain control characters" },
-    { " ", "", 0 },            /* empty line */
+    { " ", "", 0, NULL, NULL },                /* empty line */
 #ifdef TN3270
     { "apitrace",
        "(debugging) toggle tracing of API transactions",
@@ -781,11 +782,11 @@
                    "print hexadecimal representation of terminal traffic" },
     { "?",
        0,
-           togglehelp },
+           togglehelp, NULL, NULL },
     { "help",
        0,
-           togglehelp },
-    { 0 }
+           togglehelp, NULL, NULL },
+    { .name = 0 }
 };
 
 static int
@@ -870,11 +871,11 @@
  * The following perform the "set" command.
  */
 
-struct termios new_tc = { 0 };
+struct termios new_tc = { .c_iflag = 0 };
 
 struct setlist {
-    char *name;                                /* name */
-    char *help;                                /* help information */
+    const char *name;                  /* name */
+    const char *help;                  /* help information */
     void (*handler)(char *);
     cc_t *charp;                       /* where it is located at */
 };
@@ -886,13 +887,13 @@
     { "escape",        "character to escape back to telnet command mode", 0, &escape },
     { "rlogin", "rlogin escape character", 0, &rlogin },
     { "tracefile", "file to write trace information to", SetNetTrace, (cc_t *)NetTraceFile},
-    { " ", "" },
+    { " ", "", NULL, NULL },
     { " ", "The following need 'localchars' to be toggled true", 0, 0 },
     { "flushoutput", "character to cause an Abort Output", 0, termFlushCharp },
     { "interrupt", "character to cause an Interrupt Process", 0, termIntCharp },
     { "quit",  "character to cause an Abort process", 0, termQuitCharp },
     { "eof",   "character to cause an EOF ", 0, termEofCharp },
-    { " ", "" },
+    { " ", "", NULL, NULL },
     { " ", "The following are for local editing in linemode", 0, 0 },
     { "erase", "character to use to erase a character", 0, termEraseCharp },
     { "kill",  "character to use to erase a line", 0, termKillCharp },
@@ -905,7 +906,7 @@
     { "forw1", "alternate end of line character", 0, termForw1Charp },
     { "forw2", "alternate end of line character", 0, termForw2Charp },
     { "ayt",   "alternate AYT character", 0, termAytCharp },
-    { 0 }
+    { .name = 0 }
 };
 
 static struct setlist *
@@ -1136,8 +1137,8 @@
 }
 
 struct modelist {
-       char    *name;          /* command name */
-       char    *help;          /* help string */
+       const char      *name;  /* command name */
+       const char      *help;  /* help string */
        int     (*handler)      /* routine which executes command */
                        (int);
        int     needconnect;    /* Do we need to be connected to execute? */
@@ -1145,16 +1146,16 @@
 };
 
 static struct modelist ModeList[] = {
-    { "character", "Disable LINEMODE option",  docharmode, 1 },
+    { "character", "Disable LINEMODE option",  docharmode, 1, 0 },
 #ifdef KLUDGELINEMODE
-    { "",      "(or disable obsolete line-by-line mode)", 0 },
+    { "",      "(or disable obsolete line-by-line mode)", 0, 0, 0 },
 #endif
-    { "line",  "Enable LINEMODE option",       dolinemode, 1 },
+    { "line",  "Enable LINEMODE option",       dolinemode, 1, 0 },
 #ifdef KLUDGELINEMODE



Home | Main Index | Thread Index | Old Index