summaryrefslogtreecommitdiffstats
path: root/contrib/telnet/telnetd
diff options
context:
space:
mode:
authormarkm <markm@FreeBSD.org>2001-11-30 21:06:38 +0000
committermarkm <markm@FreeBSD.org>2001-11-30 21:06:38 +0000
commit19fd256fae7c15fbb63128196d5550a72c559ea8 (patch)
tree1caab024c94078fe45902c1c2f8f58e5bdb7d4f4 /contrib/telnet/telnetd
parente92874bd103e4d5462fd2c0013b77afc3d52df05 (diff)
downloadFreeBSD-src-19fd256fae7c15fbb63128196d5550a72c559ea8.zip
FreeBSD-src-19fd256fae7c15fbb63128196d5550a72c559ea8.tar.gz
Very large style makeover.
1) ANSIfy. 2) Clean up ifdefs so that a) ones that never/always apply are appropriately either fully removed, or just the #if junk is removed. b) change #if defined(FOO) for appropiate values of FOO. (currently AUTHENTICATION and ENCRYPTION) 3) WARNS=2 fixing 4) GC other unused stuff This code can now be unifdef(1)ed to make non-crypto telnet.
Diffstat (limited to 'contrib/telnet/telnetd')
-rw-r--r--contrib/telnet/telnetd/authenc.c45
-rw-r--r--contrib/telnet/telnetd/ext.h25
-rw-r--r--contrib/telnet/telnetd/slc.c80
-rw-r--r--contrib/telnet/telnetd/state.c110
-rw-r--r--contrib/telnet/telnetd/sys_term.c800
-rw-r--r--contrib/telnet/telnetd/telnetd.820
-rw-r--r--contrib/telnet/telnetd/telnetd.c291
-rw-r--r--contrib/telnet/telnetd/telnetd.h4
-rw-r--r--contrib/telnet/telnetd/termstat.c33
-rw-r--r--contrib/telnet/telnetd/utility.c114
10 files changed, 388 insertions, 1134 deletions
diff --git a/contrib/telnet/telnetd/authenc.c b/contrib/telnet/telnetd/authenc.c
index 26a85d2..fd5f585 100644
--- a/contrib/telnet/telnetd/authenc.c
+++ b/contrib/telnet/telnetd/authenc.c
@@ -31,22 +31,23 @@
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
+
+__FBSDID("$FreeBSD$");
+
#ifndef lint
-#if 0
static const char sccsid[] = "@(#)authenc.c 8.2 (Berkeley) 5/30/95";
#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-#if defined(AUTHENTICATION) || defined(ENCRYPTION)
+#ifdef AUTHENTICATION
+#ifdef ENCRYPTION
+/* Above "#ifdef"s actually "or"'ed together. XXX MarkM
+ */
#include "telnetd.h"
#include <libtelnet/misc.h>
- int
-net_write(str, len)
- unsigned char *str;
- int len;
+int
+net_write(unsigned char *str, int len)
{
if (nfrontp + len < netobuf + BUFSIZ) {
output_datalen(str, len);
@@ -55,8 +56,8 @@ net_write(str, len)
return(0);
}
- void
-net_encrypt()
+void
+net_encrypt(void)
{
#ifdef ENCRYPTION
char *s = (nclearto > nbackp) ? nclearto : nbackp;
@@ -67,27 +68,23 @@ net_encrypt()
#endif /* ENCRYPTION */
}
- int
-telnet_spin()
+int
+telnet_spin(void)
{
ttloop();
return(0);
}
- char *
-telnet_getenv(val)
- char *val;
+char *
+telnet_getenv(char *val)
{
return(getenv(val));
}
- char *
-telnet_gets(prompt, result, length, echo)
- char *prompt;
- char *result;
- int length;
- int echo;
+char *
+telnet_gets(const char *prompt __unused, char *result __unused, int length __unused, int echo __unused)
{
- return((char *)0);
+ return(NULL);
}
-#endif /* defined(AUTHENTICATION) || defined(ENCRYPTION) */
+#endif /* ENCRYPTION */
+#endif /* AUTHENTICATION */
diff --git a/contrib/telnet/telnetd/ext.h b/contrib/telnet/telnetd/ext.h
index 9b53c7c..d9becde 100644
--- a/contrib/telnet/telnetd/ext.h
+++ b/contrib/telnet/telnetd/ext.h
@@ -56,10 +56,7 @@ extern int diagnostic; /* telnet diagnostic capabilities */
#ifdef BFTPDAEMON
extern int bftpd; /* behave as bftp daemon */
#endif /* BFTPDAEMON */
-#if defined(SecurID)
-extern int require_SecurID;
-#endif
-#if defined(AUTHENTICATION)
+#ifdef AUTHENTICATION
extern int auth_level;
#endif
@@ -93,12 +90,12 @@ extern int SYNCHing; /* we are in TELNET SYNCH mode */
extern void
_termstat P((void)),
- add_slc P((int, int, int)),
+ add_slc P((char, char, cc_t)),
check_slc P((void)),
- change_slc P((int, int, int)),
+ change_slc P((char, char, cc_t)),
cleanup P((int)),
clientstat P((int, int, int)),
- copy_termbuf P((char *, int)),
+ copy_termbuf P((char *, size_t)),
deferslc P((void)),
defer_terminit P((void)),
do_opt_slc P((unsigned char *, int)),
@@ -106,8 +103,8 @@ extern void
dooption P((int)),
dontoption P((int)),
edithost P((char *, char *)),
- fatal P((int, char *)),
- fatalperror P((int, char *)),
+ fatal P((int, const char *)),
+ fatalperror P((int, const char *)),
get_slc_defaults P((void)),
init_env P((void)),
init_termbuf P((void)),
@@ -117,10 +114,11 @@ extern void
netclear P((void)),
netflush P((void)),
#ifdef DIAGNOSTICS
- printoption P((char *, int)),
- printdata P((char *, char *, int)),
- printsub P((int, unsigned char *, int)),
+ printoption P((const char *, int)),
+ printdata P((const char *, char *, int)),
+ printsub P((char, unsigned char *, int)),
#endif
+ process_slc P((unsigned char, unsigned char, cc_t)),
ptyflush P((void)),
putchr P((int)),
putf P((char *, char *)),
@@ -136,7 +134,7 @@ extern void
set_termbuf P((void)),
start_login P((char *, int, char *)),
start_slc P((int)),
-#if defined(AUTHENTICATION)
+#ifdef AUTHENTICATION
start_slave P((char *)),
#else
start_slave P((char *, int, char *)),
@@ -186,6 +184,7 @@ extern void
int output_data __P((const char *, ...)) __printflike(1, 2);
void output_datalen __P((const char *, int));
+void startslave __P((char *, int, char *));
#ifdef ENCRYPTION
extern void (*encrypt_output) P((unsigned char *, int));
diff --git a/contrib/telnet/telnetd/slc.c b/contrib/telnet/telnetd/slc.c
index 780adf1..d4eee1a 100644
--- a/contrib/telnet/telnetd/slc.c
+++ b/contrib/telnet/telnetd/slc.c
@@ -31,13 +31,13 @@
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
+
+__FBSDID("$FreeBSD$");
+
#ifndef lint
-#if 0
static const char sccsid[] = "@(#)slc.c 8.2 (Berkeley) 5/30/95";
#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
#include "telnetd.h"
@@ -56,10 +56,10 @@ static unsigned char slcbuf[NSLC*6]; /* buffer for slc negotiation */
*
* Write out the current special characters to the client.
*/
- void
-send_slc()
+void
+send_slc(void)
{
- register int i;
+ int i;
/*
* Send out list of triplets of special characters
@@ -80,10 +80,10 @@ send_slc()
*
* Set pty special characters to all the defaults.
*/
- void
-default_slc()
+static void
+default_slc(void)
{
- register int i;
+ int i;
for (i = 1; i <= NSLC; i++) {
slctab[i].current.val = slctab[i].defset.val;
@@ -105,10 +105,10 @@ default_slc()
*
* Initialize the slc mapping table.
*/
- void
-get_slc_defaults()
+void
+get_slc_defaults(void)
{
- register int i;
+ int i;
init_termbuf();
@@ -127,10 +127,8 @@ get_slc_defaults()
*
* Add an slc triplet to the slc buffer.
*/
- void
-add_slc(func, flag, val)
- register char func, flag;
- register cc_t val;
+void
+add_slc(char func, char flag, cc_t val)
{
if ((*slcptr++ = (unsigned char)func) == 0xff)
@@ -152,9 +150,8 @@ add_slc(func, flag, val)
* The parameter getit is non-zero if it is necessary to grab a copy
* of the terminal control structures.
*/
- void
-start_slc(getit)
- register int getit;
+void
+start_slc(int getit)
{
slcchange = 0;
@@ -171,11 +168,10 @@ start_slc(getit)
*
* Finish up the slc negotiation. If something to send, then send it.
*/
- int
-end_slc(bufp)
- register unsigned char **bufp;
+int
+end_slc(unsigned char **bufp)
{
- register int len;
+ int len;
/*
* If a change has occured, store the new terminal control
@@ -217,12 +213,10 @@ end_slc(bufp)
*
* Figure out what to do about the client's slc
*/
- void
-process_slc(func, flag, val)
- register unsigned char func, flag;
- register cc_t val;
+void
+process_slc(unsigned char func, unsigned char flag, cc_t val)
{
- register int hislevel, mylevel, ack;
+ int hislevel, mylevel, ack;
/*
* Ensure that we know something about this function
@@ -283,12 +277,10 @@ process_slc(func, flag, val)
* Process a request to change one of our special characters.
* Compare client's request with what we are capable of supporting.
*/
- void
-change_slc(func, flag, val)
- register char func, flag;
- register cc_t val;
+void
+change_slc(char func, char flag, cc_t val)
{
- register int hislevel, mylevel;
+ int hislevel, mylevel;
hislevel = flag & SLC_LEVELBITS;
mylevel = slctab[(int)func].defset.flag & SLC_LEVELBITS;
@@ -393,10 +385,10 @@ cc_t oldeofc = '\004';
* likely to have changed. If a local change occurs, kick the support level
* and flags up to the defaults.
*/
- void
-check_slc()
+void
+check_slc(void)
{
- register int i;
+ int i;
for (i = 1; i <= NSLC; i++) {
#if defined(USE_TERMIO) && (VEOF == VMIN)
@@ -436,14 +428,12 @@ check_slc()
*
* ptr points to the beginning of the buffer, len is the length.
*/
- void
-do_opt_slc(ptr, len)
- register unsigned char *ptr;
- register int len;
+void
+do_opt_slc(unsigned char *ptr, int len)
{
- register unsigned char func, flag;
+ unsigned char func, flag;
cc_t val;
- register unsigned char *end = ptr + len;
+ unsigned char *end = ptr + len;
if (terminit()) { /* go ahead */
while (ptr < end) {
@@ -477,8 +467,8 @@ do_opt_slc(ptr, len)
*
* Do slc stuff that was deferred.
*/
- void
-deferslc()
+void
+deferslc(void)
{
if (def_slcbuf) {
start_slc(1);
diff --git a/contrib/telnet/telnetd/state.c b/contrib/telnet/telnetd/state.c
index 57ade2f..ff0828d 100644
--- a/contrib/telnet/telnetd/state.c
+++ b/contrib/telnet/telnetd/state.c
@@ -31,20 +31,20 @@
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
+
+__FBSDID("$FreeBSD$");
+
#ifndef lint
-#if 0
static const char sccsid[] = "@(#)state.c 8.5 (Berkeley) 5/30/95";
#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
#include <stdarg.h>
#include "telnetd.h"
-#if defined(AUTHENTICATION)
+#ifdef AUTHENTICATION
#include <libtelnet/auth.h>
#endif
-#if defined(ENCRYPTION)
+#ifdef ENCRYPTION
#include <libtelnet/encrypt.h>
#endif
@@ -89,10 +89,12 @@ unsigned char *subsave;
#define TS_DO 7 /* do " */
#define TS_DONT 8 /* dont " */
- void
-telrcv()
+static void doclientstat(void);
+
+void
+telrcv(void)
{
- register int c;
+ int c;
static int state = TS_DATA;
while (ncc > 0) {
@@ -422,9 +424,8 @@ gotiac: switch (c) {
* is complete.
*
*/
- void
-send_do(option, init)
- int option, init;
+void
+send_do(int option, int init)
{
if (init) {
if ((do_dont_resp[option] == 0 && his_state_is_will(option)) ||
@@ -446,22 +447,11 @@ send_do(option, init)
DIAG(TD_OPTIONS, printoption("td: send do", option));
}
-#ifdef AUTHENTICATION
-extern void auth_request();
-#endif
-#ifdef LINEMODE
-extern void doclientstat();
-#endif
-#ifdef ENCRYPTION
-extern void encrypt_send_support();
-#endif /* ENCRYPTION */
-
- void
-willoption(option)
- int option;
+void
+willoption(int option)
{
int changeok = 0;
- void (*func)() = 0;
+ void (*func)(void) = 0;
/*
* process input from peer.
@@ -649,9 +639,8 @@ willoption(option)
(*func)();
} /* end of willoption */
- void
-send_dont(option, init)
- int option, init;
+void
+send_dont(int option, int init)
{
if (init) {
if ((do_dont_resp[option] == 0 && his_state_is_wont(option)) ||
@@ -665,9 +654,8 @@ send_dont(option, init)
DIAG(TD_OPTIONS, printoption("td: send dont", option));
}
- void
-wontoption(option)
- int option;
+void
+wontoption(int option)
{
/*
* Process client input.
@@ -731,7 +719,7 @@ wontoption(option)
slctab[SLC_XOFF].defset.flag |= SLC_CANTCHANGE;
break;
-#if defined(AUTHENTICATION)
+#ifdef AUTHENTICATION
case TELOPT_AUTHENTICATION:
auth_finished(0, AUTH_REJECT);
break;
@@ -784,7 +772,7 @@ wontoption(option)
#endif /* defined(LINEMODE) && defined(KLUDGELINEMODE) */
break;
-#if defined(AUTHENTICATION)
+#ifdef AUTHENTICATION
case TELOPT_AUTHENTICATION:
auth_finished(0, AUTH_REJECT);
break;
@@ -798,9 +786,8 @@ wontoption(option)
} /* end of wontoption */
- void
-send_will(option, init)
- int option, init;
+void
+send_will(int option, int init)
{
if (init) {
if ((will_wont_resp[option] == 0 && my_state_is_will(option))||
@@ -825,9 +812,8 @@ send_will(option, init)
int turn_on_sga = 0;
#endif
- void
-dooption(option)
- int option;
+void
+dooption(int option)
{
int changeok = 0;
@@ -956,9 +942,8 @@ dooption(option)
} /* end of dooption */
- void
-send_wont(option, init)
- int option, init;
+void
+send_wont(int option, int init)
{
if (init) {
if ((will_wont_resp[option] == 0 && my_state_is_wont(option)) ||
@@ -972,9 +957,8 @@ send_wont(option, init)
DIAG(TD_OPTIONS, printoption("td: send wont", option));
}
- void
-dontoption(option)
- int option;
+void
+dontoption(int option)
{
/*
* Process client input.
@@ -1078,17 +1062,17 @@ int env_ovalue = -1;
* Window size
* Terminal speed
*/
- void
-suboption()
+void
+suboption(void)
{
- register int subchar;
+ int subchar;
DIAG(TD_OPTIONS, {netflush(); printsub('<', subpointer, SB_LEN()+2);});
subchar = SB_GET();
switch (subchar) {
case TELOPT_TSPEED: {
- register int xspeed, rspeed;
+ int xspeed, rspeed;
if (his_state_is_wont(TELOPT_TSPEED)) /* Ignore if option disabled */
break;
@@ -1126,7 +1110,7 @@ suboption()
while ((terminaltype < (terminalname + sizeof terminalname-1)) &&
!SB_EOF()) {
- register int c;
+ int c;
c = SB_GET();
if (isupper(c)) {
@@ -1140,7 +1124,7 @@ suboption()
} /* end of case TELOPT_TTYPE */
case TELOPT_NAWS: {
- register int xwinsize, ywinsize;
+ int xwinsize, ywinsize;
if (his_state_is_wont(TELOPT_NAWS)) /* Ignore if option disabled */
break;
@@ -1165,7 +1149,7 @@ suboption()
#ifdef LINEMODE
case TELOPT_LINEMODE: {
- register int request;
+ int request;
if (his_state_is_wont(TELOPT_LINEMODE)) /* Ignore if option disabled */
break;
@@ -1245,8 +1229,8 @@ suboption()
case TELOPT_NEW_ENVIRON:
#endif
case TELOPT_OLD_ENVIRON: {
- register int c;
- register char *cp, *varp, *valp;
+ int c;
+ char *cp, *varp, *valp;
if (SB_EOF())
return;
@@ -1277,7 +1261,7 @@ suboption()
* reversed.
*/
if (env_ovar < 0) {
- register int last = -1; /* invalid value */
+ int last = -1; /* invalid value */
int empty = 0;
int got_var = 0, got_value = 0, got_uservar = 0;
@@ -1427,7 +1411,7 @@ suboption()
unsetenv(varp);
break;
} /* end of case TELOPT_NEW_ENVIRON */
-#if defined(AUTHENTICATION)
+#ifdef AUTHENTICATION
case TELOPT_AUTHENTICATION:
if (SB_EOF())
break;
@@ -1498,20 +1482,20 @@ suboption()
} /* end of suboption */
- void
-doclientstat()
+static void
+doclientstat(void)
{
clientstat(TELOPT_LINEMODE, WILL, 0);
}
#define ADD(c) *ncp++ = c
#define ADD_DATA(c) { *ncp++ = c; if (c == SE || c == IAC) *ncp++ = c; }
- void
-send_status()
+void
+send_status(void)
{
unsigned char statusbuf[256];
- register unsigned char *ncp;
- register unsigned char i;
+ unsigned char *ncp;
+ unsigned char i;
ncp = statusbuf;
diff --git a/contrib/telnet/telnetd/sys_term.c b/contrib/telnet/telnetd/sys_term.c
index 2b5dfa5..9edde84 100644
--- a/contrib/telnet/telnetd/sys_term.c
+++ b/contrib/telnet/telnetd/sys_term.c
@@ -1,4 +1,4 @@
-/*
+ /*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
*
@@ -31,67 +31,49 @@
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
+
+__FBSDID("$FreeBSD$");
+
#ifndef lint
-#if 0
static const char sccsid[] = "@(#)sys_term.c 8.4+1 (Berkeley) 5/30/95";
#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
+
+#include <sys/types.h>
+#include <sys/tty.h>
+#include <libutil.h>
+#include <stdlib.h>
+#include <utmp.h>
#include "telnetd.h"
#include "pathnames.h"
-#if defined(AUTHENTICATION)
+#ifdef AUTHENTICATION
#include <libtelnet/auth.h>
#endif
-extern char *altlogin;
-int cleanopen(char *line);
+int cleanopen(char *);
void scrub_env(void);
-#ifdef NEWINIT
-#include <initreq.h>
-#else /* NEWINIT*/
-# ifdef UTMPX
-# include <utmpx.h>
-struct utmpx wtmp;
-# else
-# include <utmp.h>
struct utmp wtmp;
-# endif /* UTMPX */
-# ifndef PARENT_DOES_UTMP
#ifdef _PATH_WTMP
char wtmpf[] = _PATH_WTMP;
#else
-char wtmpf[] = "/usr/adm/wtmp";
+char wtmpf[] = "/var/log/wtmp";
#endif
#ifdef _PATH_UTMP
char utmpf[] = _PATH_UTMP;
#else
-char utmpf[] = "/etc/utmp";
+char utmpf[] = "/var/run/utmp";
#endif
-# else /* PARENT_DOES_UTMP */
-char wtmpf[] = "/etc/wtmp";
-# endif /* PARENT_DOES_UTMP */
-
-#include <libutil.h>
-
-#endif /* NEWINIT */
-#ifdef STREAMSPTY
-#include <sac.h>
-#include <sys/stropts.h>
-#endif
+char *envinit[3];
+extern char **environ;
#define SCPYN(a, b) (void) strncpy(a, b, sizeof(a))
#define SCMPN(a, b) strncmp(a, b, sizeof(a))
-#ifdef STREAMS
-#include <sys/stream.h>
-#endif
-#include <sys/tty.h>
#ifdef t_erase
#undef t_erase
#undef t_kill
@@ -122,9 +104,6 @@ struct termbuf {
# define cfgetospeed(tp) (tp)->sg.sg_ospeed
# define cfgetispeed(tp) (tp)->sg.sg_ispeed
#else /* USE_TERMIO */
-# ifdef SYSV_TERMIO
-# define termios termio
-# endif
# ifndef TCSANOW
# ifdef TCSETS
# define TCSANOW TCSETS
@@ -156,9 +135,6 @@ struct termbuf {
# endif
# endif /* TCSANOW */
struct termios termbuf, termbuf2; /* pty control structure */
-# ifdef STREAMSPTY
-int ttyfd = -1;
-# endif
#endif /* USE_TERMIO */
#include <sys/types.h>
@@ -166,6 +142,7 @@ int ttyfd = -1;
int cleanopen __P((char *));
void scrub_env __P((void));
+static char **addarg __P((char **, const char *));
/*
* init_termbuf()
@@ -178,8 +155,8 @@ void scrub_env __P((void));
* set_termbuf() writes the structure into the kernel.
*/
- void
-init_termbuf()
+void
+init_termbuf(void)
{
#ifndef USE_TERMIO
(void) ioctl(pty, TIOCGETP, (char *)&termbuf.sg);
@@ -189,20 +166,14 @@ init_termbuf()
(void) ioctl(pty, TIOCGSTATE, (char *)&termbuf.state);
# endif
#else
-# ifdef STREAMSPTY
- (void) tcgetattr(ttyfd, &termbuf);
-# else
(void) tcgetattr(pty, &termbuf);
-# endif
#endif
termbuf2 = termbuf;
}
#if defined(LINEMODE) && defined(TIOCPKT_IOCTL)
- void
-copy_termbuf(cp, len)
- char *cp;
- int len;
+void
+copy_termbuf(char *cp, size_t len)
{
if (len > sizeof(termbuf))
len = sizeof(termbuf);
@@ -211,8 +182,8 @@ copy_termbuf(cp, len)
}
#endif /* defined(LINEMODE) && defined(TIOCPKT_IOCTL) */
- void
-set_termbuf()
+void
+set_termbuf(void)
{
/*
* Only make the necessary changes.
@@ -231,11 +202,7 @@ set_termbuf()
(void) ioctl(pty, TIOCLSET, (char *)&termbuf.lflags);
#else /* USE_TERMIO */
if (memcmp((char *)&termbuf, (char *)&termbuf2, sizeof(termbuf)))
-# ifdef STREAMSPTY
- (void) tcsetattr(ttyfd, TCSANOW, &termbuf);
-# else
(void) tcsetattr(pty, TCSANOW, &termbuf);
-# endif
#endif /* USE_TERMIO */
}
@@ -252,11 +219,8 @@ set_termbuf()
*/
#ifndef USE_TERMIO
- int
-spcset(func, valp, valpp)
- int func;
- cc_t *valp;
- cc_t **valpp;
+int
+spcset(int func, cc_t *valp, cc_t **valpp)
{
switch(func) {
case SLC_EOF:
@@ -327,18 +291,15 @@ spcset(func, valp, valpp)
#else /* USE_TERMIO */
- int
-spcset(func, valp, valpp)
- int func;
- cc_t *valp;
- cc_t **valpp;
-{
#define setval(a, b) *valp = termbuf.c_cc[a]; \
*valpp = &termbuf.c_cc[a]; \
return(b);
#define defval(a) *valp = ((cc_t)a); *valpp = (cc_t *)0; return(SLC_DEFAULT);
+int
+spcset(int func, cc_t *valp, cc_t **valpp)
+{
switch(func) {
case SLC_EOF:
setval(VEOF, SLC_VARIABLE);
@@ -423,7 +384,6 @@ spcset(func, valp, valpp)
}
#endif /* USE_TERMIO */
-#ifndef convex
/*
* getpty()
*
@@ -432,28 +392,16 @@ spcset(func, valp, valpp)
*
* Returns the file descriptor of the opened pty.
*/
+char alpha[] = "0123456789abcdefghijklmnopqrstuv";
char line[16];
- int
-getpty(ptynum)
-int *ptynum;
+int
+getpty(int *ptynum __unused)
{
- register int p;
-#ifdef STREAMSPTY
- int t;
- char *ptsname();
-
- p = open("/dev/ptmx", 2);
- if (p > 0) {
- grantpt(p);
- unlockpt(p);
- strcpy(line, ptsname(p));
- return(p);
- }
-
-#else /* ! STREAMSPTY */
- register char *cp, *p1, *p2;
- register int i;
+ int p;
+ const char *cp;
+ char *p1, *p2;
+ int i;
(void) strcpy(line, _PATH_DEV);
(void) strcat(line, "ptyXX");
@@ -473,7 +421,7 @@ int *ptynum;
if (stat(line, &stb) < 0)
break;
for (i = 0; i < 32; i++) {
- *p2 = "0123456789abcdefghijklmnopqrstuv"[i];
+ *p2 = alpha[i];
p = open(line, 2);
if (p > 0) {
line[5] = 't';
@@ -483,10 +431,8 @@ int *ptynum;
}
}
}
-#endif /* STREAMSPTY */
return(-1);
}
-#endif /* convex */
#ifdef LINEMODE
/*
@@ -510,38 +456,24 @@ int *ptynum;
* tty_rspeed(val) Set receive speed to val.
*/
-#ifdef convex
-static int linestate;
-#endif
- int
-tty_linemode()
+int
+tty_linemode(void)
{
-#ifndef convex
#ifndef USE_TERMIO
return(termbuf.state & TS_EXTPROC);
#else
return(termbuf.c_lflag & EXTPROC);
#endif
-#else
- return(linestate);
-#endif
}
- void
-tty_setlinemode(on)
- int on;
+void
+tty_setlinemode(int on)
{
#ifdef TIOCEXT
-# ifndef convex
set_termbuf();
-# else
- linestate = on;
-# endif
(void) ioctl(pty, TIOCEXT, (char *)&on);
-# ifndef convex
init_termbuf();
-# endif
#else /* !TIOCEXT */
# ifdef EXTPROC
if (on)
@@ -553,8 +485,8 @@ tty_setlinemode(on)
}
#endif /* LINEMODE */
- int
-tty_isecho()
+int
+tty_isecho(void)
{
#ifndef USE_TERMIO
return (termbuf.sg.sg_flags & ECHO);
@@ -563,8 +495,8 @@ tty_isecho()
#endif
}
- int
-tty_flowmode()
+int
+tty_flowmode(void)
{
#ifndef USE_TERMIO
return(((termbuf.tc.t_startc) > 0 && (termbuf.tc.t_stopc) > 0) ? 1 : 0);
@@ -573,8 +505,8 @@ tty_flowmode()
#endif
}
- int
-tty_restartany()
+int
+tty_restartany(void)
{
#ifndef USE_TERMIO
# ifdef DECCTQ
@@ -587,9 +519,8 @@ tty_restartany()
#endif
}
- void
-tty_setecho(on)
- int on;
+void
+tty_setecho(int on)
{
#ifndef USE_TERMIO
if (on)
@@ -604,8 +535,8 @@ tty_setecho(on)
#endif
}
- int
-tty_israw()
+int
+tty_israw(void)
{
#ifndef USE_TERMIO
return(termbuf.sg.sg_flags & RAW);
@@ -614,9 +545,10 @@ tty_israw()
#endif
}
-#if defined (AUTHENTICATION) && defined(NO_LOGIN_F) && defined(LOGIN_R)
- int
-tty_setraw(on)
+#ifdef AUTHENTICATION
+#if defined(NO_LOGIN_F) && defined(LOGIN_R)
+int
+tty_setraw(int on)
{
# ifndef USE_TERMIO
if (on)
@@ -631,10 +563,10 @@ tty_setraw(on)
# endif
}
#endif
+#endif /* AUTHENTICATION */
- void
-tty_binaryin(on)
- int on;
+void
+tty_binaryin(int on)
{
#ifndef USE_TERMIO
if (on)
@@ -650,9 +582,8 @@ tty_binaryin(on)
#endif
}
- void
-tty_binaryout(on)
- int on;
+void
+tty_binaryout(int on)
{
#ifndef USE_TERMIO
if (on)
@@ -672,8 +603,8 @@ tty_binaryout(on)
#endif
}
- int
-tty_isbinaryin()
+int
+tty_isbinaryin(void)
{
#ifndef USE_TERMIO
return(termbuf.lflags & LPASS8);
@@ -682,8 +613,8 @@ tty_isbinaryin()
#endif
}
- int
-tty_isbinaryout()
+int
+tty_isbinaryout(void)
{
#ifndef USE_TERMIO
return(termbuf.lflags & LLITOUT);
@@ -693,8 +624,8 @@ tty_isbinaryout()
}
#ifdef LINEMODE
- int
-tty_isediting()
+int
+tty_isediting(void)
{
#ifndef USE_TERMIO
return(!(termbuf.sg.sg_flags & (CBREAK|RAW)));
@@ -703,8 +634,8 @@ tty_isediting()
#endif
}
- int
-tty_istrapsig()
+int
+tty_istrapsig(void)
{
#ifndef USE_TERMIO
return(!(termbuf.sg.sg_flags&RAW));
@@ -713,9 +644,8 @@ tty_istrapsig()
#endif
}
- void
-tty_setedit(on)
- int on;
+void
+tty_setedit(int on)
{
#ifndef USE_TERMIO
if (on)
@@ -730,9 +660,8 @@ tty_setedit(on)
#endif
}
- void
-tty_setsig(on)
- int on;
+void
+tty_setsig(int on)
{
#ifndef USE_TERMIO
if (on)
@@ -746,8 +675,8 @@ tty_setsig(on)
}
#endif /* LINEMODE */
- int
-tty_issofttab()
+int
+tty_issofttab(void)
{
#ifndef USE_TERMIO
return (termbuf.sg.sg_flags & XTABS);
@@ -761,9 +690,8 @@ tty_issofttab()
#endif
}
- void
-tty_setsofttab(on)
- int on;
+void
+tty_setsofttab(int on)
{
#ifndef USE_TERMIO
if (on)
@@ -791,8 +719,8 @@ tty_setsofttab(on)
#endif
}
- int
-tty_islitecho()
+int
+tty_islitecho(void)
{
#ifndef USE_TERMIO
return (!(termbuf.lflags & LCTLECH));
@@ -809,9 +737,8 @@ tty_islitecho()
#endif
}
- void
-tty_setlitecho(on)
- int on;
+void
+tty_setlitecho(int on)
{
#ifndef USE_TERMIO
if (on)
@@ -834,8 +761,8 @@ tty_setlitecho(on)
#endif
}
- int
-tty_iscrnl()
+int
+tty_iscrnl(void)
{
#ifndef USE_TERMIO
return (termbuf.sg.sg_flags & CRMOD);
@@ -894,12 +821,11 @@ struct termspeeds {
};
#endif /* DECODE_BAUD */
- void
-tty_tspeed(val)
- int val;
+void
+tty_tspeed(int val)
{
#ifdef DECODE_BAUD
- register struct termspeeds *tp;
+ struct termspeeds *tp;
for (tp = termspeeds; (tp->speed != -1) && (val > tp->speed); tp++)
;
@@ -911,12 +837,11 @@ tty_tspeed(val)
#endif /* DECODE_BAUD */
}
- void
-tty_rspeed(val)
- int val;
+void
+tty_rspeed(int val)
{
#ifdef DECODE_BAUD
- register struct termspeeds *tp;
+ struct termspeeds *tp;
for (tp = termspeeds; (tp->speed != -1) && (val > tp->speed); tp++)
;
@@ -928,42 +853,16 @@ tty_rspeed(val)
#endif /* DECODE_BAUD */
}
-#ifdef PARENT_DOES_UTMP
-# ifndef NEWINIT
-extern struct utmp wtmp;
-extern char wtmpf[];
-# else /* NEWINIT */
-int gotalarm;
-
- /* ARGSUSED */
- void
-nologinproc(sig)
- int sig;
-{
- gotalarm++;
-}
-# endif /* NEWINIT */
-#endif /* PARENT_DOES_UTMP */
-
-#ifndef NEWINIT
-# ifdef PARENT_DOES_UTMP
-extern void utmp_sig_init P((void));
-extern void utmp_sig_reset P((void));
-extern void utmp_sig_wait P((void));
-extern void utmp_sig_notify P((int));
-# endif /* PARENT_DOES_UTMP */
-#endif
-
/*
* getptyslave()
*
* Open the slave side of the pty, and do any initialization
* that is necessary.
*/
- void
-getptyslave()
+static void
+getptyslave(void)
{
- register int t = -1;
+ int t = -1;
char erase;
# ifdef LINEMODE
@@ -1000,31 +899,10 @@ getptyslave()
}
# endif
-
-# ifdef PARENT_DOES_UTMP
- /*
- * Wait for our parent to get the utmp stuff to get done.
- */
- utmp_sig_wait();
-# endif
-
t = cleanopen(line);
if (t < 0)
fatalperror(net, line);
-#ifdef STREAMSPTY
-#ifdef USE_TERMIO
- ttyfd = t;
-#endif
- if (ioctl(t, I_PUSH, "ptem") < 0)
- fatal(net, "I_PUSH ptem");
- if (ioctl(t, I_PUSH, "ldterm") < 0)
- fatal(net, "I_PUSH ldterm");
- if (ioctl(t, I_PUSH, "ttcompat") < 0)
- fatal(net, "I_PUSH ttcompat");
- if (ioctl(pty, I_PUSH, "pckt") < 0)
- fatal(net, "I_PUSH pckt");
-#endif
/*
* set up the tty modes as we like them to be.
@@ -1051,15 +929,6 @@ getptyslave()
* systems, other than 4.4BSD. In 4.4BSD the
* kernel does the initial terminal setup.
*/
-# if defined(USE_TERMIO) && (BSD <= 43)
-# ifndef OXTABS
-# define OXTABS 0
-# endif
- termbuf.c_lflag |= ECHO;
- termbuf.c_oflag |= ONLCR|OXTABS;
- termbuf.c_iflag |= ICRNL;
- termbuf.c_iflag &= ~IXOFF;
-# endif /* defined(USE_TERMIO) && (BSD <= 43) */
tty_rspeed((def_rspeed > 0) ? def_rspeed : 9600);
tty_tspeed((def_tspeed > 0) ? def_tspeed : 9600);
if (erase)
@@ -1077,7 +946,8 @@ getptyslave()
fatalperror(net, "login_tty");
if (net > 2)
(void) close(net);
-#if defined(AUTHENTICATION) && defined(NO_LOGIN_F) && defined(LOGIN_R)
+#ifdef AUTHENTICATION
+#if defined(NO_LOGIN_F) && defined(LOGIN_R)
/*
* Leave the pty open so that we can write out the rlogin
* protocol for /bin/login, if the authentication works.
@@ -1088,6 +958,7 @@ getptyslave()
pty = -1;
}
#endif
+#endif /* AUTHENTICATION */
}
#ifndef O_NOCTTY
@@ -1097,90 +968,28 @@ getptyslave()
* Open the specified slave side of the pty,
* making sure that we have a clean tty.
*/
- int
-cleanopen(line)
- char *line;
+int
+cleanopen(char *li)
{
- register int t;
+ int t;
-#ifndef STREAMSPTY
/*
* Make sure that other people can't open the
* slave side of the connection.
*/
- (void) chown(line, 0, 0);
- (void) chmod(line, 0600);
-#endif
+ (void) chown(li, 0, 0);
+ (void) chmod(li, 0600);
- (void) revoke(line);
+ (void) revoke(li);
t = open(line, O_RDWR|O_NOCTTY);
if (t < 0)
return(-1);
- /*
- * Hangup anybody else using this ttyp, then reopen it for
- * ourselves.
- */
-# if (BSD <= 43) && !defined(STREAMSPTY)
- (void) signal(SIGHUP, SIG_IGN);
- vhangup();
- (void) signal(SIGHUP, SIG_DFL);
- t = open(line, O_RDWR|O_NOCTTY);
- if (t < 0)
- return(-1);
-# endif
return(t);
}
-#if BSD <= 43
-
- int
-login_tty(t)
- int t;
-{
- if (setsid() < 0) {
-#ifdef ultrix
- /*
- * The setsid() may have failed because we
- * already have a pgrp == pid. Zero out
- * our pgrp and try again...
- */
- if ((setpgrp(0, 0) < 0) || (setsid() < 0))
-#endif
- fatalperror(net, "setsid()");
- }
-# ifdef TIOCSCTTY
- if (ioctl(t, TIOCSCTTY, (char *)0) < 0)
- fatalperror(net, "ioctl(sctty)");
-# else
- /*
- * We get our controlling tty assigned as a side-effect
- * of opening up a tty device. But on BSD based systems,
- * this only happens if our process group is zero. The
- * setsid() call above may have set our pgrp, so clear
- * it out before opening the tty...
- */
- (void) setpgrp(0, 0);
- close(open(line, O_RDWR));
-# endif
- if (t != 0)
- (void) dup2(t, 0);
- if (t != 1)
- (void) dup2(t, 1);
- if (t != 2)
- (void) dup2(t, 2);
- if (t > 2)
- close(t);
- return(0);
-}
-#endif /* BSD <= 43 */
-
-#ifdef NEWINIT
-char *gen_id = "fe";
-#endif
-
/*
* startslave(host)
*
@@ -1189,21 +998,12 @@ char *gen_id = "fe";
*/
/* ARGSUSED */
- void
-startslave(host, autologin, autoname)
- char *host;
- int autologin;
- char *autoname;
+void
+startslave(char *host, int autologin, char *autoname)
{
- register int i;
-#ifdef NEWINIT
- extern char *ptyip;
- struct init_request request;
- void nologinproc();
- register int n;
-#endif /* NEWINIT */
-
-#if defined(AUTHENTICATION)
+ int i;
+
+#ifdef AUTHENTICATION
if (!autoname || !autoname[0])
autologin = 0;
@@ -1213,109 +1013,20 @@ startslave(host, autologin, autoname)
}
#endif
-#ifndef NEWINIT
-# ifdef PARENT_DOES_UTMP
- utmp_sig_init();
-# endif /* PARENT_DOES_UTMP */
if ((i = fork()) < 0)
fatalperror(net, "fork");
if (i) {
-# ifdef PARENT_DOES_UTMP
- /*
- * Cray parent will create utmp entry for child and send
- * signal to child to tell when done. Child waits for signal
- * before doing anything important.
- */
- register int pid = i;
- void sigjob P((int));
-
- setpgrp();
- utmp_sig_reset(); /* reset handler to default */
- /*
- * Create utmp entry for child
- */
- (void) time(&wtmp.ut_time);
- wtmp.ut_type = LOGIN_PROCESS;
- wtmp.ut_pid = pid;
- SCPYN(wtmp.ut_user, "LOGIN");
- SCPYN(wtmp.ut_host, host);
- SCPYN(wtmp.ut_line, line + sizeof(_PATH_DEV) - 1);
- SCPYN(wtmp.ut_id, wtmp.ut_line+3);
- pututline(&wtmp);
- endutent();
- if ((i = open(wtmpf, O_WRONLY|O_APPEND)) >= 0) {
- (void) write(i, (char *)&wtmp, sizeof(struct utmp));
- (void) close(i);
- }
- utmp_sig_notify(pid);
-# endif /* PARENT_DOES_UTMP */
} else {
- getptyslave(autologin);
+ getptyslave();
start_login(host, autologin, autoname);
/*NOTREACHED*/
}
-#else /* NEWINIT */
-
- /*
- * Init will start up login process if we ask nicely. We only wait
- * for it to start up and begin normal telnet operation.
- */
- if ((i = open(INIT_FIFO, O_WRONLY)) < 0) {
- char tbuf[128];
- (void) snprintf(tbuf, sizeof(tbuf), "Can't open %s\n", INIT_FIFO);
- fatalperror(net, tbuf);
- }
- memset((char *)&request, 0, sizeof(request));
- request.magic = INIT_MAGIC;
- SCPYN(request.gen_id, gen_id);
- SCPYN(request.tty_id, &line[8]);
- SCPYN(request.host, host);
- SCPYN(request.term_type, terminaltype ? terminaltype : "network");
- request.signal = SIGCLD;
- request.pid = getpid();
-#ifdef BFTPDAEMON
- /*
- * Are we working as the bftp daemon?
- */
- if (bftpd) {
- SCPYN(request.exec_name, BFTPPATH);
- }
-#endif /* BFTPDAEMON */
- if (write(i, (char *)&request, sizeof(request)) < 0) {
- char tbuf[128];
- (void) snprintf(tbuf, sizeof(tbuf), "Can't write to %s\n", INIT_FIFO);
- fatalperror(net, tbuf);
- }
- (void) close(i);
- (void) signal(SIGALRM, nologinproc);
- for (i = 0; ; i++) {
- char tbuf[128];
- alarm(15);
- n = read(pty, ptyip, BUFSIZ);
- if (i == 3 || n >= 0 || !gotalarm)
- break;
- gotalarm = 0;
- snprintf(tbuf, sizeof(tbuf), "telnetd: waiting for /etc/init to start login process on %s\r\n", line);
- (void) write(net, tbuf, strlen(tbuf));
- }
- if (n < 0 && gotalarm)
- fatal(net, "/etc/init didn't start login process");
- pcc += n;
- alarm(0);
- (void) signal(SIGALRM, SIG_DFL);
-
- return;
-#endif /* NEWINIT */
}
-char *envinit[3];
-extern char **environ;
-
- void
-init_env()
+void
+init_env(void)
{
- extern char *getenv();
char **envp;
envp = envinit;
@@ -1325,7 +1036,6 @@ init_env()
environ = envinit;
}
-#ifndef NEWINIT
/*
* start_login(host)
@@ -1334,42 +1044,16 @@ init_env()
* function will turn us into the login process.
*/
- void
-start_login(host, autologin, name)
- char *host;
- int autologin;
- char *name;
-{
- register char **argv;
- char **addarg(), *user;
- extern char *getenv();
-#ifdef UTMPX
- register int pid = getpid();
- struct utmpx utmpx;
-#endif
-#ifdef SOLARIS
- char *term;
- char termbuf[64];
+#ifndef AUTHENTICATION
+#define undef1 __unused
+#else
+#define undef1
#endif
-#ifdef UTMPX
- /*
- * Create utmp entry for child
- */
-
- memset(&utmpx, 0, sizeof(utmpx));
- SCPYN(utmpx.ut_user, ".telnet");
- SCPYN(utmpx.ut_line, line + sizeof(_PATH_DEV) - 1);
- utmpx.ut_pid = pid;
- utmpx.ut_id[0] = 't';
- utmpx.ut_id[1] = 'n';
- utmpx.ut_id[2] = SC_WILDC;
- utmpx.ut_id[3] = SC_WILDC;
- utmpx.ut_type = LOGIN_PROCESS;
- (void) time(&utmpx.ut_tv.tv_sec);
- if (makeutx(&utmpx) == NULL)
- fatal(net, "makeutx failed");
-#endif
+void
+start_login(char *host undef1, int autologin undef1, char *name undef1)
+{
+ char **argv;
scrub_env();
@@ -1384,8 +1068,8 @@ start_login(host, autologin, name)
argv = addarg(0, "login");
#if !defined(NO_LOGIN_H)
-
-# if defined (AUTHENTICATION) && defined(NO_LOGIN_F) && defined(LOGIN_R)
+#ifdef AUTHENTICATION
+# if defined(NO_LOGIN_F) && defined(LOGIN_R)
/*
* Don't add the "-h host" option if we are going
* to be adding the "-r host" option down below...
@@ -1395,21 +1079,8 @@ start_login(host, autologin, name)
{
argv = addarg(argv, "-h");
argv = addarg(argv, host);
-#ifdef SOLARIS
- /*
- * SVR4 version of -h takes TERM= as second arg, or -
- */
- term = getenv("TERM");
- if (term == NULL || term[0] == 0) {
- term = "-";
- } else {
- strcpy(termbuf, "TERM=");
- strncat(termbuf, term, sizeof(termbuf) - 6);
- term = termbuf;
- }
- argv = addarg(argv, term);
-#endif
}
+#endif /* AUTHENTICATION */
#endif
#if !defined(NO_LOGIN_P)
argv = addarg(argv, "-p");
@@ -1437,15 +1108,7 @@ start_login(host, autologin, name)
argv = addarg(argv, BFTPPATH);
} else
#endif
-#if defined (SecurID)
- /*
- * don't worry about the -f that might get sent.
- * A -s is supposed to override it anyhow.
- */
- if (require_SecurID)
- argv = addarg(argv, "-s");
-#endif
-#if defined (AUTHENTICATION)
+#ifdef AUTHENTICATION
if (auth_level >= 0 && autologin == AUTH_VALID) {
# if !defined(NO_LOGIN_F)
argv = addarg(argv, "-f");
@@ -1462,7 +1125,7 @@ start_login(host, autologin, name)
*/
if (pty > 2) {
- register char *cp;
+ char *cp;
char speed[128];
int isecho, israw, xpty, len;
extern int def_rspeed;
@@ -1484,11 +1147,7 @@ start_login(host, autologin, name)
argv = addarg(argv, LOGIN_HOST);
xpty = pty;
-# ifndef STREAMSPTY
pty = 0;
-# else
- ttyfd = 0;
-# endif
init_termbuf();
isecho = tty_isecho();
israw = tty_israw();
@@ -1534,7 +1193,7 @@ start_login(host, autologin, name)
argv = addarg(argv, getenv("USER"));
#if defined(LOGIN_ARGS) && defined(NO_LOGIN_P)
{
- register char **cpp;
+ char **cpp;
for (cpp = environ; *cpp; cpp++)
argv = addarg(argv, *cpp);
}
@@ -1551,20 +1210,12 @@ start_login(host, autologin, name)
*/
unsetenv("USER");
}
-#ifdef SOLARIS
- else {
- char **p;
-
- argv = addarg(argv, ""); /* no login name */
- for (p = environ; *p; p++) {
- argv = addarg(argv, *p);
- }
- }
-#endif /* SOLARIS */
-#if defined(AUTHENTICATION) && defined(NO_LOGIN_F) && defined(LOGIN_R)
+#ifdef AUTHENTICATION
+#if defined(NO_LOGIN_F) && defined(LOGIN_R)
if (pty > 2)
close(pty);
#endif
+#endif /* AUTHENTICATION */
closelog();
if (altlogin == NULL) {
@@ -1577,12 +1228,10 @@ start_login(host, autologin, name)
/*NOTREACHED*/
}
- char **
-addarg(argv, val)
- register char **argv;
- register char *val;
+static char **
+addarg(char **argv, const char *val)
{
- register char **cpp;
+ char **cpp;
if (argv == NULL) {
/*
@@ -1605,26 +1254,25 @@ addarg(argv, val)
argv++;
cpp = &argv[(int)argv[-1] - 10];
}
- *cpp++ = val;
+ *cpp++ = strdup(val);
*cpp = 0;
return(argv);
}
-#endif /* NEWINIT */
/*
* scrub_env()
*
* We only accept the environment variables listed below.
*/
- void
-scrub_env()
+void
+scrub_env(void)
{
- static const char *reject[] = {
+ static const char *rej[] = {
"TERMCAP=/",
NULL
};
- static const char *accept[] = {
+ static const char *acc[] = {
"XAUTH=", "XAUTHORITY=", "DISPLAY=",
"TERM=",
"EDITOR=",
@@ -1641,7 +1289,7 @@ scrub_env()
for (cpp2 = cpp = environ; *cpp; cpp++) {
int reject_it = 0;
- for(p = reject; *p; p++)
+ for(p = rej; *p; p++)
if(strncmp(*cpp, *p, strlen(*p)) == 0) {
reject_it = 1;
break;
@@ -1649,7 +1297,7 @@ scrub_env()
if (reject_it)
continue;
- for(p = accept; *p; p++)
+ for(p = acc; *p; p++)
if(strncmp(*cpp, *p, strlen(*p)) == 0)
break;
if(*p != NULL)
@@ -1664,13 +1312,10 @@ scrub_env()
* This is the routine to call when we are all through, to
* clean up anything that needs to be cleaned up.
*/
- /* ARGSUSED */
- void
-cleanup(sig)
- int sig;
+/* ARGSUSED */
+void
+cleanup(int sig __unused)
{
-#ifndef PARENT_DOES_UTMP
-# if (BSD > 43) || defined(convex)
char *p;
p = line + sizeof(_PATH_DEV) - 1;
@@ -1683,173 +1328,4 @@ cleanup(sig)
(void)chown(line, 0, 0);
(void) shutdown(net, 2);
exit(1);
-# else
- void rmut();
-
- rmut();
- vhangup(); /* XXX */
- (void) shutdown(net, 2);
- exit(1);
-# endif
-#else /* PARENT_DOES_UTMP */
-# ifdef NEWINIT
- (void) shutdown(net, 2);
- exit(1);
-# else /* NEWINIT */
- rmut(line);
- close(pty);
- (void) shutdown(net, 2);
- exit(1);
-# endif /* NEWINT */
-#endif /* PARENT_DOES_UTMP */
-}
-
-#if defined(PARENT_DOES_UTMP) && !defined(NEWINIT)
-/*
- * _utmp_sig_rcv
- * utmp_sig_init
- * utmp_sig_wait
- * These three functions are used to coordinate the handling of
- * the utmp file between the server and the soon-to-be-login shell.
- * The server actually creates the utmp structure, the child calls
- * utmp_sig_wait(), until the server calls utmp_sig_notify() and
- * signals the future-login shell to proceed.
- */
-static int caught=0; /* NZ when signal intercepted */
-static void (*func)(); /* address of previous handler */
-
- void
-_utmp_sig_rcv(sig)
- int sig;
-{
- caught = 1;
- (void) signal(SIGUSR1, func);
}
-
- void
-utmp_sig_init()
-{
- /*
- * register signal handler for UTMP creation
- */
- if ((int)(func = signal(SIGUSR1, _utmp_sig_rcv)) == -1)
- fatalperror(net, "telnetd/signal");
-}
-
- void
-utmp_sig_reset()
-{
- (void) signal(SIGUSR1, func); /* reset handler to default */
-}
-
- void
-utmp_sig_wait()
-{
- /*
- * Wait for parent to write our utmp entry.
- */
- sigoff();
- while (caught == 0) {
- pause(); /* wait until we get a signal (sigon) */
- sigoff(); /* turn off signals while we check caught */
- }
- sigon(); /* turn on signals again */
-}
-
- void
-utmp_sig_notify(pid)
-{
- kill(pid, SIGUSR1);
-}
-
-#endif /* defined(PARENT_DOES_UTMP) && !defined(NEWINIT) */
-
-/*
- * rmut()
- *
- * This is the function called by cleanup() to
- * remove the utmp entry for this person.
- */
-
-#ifdef UTMPX
- void
-rmut()
-{
- register f;
- int found = 0;
- struct utmp *u, *utmp;
- int nutmp;
- struct stat statbf;
-
- struct utmpx *utxp, utmpx;
-
- /*
- * This updates the utmpx and utmp entries and make a wtmp/x entry
- */
-
- SCPYN(utmpx.ut_line, line + sizeof(_PATH_DEV) - 1);
- utxp = getutxline(&utmpx);
- if (utxp) {
- utxp->ut_type = DEAD_PROCESS;
- utxp->ut_exit.e_termination = 0;
- utxp->ut_exit.e_exit = 0;
- (void) time(&utmpx.ut_tv.tv_sec);
- utmpx.ut_tv.tv_usec = 0;
- modutx(utxp);
- }
- endutxent();
-} /* end of rmut */
-#endif
-
-#if !defined(UTMPX) && BSD <= 43
- void
-rmut()
-{
- register f;
- int found = 0;
- struct utmp *u, *utmp;
- int nutmp;
- struct stat statbf;
-
- f = open(utmpf, O_RDWR);
- if (f >= 0) {
- (void) fstat(f, &statbf);
- utmp = (struct utmp *)malloc((unsigned)statbf.st_size);
- if (!utmp)
- syslog(LOG_ERR, "utmp malloc failed");
- if (statbf.st_size && utmp) {
- nutmp = read(f, (char *)utmp, (int)statbf.st_size);
- nutmp /= sizeof(struct utmp);
-
- for (u = utmp ; u < &utmp[nutmp] ; u++) {
- if (SCMPN(u->ut_line, line+5) ||
- u->ut_name[0]==0)
- continue;
- (void) lseek(f, ((long)u)-((long)utmp), L_SET);
- SCPYN(u->ut_name, "");
- SCPYN(u->ut_host, "");
- (void) time(&u->ut_time);
- (void) write(f, (char *)u, sizeof(wtmp));
- found++;
- }
- }
- (void) close(f);
- }
- if (found) {
- f = open(wtmpf, O_WRONLY|O_APPEND);
- if (f >= 0) {
- SCPYN(wtmp.ut_line, line+5);
- SCPYN(wtmp.ut_name, "");
- SCPYN(wtmp.ut_host, "");
- (void) time(&wtmp.ut_time);
- (void) write(f, (char *)&wtmp, sizeof(wtmp));
- (void) close(f);
- }
- }
- (void) chmod(line, 0666);
- (void) chown(line, 0, 0);
- line[strlen(_PATH_DEV)] = 'p';
- (void) chmod(line, 0666);
- (void) chown(line, 0, 0);
-} /* end of rmut */
-#endif
diff --git a/contrib/telnet/telnetd/telnetd.8 b/contrib/telnet/telnetd/telnetd.8
index 00b444c..a884357 100644
--- a/contrib/telnet/telnetd/telnetd.8
+++ b/contrib/telnet/telnetd/telnetd.8
@@ -243,26 +243,6 @@ have been idle for some period of time to determine
if the client is still there, so that idle connections
from machines that have crashed or can no longer
be reached may be cleaned up.
-.It Fl s
-This option is only enabled if
-.Nm
-is compiled with support for
-.Tn SecurID
-cards.
-It causes the
-.Fl s
-option to be passed on to
-.Xr login 1 ,
-and thus is only useful if
-.Xr login 1
-supports the
-.Fl s
-flag to indicate that only
-.Tn SecurID
-validated logins are allowed, and is
-usually useful for controlling remote logins
-from outside of a firewall.
-.It Fl S Ar tos
.It Fl u Ar len
This option is used to specify the size of the field
in the
diff --git a/contrib/telnet/telnetd/telnetd.c b/contrib/telnet/telnetd/telnetd.c
index f141dd3..7527b7e 100644
--- a/contrib/telnet/telnetd/telnetd.c
+++ b/contrib/telnet/telnetd/telnetd.c
@@ -31,67 +31,39 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1989, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
+#include <sys/cdefs.h>
+
+__FBSDID("$FreeBSD$");
#ifndef lint
-#if 0
static const char sccsid[] = "@(#)telnetd.c 8.4 (Berkeley) 5/30/95";
#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
#include "telnetd.h"
#include "pathnames.h"
-#include <err.h>
-#include <arpa/inet.h>
-
#include <sys/mman.h>
+#include <err.h>
#include <libutil.h>
#include <paths.h>
+#include <termcap.h>
#include <utmp.h>
-#if defined(AUTHENTICATION)
+#include <arpa/inet.h>
+
+#ifdef AUTHENTICATION
#include <libtelnet/auth.h>
int auth_level = 0;
#endif
-#if defined(ENCRYPTION)
+#ifdef ENCRYPTION
#include <libtelnet/encrypt.h>
#endif
#include <libtelnet/misc.h>
-#if defined(SecurID)
-int require_SecurID = 0;
-#endif
char remote_hostname[MAXHOSTNAMELEN];
-int utmp_len = sizeof(remote_hostname) - 1;
+size_t utmp_len = sizeof(remote_hostname) - 1;
int registerd_host_only = 0;
-#ifdef STREAMSPTY
-# include <stropts.h>
-# include <termio.h>
-/* make sure we don't get the bsd version */
-# include "/usr/include/sys/tty.h"
-# include <sys/ptyvar.h>
-
-/*
- * Because of the way ptyibuf is used with streams messages, we need
- * ptyibuf+1 to be on a full-word boundary. The following weirdness
- * is simply to make that happen.
- */
-long ptyibufbuf[BUFSIZ/sizeof(long)+1];
-char *ptyibuf = ((char *)&ptyibufbuf[1])-1;
-char *ptyip = ((char *)&ptyibufbuf[1])-1;
-char ptyibuf2[BUFSIZ];
-unsigned char ctlbuf[BUFSIZ];
-struct strbuf strbufc, strbufd;
-
-#else /* ! STREAMPTY */
/*
* I/O data buffers,
@@ -100,25 +72,21 @@ struct strbuf strbufc, strbufd;
char ptyibuf[BUFSIZ], *ptyip = ptyibuf;
char ptyibuf2[BUFSIZ];
-# include <termcap.h>
-
-int readstream(int p, char *ibuf, int bufsize);
-void doit(struct sockaddr *who);
-int terminaltypeok(char *s);
-void startslave(char *host, int autologin, char *autoname);
-
-#endif /* ! STREAMPTY */
+int readstream(int, char *, int);
+void doit(struct sockaddr *);
+int terminaltypeok(char *);
int hostinfo = 1; /* do we print login banner? */
int debug = 0;
int keepalive = 1;
-char *altlogin;
+const char *altlogin;
void doit __P((struct sockaddr *));
int terminaltypeok __P((char *));
void startslave __P((char *, int, char *));
extern void usage P((void));
+static void _gettermname __P((void));
/*
* The string to pass to getopt(). We do it this way so
@@ -143,21 +111,29 @@ char valid_opts[] = {
#ifdef LINEMODE
'l',
#endif
-#ifdef SecurID
- 's',
-#endif
'\0'
};
int family = AF_INET;
+#ifndef MAXHOSTNAMELEN
+#define MAXHOSTNAMELEN 256
+#endif /* MAXHOSTNAMELEN */
+
+char *hostname;
+char host_name[MAXHOSTNAMELEN];
+
+extern void telnet P((int, int, char *));
+
+int level;
+char user_name[256];
+
int
-main(argc, argv)
- char *argv[];
+main(int argc, char *argv[])
{
struct sockaddr_storage from;
int on = 1, fromlen;
- register int ch;
+ int ch;
#if defined(IPPROTO_IP) && defined(IP_TOS)
int tos = -1;
#endif
@@ -290,12 +266,6 @@ main(argc, argv)
altlogin = optarg;
break;
-#ifdef SecurID
- case 's':
- /* SecurID required */
- require_SecurID = 1;
- break;
-#endif /* SecurID */
case 'S':
#ifdef HAS_GETTOS
if ((tos = parsetos(optarg, "tcp")) < 0)
@@ -308,9 +278,7 @@ main(argc, argv)
break;
case 'u':
- utmp_len = atoi(optarg);
- if (utmp_len < 0)
- utmp_len = -utmp_len;
+ utmp_len = (size_t)atoi(optarg);
if (utmp_len >= sizeof(remote_hostname))
utmp_len = sizeof(remote_hostname) - 1;
break;
@@ -352,7 +320,7 @@ main(argc, argv)
if (debug) {
int s, ns, foo, error;
- char *service = "telnet";
+ const char *service = "telnet";
struct addrinfo hints, *res;
if (argc > 1) {
@@ -460,9 +428,6 @@ usage()
#endif
fprintf(stderr, " [-n]");
fprintf(stderr, "\n\t");
-#ifdef SecurID
- fprintf(stderr, " [-s]");
-#endif
#ifdef HAS_GETTOS
fprintf(stderr, " [-S tos]");
#endif
@@ -484,15 +449,20 @@ static unsigned char ttytype_sbbuf[] = {
IAC, SB, TELOPT_TTYPE, TELQUAL_SEND, IAC, SE
};
- int
-getterminaltype(name)
- char *name;
+
+#ifndef AUTHENTICATION
+#define undef2 __unused
+#else
+#define undef2
+#endif
+
+static int
+getterminaltype(char *name undef2)
{
int retval = -1;
- void _gettermname();
settimer(baseline);
-#if defined(AUTHENTICATION)
+#ifdef AUTHENTICATION
/*
* Handle the Authentication option before we do anything else.
*/
@@ -630,8 +600,8 @@ getterminaltype(name)
return(retval);
} /* end of getterminaltype */
- void
-_gettermname()
+static void
+_gettermname(void)
{
/*
* If the client turned off the option,
@@ -648,9 +618,8 @@ _gettermname()
ttloop();
}
- int
-terminaltypeok(s)
- char *s;
+int
+terminaltypeok(char *s)
{
char buf[1024];
@@ -669,25 +638,13 @@ terminaltypeok(s)
return(1);
}
-#ifndef MAXHOSTNAMELEN
-#define MAXHOSTNAMELEN 256
-#endif /* MAXHOSTNAMELEN */
-
-char *hostname;
-char host_name[MAXHOSTNAMELEN];
-
-extern void telnet P((int, int, char *));
-
-int level;
-char user_name[256];
/*
* Get a pty, scan input lines.
*/
- void
-doit(who)
- struct sockaddr *who;
+void
+doit(struct sockaddr *who)
{
- int err;
+ int err_; /* XXX */
int ptynum;
/*
@@ -721,18 +678,24 @@ doit(who)
trimdomain(remote_hostname, UT_HOSTSIZE);
if (!isdigit(remote_hostname[0]) && strlen(remote_hostname) > utmp_len)
- err = getnameinfo(who, who->sa_len, remote_hostname,
+ err_ = getnameinfo(who, who->sa_len, remote_hostname,
sizeof(remote_hostname), NULL, 0,
NI_NUMERICHOST|NI_WITHSCOPEID);
- /* XXX: do 'err' check */
+ /* XXX: do 'err_' check */
(void) gethostname(host_name, sizeof(host_name) - 1);
host_name[sizeof(host_name) - 1] = '\0';
hostname = host_name;
-#if defined(AUTHENTICATION) || defined(ENCRYPTION)
+#ifdef AUTHENTICATION
+#ifdef ENCRYPTION
+/* The above #ifdefs should actually be "or"'ed, not "and"'ed.
+ * This is a byproduct of needing "#ifdef" and not "#if defined()"
+ * for unifdef. XXX MarkM
+ */
auth_encrypt_init(hostname, remote_hostname, "TELNETD", 1);
#endif
+#endif
init_env();
/*
@@ -751,10 +714,8 @@ doit(who)
* Main loop. Select from pty and network, and
* hand data to telnet receiver finite state machine.
*/
- void
-telnet(f, p, host)
- int f, p;
- char *host;
+void
+telnet(int f, int p, char *host)
{
int on = 1;
#define TABBUFSIZ 512
@@ -861,12 +822,10 @@ telnet(f, p, host)
if (my_state_is_wont(TELOPT_ECHO))
send_will(TELOPT_ECHO, 1);
-#ifndef STREAMSPTY
/*
* Turn on packet mode
*/
(void) ioctl(p, TIOCPKT, (char *)&on);
-#endif
#if defined(LINEMODE) && defined(KLUDGELINEMODE)
/*
@@ -908,7 +867,7 @@ telnet(f, p, host)
#ifdef TIOCNOTTY
{
- register int t;
+ int t;
t = open(_PATH_TTY, O_RDWR);
if (t >= 0) {
(void) ioctl(t, TIOCNOTTY, (char *)0);
@@ -926,7 +885,6 @@ telnet(f, p, host)
*/
if (getent(defent, "default") == 1) {
- char *Getstr();
char *cp=defstrs;
HE = Getstr("he", &cp);
@@ -935,9 +893,9 @@ telnet(f, p, host)
if (HN && *HN)
(void) strlcpy(host_name, HN, sizeof(host_name));
if (IM == 0)
- IM = "";
+ IM = strdup("");
} else {
- IM = DEFAULT_IM;
+ IM = strdup(DEFAULT_IM);
HE = 0;
}
edithost(HE, host_name);
@@ -968,7 +926,7 @@ telnet(f, p, host)
nfd = ((f > p) ? f : p) + 1;
for (;;) {
fd_set ibits, obits, xbits;
- register int c;
+ int c;
if (ncc < 0 && pcc < 0)
break;
@@ -1089,11 +1047,7 @@ telnet(f, p, host)
* Something to read from the pty...
*/
if (FD_ISSET(p, &ibits)) {
-#ifndef STREAMSPTY
pcc = read(p, ptyibuf, BUFSIZ);
-#else
- pcc = readstream(p, ptyibuf, BUFSIZ);
-#endif
/*
* On some systems, if we try to read something
* off the master side before the slave side is
@@ -1188,114 +1142,16 @@ telnet(f, p, host)
# endif
#endif
-#ifdef STREAMSPTY
-
-int flowison = -1; /* current state of flow: -1 is unknown */
-
-int readstream(p, ibuf, bufsize)
- int p;
- char *ibuf;
- int bufsize;
-{
- int flags = 0;
- int ret = 0;
- struct termios *tsp;
- struct termio *tp;
- struct iocblk *ip;
- char vstop, vstart;
- int ixon;
- int newflow;
-
- strbufc.maxlen = BUFSIZ;
- strbufc.buf = (char *)ctlbuf;
- strbufd.maxlen = bufsize-1;
- strbufd.len = 0;
- strbufd.buf = ibuf+1;
- ibuf[0] = 0;
-
- ret = getmsg(p, &strbufc, &strbufd, &flags);
- if (ret < 0) /* error of some sort -- probably EAGAIN */
- return(-1);
-
- if (strbufc.len <= 0 || ctlbuf[0] == M_DATA) {
- /* data message */
- if (strbufd.len > 0) { /* real data */
- return(strbufd.len + 1); /* count header char */
- } else {
- /* nothing there */
- errno = EAGAIN;
- return(-1);
- }
- }
-
- /*
- * It's a control message. Return 1, to look at the flag we set
- */
-
- switch (ctlbuf[0]) {
- case M_FLUSH:
- if (ibuf[1] & FLUSHW)
- ibuf[0] = TIOCPKT_FLUSHWRITE;
- return(1);
-
- case M_IOCTL:
- ip = (struct iocblk *) (ibuf+1);
-
- switch (ip->ioc_cmd) {
- case TCSETS:
- case TCSETSW:
- case TCSETSF:
- tsp = (struct termios *)
- (ibuf+1 + sizeof(struct iocblk));
- vstop = tsp->c_cc[VSTOP];
- vstart = tsp->c_cc[VSTART];
- ixon = tsp->c_iflag & IXON;
- break;
- case TCSETA:
- case TCSETAW:
- case TCSETAF:
- tp = (struct termio *) (ibuf+1 + sizeof(struct iocblk));
- vstop = tp->c_cc[VSTOP];
- vstart = tp->c_cc[VSTART];
- ixon = tp->c_iflag & IXON;
- break;
- default:
- errno = EAGAIN;
- return(-1);
- }
-
- newflow = (ixon && (vstart == 021) && (vstop == 023)) ? 1 : 0;
- if (newflow != flowison) { /* it's a change */
- flowison = newflow;
- ibuf[0] = newflow ? TIOCPKT_DOSTOP : TIOCPKT_NOSTOP;
- return(1);
- }
- }
-
- /* nothing worth doing anything about */
- errno = EAGAIN;
- return(-1);
-}
-#endif /* STREAMSPTY */
-
/*
* Send interrupt to process on other side of pty.
* If it is in raw mode, just write NULL;
* otherwise, write intr char.
*/
- void
-interrupt()
+void
+interrupt(void)
{
ptyflush(); /* half-hearted */
-#if defined(STREAMSPTY) && defined(TIOCSIGNAL)
- /* Streams PTY style ioctl to post a signal */
- {
- int sig = SIGINT;
- (void) ioctl(pty, TIOCSIGNAL, &sig);
- (void) ioctl(pty, I_FLUSH, FLUSHR);
- }
-#else
#ifdef TCSIG
(void) ioctl(pty, TCSIG, (char *)SIGINT);
#else /* TCSIG */
@@ -1303,7 +1159,6 @@ interrupt()
*pfrontp++ = slctab[SLC_IP].sptr ?
(unsigned char)*slctab[SLC_IP].sptr : '\177';
#endif /* TCSIG */
-#endif
}
/*
@@ -1311,8 +1166,8 @@ interrupt()
* If it is in raw mode, just write NULL;
* otherwise, write quit char.
*/
- void
-sendbrk()
+void
+sendbrk(void)
{
ptyflush(); /* half-hearted */
#ifdef TCSIG
@@ -1324,8 +1179,8 @@ sendbrk()
#endif /* TCSIG */
}
- void
-sendsusp()
+void
+sendsusp(void)
{
#ifdef SIGTSTP
ptyflush(); /* half-hearted */
@@ -1342,8 +1197,8 @@ sendsusp()
* When we get an AYT, if ^T is enabled, use that. Otherwise,
* just send back "[Yes]".
*/
- void
-recv_ayt()
+void
+recv_ayt(void)
{
#if defined(SIGINFO) && defined(TCSIG)
if (slctab[SLC_AYT].sptr && *slctab[SLC_AYT].sptr != _POSIX_VDISABLE) {
@@ -1354,8 +1209,8 @@ recv_ayt()
output_data("\r\n[Yes]\r\n");
}
- void
-doeof()
+void
+doeof(void)
{
init_termbuf();
diff --git a/contrib/telnet/telnetd/telnetd.h b/contrib/telnet/telnetd/telnetd.h
index 234b973..5bfc572 100644
--- a/contrib/telnet/telnetd/telnetd.h
+++ b/contrib/telnet/telnetd/telnetd.h
@@ -31,6 +31,7 @@
* SUCH DAMAGE.
*
* @(#)telnetd.h 8.1 (Berkeley) 6/4/93
+ * $FreeBSD$
*/
@@ -45,5 +46,4 @@
/* other external variables */
extern char **environ;
-extern int errno;
-
+extern const char *altlogin;
diff --git a/contrib/telnet/telnetd/termstat.c b/contrib/telnet/telnetd/termstat.c
index ebfc745..c7dc845 100644
--- a/contrib/telnet/telnetd/termstat.c
+++ b/contrib/telnet/telnetd/termstat.c
@@ -31,17 +31,17 @@
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
+
+__FBSDID("$FreeBSD$");
+
#ifndef lint
-#if 0
static const char sccsid[] = "@(#)termstat.c 8.2 (Berkeley) 5/30/95";
#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
#include "telnetd.h"
-#if defined(ENCRYPTION)
+#ifdef ENCRYPTION
#include <libtelnet/encrypt.h>
#endif
@@ -133,8 +133,8 @@ static int _terminit = 0;
* then linemode is off, if server won't SGA, then linemode
* is on.
*/
- void
-localstat()
+void
+localstat(void)
{
int need_will_echo = 0;
@@ -357,8 +357,8 @@ done:
*
* Check for changes to flow control
*/
- void
-flowstat()
+void
+flowstat(void)
{
if (his_state_is_will(TELOPT_LFLOW)) {
if (tty_flowmode() != flowmode) {
@@ -387,9 +387,8 @@ flowstat()
* at a time, and if using kludge linemode, then only linemode may be
* affected.
*/
- void
-clientstat(code, parm1, parm2)
- register int code, parm1, parm2;
+void
+clientstat(int code, int parm1, int parm2)
{
/*
@@ -464,7 +463,7 @@ clientstat(code, parm1, parm2)
case LM_MODE:
{
- register int ack, changed;
+ int ack, changed;
/*
* Client has sent along a mode mask. If it agrees with
@@ -589,8 +588,8 @@ clientstat(code, parm1, parm2)
* function is called when the pty state has been processed for the first time.
* It calls other functions that do things that were deferred in each module.
*/
- void
-defer_terminit()
+void
+defer_terminit(void)
{
/*
@@ -624,8 +623,8 @@ defer_terminit()
*
* Returns true if the pty state has been processed yet.
*/
- int
-terminit()
+int
+terminit(void)
{
return(_terminit);
diff --git a/contrib/telnet/telnetd/utility.c b/contrib/telnet/telnetd/utility.c
index f9b4e46..4bbbfb8 100644
--- a/contrib/telnet/telnetd/utility.c
+++ b/contrib/telnet/telnetd/utility.c
@@ -47,10 +47,10 @@ static const char rcsid[] =
#define PRINTOPTIONS
#include "telnetd.h"
-#if defined(AUTHENTICATION)
+#ifdef AUTHENTICATION
#include <libtelnet/auth.h>
#endif
-#if defined(ENCRYPTION)
+#ifdef ENCRYPTION
#include <libtelnet/encrypt.h>
#endif
@@ -95,11 +95,10 @@ ttloop()
/*
* Check a descriptor to see if out of band data exists on it.
*/
- int
-stilloob(s)
- int s; /* socket number */
+int
+stilloob(int s)
{
- static struct timeval timeout = { 0 };
+ static struct timeval timeout = { 0, 0 };
fd_set excepts;
int value;
@@ -120,8 +119,8 @@ stilloob(s)
}
}
- void
-ptyflush()
+void
+ptyflush(void)
{
int n;
@@ -151,9 +150,8 @@ ptyflush()
* if the current address is a TELNET IAC ("I Am a Command")
* character.
*/
- char *
-nextitem(current)
- char *current;
+static char *
+nextitem(char *current)
{
if ((*current&0xff) != IAC) {
return current+1;
@@ -166,7 +164,7 @@ nextitem(current)
return current+3;
case SB: /* loop forever looking for the SE */
{
- register char *look = current+2;
+ char *look = current+2;
for (;;) {
if ((*look++&0xff) == IAC) {
@@ -181,7 +179,6 @@ nextitem(current)
}
} /* end of nextitem */
-
/*
* netclear()
*
@@ -198,10 +195,10 @@ nextitem(current)
* caller should be setting the urgent data pointer AFTER calling
* us in any case.
*/
- void
-netclear()
+void
+netclear(void)
{
- register char *thisitem, *next;
+ char *thisitem, *next;
char *good;
#define wewant(p) ((nfrontp > p) && ((*p&0xff) == IAC) && \
((*(p+1)&0xff) != EC) && ((*(p+1)&0xff) != EL))
@@ -251,8 +248,8 @@ netclear()
* Send as much data as possible to the network,
* handling requests for urgent data.
*/
- void
-netflush()
+void
+netflush(void)
{
int n;
extern int not42;
@@ -326,10 +323,8 @@ netflush()
*/
- void
-fatal(f, msg)
- int f;
- char *msg;
+void
+fatal(int f, const char *msg)
{
char buf[BUFSIZ];
@@ -349,12 +344,10 @@ fatal(f, msg)
exit(1);
}
- void
-fatalperror(f, msg)
- int f;
- char *msg;
+void
+fatalperror(int f, const char *msg)
{
- char buf[BUFSIZ], *strerror();
+ char buf[BUFSIZ];
(void) snprintf(buf, sizeof(buf), "%s: %s", msg, strerror(errno));
fatal(f, buf);
@@ -362,15 +355,13 @@ fatalperror(f, msg)
char editedhost[32];
- void
-edithost(pat, host)
- register char *pat;
- register char *host;
+void
+edithost(char *pat, char *host)
{
- register char *res = editedhost;
+ char *res = editedhost;
if (!pat)
- pat = "";
+ pat = strdup("");
while (*pat) {
switch (*pat) {
@@ -404,18 +395,16 @@ edithost(pat, host)
static char *putlocation;
- void
-putstr(s)
- register char *s;
+static void
+putstr(const char *s)
{
while (*s)
putchr(*s++);
}
- void
-putchr(cc)
- int cc;
+void
+putchr(int cc)
{
*putlocation++ = cc;
}
@@ -423,18 +412,11 @@ putchr(cc)
#ifdef __FreeBSD__
static char fmtstr[] = { "%+" };
#else
-/*
- * 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\
-%P on %A, %d %B %Y" };
+static char fmtstr[] = { "%l:%M%P on %A, %d %B %Y" };
#endif
- void
-putf(cp, where)
- register char *cp;
- char *where;
+void
+putf(char *cp, char *where)
{
char *slash;
time_t t;
@@ -515,10 +497,8 @@ putf(cp, where)
/*
* Print telnet options and commands in plain text, if possible.
*/
- void
-printoption(fmt, option)
- register char *fmt;
- register int option;
+void
+printoption(const char *fmt, int option)
{
if (TELOPT_OK(option))
output_data("%s %s\r\n", fmt, TELOPT(option));
@@ -529,13 +509,10 @@ printoption(fmt, option)
return;
}
- void
-printsub(direction, pointer, length)
- char direction; /* '<' or '>' */
- unsigned char *pointer; /* where suboption data sits */
- int length; /* length of suboption data */
+void
+printsub(char direction, unsigned char *pointer, int length)
{
- register int i = 0;
+ int i = 0;
if (!(diagnostic & TD_OPTIONS))
return;
@@ -544,7 +521,7 @@ printsub(direction, pointer, length)
output_data("td: %s suboption ",
direction == '<' ? "recv" : "send");
if (length >= 3) {
- register int j;
+ int j;
i = pointer[length-2];
j = pointer[length-1];
@@ -764,8 +741,8 @@ printsub(direction, pointer, length)
break;
case TELOPT_STATUS: {
- register char *cp;
- register int j, k;
+ const char *cp;
+ int j, k;
output_data("STATUS");
@@ -866,7 +843,7 @@ printsub(direction, pointer, length)
output_data("INFO ");
env_common:
{
- register int noquote = 2;
+ int noquote = 2;
for (i = 2; i < length; i++ ) {
switch (pointer[i]) {
case NEW_ENV_VAR:
@@ -911,7 +888,7 @@ printsub(direction, pointer, length)
}
break;
-#if defined(AUTHENTICATION)
+#ifdef AUTHENTICATION
case TELOPT_AUTHENTICATION:
output_data("AUTHENTICATION");
@@ -1070,13 +1047,10 @@ printsub(direction, pointer, length)
/*
* Dump a data buffer in hex and ascii to the output data stream.
*/
- void
-printdata(tag, ptr, cnt)
- register char *tag;
- register char *ptr;
- register int cnt;
+void
+printdata(const char *tag, char *ptr, int cnt)
{
- register int i;
+ int i;
char xbuf[30];
while (cnt) {
OpenPOWER on IntegriCloud