[2717] in Kerberos-V5-bugs

home help back first fref pref prev next nref lref last post

krb5-appl/412: appl/bsd/login.c fixes

daemon@ATHENA.MIT.EDU (Kenneth D. Renard" (CICC/HPCD))
Thu Apr 3 10:11:07 1997

Resent-From: gnats@rt-11.MIT.EDU (GNATS Management)
Resent-To: krb5-unassigned@RT-11.MIT.EDU
Resent-Reply-To: krb5-bugs@MIT.EDU,
        "Kenneth D. Renard" (CICC/HPCD) <kdrenard@ARL.MIL>
Date: Thu, 3 Apr 97 10:04:51 EST
From: "Kenneth D. Renard" (CICC/HPCD) <kdrenard@ARL.MIL>
To: krb5-bugs@MIT.EDU
Cc: kdrenard@ARL.MIL


>Number:         412
>Category:       krb5-appl
>Synopsis:       SGI fixes, Solaris ccaches & more syslog to appl/bsd/login.c
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    krb5-unassigned
>State:          open
>Class:          support
>Submitter-Id:   unknown
>Arrival-Date:   Thu Apr 03 10:06:00 EST 1997
>Last-Modified:
>Originator:     Kenneth D. Renard <kdrenard@arl.mil>
>Organization:
Army Research Lab, APG, MD
>Release:        1.0
>Environment:
SGI Irix 5.x, 6.x, Sun Solaris 2.x
>Description:
	SGI Irix printed out 2 MOTDs
	SGI Irix failed to print or update lastlog message
	Solaris 2.x: login.krb5 parsing of ttyname into ccachename

>How-To-Repeat:
	SGI problems: use login.krb5
	Solaris:  Run login.krb5 without KRB5CCNAME pre-set on /dev/pts/0
		and you'll get KRB5CCNAME=FILE:/tmp/krb5cc_0

>Fix:

Here are a few additions that I have made to appl/bsd/login.c to help
out Solaris, SGIs and to do some extra SYSLOG-ing.

1.  Moved char string rusername out to a global (line 271) so it can be
    used in additional syslog msg at lines 1914-1920

2.  Added "sgi" to ifdef (line 284) so SGIs wouldn't do 2nd MOTD

3.  Parsed ttyname better for case of Solaris "/dev/pts/0" would produce
    cachename "FILE:/tmp/krb5cc_pts-0" instead of "FILE:/tmp/krb5cc_0".
    (lines 483-496)

4.  In dolastlog(), added suuport for SGI Irix which stores its lastlog
    info in LASTLOG/<username> instead of flat LASTLOG file.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
*** 1.1	1997/03/06 16:51:02
--- login.c	1997/04/03 14:37:15
***************
*** 268,273 ****
--- 268,274 ----
  int	timeout = 300;
  
  char term[64], *hostname, *username;
+ char rusername[UT_NAMESIZE+1];
  
  extern int errno;
  
***************
*** 281,287 ****
  					   passsword */
  #endif
  
! #ifdef __SVR4
  #define NO_MOTD
  #define NO_MAILCHECK
  #endif
--- 282,288 ----
  					   passsword */
  #endif
  
! #if defined(__SVR4) || defined(sgi)
  #define NO_MOTD
  #define NO_MAILCHECK
  #endif
***************
*** 482,488 ****
  
      /* Set up the credential cache environment variable */
      if (!getenv(KRB5_ENV_CCNAME)) {
! 	sprintf(ccfile, "FILE:/tmp/krb5cc_%s", strrchr(ttyn, '/')+1);
  	setenv(KRB5_ENV_CCNAME, ccfile, 1);
  	unlink(ccfile+strlen("FILE:"));
      } else {
--- 483,496 ----
  
      /* Set up the credential cache environment variable */
      if (!getenv(KRB5_ENV_CCNAME)) {
! 	char *ttyname, *c;
! 	if ((ttyname = strchr(ttyn,'/')) && (ttyname = strchr(ttyname+1,'/')))
! 	  ++ttyname;
! 	else
! 	  ttyname = ttyn;
! 	while (c = strchr(ttyname, '/'))
! 	  *c = '-';
! 	sprintf(ccfile, "FILE:/tmp/krb5cc_%s",ttyname);
  	setenv(KRB5_ENV_CCNAME, ccfile, 1);
  	unlink(ccfile+strlen("FILE:"));
      } else {
***************
*** 1903,1908 ****
--- 1911,1924 ----
  
  	afs_login ();
  
+ #ifdef LOG_ALL_LOGINS
+ 	if ( !(hflag || rflag))
+ 	  syslog(LOG_AUTH|LOG_INFO,"%s on %s", pwd->pw_name, tty);
+ 	else
+ 	  syslog(LOG_AUTH|LOG_INFO,"%s@%s as %s", (rusername) ? rusername : "?",
+ 		(hostname) ? (hostname) : "unknown host", pwd->pw_name);
+ #endif
+ 
  	if (!quietlog) {
  #ifdef KRB4_KLOGIN
  		if (!krbflag && !fflag && !eflag )
***************
*** 2185,2192 ****
--- 2201,2216 ----
  	struct lastlog ll;
  	int fd;
  
+ #ifdef sgi
+         char *fname = malloc(strlen(LASTLOG) + strlen(pwd->pw_name) + 1);
+         if (!fname) return;
+         sprintf(fname,"%s/%s", LASTLOG, pwd->pw_name);
+         if ((fd = open(fname, (O_RDWR|O_CREAT), 0)) >= 0) {
+ 
+ #else
  	if ((fd = open(LASTLOG, O_RDWR, 0)) >= 0) {
  		(void)lseek(fd, (off_t)pwd->pw_uid * sizeof(ll), SEEK_SET);
+ #endif
  		if (!quiet) {
  			if (read(fd, (char *)&ll, sizeof(ll)) == sizeof(ll) &&
  			    ll.ll_time != 0) {
***************
*** 2199,2205 ****
--- 2223,2233 ----
  					printf("on %.*s\n",
  					    sizeof(ll.ll_line), ll.ll_line);
  			}
+ #ifdef sgi
+                         (void)lseek(fd, 0, SEEK_SET);
+ #else
  			(void)lseek(fd, (off_t)pwd->pw_uid * sizeof(ll), SEEK_SET);
+ #endif
  		}
  		(void)time(&ll.ll_time);
  		(void) strncpy(ll.ll_line, tty, sizeof(ll.ll_line));
***************
*** 2210,2215 ****
--- 2238,2246 ----
  		(void)write(fd, (char *)&ll, sizeof(ll));
  		(void)close(fd);
  	}
+ #ifdef sgi
+         free(fname);
+ #endif
  #endif
  }
  
***************
*** 2242,2248 ****
  	char *host;
  {
  	static char lusername[UT_NAMESIZE+1];
- 	char rusername[UT_NAMESIZE+1];
  
  	lgetstr(rusername, sizeof(rusername), "Remote user");
  	lgetstr(lusername, sizeof(lusername), "Local user");
--- 2273,2278 ----
>Audit-Trail:
>Unformatted:
>Architecture:	*


home help back first fref pref prev next nref lref last post