From cd2a6be22c3f5c010eb7ec63c77cd0699a832567 Mon Sep 17 00:00:00 2001 From: markm Date: Sun, 7 Sep 1997 07:02:53 +0000 Subject: Bring the FreeBSD changes to the virgin sources. --- contrib/telnet/arpa/telnet.h | 42 +++++++--- contrib/telnet/libtelnet/auth-proto.h | 4 + contrib/telnet/libtelnet/auth.c | 11 ++- contrib/telnet/libtelnet/enc-proto.h | 17 ++-- contrib/telnet/libtelnet/enc_des.c | 30 +++---- contrib/telnet/libtelnet/encrypt.c | 36 ++++++--- contrib/telnet/libtelnet/encrypt.h | 2 +- contrib/telnet/libtelnet/genget.c | 7 +- contrib/telnet/libtelnet/kerberos.c | 48 +++++------ contrib/telnet/libtelnet/krb4encpwd.c | 1 - contrib/telnet/libtelnet/misc.c | 6 +- contrib/telnet/libtelnet/spx.c | 1 - contrib/telnet/telnet/authenc.c | 4 +- contrib/telnet/telnet/commands.c | 145 +++++++++++++++++++++++----------- contrib/telnet/telnet/externs.h | 13 ++- contrib/telnet/telnet/main.c | 23 +++++- contrib/telnet/telnet/network.c | 3 +- contrib/telnet/telnet/ring.c | 4 +- contrib/telnet/telnet/sys_bsd.c | 7 +- contrib/telnet/telnet/telnet.c | 32 +++++--- contrib/telnet/telnet/terminal.c | 6 +- contrib/telnet/telnet/tn3270.c | 2 +- contrib/telnet/telnet/utilities.c | 13 ++- contrib/telnet/telnetd/authenc.c | 2 +- contrib/telnet/telnetd/ext.h | 6 +- contrib/telnet/telnetd/global.c | 2 +- contrib/telnet/telnetd/slc.c | 40 +++++----- contrib/telnet/telnetd/state.c | 5 +- contrib/telnet/telnetd/sys_term.c | 64 ++++++++++----- contrib/telnet/telnetd/telnetd.8 | 10 ++- contrib/telnet/telnetd/telnetd.c | 75 +++++++++--------- contrib/telnet/telnetd/termstat.c | 53 ++++++++----- contrib/telnet/telnetd/utility.c | 25 +++++- 33 files changed, 472 insertions(+), 267 deletions(-) (limited to 'contrib') diff --git a/contrib/telnet/arpa/telnet.h b/contrib/telnet/arpa/telnet.h index 10155a8..01601f1 100644 --- a/contrib/telnet/arpa/telnet.h +++ b/contrib/telnet/arpa/telnet.h @@ -33,8 +33,8 @@ * @(#)telnet.h 8.2 (Berkeley) 12/15/93 */ -#ifndef _TELNET_H_ -#define _TELNET_H_ +#ifndef _ARPA_TELNET_H_ +#define _ARPA_TELNET_H_ /* * Definitions for the TELNET protocol. @@ -66,7 +66,8 @@ char *telcmds[] = { "EOF", "SUSP", "ABORT", "EOR", "SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC", - "EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC", 0, + "EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC", + 0 }; #else extern char *telcmds[]; @@ -135,7 +136,7 @@ char *telopts[NTELOPTS+1] = { "3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW", "LINEMODE", "XDISPLOC", "OLD-ENVIRON", "AUTHENTICATION", "ENCRYPT", "NEW-ENVIRON", - 0, + 0 }; #define TELOPT_FIRST TELOPT_BINARY #define TELOPT_LAST TELOPT_NEW_ENVIRON @@ -196,8 +197,20 @@ char *telopts[NTELOPTS+1] = { #define SLC_XOFF 16 #define SLC_FORW1 17 #define SLC_FORW2 18 - -#define NSLC 18 +#define SLC_MCL 19 +#define SLC_MCR 20 +#define SLC_MCWL 21 +#define SLC_MCWR 22 +#define SLC_MCBOL 23 +#define SLC_MCEOL 24 +#define SLC_INSRT 25 +#define SLC_OVER 26 +#define SLC_ECR 27 +#define SLC_EWR 28 +#define SLC_EBOL 29 +#define SLC_EEOL 30 + +#define NSLC 30 /* * For backwards compatability, we define SLC_NAMES to be the @@ -205,7 +218,12 @@ char *telopts[NTELOPTS+1] = { */ #define SLC_NAMELIST "0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR", \ "ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP", \ - "LNEXT", "XON", "XOFF", "FORW1", "FORW2", 0, + "LNEXT", "XON", "XOFF", "FORW1", "FORW2", \ + "MCL", "MCR", "MCWL", "MCWR", "MCBOL", \ + "MCEOL", "INSRT", "OVER", "ECR", "EWR", \ + "EBOL", "EEOL", \ + 0 + #ifdef SLC_NAMES char *slc_names[] = { SLC_NAMELIST @@ -268,7 +286,8 @@ extern char *slc_names[]; #ifdef AUTH_NAMES char *authtype_names[] = { - "NULL", "KERBEROS_V4", "KERBEROS_V5", "SPX", "MINK", 0, + "NULL", "KERBEROS_V4", "KERBEROS_V5", "SPX", "MINK", + 0 }; #else extern char *authtype_names[]; @@ -286,7 +305,7 @@ extern char *authtype_names[]; #define ENCRYPT_START 3 /* Am starting to send encrypted */ #define ENCRYPT_END 4 /* Am ending encrypted */ #define ENCRYPT_REQSTART 5 /* Request you start encrypting */ -#define ENCRYPT_REQEND 6 /* Request you send encrypting */ +#define ENCRYPT_REQEND 6 /* Request you end encrypting */ #define ENCRYPT_ENC_KEYID 7 #define ENCRYPT_DEC_KEYID 8 #define ENCRYPT_CNT 9 @@ -300,10 +319,11 @@ extern char *authtype_names[]; char *encrypt_names[] = { "IS", "SUPPORT", "REPLY", "START", "END", "REQUEST-START", "REQUEST-END", "ENC-KEYID", "DEC-KEYID", - 0, + 0 }; char *enctype_names[] = { - "ANY", "DES_CFB64", "DES_OFB64", 0, + "ANY", "DES_CFB64", "DES_OFB64", + 0 }; #else extern char *encrypt_names[]; diff --git a/contrib/telnet/libtelnet/auth-proto.h b/contrib/telnet/libtelnet/auth-proto.h index 06bba2b..a1e9aa4 100644 --- a/contrib/telnet/libtelnet/auth-proto.h +++ b/contrib/telnet/libtelnet/auth-proto.h @@ -75,6 +75,10 @@ void auth_finished P((Authenticator *, int)); int auth_wait P((char *)); void auth_disable_name P((char *)); void auth_gen_printsub P((unsigned char *, int, unsigned char *, int)); +void auth_name P((unsigned char *, int)); +void auth_printsub P((unsigned char *, int, unsigned char *, int)); +int auth_sendname P((unsigned char *, int)); +void auth_encrypt_user P((char *)); #ifdef KRB4 int kerberos4_init P((Authenticator *, int)); diff --git a/contrib/telnet/libtelnet/auth.c b/contrib/telnet/libtelnet/auth.c index a8b287c..4262b55 100644 --- a/contrib/telnet/libtelnet/auth.c +++ b/contrib/telnet/libtelnet/auth.c @@ -32,7 +32,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)auth.c 8.3 (Berkeley) 5/30/95"; +static const char sccsid[] = "@(#)auth.c 8.3 (Berkeley) 5/30/95"; #endif /* not lint */ /* @@ -64,6 +64,7 @@ static char sccsid[] = "@(#)auth.c 8.3 (Berkeley) 5/30/95"; #include #ifdef __STDC__ #include +#include #endif #ifdef NO_STRING_H #include @@ -106,6 +107,9 @@ static unsigned char _auth_send_data[256]; static unsigned char *auth_send_data; static int auth_send_cnt = 0; +int auth_onoff(char *type, int on); +void auth_encrypt_user(char *name); + /* * Authentication types supported. Plese note that these are stored * in priority order, i.e. try the first one first. @@ -500,7 +504,7 @@ auth_is(data, cnt) return; } - if (ap = findauthenticator(data[0], data[1])) { + if ((ap = findauthenticator(data[0], data[1]))) { if (ap->is) (*ap->is)(ap, data+2, cnt-2); } else if (auth_debug_mode) @@ -518,7 +522,7 @@ auth_reply(data, cnt) if (cnt < 2) return; - if (ap = findauthenticator(data[0], data[1])) { + if ((ap = findauthenticator(data[0], data[1]))) { if (ap->reply) (*ap->reply)(ap, data+2, cnt-2); } else if (auth_debug_mode) @@ -531,7 +535,6 @@ auth_name(data, cnt) unsigned char *data; int cnt; { - Authenticator *ap; unsigned char savename[256]; if (cnt < 1) { diff --git a/contrib/telnet/libtelnet/enc-proto.h b/contrib/telnet/libtelnet/enc-proto.h index 2e30908..8e15ffd 100644 --- a/contrib/telnet/libtelnet/enc-proto.h +++ b/contrib/telnet/libtelnet/enc-proto.h @@ -79,11 +79,17 @@ void encrypt_send_end P((void)); void encrypt_wait P((void)); void encrypt_send_support P((void)); void encrypt_send_keyid P((int, unsigned char *, int, int)); +void encrypt_start P((unsigned char *, int)); +void encrypt_end P((void)); +void encrypt_support P((unsigned char *, int)); +void encrypt_request_start P((unsigned char *, int)); +void encrypt_request_end P((void)); +void encrypt_enc_keyid P((unsigned char *, int)); +void encrypt_dec_keyid P((unsigned char *, int)); +void encrypt_printsub P((unsigned char *, int, unsigned char *, int)); int net_write P((unsigned char *, int)); -#ifdef TELENTD -void encrypt_wait P((void)); -#else +#ifndef TELENTD int encrypt_cmd P((int, char **)); void encrypt_display P((void)); #endif @@ -117,9 +123,4 @@ void ofb64_session P((Session_Key *, int)); int ofb64_keyid P((int, unsigned char *, int *)); void ofb64_printsub P((unsigned char *, int, unsigned char *, int)); -int des_new_random_key P((Block)); -void des_set_random_generator_seed P((Block)); -void des_key_sched P((Block, Schedule)); -void des_ecb_encrypt P((Block, Block, Schedule, int)); -int des_string_to_key P((char *, Block)); #endif /* ENCRYPTION */ diff --git a/contrib/telnet/libtelnet/enc_des.c b/contrib/telnet/libtelnet/enc_des.c index d6886fd..8e4b9a7 100644 --- a/contrib/telnet/libtelnet/enc_des.c +++ b/contrib/telnet/libtelnet/enc_des.c @@ -32,7 +32,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)enc_des.c 8.3 (Berkeley) 5/30/95"; +static const char sccsid[] = "@(#)enc_des.c 8.3 (Berkeley) 5/30/95"; #endif /* not lint */ #ifdef ENCRYPTION @@ -44,6 +44,8 @@ static char sccsid[] = "@(#)enc_des.c 8.3 (Berkeley) 5/30/95"; #include #endif +#include +#include #include "encrypt.h" #include "key-proto.h" #include "misc-proto.h" @@ -180,7 +182,6 @@ fb64_start(fbp, dir, server) int dir; int server; { - Block b; int x; unsigned char *p; register int state; @@ -215,8 +216,8 @@ fb64_start(fbp, dir, server) /* * Create a random feed and send it over. */ - des_new_random_key(fbp->temp_feed); - des_ecb_encrypt(fbp->temp_feed, fbp->temp_feed, + des_new_random_key((Block *)fbp->temp_feed); + des_ecb_encrypt((Block *)fbp->temp_feed, (Block *)fbp->temp_feed, fbp->krbdes_sched, 1); p = fbp->fb_feed + 3; *p++ = ENCRYPT_IS; @@ -264,9 +265,7 @@ fb64_is(data, cnt, fbp) int cnt; struct fb *fbp; { - int x; unsigned char *p; - Block b; register int state = fbp->state[DIR_DECRYPT-1]; if (cnt-- < 1) @@ -356,9 +355,6 @@ fb64_reply(data, cnt, fbp) int cnt; struct fb *fbp; { - int x; - unsigned char *p; - Block b; register int state = fbp->state[DIR_ENCRYPT-1]; if (cnt-- < 1) @@ -428,10 +424,10 @@ fb64_session(key, server, fbp) fb64_stream_key(fbp->krbdes_key, &fbp->streams[DIR_DECRYPT-1]); if (fbp->once == 0) { - des_set_random_generator_seed(fbp->krbdes_key); + des_set_random_generator_seed((Block *)fbp->krbdes_key); fbp->once = 1; } - des_key_sched(fbp->krbdes_key, fbp->krbdes_sched); + des_key_sched((Block *)fbp->krbdes_key, fbp->krbdes_sched); /* * Now look to see if krbdes_start() was was waiting for * the key to show up. If so, go ahead an call it now @@ -552,7 +548,7 @@ fb64_stream_iv(seed, stp) memmove((void *)stp->str_iv, (void *)seed, sizeof(Block)); memmove((void *)stp->str_output, (void *)seed, sizeof(Block)); - des_key_sched(stp->str_ikey, stp->str_sched); + des_key_sched((Block *)stp->str_ikey, stp->str_sched); stp->str_index = sizeof(Block); } @@ -563,7 +559,7 @@ fb64_stream_key(key, stp) register struct stinfo *stp; { memmove((void *)stp->str_ikey, (void *)key, sizeof(Block)); - des_key_sched(key, stp->str_sched); + des_key_sched((Block *)key, stp->str_sched); memmove((void *)stp->str_output, (void *)stp->str_iv, sizeof(Block)); @@ -604,7 +600,7 @@ cfb64_encrypt(s, c) while (c-- > 0) { if (index == sizeof(Block)) { Block b; - des_ecb_encrypt(stp->str_output, b, stp->str_sched, 1); + des_ecb_encrypt((Block *)stp->str_output, (Block *)b, stp->str_sched, 1); memmove((void *)stp->str_feed, (void *)b, sizeof(Block)); index = 0; } @@ -638,7 +634,7 @@ cfb64_decrypt(data) index = stp->str_index++; if (index == sizeof(Block)) { Block b; - des_ecb_encrypt(stp->str_output, b, stp->str_sched, 1); + des_ecb_encrypt((Block *)stp->str_output, (Block *)b, stp->str_sched, 1); memmove((void *)stp->str_feed, (void *)b, sizeof(Block)); stp->str_index = 1; /* Next time will be 1 */ index = 0; /* But now use 0 */ @@ -680,7 +676,7 @@ ofb64_encrypt(s, c) while (c-- > 0) { if (index == sizeof(Block)) { Block b; - des_ecb_encrypt(stp->str_feed, b, stp->str_sched, 1); + des_ecb_encrypt((Block *)stp->str_feed, (Block *)b, stp->str_sched, 1); memmove((void *)stp->str_feed, (void *)b, sizeof(Block)); index = 0; } @@ -711,7 +707,7 @@ ofb64_decrypt(data) index = stp->str_index++; if (index == sizeof(Block)) { Block b; - des_ecb_encrypt(stp->str_feed, b, stp->str_sched, 1); + des_ecb_encrypt((Block *)stp->str_feed, (Block *)b, stp->str_sched, 1); memmove((void *)stp->str_feed, (void *)b, sizeof(Block)); stp->str_index = 1; /* Next time will be 1 */ index = 0; /* But now use 0 */ diff --git a/contrib/telnet/libtelnet/encrypt.c b/contrib/telnet/libtelnet/encrypt.c index 432df0c..41dd5cc 100644 --- a/contrib/telnet/libtelnet/encrypt.c +++ b/contrib/telnet/libtelnet/encrypt.c @@ -32,7 +32,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)encrypt.c 8.2 (Berkeley) 5/30/95"; +static const char sccsid[] = "@(#)encrypt.c 8.2 (Berkeley) 5/30/95"; #endif /* not lint */ /* @@ -58,6 +58,7 @@ static char sccsid[] = "@(#)encrypt.c 8.2 (Berkeley) 5/30/95"; #ifdef ENCRYPTION #define ENCRYPT_NAMES +#include #include #include "encrypt.h" @@ -79,6 +80,18 @@ static char sccsid[] = "@(#)encrypt.c 8.2 (Berkeley) 5/30/95"; void (*encrypt_output) P((unsigned char *, int)); int (*decrypt_input) P((int)); +int EncryptType(char *type, char *mode); +int EncryptStart(char *mode); +int EncryptStop(char *mode); +int EncryptStartInput(void); +int EncryptStartOutput(void); +int EncryptStopInput(void); +int EncryptStopOutput(void); + +int Ambiguous(char **s); +int isprefix(char *s1, char *s2); +char **genget(char *name, char **table, int stlen); + int encrypt_debug_mode = 0; static int decrypt_mode = 0; static int encrypt_mode = 0; @@ -174,6 +187,8 @@ static struct key_info { { { 0 }, 0, DIR_DECRYPT, &decrypt_mode, finddecryption }, }; +static void encrypt_keyid(struct key_info *kp, unsigned char *keyid, int len); + void encrypt_init(name, server) char *name; @@ -248,10 +263,10 @@ EncryptDisable(type, mode) if (isprefix(type, "help") || isprefix(type, "?")) { printf("Usage: encrypt disable [input|output]\n"); encrypt_list_types(); - } else if ((ep = (Encryptions *)genget(type, encryptions, + } else if ((ep = (Encryptions *)genget(type, (char **)encryptions, sizeof(Encryptions))) == 0) { printf("%s: invalid encryption type\n", type); - } else if (Ambiguous(ep)) { + } else if (Ambiguous((char **)ep)) { printf("Ambiguous type '%s'\n", type); } else { if ((mode == 0) || (isprefix(mode, "input") ? 1 : 0)) { @@ -283,10 +298,10 @@ EncryptType(type, mode) if (isprefix(type, "help") || isprefix(type, "?")) { printf("Usage: encrypt type [input|output]\n"); encrypt_list_types(); - } else if ((ep = (Encryptions *)genget(type, encryptions, + } else if ((ep = (Encryptions *)genget(type, (char **)encryptions, sizeof(Encryptions))) == 0) { printf("%s: invalid encryption type\n", type); - } else if (Ambiguous(ep)) { + } else if (Ambiguous((char **)ep)) { printf("Ambiguous type '%s'\n", type); } else { if ((mode == 0) || isprefix(mode, "input")) { @@ -559,7 +574,7 @@ encrypt_is(data, cnt) } else { ret = (*ep->is)(data, cnt); if (encrypt_debug_mode) - printf("(*ep->is)(%x, %d) returned %s(%d)\n", data, cnt, + printf("(*ep->is)(%p, %d) returned %s(%d)\n", data, cnt, (ret < 0) ? "FAIL " : (ret == 0) ? "SUCCESS " : "MORE_TO_DO ", ret); } @@ -603,7 +618,7 @@ encrypt_reply(data, cnt) } else { ret = (*ep->reply)(data, cnt); if (encrypt_debug_mode) - printf("(*ep->reply)(%x, %d) returned %s(%d)\n", + printf("(*ep->reply)(%p, %d) returned %s(%d)\n", data, cnt, (ret < 0) ? "FAIL " : (ret == 0) ? "SUCCESS " : "MORE_TO_DO ", ret); @@ -641,7 +656,7 @@ encrypt_start(data, cnt) return; } - if (ep = finddecryption(decrypt_mode)) { + if ((ep = finddecryption(decrypt_mode))) { decrypt_input = ep->input; if (encrypt_verbose) printf("[ Input is now decrypted with type %s ]\r\n", @@ -725,6 +740,7 @@ encrypt_request_start(data, cnt) static unsigned char str_keyid[(MAXKEYLEN*2)+5] = { IAC, SB, TELOPT_ENCRYPT }; + void encrypt_enc_keyid(keyid, len) unsigned char *keyid; int len; @@ -732,6 +748,7 @@ encrypt_enc_keyid(keyid, len) encrypt_keyid(&ki[1], keyid, len); } + void encrypt_dec_keyid(keyid, len) unsigned char *keyid; int len; @@ -739,13 +756,13 @@ encrypt_dec_keyid(keyid, len) encrypt_keyid(&ki[0], keyid, len); } + void encrypt_keyid(kp, keyid, len) struct key_info *kp; unsigned char *keyid; int len; { Encryptions *ep; - unsigned char *strp, *cp; int dir = kp->dir; register int ret = 0; @@ -942,7 +959,6 @@ encrypt_send_request_end() void encrypt_wait() { - register int encrypt, decrypt; if (encrypt_debug_mode) printf(">>>%s: in encrypt_wait\r\n", Name); if (!havesessionkey || !(I_SUPPORT_ENCRYPT & remote_supports_decrypt)) diff --git a/contrib/telnet/libtelnet/encrypt.h b/contrib/telnet/libtelnet/encrypt.h index e0ae385..1c942dc 100644 --- a/contrib/telnet/libtelnet/encrypt.h +++ b/contrib/telnet/libtelnet/encrypt.h @@ -62,7 +62,7 @@ typedef unsigned char Block[8]; typedef unsigned char *BlockT; -typedef struct { Block _; } Schedule[16]; +typedef struct { Block __; } Schedule[16]; #define VALIDKEY(key) ( key[0] | key[1] | key[2] | key[3] | \ key[4] | key[5] | key[6] | key[7]) diff --git a/contrib/telnet/libtelnet/genget.c b/contrib/telnet/libtelnet/genget.c index 7be3846..8668db4 100644 --- a/contrib/telnet/libtelnet/genget.c +++ b/contrib/telnet/libtelnet/genget.c @@ -32,7 +32,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)genget.c 8.2 (Berkeley) 5/30/95"; +static const char sccsid[] = "@(#)genget.c 8.2 (Berkeley) 5/30/95"; #endif /* not lint */ @@ -49,7 +49,6 @@ static char sccsid[] = "@(#)genget.c 8.2 (Berkeley) 5/30/95"; isprefix(s1, s2) register char *s1, *s2; { - register int n = 0; char *os1; register char c1, c2; @@ -99,7 +98,7 @@ genget(name, table, stlen) */ int Ambiguous(s) - char *s; + char **s; { - return((char **)s == &ambiguous); + return(s == &ambiguous); } diff --git a/contrib/telnet/libtelnet/kerberos.c b/contrib/telnet/libtelnet/kerberos.c index dbf4956..738a57f 100644 --- a/contrib/telnet/libtelnet/kerberos.c +++ b/contrib/telnet/libtelnet/kerberos.c @@ -32,7 +32,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)kerberos.c 8.3 (Berkeley) 5/30/95"; +static const char sccsid[] = "@(#)kerberos.c 8.3 (Berkeley) 5/30/95"; #endif /* not lint */ /* @@ -75,19 +75,12 @@ static char sccsid[] = "@(#)kerberos.c 8.3 (Berkeley) 5/30/95"; #include "misc.h" int kerberos4_cksum P((unsigned char *, int)); -int krb_mk_req P((KTEXT, char *, char *, char *, u_long)); -int krb_rd_req P((KTEXT, char *, char *, u_long, AUTH_DAT *, char *)); -int krb_kntoln P((AUTH_DAT *, char *)); -int krb_get_cred P((char *, char *, char *, CREDENTIALS *)); -int krb_get_lrealm P((char *, int)); int kuserok P((AUTH_DAT *, char *)); extern auth_debug_mode; static unsigned char str_data[1024] = { IAC, SB, TELOPT_AUTHENTICATION, 0, AUTHTYPE_KERBEROS_V4, }; -static unsigned char str_name[1024] = { IAC, SB, TELOPT_AUTHENTICATION, - TELQUAL_NAME, }; #define KRB_AUTH 0 /* Authentication data follows */ #define KRB_REJECT 1 /* Rejected (reason might follow) */ @@ -102,7 +95,7 @@ static char name[ANAME_SZ]; static AUTH_DAT adat = { 0 }; #ifdef ENCRYPTION static Block session_key = { 0 }; -static Schedule sched; +static des_key_schedule sched; static Block challenge = { 0 }; #endif /* ENCRYPTION */ @@ -167,9 +160,6 @@ kerberos4_send(ap) Authenticator *ap; { KTEXT_ST auth; -#ifdef ENCRYPTION - Block enckey; -#endif /* ENCRYPTION */ char instance[INST_SZ]; char *realm; char *krb_realmofhost(); @@ -187,7 +177,7 @@ kerberos4_send(ap) memset(instance, 0, sizeof(instance)); - if (realm = krb_get_phost(RemoteHostName)) + if ((realm = krb_get_phost(RemoteHostName))) strncpy(instance, realm, sizeof(instance)); instance[sizeof(instance)-1] = '\0'; @@ -198,11 +188,11 @@ kerberos4_send(ap) printf("Kerberos V4: no realm for %s\r\n", RemoteHostName); return(0); } - if (r = krb_mk_req(&auth, KRB_SERVICE_NAME, instance, realm, 0L)) { + if ((r = krb_mk_req(&auth, KRB_SERVICE_NAME, instance, realm, 0L))) { printf("mk_req failed: %s\r\n", krb_err_txt[r]); return(0); } - if (r = krb_get_cred(KRB_SERVICE_NAME, instance, realm, &cred)) { + if ((r = krb_get_cred(KRB_SERVICE_NAME, instance, realm, &cred))) { printf("get_cred failed: %s\r\n", krb_err_txt[r]); return(0); } @@ -226,11 +216,11 @@ kerberos4_send(ap) if ((ap->way & AUTH_HOW_MASK) == AUTH_HOW_MUTUAL) { register int i; - des_key_sched(cred.session, sched); - des_init_random_number_generator(cred.session); - des_new_random_key(session_key); - des_ecb_encrypt(session_key, session_key, sched, 0); - des_ecb_encrypt(session_key, challenge, sched, 0); + des_key_sched(&cred.session, sched); + des_init_random_number_generator(&cred.session); + des_new_random_key(&session_key); + des_ecb_encrypt(&session_key, &session_key, sched, 0); + des_ecb_encrypt(&session_key, &challenge, sched, 0); /* * Increment the challenge by 1, and encrypt it for * later comparison. @@ -242,7 +232,7 @@ kerberos4_send(ap) if (x < 256) /* if no overflow, all done */ break; } - des_ecb_encrypt(challenge, challenge, sched, 1); + des_ecb_encrypt(&challenge, &challenge, sched, 1); } #endif /* ENCRYPTION */ @@ -288,8 +278,8 @@ kerberos4_is(ap, data, cnt) printf("\r\n"); } instance[0] = '*'; instance[1] = 0; - if (r = krb_rd_req(&auth, KRB_SERVICE_NAME, - instance, 0, &adat, "")) { + if ((r = krb_rd_req(&auth, KRB_SERVICE_NAME, + instance, 0, &adat, ""))) { if (auth_debug_mode) printf("Kerberos failed him as %s\r\n", name); Data(ap, KRB_REJECT, (void *)krb_err_txt[r], -1); @@ -327,15 +317,15 @@ kerberos4_is(ap, data, cnt) * Initialize the random number generator since it's * used later on by the encryption routine. */ - des_init_random_number_generator(session_key); - des_key_sched(session_key, sched); + des_init_random_number_generator(&session_key); + des_key_sched(&session_key, sched); memmove((void *)datablock, (void *)data, sizeof(Block)); /* * Take the received encrypted challenge, and encrypt * it again to get a unique session_key for the * ENCRYPT option. */ - des_ecb_encrypt(datablock, session_key, sched, 1); + des_ecb_encrypt(&datablock, &session_key, sched, 1); skey.type = SK_DES; skey.length = 8; skey.data = session_key; @@ -344,7 +334,7 @@ kerberos4_is(ap, data, cnt) * Now decrypt the received encrypted challenge, * increment by one, re-encrypt it and send it back. */ - des_ecb_encrypt(datablock, challenge, sched, 0); + des_ecb_encrypt(&datablock, &challenge, sched, 0); for (r = 7; r >= 0; r--) { register int t; t = (unsigned int)challenge[r] + 1; @@ -352,7 +342,7 @@ kerberos4_is(ap, data, cnt) if (t < 256) /* if no overflow, all done */ break; } - des_ecb_encrypt(challenge, challenge, sched, 1); + des_ecb_encrypt(&challenge, &challenge, sched, 1); Data(ap, KRB_RESPONSE, (void *)challenge, sizeof(challenge)); #endif /* ENCRYPTION */ break; @@ -397,7 +387,7 @@ kerberos4_reply(ap, data, cnt) #else /* ENCRYPTION */ Data(ap, KRB_CHALLENGE, (void *)session_key, sizeof(session_key)); - des_ecb_encrypt(session_key, session_key, sched, 1); + des_ecb_encrypt(&session_key, &session_key, sched, 1); skey.type = SK_DES; skey.length = 8; skey.data = session_key; diff --git a/contrib/telnet/libtelnet/krb4encpwd.c b/contrib/telnet/libtelnet/krb4encpwd.c index 6148190..cb9523c 100644 --- a/contrib/telnet/libtelnet/krb4encpwd.c +++ b/contrib/telnet/libtelnet/krb4encpwd.c @@ -115,7 +115,6 @@ static AUTH_DAT adat = { 0 }; #ifdef ENCRYPTION static Block session_key = { 0 }; #endif /* ENCRYPTION */ -static Schedule sched; static char challenge[REALM_SZ]; static int diff --git a/contrib/telnet/libtelnet/misc.c b/contrib/telnet/libtelnet/misc.c index 9565900..4f8f8d5 100644 --- a/contrib/telnet/libtelnet/misc.c +++ b/contrib/telnet/libtelnet/misc.c @@ -32,10 +32,14 @@ */ #ifndef lint -static char sccsid[] = "@(#)misc.c 8.1 (Berkeley) 6/4/93"; +static const char sccsid[] = "@(#)misc.c 8.1 (Berkeley) 6/4/93"; #endif /* not lint */ +#include +#include #include "misc.h" +#include "auth.h" +#include "encrypt.h" char *RemoteHostName; char *LocalHostName; diff --git a/contrib/telnet/libtelnet/spx.c b/contrib/telnet/libtelnet/spx.c index 86c6197..90c37a4 100644 --- a/contrib/telnet/libtelnet/spx.c +++ b/contrib/telnet/libtelnet/spx.c @@ -101,7 +101,6 @@ static unsigned char str_name[1024] = { IAC, SB, TELOPT_AUTHENTICATION, #ifdef ENCRYPTION static Block session_key = { 0 }; #endif /* ENCRYPTION */ -static Schedule sched; static Block challenge = { 0 }; diff --git a/contrib/telnet/telnet/authenc.c b/contrib/telnet/telnet/authenc.c index 545df78..f829b1a 100644 --- a/contrib/telnet/telnet/authenc.c +++ b/contrib/telnet/telnet/authenc.c @@ -32,7 +32,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)authenc.c 8.1 (Berkeley) 6/6/93"; +static const char sccsid[] = "@(#)authenc.c 8.1 (Berkeley) 6/6/93"; #endif /* not lint */ #if defined(AUTHENTICATION) || defined(ENCRYPTION) @@ -101,7 +101,7 @@ telnet_gets(prompt, result, length, echo) if (echo) { printf("%s", prompt); res = fgets(result, length, stdin); - } else if (res = getpass(prompt)) { + } else if ((res = getpass(prompt))) { strncpy(result, res, length); res = result; } diff --git a/contrib/telnet/telnet/commands.c b/contrib/telnet/telnet/commands.c index 41ef5cd..8073fb5 100644 --- a/contrib/telnet/telnet/commands.c +++ b/contrib/telnet/telnet/commands.c @@ -32,7 +32,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)commands.c 8.4 (Berkeley) 5/30/95"; +static const char sccsid[] = "@(#)commands.c 8.4 (Berkeley) 5/30/95"; #endif /* not lint */ #if defined(unix) @@ -56,6 +56,8 @@ static char sccsid[] = "@(#)commands.c 8.4 (Berkeley) 5/30/95"; #include #include #include +#include +#include #include @@ -67,6 +69,13 @@ static char sccsid[] = "@(#)commands.c 8.4 (Berkeley) 5/30/95"; #include "defines.h" #include "types.h" +#if defined(AUTHENTICATION) +#include +#endif +#if defined(ENCRYPTION) +#include +#endif + #if !defined(CRAY) && !defined(sysV88) #include # if (defined(vax) || defined(tahoe) || defined(hp300)) && !defined(ultrix) @@ -93,7 +102,11 @@ extern int isprefix(); extern char **genget(); extern int Ambiguous(); -static call(); +static int help(int argc, char *argv[]); +static int call(); +static void cmdrc(char *m1, char *m2); + +int quit(void); typedef struct { char *name; /* command name */ @@ -107,6 +120,37 @@ static char saveline[256]; static int margc; static char *margv[20]; +#if defined(SKEY) +#include +#define PATH_SKEY "/usr/bin/key" + int +skey_calc(argc, argv) + int argc; + char **argv; +{ + int status; + + if(argc != 3) { + printf("%s sequence challenge\n", argv[0]); + return; + } + + switch(fork()) { + case 0: + execv(PATH_SKEY, argv); + exit (1); + case -1: + perror("fork"); + break; + default: + (void) wait(&status); + if (WIFEXITED(status)) + return (WEXITSTATUS(status)); + return (0); + } +} +#endif + static void makeargv() { @@ -121,7 +165,7 @@ makeargv() margc++; cp++; } - while (c = *cp) { + while ((c = *cp)) { register int inquote = 0; while (isspace(c)) c = *++cp; @@ -164,7 +208,7 @@ makeargv() * Todo: 1. Could take random integers (12, 0x12, 012, 0b1). */ - static + static int special(s) register char *s; { @@ -293,7 +337,6 @@ sendcmd(argc, argv) { int count; /* how many bytes we are going to need to send */ int i; - int question = 0; /* was at least one argument a question */ struct sendlist *s; /* pointer to current command */ int success = 0; int needconnect = 0; @@ -499,7 +542,7 @@ togdebug() } #else /* NOT43 */ if (debug) { - if (net > 0 && SetSockOpt(net, SOL_SOCKET, SO_DEBUG, 0, 0) < 0) + if (net > 0 && SetSockOpt(net, SOL_SOCKET, SO_DEBUG, 1) < 0) perror("setsockopt (SO_DEBUG)"); } else printf("Cannot turn off socket debugging\n"); @@ -1082,7 +1125,7 @@ unsetcmd(argc, argv) #ifdef KLUDGELINEMODE extern int kludgelinemode; - static int + static void dokludgemode() { kludgelinemode = 1; @@ -1139,7 +1182,7 @@ dolmmode(bit, on) } int -setmode(bit) +setmod(bit) { return dolmmode(bit, 1); } @@ -1171,17 +1214,17 @@ static struct modelist ModeList[] = { #endif { "", "", 0 }, { "", "These require the LINEMODE option to be enabled", 0 }, - { "isig", "Enable signal trapping", setmode, 1, MODE_TRAPSIG }, - { "+isig", 0, setmode, 1, MODE_TRAPSIG }, + { "isig", "Enable signal trapping", setmod, 1, MODE_TRAPSIG }, + { "+isig", 0, setmod, 1, MODE_TRAPSIG }, { "-isig", "Disable signal trapping", clearmode, 1, MODE_TRAPSIG }, - { "edit", "Enable character editing", setmode, 1, MODE_EDIT }, - { "+edit", 0, setmode, 1, MODE_EDIT }, + { "edit", "Enable character editing", setmod, 1, MODE_EDIT }, + { "+edit", 0, setmod, 1, MODE_EDIT }, { "-edit", "Disable character editing", clearmode, 1, MODE_EDIT }, - { "softtabs", "Enable tab expansion", setmode, 1, MODE_SOFT_TAB }, - { "+softtabs", 0, setmode, 1, MODE_SOFT_TAB }, + { "softtabs", "Enable tab expansion", setmod, 1, MODE_SOFT_TAB }, + { "+softtabs", 0, setmod, 1, MODE_SOFT_TAB }, { "-softtabs", "Disable character editing", clearmode, 1, MODE_SOFT_TAB }, - { "litecho", "Enable literal character echo", setmode, 1, MODE_LIT_ECHO }, - { "+litecho", 0, setmode, 1, MODE_LIT_ECHO }, + { "litecho", "Enable literal character echo", setmod, 1, MODE_LIT_ECHO }, + { "+litecho", 0, setmod, 1, MODE_LIT_ECHO }, { "-litecho", "Disable literal character echo", clearmode, 1, MODE_LIT_ECHO }, { "help", 0, modehelp, 0 }, #ifdef KLUDGELINEMODE @@ -1435,7 +1478,7 @@ extern int shell(); #endif /* !defined(TN3270) */ /*VARARGS*/ - static + static int bye(argc, argv) int argc; /* Number of arguments */ char *argv[]; /* arguments */ @@ -1465,6 +1508,7 @@ bye(argc, argv) } /*VARARGS*/ + int quit() { (void) call(bye, "bye", "fromquit", 0); @@ -1530,7 +1574,7 @@ getslc(name) genget(name, (char **) SlcList, sizeof(struct slclist)); } - static + static int slccmd(argc, argv) int argc; char *argv[]; @@ -1627,6 +1671,7 @@ getenvcmd(name) genget(name, (char **) EnvList, sizeof(struct envlist)); } + int env_cmd(argc, argv) int argc; char *argv[]; @@ -1693,7 +1738,7 @@ env_init() extern char *strchr(); for (epp = environ; *epp; epp++) { - if (cp = strchr(*epp, '=')) { + if ((cp = strchr(*epp, '='))) { *cp = '\0'; ep = env_define((unsigned char *)*epp, (unsigned char *)cp+1); @@ -1738,7 +1783,7 @@ env_define(var, value) { register struct env_lst *ep; - if (ep = env_find(var)) { + if ((ep = env_find(var))) { if (ep->var) free(ep->var); if (ep->value) @@ -1764,7 +1809,7 @@ env_undefine(var) { register struct env_lst *ep; - if (ep = env_find(var)) { + if ((ep = env_find(var))) { ep->prev->next = ep->next; if (ep->next) ep->next->prev = ep->prev; @@ -1782,7 +1827,7 @@ env_export(var) { register struct env_lst *ep; - if (ep = env_find(var)) + if ((ep = env_find(var))) ep->export = 1; } @@ -1792,7 +1837,7 @@ env_unexport(var) { register struct env_lst *ep; - if (ep = env_find(var)) + if ((ep = env_find(var))) ep->export = 0; } @@ -1842,10 +1887,10 @@ env_default(init, welldefined) if (init) { nep = &envlisthead; - return; + return(NULL); } if (nep) { - while (nep = nep->next) { + while ((nep = nep->next)) { if (nep->export && (nep->welldefined == welldefined)) return(nep->var); } @@ -1859,7 +1904,7 @@ env_getvalue(var) { register struct env_lst *ep; - if (ep = env_find(var)) + if ((ep = env_find(var))) return(ep->value); return(NULL); } @@ -1949,6 +1994,7 @@ auth_help() return 0; } + int auth_cmd(argc, argv) int argc; char *argv[]; @@ -2055,6 +2101,7 @@ EncryptHelp() return 0; } + int encrypt_cmd(argc, argv) int argc; char *argv[]; @@ -2142,7 +2189,7 @@ filestuff(fd) * Print status about the connection. */ /*ARGSUSED*/ - static + static int status(argc, argv) int argc; char *argv[]; @@ -2215,6 +2262,7 @@ status(argc, argv) /* * Function that gets called when SIGINFO is received. */ + void ayt_status() { (void) call(status, "status", "notmuch", 0); @@ -2313,10 +2361,15 @@ tn(argc, argv) } else { #endif temp = inet_addr(hostp); - if (temp != (unsigned long) -1) { + if (temp != INADDR_NONE) { sin.sin_addr.s_addr = temp; sin.sin_family = AF_INET; - (void) strcpy(_hostname, hostp); + host = gethostbyaddr((char *)&temp, sizeof(temp), AF_INET); + if (host) + (void) strncpy(_hostname, host->h_name, sizeof(_hostname)); + else + (void) strncpy(_hostname, hostp, sizeof(_hostname)); + _hostname[sizeof(_hostname)-1] = '\0'; hostname = _hostname; } else { host = gethostbyname(hostp); @@ -2437,8 +2490,8 @@ tn(argc, argv) user = getenv("USER"); if (user == NULL || - (pw = getpwnam(user)) && pw->pw_uid != getuid()) { - if (pw = getpwuid(getuid())) + ((pw = getpwnam(user)) && pw->pw_uid != getuid())) { + if ((pw = getpwuid(getuid()))) user = pw->pw_name; else user = NULL; @@ -2483,12 +2536,13 @@ static char #if defined(unix) zhelp[] = "suspend telnet", #endif /* defined(unix) */ +#if defined(SKEY) + skeyhelp[] = "compute response to s/key challenge", +#endif shellhelp[] = "invoke a subshell", envhelp[] = "change environment variables ('environ ?' for more)", modestring[] = "try to enter line or character mode ('mode ?' for more)"; -static int help(); - static Command cmdtab[] = { { "close", closehelp, bye, 1 }, { "logout", logouthelp, logout, 1 }, @@ -2521,7 +2575,10 @@ static Command cmdtab[] = { #endif { "environ", envhelp, env_cmd, 0 }, { "?", helphelp, help, 0 }, - 0 +#if defined(SKEY) + { "skey", skeyhelp, skey_calc, 0 }, +#endif + { 0, 0, 0, 0 } }; static char crmodhelp[] = "deprecated command -- use 'toggle crmod' instead"; @@ -2531,7 +2588,7 @@ static Command cmdtab2[] = { { "help", 0, help, 0 }, { "escape", escapehelp, setescape, 0 }, { "crmod", crmodhelp, togcrmod, 0 }, - 0 + { 0, 0, 0, 0 } }; @@ -2540,7 +2597,7 @@ static Command cmdtab2[] = { */ /*VARARGS1*/ - static + static int call(va_alist) va_dcl { @@ -2566,7 +2623,7 @@ getcmd(name) { Command *cm; - if (cm = (Command *) genget(name, (char **) cmdtab, sizeof(Command))) + if ((cm = (Command *) genget(name, (char **) cmdtab, sizeof(Command)))) return cm; return (Command *) genget(name, (char **) cmdtab2, sizeof(Command)); } @@ -2655,7 +2712,7 @@ command(top, tbuf, cnt) /* * Help command. */ - static + static int help(argc, argv) int argc; char *argv[]; @@ -2669,9 +2726,8 @@ help(argc, argv) printf("%-*s\t%s\n", HELPINDENT, c->name, c->help); } - return 0; } - while (--argc > 0) { + else while (--argc > 0) { register char *arg; arg = *++argv; c = getcmd(arg); @@ -2682,12 +2738,13 @@ help(argc, argv) else printf("%s\n", c->help); } - return 0; + return(0); } static char *rcname = 0; static char rcbuf[128]; + void cmdrc(m1, m2) char *m1, *m2; { @@ -2706,7 +2763,7 @@ cmdrc(m1, m2) if (rcname == 0) { rcname = getenv("HOME"); - if (rcname) + if (rcname && (strlen(rcname) + 10) < sizeof(rcbuf)) strcpy(rcbuf, rcname); else rcbuf[0] = '\0'; @@ -2881,7 +2938,7 @@ sourceroute(arg, cpp, lenp) for (c = 0;;) { if (c == ':') cp2 = 0; - else for (cp2 = cp; c = *cp2; cp2++) { + else for (cp2 = cp; (c = *cp2); cp2++) { if (c == ',') { *cp2++ = '\0'; if (*cp2 == '@') @@ -2899,7 +2956,7 @@ sourceroute(arg, cpp, lenp) if ((tmp = inet_addr(cp)) != -1) { sin_addr.s_addr = tmp; - } else if (host = gethostbyname(cp)) { + } else if ((host = gethostbyname(cp))) { #if defined(h_addr) memmove((caddr_t)&sin_addr, host->h_addr_list[0], host->h_length); diff --git a/contrib/telnet/telnet/externs.h b/contrib/telnet/telnet/externs.h index 83ba07b..a834c61 100644 --- a/contrib/telnet/telnet/externs.h +++ b/contrib/telnet/telnet/externs.h @@ -145,7 +145,8 @@ extern int #endif /* defined(TN3270) */ termdata, /* Print out terminal data flow */ #endif /* defined(unix) */ - debug; /* Debug level */ + debug, /* Debug level */ + clienteof; /* Client received EOF */ extern cc_t escape; /* Escape to command mode */ extern cc_t rlogin; /* Rlogin mode escape character */ @@ -245,6 +246,7 @@ extern jmp_buf extern void command P((int, char *, int)), Dump P((int, unsigned char *, int)), + ExitString P((char *, int)), init_3270 P((void)), printoption P((char *, int, int)), printsub P((int, unsigned char *, int)), @@ -290,7 +292,14 @@ extern void slc_add_reply P((int, int, int)), slc_end_reply P((void)); extern int - slc_update P((void)); + NetClose P((int)), + netflush P((void)), + SetSockOpt P((int, int, int, int)), + slc_update P((void)), + telrcv P((void)), + TerminalWrite P((char *, int)), + TerminalAutoFlush P((void)), + ttyflush P((int)); extern void env_opt P((unsigned char *, int)), diff --git a/contrib/telnet/telnet/main.c b/contrib/telnet/telnet/main.c index 6073dbf..9049385 100644 --- a/contrib/telnet/telnet/main.c +++ b/contrib/telnet/telnet/main.c @@ -32,21 +32,29 @@ */ #ifndef lint -static char copyright[] = +static const char copyright[] = "@(#) Copyright (c) 1988, 1990, 1993\n\ The Regents of the University of California. All rights reserved.\n"; #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 5/30/95"; +static const char sccsid[] = "@(#)main.c 8.3 (Berkeley) 5/30/95"; #endif /* not lint */ #include +#include #include "ring.h" #include "externs.h" #include "defines.h" +#if defined(AUTHENTICATION) +#include +#endif +#if defined(ENCRYPTION) +#include +#endif + /* 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 @@ -56,6 +64,12 @@ static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 5/30/95"; #define FORWARD #endif +void init_terminal(void); +void init_network(void); +void init_telnet(void); +void init_sys(void); +void init_3270(void); + /* * Initialize variables. */ @@ -109,7 +123,7 @@ usage() * main. Parse arguments, invoke the protocol or command parser. */ - + int main(argc, argv) int argc; char *argv[]; @@ -129,7 +143,7 @@ main(argc, argv) TerminalSaveState(); - if (prompt = strrchr(argv[0], '/')) + if ((prompt = strrchr(argv[0], '/'))) ++prompt; else prompt = argv[0]; @@ -319,4 +333,5 @@ main(argc, argv) #endif command(1, 0, 0); } + return 0; } diff --git a/contrib/telnet/telnet/network.c b/contrib/telnet/telnet/network.c index 0fe5cee..9964bc2 100644 --- a/contrib/telnet/telnet/network.c +++ b/contrib/telnet/telnet/network.c @@ -32,7 +32,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)network.c 8.2 (Berkeley) 12/15/93"; +static const char sccsid[] = "@(#)network.c 8.2 (Berkeley) 12/15/93"; #endif /* not lint */ #include @@ -42,6 +42,7 @@ static char sccsid[] = "@(#)network.c 8.2 (Berkeley) 12/15/93"; #include #include +#include #include "ring.h" diff --git a/contrib/telnet/telnet/ring.c b/contrib/telnet/telnet/ring.c index 37dfda8..13fe6c2 100644 --- a/contrib/telnet/telnet/ring.c +++ b/contrib/telnet/telnet/ring.c @@ -32,7 +32,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)ring.c 8.2 (Berkeley) 5/30/95"; +static const char sccsid[] = "@(#)ring.c 8.2 (Berkeley) 5/30/95"; #endif /* not lint */ /* @@ -48,6 +48,7 @@ static char sccsid[] = "@(#)ring.c 8.2 (Berkeley) 5/30/95"; #include #include +#include #ifdef size_t #undef size_t @@ -99,6 +100,7 @@ static u_long ring_clock = 0; /* Buffer state transition routines */ + int ring_init(ring, buffer, count) Ring *ring; unsigned char *buffer; diff --git a/contrib/telnet/telnet/sys_bsd.c b/contrib/telnet/telnet/sys_bsd.c index f2769ac..ed5f459 100644 --- a/contrib/telnet/telnet/sys_bsd.c +++ b/contrib/telnet/telnet/sys_bsd.c @@ -32,7 +32,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)sys_bsd.c 8.4 (Berkeley) 5/30/95"; +static const char sccsid[] = "@(#)sys_bsd.c 8.4 (Berkeley) 5/30/95"; #endif /* not lint */ /* @@ -48,6 +48,7 @@ static char sccsid[] = "@(#)sys_bsd.c 8.4 (Berkeley) 5/30/95"; #include #include #include +#include #include "ring.h" @@ -140,7 +141,7 @@ TerminalWrite(buf, n) int TerminalRead(buf, n) - unsigned char *buf; + char *buf; int n; { return read(tin, buf, n); @@ -1051,7 +1052,7 @@ process_rings(netin, netout, netex, ttyin, ttyout, poll) } # endif /* defined(TN3270) */ /* I don't like this, does it ever happen? */ - printf("sleep(5) from telnet, after select\r\n"); + printf("sleep(5) from telnet, after select: %s\r\n", strerror(errno)); sleep(5); } return 0; diff --git a/contrib/telnet/telnet/telnet.c b/contrib/telnet/telnet/telnet.c index e792262..1c1ee33 100644 --- a/contrib/telnet/telnet/telnet.c +++ b/contrib/telnet/telnet/telnet.c @@ -32,7 +32,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)telnet.c 8.4 (Berkeley) 5/30/95"; +static const char sccsid[] = "@(#)telnet.c 8.4 (Berkeley) 5/30/95"; #endif /* not lint */ #include @@ -49,6 +49,10 @@ static char sccsid[] = "@(#)telnet.c 8.4 (Berkeley) 5/30/95"; #include +#include +#include +#include + #include "ring.h" #include "defines.h" @@ -56,6 +60,13 @@ static char sccsid[] = "@(#)telnet.c 8.4 (Berkeley) 5/30/95"; #include "types.h" #include "general.h" +#if defined(AUTHENTICATION) +#include +#endif +#if defined(ENCRYPTION) +#include +#endif +#include #define strip(x) ((my_want_state_is_wont(TELOPT_BINARY)) ? ((x)&0x7f) : (x)) @@ -104,7 +115,8 @@ int donelclchars, /* the user has set "localchars" */ donebinarytoggle, /* the user has put us in binary */ dontlecho, /* do we suppress local echoing right now? */ - globalmode; + globalmode, + clienteof = 0; char *prompt = 0; @@ -856,7 +868,7 @@ suboption() TerminalSpeeds(&ispeed, &ospeed); - sprintf((char *)temp, "%c%c%c%c%d,%d%c%c", IAC, SB, TELOPT_TSPEED, + sprintf((char *)temp, "%c%c%c%c%ld,%ld%c%c", IAC, SB, TELOPT_TSPEED, TELQUAL_IS, ospeed, ispeed, IAC, SE); len = strlen((char *)temp+4) + 4; /* temp[3] is 0 ... */ @@ -1212,7 +1224,7 @@ slc_init() #define initfunc(func, flags) { \ spcp = &spc_data[func]; \ - if (spcp->valp = tcval(func)) { \ + if ((spcp->valp = tcval(func))) { \ spcp->val = *spcp->valp; \ spcp->mylevel = SLC_VARIABLE|flags; \ } else { \ @@ -1620,12 +1632,12 @@ env_opt_add(ep) if (ep == NULL || *ep == '\0') { /* Send user defined variables first. */ env_default(1, 0); - while (ep = env_default(0, 0)) + while ((ep = env_default(0, 0))) env_opt_add(ep); /* Now add the list of well know variables. */ env_default(1, 1); - while (ep = env_default(0, 1)) + while ((ep = env_default(0, 1))) env_opt_add(ep); return; } @@ -1655,7 +1667,7 @@ env_opt_add(ep) else *opt_replyp++ = ENV_USERVAR; for (;;) { - while (c = *ep++) { + while ((c = *ep++)) { switch(c&0xff) { case IAC: *opt_replyp++ = IAC; @@ -1669,7 +1681,7 @@ env_opt_add(ep) } *opt_replyp++ = c; } - if (ep = vp) { + if ((ep = vp)) { #ifdef OLD_ENVIRON if (telopt_environ == TELOPT_OLD_ENVIRON) *opt_replyp++ = old_env_value; @@ -2184,9 +2196,9 @@ Scheduler(block) ttyout = ring_full_count(&ttyoring); #if defined(TN3270) - ttyin = ring_empty_count(&ttyiring) && (shell_active == 0); + ttyin = ring_empty_count(&ttyiring) && (clienteof == 0) && (shell_active == 0); #else /* defined(TN3270) */ - ttyin = ring_empty_count(&ttyiring); + ttyin = ring_empty_count(&ttyiring) && (clienteof == 0); #endif /* defined(TN3270) */ #if defined(TN3270) diff --git a/contrib/telnet/telnet/terminal.c b/contrib/telnet/telnet/terminal.c index b5ceeda..a2383d9 100644 --- a/contrib/telnet/telnet/terminal.c +++ b/contrib/telnet/telnet/terminal.c @@ -32,7 +32,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)terminal.c 8.2 (Berkeley) 2/16/95"; +static const char sccsid[] = "@(#)terminal.c 8.2 (Berkeley) 2/16/95"; #endif /* not lint */ #include @@ -43,6 +43,10 @@ static char sccsid[] = "@(#)terminal.c 8.2 (Berkeley) 2/16/95"; #include "externs.h" #include "types.h" +#if defined(ENCRYPTION) +#include +#endif + Ring ttyoring, ttyiring; unsigned char ttyobuf[2*BUFSIZ], ttyibuf[BUFSIZ]; diff --git a/contrib/telnet/telnet/tn3270.c b/contrib/telnet/telnet/tn3270.c index a75cd1e..5a453d9 100644 --- a/contrib/telnet/telnet/tn3270.c +++ b/contrib/telnet/telnet/tn3270.c @@ -32,7 +32,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)tn3270.c 8.2 (Berkeley) 5/30/95"; +static const char sccsid[] = "@(#)tn3270.c 8.2 (Berkeley) 5/30/95"; #endif /* not lint */ #include diff --git a/contrib/telnet/telnet/utilities.c b/contrib/telnet/telnet/utilities.c index 06d08a4..0ee882e 100644 --- a/contrib/telnet/telnet/utilities.c +++ b/contrib/telnet/telnet/utilities.c @@ -32,7 +32,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)utilities.c 8.3 (Berkeley) 5/30/95"; +static const char sccsid[] = "@(#)utilities.c 8.3 (Berkeley) 5/30/95"; #endif /* not lint */ #define TELOPTS @@ -40,7 +40,9 @@ static char sccsid[] = "@(#)utilities.c 8.3 (Berkeley) 5/30/95"; #define SLC_NAMES #include #include +#include #include +#include #include @@ -54,6 +56,13 @@ static char sccsid[] = "@(#)utilities.c 8.3 (Berkeley) 5/30/95"; #include "externs.h" +#if defined(AUTHENTICATION) +#include +#endif +#if defined(ENCRYPTION) +#include +#endif + FILE *NetTrace = 0; /* Not in bss, since needs to stay */ int prettydump; @@ -134,7 +143,6 @@ Dump(direction, buffer, length) # define min(x,y) ((x #endif +#if defined(ENCRYPTION) +#include +#endif unsigned char doopt[] = { IAC, DO, '%', 'c', 0 }; unsigned char dont[] = { IAC, DONT, '%', 'c', 0 }; diff --git a/contrib/telnet/telnetd/sys_term.c b/contrib/telnet/telnetd/sys_term.c index 67a2f94..fe9509e 100644 --- a/contrib/telnet/telnetd/sys_term.c +++ b/contrib/telnet/telnetd/sys_term.c @@ -32,7 +32,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)sys_term.c 8.4+1 (Berkeley) 5/30/95"; +static const char sccsid[] = "@(#)sys_term.c 8.4+1 (Berkeley) 5/30/95"; #endif /* not lint */ #include "telnetd.h" @@ -42,13 +42,17 @@ static char sccsid[] = "@(#)sys_term.c 8.4+1 (Berkeley) 5/30/95"; #include #endif +extern char *altlogin; +int cleanopen(char *line); +void scrub_env(void); + #if defined(CRAY) || defined(__hpux) # define PARENT_DOES_UTMP #endif +int utmp_len = MAXHOSTNAMELEN; #ifdef NEWINIT #include -int utmp_len = MAXHOSTNAMELEN; /* sizeof(init_request.host) */ #else /* NEWINIT*/ # ifdef UTMPX # include @@ -58,14 +62,23 @@ struct utmpx wtmp; struct utmp wtmp; # endif /* UTMPX */ -int utmp_len = sizeof(wtmp.ut_host); # ifndef PARENT_DOES_UTMP +#ifdef _PATH_WTMP +char wtmpf[] = _PATH_WTMP; +#else char wtmpf[] = "/usr/adm/wtmp"; +#endif +#ifdef _PATH_UTMP +char utmpf[] = _PATH_UTMP; +#else char utmpf[] = "/etc/utmp"; +#endif # else /* PARENT_DOES_UTMP */ char wtmpf[] = "/etc/wtmp"; # endif /* PARENT_DOES_UTMP */ +#include + # ifdef CRAY #include #include @@ -504,7 +517,7 @@ int *ptynum; p2 = &line[14]; #endif - for (cp = "pqrstuvwxyzPQRST"; *cp; cp++) { + for (cp = "pqrsPQRS"; *cp; cp++) { struct stat stb; *p1 = *cp; @@ -516,8 +529,8 @@ int *ptynum; */ if (stat(line, &stb) < 0) break; - for (i = 0; i < 16; i++) { - *p2 = "0123456789abcdef"[i]; + for (i = 0; i < 32; i++) { + *p2 = "0123456789abcdefghijklmnopqrstuv"[i]; p = open(line, 2); if (p > 0) { #ifndef __hpux @@ -1065,10 +1078,11 @@ extern void utmp_sig_notify P((int)); * that is necessary. The return value is a file descriptor * for the slave side. */ - int + void getptyslave() { register int t = -1; + char erase; #if !defined(CRAY) || !defined(NEWINIT) # ifdef LINEMODE @@ -1085,12 +1099,13 @@ getptyslave() * if linemode was turned on * terminal window size * terminal speed + * erase character * so that we can re-set them if we need to. */ # ifdef LINEMODE waslm = tty_linemode(); # endif - + erase = termbuf.c_cc[VERASE]; /* * Make sure that we don't have a controlling tty, and @@ -1176,6 +1191,8 @@ getptyslave() # endif /* defined(USE_TERMIO) && !defined(CRAY) && (BSD <= 43) */ tty_rspeed((def_rspeed > 0) ? def_rspeed : 9600); tty_tspeed((def_tspeed > 0) ? def_tspeed : 9600); + if (erase) + termbuf.c_cc[VERASE] = erase; # ifdef LINEMODE if (waslm) tty_setlinemode(1); @@ -1384,7 +1401,6 @@ startslave(host, autologin, autoname) { register int i; long time(); - char name[256]; #ifdef NEWINIT extern char *ptyip; struct init_request request; @@ -1517,7 +1533,7 @@ init_env() char **envp; envp = envinit; - if (*envp = getenv("TZ")) + if ((*envp = getenv("TZ"))) *envp++ -= 3; #if defined(CRAY) || defined(__hpux) else @@ -1542,9 +1558,8 @@ start_login(host, autologin, name) int autologin; char *name; { - register char *cp; register char **argv; - char **addarg(); + char **addarg(), *user; extern char *getenv(); #ifdef UTMPX register int pid = getpid(); @@ -1652,6 +1667,7 @@ start_login(host, autologin, name) if (auth_level >= 0 && autologin == AUTH_VALID) { # if !defined(NO_LOGIN_F) argv = addarg(argv, "-f"); + argv = addarg(argv, "--"); argv = addarg(argv, name); # else # if defined(LOGIN_R) @@ -1724,12 +1740,14 @@ start_login(host, autologin, name) pty = xpty; } # else + argv = addarg(argv, "--"); argv = addarg(argv, name); # endif # endif } else #endif if (getenv("USER")) { + argv = addarg(argv, "--"); argv = addarg(argv, getenv("USER")); #if defined(LOGIN_ARGS) && defined(NO_LOGIN_P) { @@ -1765,16 +1783,14 @@ start_login(host, autologin, name) close(pty); #endif closelog(); - /* - * This sleep(1) is in here so that telnetd can - * finish up with the tty. There's a race condition - * the login banner message gets lost... - */ - sleep(1); - execv(_PATH_LOGIN, argv); - syslog(LOG_ERR, "%s: %m\n", _PATH_LOGIN); - fatalperror(net, _PATH_LOGIN); + if (altlogin == NULL) { + altlogin = _PATH_LOGIN; + } + execv(altlogin, argv); + + syslog(LOG_ERR, "%s: %m\n", altlogin); + fatalperror(net, altlogin); /*NOTREACHED*/ } @@ -1818,14 +1834,20 @@ addarg(argv, val) * Remove a few things from the environment that * don't need to be there. */ + void scrub_env() { register char **cpp, **cpp2; for (cpp2 = cpp = environ; *cpp; cpp++) { +#ifdef __FreeBSD__ + if (strncmp(*cpp, "LD_LIBRARY_PATH=", 16) && + strncmp(*cpp, "LD_PRELOAD=", 11) && +#else if (strncmp(*cpp, "LD_", 3) && strncmp(*cpp, "_RLD_", 5) && strncmp(*cpp, "LIBPATH=", 8) && +#endif strncmp(*cpp, "IFS=", 4)) *cpp2++ = *cpp; } diff --git a/contrib/telnet/telnetd/telnetd.8 b/contrib/telnet/telnetd/telnetd.8 index f618385..e77443e 100644 --- a/contrib/telnet/telnetd/telnetd.8 +++ b/contrib/telnet/telnetd/telnetd.8 @@ -48,6 +48,7 @@ protocol server .Op Fl X Ar authtype .Op Fl a Ar authmode .Op Fl edebug +.Op Fl P Ar loginprog .Op Fl r Ns Ar lowpty-highpty .Op Fl u Ar len .Op Fl debug Op Ar port @@ -187,6 +188,11 @@ If has been compiled with support for data encryption, then the .Fl edebug option may be used to enable encryption debugging code. +.It Fl P Ar loginprog +Specifies an alternate +.Xr login 1 +command to run to complete the login. The alternate command must +understand the same command arguments as the standard login. .It Fl h Disables the printing of host-specific information before login has been completed. @@ -532,9 +538,9 @@ the data stream. .Pa /usr/ucb/bftp (if supported) .Sh "SEE ALSO" -.Xr telnet 1 , +.Xr bftp 1 , .Xr login 1 , -.Xr bftp 1 +.Xr telnet 1 (if supported) .Sh STANDARDS .Bl -tag -compact -width RFC-1572 diff --git a/contrib/telnet/telnetd/telnetd.c b/contrib/telnet/telnetd/telnetd.c index 70c0fc0..6e09ab4 100644 --- a/contrib/telnet/telnetd/telnetd.c +++ b/contrib/telnet/telnetd/telnetd.c @@ -32,13 +32,13 @@ */ #ifndef lint -static char copyright[] = +static const char copyright[] = "@(#) Copyright (c) 1989, 1993\n\ The Regents of the University of California. All rights reserved.\n"; #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)telnetd.c 8.4 (Berkeley) 5/30/95"; +static const char sccsid[] = "@(#)telnetd.c 8.4 (Berkeley) 5/30/95"; #endif /* not lint */ #include "telnetd.h" @@ -75,6 +75,10 @@ struct socket_security ss; #include int auth_level = 0; #endif +#if defined(ENCRYPTION) +#include +#endif +#include #if defined(SecurID) int require_SecurID = 0; #endif @@ -101,8 +105,6 @@ char ptyibuf2[BUFSIZ]; unsigned char ctlbuf[BUFSIZ]; struct strbuf strbufc, strbufd; -int readstream(); - #else /* ! STREAMPTY */ /* @@ -112,6 +114,13 @@ int readstream(); char ptyibuf[BUFSIZ], *ptyip = ptyibuf; char ptyibuf2[BUFSIZ]; +# include + +int readstream(int p, char *ibuf, int bufsize); +void doit(struct sockaddr_in *who); +int terminaltypeok(char *s); +void startslave(char *host, int autologin, char *autoname); + #endif /* ! STREAMPTY */ int hostinfo = 1; /* do we print login banner? */ @@ -124,6 +133,7 @@ int lowpty = 0, highpty; /* low, high pty numbers */ int debug = 0; int keepalive = 1; char *progname; +char *altlogin; extern void usage P((void)); @@ -133,7 +143,7 @@ extern void usage P((void)); * passed off to getopt(). */ char valid_opts[] = { - 'd', ':', 'h', 'k', 'n', 'S', ':', 'u', ':', 'U', + 'd', ':', 'h', 'k', 'n', 'p', ':', 'S', ':', 'u', ':', 'U', #ifdef AUTHENTICATION 'a', ':', 'X', ':', #endif @@ -301,6 +311,10 @@ main(argc, argv) keepalive = 0; break; + case 'p': + altlogin = optarg; + break; + #ifdef CRAY case 'r': { @@ -385,7 +399,7 @@ main(argc, argv) usage(); /* NOT REACHED */ } else if (argc == 1) { - if (sp = getservbyname(*argv, "tcp")) { + if ((sp = getservbyname(*argv, "tcp"))) { sin.sin_port = sp->s_port; } else { sin.sin_port = atoi(*argv); @@ -699,12 +713,14 @@ getterminaltype(name) * we have to just go with what we (might) have already gotten. */ if (his_state_is_will(TELOPT_TTYPE) && !terminaltypeok(terminaltype)) { - (void) strncpy(first, terminaltype, sizeof(first)); + (void) strncpy(first, terminaltype, sizeof(first)-1); + first[sizeof(first)-1] = '\0'; for(;;) { /* * Save the unknown name, and request the next name. */ - (void) strncpy(last, terminaltype, sizeof(last)); + (void) strncpy(last, terminaltype, sizeof(last)-1); + last[sizeof(last)-1] = '\0'; _gettermname(); if (terminaltypeok(terminaltype)) break; @@ -722,8 +738,10 @@ getterminaltype(name) * the start of the list. */ _gettermname(); - if (strncmp(first, terminaltype, sizeof(first)) != 0) - (void) strncpy(terminaltype, first, sizeof(first)); + if (strncmp(first, terminaltype, sizeof(first)) != 0) { + (void) strncpy(terminaltype, first, sizeof(terminaltype)-1); + terminaltype[sizeof(terminaltype)-1] = '\0'; + } break; } } @@ -780,24 +798,20 @@ char *hostname; char host_name[MAXHOSTNAMELEN]; char remote_host_name[MAXHOSTNAMELEN]; -#ifndef convex -extern void telnet P((int, int)); -#else extern void telnet P((int, int, char *)); -#endif +int level; +char user_name[256]; /* * Get a pty, scan input lines. */ +void doit(who) struct sockaddr_in *who; { char *host, *inet_ntoa(); - int t; struct hostent *hp; - int level; int ptynum; - char user_name[256]; /* * Find an available pty to use. @@ -875,12 +889,6 @@ doit(who) level = getterminaltype(user_name); setenv("TERM", terminaltype ? terminaltype : "network", 1); - /* - * Start up the login process on the slave side of the terminal - */ -#ifndef convex - startslave(host, level, user_name); - #if defined(_SC_CRAY_SECURE_SYS) if (secflag) { if (setulvl(dv.dv_actlvl) < 0) @@ -890,10 +898,8 @@ doit(who) } #endif /* _SC_CRAY_SECURE_SYS */ - telnet(net, pty); /* begin server processing */ -#else - telnet(net, pty, host); -#endif + telnet(net, pty, host); /* begin server process */ + /*NOTREACHED*/ } /* end of doit */ @@ -917,15 +923,9 @@ Xterm_output(ibufp, obuf, icountp, ocount) * hand data to telnet receiver finite state machine. */ void -#ifndef convex -telnet(f, p) -#else telnet(f, p, host) -#endif int f, p; -#ifdef convex char *host; -#endif { int on = 1; #define TABBUFSIZ 512 @@ -1162,9 +1162,12 @@ telnet(f, p, host) {sprintf(nfrontp, "td: Entering processing loop\r\n"); nfrontp += strlen(nfrontp);}); -#ifdef convex - startslave(host); -#endif + /* + * Startup the login process on the slave side of the terminal + * now. We delay this until here to insure option negotiation + * is complete. + */ + startslave(host, level, user_name); nfd = ((f > p) ? f : p) + 1; for (;;) { diff --git a/contrib/telnet/telnetd/termstat.c b/contrib/telnet/telnetd/termstat.c index ebc843a..be1372a 100644 --- a/contrib/telnet/telnetd/termstat.c +++ b/contrib/telnet/telnetd/termstat.c @@ -32,11 +32,15 @@ */ #ifndef lint -static char sccsid[] = "@(#)termstat.c 8.2 (Berkeley) 5/30/95"; +static const char sccsid[] = "@(#)termstat.c 8.2 (Berkeley) 5/30/95"; #endif /* not lint */ #include "telnetd.h" +#if defined(ENCRYPTION) +#include +#endif + /* * local variables */ @@ -144,8 +148,35 @@ localstat() #endif /* defined(CRAY2) && defined(UNICOS5) */ /* + * Check for changes to flow control if client supports it. + */ + flowstat(); + + /* + * Check linemode on/off state + */ + uselinemode = tty_linemode(); + + /* + * If alwayslinemode is on, and pty is changing to turn it off, then + * force linemode back on. + */ + if (alwayslinemode && linemode && !uselinemode) { + uselinemode = 1; + tty_setlinemode(uselinemode); + } + + if (uselinemode) { + /* * Check for state of BINARY options. + * + * We only need to do the binary dance if we are actually going + * to use linemode. As this confuses some telnet clients + * that don't support linemode, and doesn't gain us + * anything, we don't do it unless we're doing linemode. + * -Crh (henrich@msu.edu) */ + if (tty_isbinaryin()) { if (his_want_state_is_wont(TELOPT_BINARY)) send_do(TELOPT_BINARY, 1); @@ -161,24 +192,6 @@ localstat() if (my_want_state_is_will(TELOPT_BINARY)) send_wont(TELOPT_BINARY, 1); } - - /* - * Check for changes to flow control if client supports it. - */ - flowstat(); - - /* - * Check linemode on/off state - */ - uselinemode = tty_linemode(); - - /* - * If alwayslinemode is on, and pty is changing to turn it off, then - * force linemode back on. - */ - if (alwayslinemode && linemode && !uselinemode) { - uselinemode = 1; - tty_setlinemode(uselinemode); } #ifdef ENCRYPTION @@ -479,7 +492,7 @@ clientstat(code, parm1, parm2) ack = (useeditmode & MODE_ACK); useeditmode &= ~MODE_ACK; - if (changed = (useeditmode ^ editmode)) { + if ((changed = (useeditmode ^ editmode))) { /* * This check is for a timing problem. If the * state of the tty has changed (due to the user diff --git a/contrib/telnet/telnetd/utility.c b/contrib/telnet/telnetd/utility.c index 9553d58..eac3b69 100644 --- a/contrib/telnet/telnetd/utility.c +++ b/contrib/telnet/telnetd/utility.c @@ -32,12 +32,22 @@ */ #ifndef lint -static char sccsid[] = "@(#)utility.c 8.4 (Berkeley) 5/30/95"; +static const char sccsid[] = "@(#)utility.c 8.4 (Berkeley) 5/30/95"; #endif /* not lint */ +#ifdef __FreeBSD__ +#include +#endif #define PRINTOPTIONS #include "telnetd.h" +#if defined(AUTHENTICATION) +#include +#endif +#if defined(ENCRYPTION) +#include +#endif + /* * utility functions performing io related tasks */ @@ -93,6 +103,7 @@ stilloob(s) do { FD_ZERO(&excepts); FD_SET(s, &excepts); + memset((char *)&timeout, 0, sizeof timeout); value = select(s+1, (fd_set *)0, (fd_set *)0, &excepts, &timeout); } while ((value == -1) && (errno == EINTR)); @@ -433,12 +444,16 @@ putchr(cc) *putlocation++ = 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" }; +#endif void putf(cp, where) @@ -481,6 +496,9 @@ putf(cp, where) break; case 'd': +#ifdef __FreeBSD__ + setlocale(LC_TIME, ""); +#endif (void)time(&t); (void)strftime(db, sizeof(db), fmtstr, localtime(&t)); putstr(db); @@ -939,7 +957,6 @@ printsub(direction, pointer, length) break; default: - def_case: if (isprint(pointer[i]) && pointer[i] != '"') { if (noquote) { *nfrontp++ = '"'; @@ -1110,12 +1127,12 @@ printsub(direction, pointer, length) break; case ENCRYPT_ENC_KEYID: - sprintf(nfrontp, " ENC_KEYID", pointer[1]); + sprintf(nfrontp, " ENC_KEYID"); nfrontp += strlen(nfrontp); goto encommon; case ENCRYPT_DEC_KEYID: - sprintf(nfrontp, " DEC_KEYID", pointer[1]); + sprintf(nfrontp, " DEC_KEYID"); nfrontp += strlen(nfrontp); goto encommon; -- cgit v1.1