Module Name:    src
Committed By:   christos
Date:           Mon Jan  9 16:36:48 UTC 2012

Modified Files:
        src/libexec/telnetd: Makefile ext.h state.c sys_term.c telnetd.c
            utility.c

Log Message:
PR/45805: Borodin Oleg: telnet/telnetd with -DAUTHENTICATION -DENCRYPTION
(rfc2941)
- separate MKCRYPTO from USE_KERBEROS
- WARNS=4


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/libexec/telnetd/Makefile
cvs rdiff -u -r1.20 -r1.21 src/libexec/telnetd/ext.h
cvs rdiff -u -r1.28 -r1.29 src/libexec/telnetd/state.c
cvs rdiff -u -r1.44 -r1.45 src/libexec/telnetd/sys_term.c
cvs rdiff -u -r1.52 -r1.53 src/libexec/telnetd/telnetd.c
cvs rdiff -u -r1.31 -r1.32 src/libexec/telnetd/utility.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/libexec/telnetd/Makefile
diff -u src/libexec/telnetd/Makefile:1.48 src/libexec/telnetd/Makefile:1.49
--- src/libexec/telnetd/Makefile:1.48	Sun Apr 24 17:42:06 2011
+++ src/libexec/telnetd/Makefile	Mon Jan  9 11:36:48 2012
@@ -1,7 +1,7 @@
-#	$NetBSD: Makefile,v 1.48 2011/04/24 21:42:06 elric Exp $
+#	$NetBSD: Makefile,v 1.49 2012/01/09 16:36:48 christos Exp $
 #	from: @(#)Makefile	8.2 (Berkeley) 12/15/93
 
-WARNS?=	2		# XXX: const issues in sys_term.c
+WARNS?=	4		# XXX: const issues in sys_term.c
 
 .include <bsd.own.mk>
 
@@ -22,17 +22,18 @@ LIBTELNETDIR!=	cd ${.CURDIR}/../../lib/l
 
 .if (${USE_KERBEROS} != "no")
 CPPFLAGS+=-DKRB5 -DAUTHENTICATION -DENCRYPTION
-LDADD+= -lkrb5 -lasn1 -lcrypto -lcrypt
-DPADD+=	${LIBKRB5} ${LIBASN1} ${LIBCRYPTO} ${LIBCRYPT}
+LDADD+= -lkrb5 -lasn1 -lcom_err -lroken
+DPADD+=	${LIBKRB5} ${LIBASN1} ${LIBCOM_ERR} ${LIBROKEN}
+.endif
+
+.if (${MKCRYPTO} != "no")
+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
-
 .include <bsd.prog.mk>

Index: src/libexec/telnetd/ext.h
diff -u src/libexec/telnetd/ext.h:1.20 src/libexec/telnetd/ext.h:1.21
--- src/libexec/telnetd/ext.h:1.20	Tue Jun 21 18:29:53 2005
+++ src/libexec/telnetd/ext.h	Mon Jan  9 11:36:48 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext.h,v 1.20 2005/06/21 22:29:53 lha Exp $	*/
+/*	$NetBSD: ext.h,v 1.21 2012/01/09 16:36:48 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -90,7 +90,7 @@ extern void
 	doeof(void),
 	dooption(int),
 	dontoption(int),
-	edithost(char *, char *),
+	edithost(const char *, const char *),
 	fatal(int, const char *),
 	fatalperror(int, const char *),
 	get_slc_defaults(void),
@@ -103,7 +103,7 @@ extern void
 	netflush(void),
 #ifdef DIAGNOSTICS
 	printoption(const char *, int),
-	printdata(char *, char *, int),
+	printdata(const char *, char *, int),
 #ifndef ENCRYPTION
 	printsub(int, unsigned char *, int),
 #endif
@@ -130,7 +130,7 @@ extern void
 	tty_binaryout(int);
 
 extern char *
-	putf(char *, char *);
+	putf(const char *, char *);
 
 extern int
 	end_slc(unsigned char **),

Index: src/libexec/telnetd/state.c
diff -u src/libexec/telnetd/state.c:1.28 src/libexec/telnetd/state.c:1.29
--- src/libexec/telnetd/state.c:1.28	Fri Dec 23 11:56:54 2011
+++ src/libexec/telnetd/state.c	Mon Jan  9 11:36:48 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: state.c,v 1.28 2011/12/23 16:56:54 christos Exp $	*/
+/*	$NetBSD: state.c,v 1.29 2012/01/09 16:36:48 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)state.c	8.5 (Berkeley) 5/30/95";
 #else
-__RCSID("$NetBSD: state.c,v 1.28 2011/12/23 16:56:54 christos Exp $");
+__RCSID("$NetBSD: state.c,v 1.29 2012/01/09 16:36:48 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -45,10 +45,6 @@ __RCSID("$NetBSD: state.c,v 1.28 2011/12
 
 static int envvarok(char *);
 
-unsigned const char	doopt[] = { IAC, DO, '%', 'c', 0 };
-unsigned const char	dont[] = { IAC, DONT, '%', 'c', 0 };
-unsigned const char	will[] = { IAC, WILL, '%', 'c', 0 };
-unsigned const char	wont[] = { IAC, WONT, '%', 'c', 0 };
 int	not42 = 1;
 
 /*
@@ -437,7 +433,7 @@ send_do(int option, int init)
 			set_his_want_state_will(option);
 		do_dont_resp[option]++;
 	}
-	(void) output_data((const char *)doopt, option);
+	(void) output_data("%c%c%c", IAC, DO, option);
 
 	DIAG(TD_OPTIONS, printoption("td: send do", option));
 }
@@ -657,7 +653,7 @@ send_dont(int option, int init)
 		set_his_want_state_wont(option);
 		do_dont_resp[option]++;
 	}
-	(void) output_data((const char *)dont, option);
+	(void) output_data("%c%c%c", IAC, DONT, option);
 
 	DIAG(TD_OPTIONS, printoption("td: send dont", option));
 }
@@ -805,7 +801,7 @@ send_will(int option, int init)
 		set_my_want_state_will(option);
 		will_wont_resp[option]++;
 	}
-	(void) output_data((const char *)will, option);
+	(void) output_data("%c%c%c", IAC, WILL, option);
 
 	DIAG(TD_OPTIONS, printoption("td: send will", option));
 }
@@ -959,7 +955,7 @@ send_wont(int option, int init)
 		set_my_want_state_wont(option);
 		will_wont_resp[option]++;
 	}
-	(void) output_data((const char *)wont, option);
+	(void) output_data("%c%c%c", IAC, WONT, option);
 
 	DIAG(TD_OPTIONS, printoption("td: send wont", option));
 }

Index: src/libexec/telnetd/sys_term.c
diff -u src/libexec/telnetd/sys_term.c:1.44 src/libexec/telnetd/sys_term.c:1.45
--- src/libexec/telnetd/sys_term.c:1.44	Wed Jan 17 16:44:50 2007
+++ src/libexec/telnetd/sys_term.c	Mon Jan  9 11:36:48 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_term.c,v 1.44 2007/01/17 21:44:50 hubertf Exp $	*/
+/*	$NetBSD: sys_term.c,v 1.45 2012/01/09 16:36:48 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)sys_term.c	8.4+1 (Berkeley) 5/30/95";
 #else
-__RCSID("$NetBSD: sys_term.c,v 1.44 2007/01/17 21:44:50 hubertf Exp $");
+__RCSID("$NetBSD: sys_term.c,v 1.45 2012/01/09 16:36:48 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -54,7 +54,7 @@ struct termios termbuf, termbuf2;	/* pty
 
 void getptyslave(void);
 int cleanopen(char *);
-char **addarg(char **, char *);
+char **addarg(char **, const char *);
 void scrub_env(void);
 int getent(char *, char *);
 char *getstr(const char *, char **);
@@ -84,7 +84,7 @@ init_termbuf(void)
 void
 copy_termbuf(char *cp, int len)
 {
-	if (len > sizeof(termbuf))
+	if ((size_t)len > sizeof(termbuf))
 		len = sizeof(termbuf);
 	memmove((char *)&termbuf, cp, len);
 	termbuf2 = termbuf;
@@ -677,7 +677,7 @@ start_login(char *host, int autologin, c
 }
 
 char **
-addarg(char **argv, char *val)
+addarg(char **argv, const char *val)
 {
 	char **cpp;
 	char **nargv;
@@ -707,7 +707,7 @@ addarg(char **argv, char *val)
 		argv++;
 		cpp = &argv[(long)argv[-1] - 10];
 	}
-	*cpp++ = val;
+	*cpp++ = __UNCONST(val);
 	*cpp = 0;
 	return(argv);
 }

Index: src/libexec/telnetd/telnetd.c
diff -u src/libexec/telnetd/telnetd.c:1.52 src/libexec/telnetd/telnetd.c:1.53
--- src/libexec/telnetd/telnetd.c:1.52	Sun Apr 24 17:18:24 2011
+++ src/libexec/telnetd/telnetd.c	Mon Jan  9 11:36:48 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: telnetd.c,v 1.52 2011/04/24 21:18:24 elric Exp $	*/
+/*	$NetBSD: telnetd.c,v 1.53 2012/01/09 16:36:48 christos Exp $	*/
 
 /*
  * Copyright (C) 1997 and 1998 WIDE Project.
@@ -65,7 +65,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 19
 #if 0
 static char sccsid[] = "@(#)telnetd.c	8.4 (Berkeley) 5/30/95";
 #else
-__RCSID("$NetBSD: telnetd.c,v 1.52 2011/04/24 21:18:24 elric Exp $");
+__RCSID("$NetBSD: telnetd.c,v 1.53 2012/01/09 16:36:48 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -118,13 +118,13 @@ int	hostinfo = 1;			/* do we print login
 
 static int debug = 0;
 int keepalive = 1;
-char *gettyname = "default";
+const char *gettyname = "default";
 char *progname;
 
 int main(int, char *[]);
 void usage(void);
 int getterminaltype(char *, size_t);
-int getent(char *, char *);
+int getent(char *, const char *);
 void doit(struct sockaddr *);
 void _gettermname(void);
 int terminaltypeok(char *);
@@ -360,7 +360,7 @@ main(int argc, char *argv[])
 	if (debug) {
 	    int s, ns, error;
 	    socklen_t foo;
-	    char *service = "telnet";
+	    const char *service = "telnet";
 	    struct addrinfo hints, *res;
 
 	    if (argc > 1) {
@@ -747,7 +747,8 @@ telnet(int f, int p)
 	char	defent[TABBUFSIZ];
 	char	defstrs[TABBUFSIZ];
 #undef	TABBUFSIZ
-	char *HE, *HN, *IM, *IF, *ptyibuf2ptr;
+	char *HE, *HN, *IF, *ptyibuf2ptr;
+	const char *IM;
 	struct pollfd set[2];
 
 	/*

Index: src/libexec/telnetd/utility.c
diff -u src/libexec/telnetd/utility.c:1.31 src/libexec/telnetd/utility.c:1.32
--- src/libexec/telnetd/utility.c:1.31	Wed Feb 21 16:14:07 2007
+++ src/libexec/telnetd/utility.c	Mon Jan  9 11:36:48 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: utility.c,v 1.31 2007/02/21 21:14:07 hubertf Exp $	*/
+/*	$NetBSD: utility.c,v 1.32 2012/01/09 16:36:48 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)utility.c	8.4 (Berkeley) 5/30/95";
 #else
-__RCSID("$NetBSD: utility.c,v 1.31 2007/02/21 21:14:07 hubertf Exp $");
+__RCSID("$NetBSD: utility.c,v 1.32 2012/01/09 16:36:48 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -370,7 +370,7 @@ fatalperror(f, msg)
 char editedhost[MAXHOSTNAMELEN];
 
 void
-edithost(char *pat, char *host)
+edithost(const char *pat, const char *host)
 {
 	char *res = editedhost;
 
@@ -427,11 +427,11 @@ putchr(int cc)
  * This is split on two lines so that SCCS will not see the M
  * between two % signs and expand it...
  */
-static char fmtstr[] = { "%l:%M\
+static const char fmtstr[] = { "%l:%M\
 %p on %A, %d %B %Y" };
 
 char *
-putf(char *cp, char *where)
+putf(const char *cp, char *where)
 {
 	char *slash;
 	time_t t;
@@ -740,7 +740,7 @@ printsub(
 	    break;
 
 	case TELOPT_STATUS: {
-	    char *cp;
+	    const char *cp;
 	    int j, k;
 
 	    output_data("STATUS");
@@ -841,39 +841,40 @@ printsub(
 		output_data("INFO ");
 	    env_common:
 		{
-		    int noquote = 2;
+		    static const char NQ[] = "\" ";
+		    const char *noquote = NQ;
 		    for (i = 2; i < length; i++ ) {
 			switch (pointer[i]) {
 			case NEW_ENV_VAR:
-			    output_data("%s", "\" VAR " + noquote);
-			    noquote = 2;
+			    output_data("%sVAR ", noquote);
+			    noquote = NQ;
 			    break;
 
 			case NEW_ENV_VALUE:
-			    output_data("%s", "\" VALUE " + noquote);
-			    noquote = 2;
+			    output_data("%sVALUE ", noquote);
+			    noquote = NQ;
 			    break;
 
 			case ENV_ESC:
-			    output_data("%s", "\" ESC " + noquote);
-			    noquote = 2;
+			    output_data("%sESC ", noquote);
+			    noquote = NQ;
 			    break;
 
 			case ENV_USERVAR:
-			    output_data("%s", "\" USERVAR " + noquote);
-			    noquote = 2;
+			    output_data("%sUSERVAR ", noquote);
+			    noquote = NQ;
 			    break;
 
 			default:
 			    if (isprint(pointer[i]) && pointer[i] != '"') {
-				if (noquote) {
+				if (*noquote) {
 				    output_data("\"");
-				    noquote = 0;
+				    noquote = "";
 				}
 				output_data("%c", pointer[i]);
 			    } else {
-				output_data("\" %03o " + noquote, pointer[i]);
-				noquote = 2;
+				output_data("%s%03o ", noquote, pointer[i]);
+				noquote = NQ;
 			    }
 			    break;
 			}
@@ -1044,7 +1045,7 @@ printsub(
  * Dump a data buffer in hex and ascii to the output data stream.
  */
 void
-printdata(char *tag, char *ptr, int cnt)
+printdata(const char *tag, char *ptr, int cnt)
 {
 	int i;
 	char xbuf[30];

Reply via email to