From ee87d787f780d91047a98695e6fec678a16aab4b Mon Sep 17 00:00:00 2001 From: Theodore Tso Date: Thu, 11 Jan 1996 03:14:46 +0000 Subject: [PATCH] kcmd.c (getport): Clear the sin structure to be zero. (From Doug Engbert.) krsh.c (main): Added code to default port to 544 if service not found. (From Doug Engbert.) krlogin.c (main): Added code to default port to 543 or 2105 if service not found. (From Doug Engbert.) login.c (main): Save KRB5CCNAME environment variable, which may have been set by forward.c. Add code for SGI to set environment for its /etc/TIMEZONE (untested). Don't print MOTD twice on Suns, added #ifdef NO_MOTD. (Patches from Doug Engbert). git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@7295 dc483132-0cff-0310-8789-dd5450dbe970 --- src/appl/bsd/ChangeLog | 15 +++++++++++++++ src/appl/bsd/kcmd.c | 1 + src/appl/bsd/krlogin.c | 7 +++---- src/appl/bsd/krsh.c | 5 +++-- src/appl/bsd/login.c | 29 ++++++++++++++++++++++++++++- 5 files changed, 50 insertions(+), 7 deletions(-) diff --git a/src/appl/bsd/ChangeLog b/src/appl/bsd/ChangeLog index b705d0124..f05c9a983 100644 --- a/src/appl/bsd/ChangeLog +++ b/src/appl/bsd/ChangeLog @@ -1,5 +1,20 @@ Wed Jan 10 21:26:20 1996 Theodore Y. Ts'o + * kcmd.c (getport): Clear the sin structure to be zero. (From + Doug Engbert.) + + * krsh.c (main): Added code to default port to 544 if service not + found. (From Doug Engbert.) + + * krlogin.c (main): Added code to default port to 543 or 2105 if + service not found. (From Doug Engbert.) + + * login.c (main): Save KRB5CCNAME environment variable, which may + have been set by forward.c. Add code for SGI to set + environment for its /etc/TIMEZONE (untested). Don't print + MOTD twice on Suns, added #ifdef NO_MOTD. (Patches from + Doug Engbert). + * kcmd.c: Removed extern global of krb5_kdc_req_sumtype, which wasn't being used anyway. diff --git a/src/appl/bsd/kcmd.c b/src/appl/bsd/kcmd.c index f06383432..1c232c6a0 100644 --- a/src/appl/bsd/kcmd.c +++ b/src/appl/bsd/kcmd.c @@ -402,6 +402,7 @@ getport(alport) struct sockaddr_in sin; int s; + memset((char *) &sin, 0,sizeof(sin)); sin.sin_family = AF_INET; sin.sin_addr.s_addr = INADDR_ANY; s = socket(AF_INET, SOCK_STREAM, 0); diff --git a/src/appl/bsd/krlogin.c b/src/appl/bsd/krlogin.c index 3c2a78761..5e4c4352d 100644 --- a/src/appl/bsd/krlogin.c +++ b/src/appl/bsd/krlogin.c @@ -309,6 +309,7 @@ main(argc, argv) #endif struct passwd *pwd; struct servent *sp; + struct servent defaultservent = {0,0,0,0}; int uid, options = 0; #ifdef POSIX_SIGNALS struct sigaction sa; @@ -474,10 +475,8 @@ main(argc, argv) else sp = getservbyname("klogin","tcp"); if (sp == 0) { - fprintf(stderr, "rlogin: %s/tcp: unknown service\n", - encrypt_flag ? "eklogin" : "klogin"); - - try_normal(orig_argv); + sp = &defaultservent; /* ANL */ + sp->s_port = encrypt_flag ? htons(2105) : htons(543); } #else sp = getservbyname("login", "tcp"); diff --git a/src/appl/bsd/krsh.c b/src/appl/bsd/krsh.c index 80be6dbeb..0f0ed633e 100644 --- a/src/appl/bsd/krsh.c +++ b/src/appl/bsd/krsh.c @@ -130,6 +130,7 @@ main(argc, argv0) fd_set readfrom, ready; int one = 1; struct servent *sp; + struct servent defaultservent = {0,0,0,0}; #ifdef POSIX_SIGNALS sigset_t omask, igmask; @@ -319,8 +320,8 @@ main(argc, argv0) #endif /* KERBEROS */ if (sp == 0) { #ifdef KERBEROS - fprintf(stderr, "rsh: kshell/tcp: unknown service\n"); - try_normal(argv0); + sp = &defaultservent; + sp->s_port = htons(544); #else fprintf(stderr, "rsh: shell/tcp: unknown service\n"); #endif /* KERBEROS */ diff --git a/src/appl/bsd/login.c b/src/appl/bsd/login.c index d102006aa..a6c45173a 100644 --- a/src/appl/bsd/login.c +++ b/src/appl/bsd/login.c @@ -258,6 +258,7 @@ int main(argc, argv) char tbuf[MAXPATHLEN + 2]; char *ttyname(), *stypeof(), *crypt(), *getpass(); time_t login_time; + char *ccname = 0; /* name of forwarded cache */ int retval; off_t lseek(); @@ -500,7 +501,6 @@ int retval; (void)ioctl(0, TIOCSETC, (char *)&tc); (void)ioctl(0, TIOCSETP, (char *)&sgttyb); #endif - for (cnt = getdtablesize(); cnt > 2; cnt--) (void) close(cnt); @@ -878,6 +878,8 @@ bad_login: } #endif + ccname = getenv("KRB5CCNAME"); /* save cache */ + /* destroy environment unless user has requested preservation */ envinit = (char **)malloc(MAXENVIRON * sizeof(char *)); if (envinit == 0) { @@ -907,6 +909,26 @@ bad_login: } } #endif +/* Set login timezone for date information (PDG) */ +#ifdef __sgi__ + { + FILE *fp; + if ((fp = fopen("/etc/TIMEZONE", "r")) != NULL) { + while(fgets(tbuf, sizeof(tbuf), fp)) { + if ((tbuf[0] == '#') || (strchr(tbuf, '=') == 0)) + continue; + for (p = tbuf; *p; p++) + if (*p == '\n') { + *p = '\0'; + break; + } + envinit[i++] = strsave(tbuf); + } + fclose(fp); + } + } +#endif + sprintf(tbuf,"LOGNAME=%s",pwd->pw_name); envinit[i++] = strsave(tbuf); sprintf(tbuf,"LOGIN=%s",pwd->pw_name); @@ -914,6 +936,9 @@ bad_login: envinit[i++] = NULL; + if (ccname) + setenv("KRB5CCNAME", ccname, 0); + setenv("HOME", pwd->pw_dir, 0); setenv("PATH", LPATH, 0); setenv("USER", pwd->pw_name, 0); @@ -987,7 +1012,9 @@ bad_login: if (!krbflag && !fflag && !Fflag && !eflag ) printf("\nWarning: No Kerberos tickets obtained.\n\n"); #endif /* KRB4 */ +#ifndef NO_MOTD motd(); +#endif (void)sprintf(tbuf, "%s/%s", MAILDIR, pwd->pw_name); if (stat(tbuf, &st) == 0 && st.st_size != 0) printf("You have %smail.\n", -- 2.26.2