[2773] in Release_Engineering

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

dm.c fix

daemon@ATHENA.MIT.EDU (Mark Rosenstein)
Thu Apr 16 23:55:37 1992

Date: Thu, 16 Apr 92 23:55:24 -0400
From: Mark Rosenstein <mar@MIT.EDU>
To: rel-eng@MIT.EDU

This is one of the "dialup derived fixes".  It corrects the locking
protocol used with /etc/passwd.  xlogin and /bin/login are already
accounted for.  Next I'll check rlogind and cleanup.  Anything else
we've written that may be this protocol wrong?
					-Mark

*** /source/athena/athena.etc/xdm/dm/dm.c	Sun Apr  5 16:41:09 1992
--- dm.c	Thu Apr 16 23:41:36 1992
***************
*** 1031,1049 ****
  
      if (!strcmp(login, "root")) return;
  
!     while ((access(passwdtf, F_OK) == 0) && --count) {
! 	alarm(1);
! 	sigpause(0);
      }
-     if (count == 0) unlink(passwdtf);
- 
      oldfile = open(passwdf, O_RDONLY, 0);
      if (oldfile < 0) return;
-     newfile = open(passwdtf, O_WRONLY|O_CREAT|O_TRUNC, 0644);
-     if (newfile < 0) {
- 	close(oldfile);
- 	return;
-     }
  
      /* process each line of file */
      cc = read(oldfile, buf, BUFSIZ);
--- 1031,1052 ----
  
      if (!strcmp(login, "root")) return;
  
!     for (count = 0; count < 10; count++)
!       if ((newfile = open(passwdtf, O_RDWR|O_CREAT|O_EXCL, 0644)) == -1 &&
! 	  errno == EEXIST) {
! 	  alarm(1);
! 	  sigpause(0);
!       } else
! 	break;
!     if (newfile == -1) {
! 	if (count < 10)
! 	  return(errno);
! 	else
! 	  (void) unlink(passwdtf);
! 	return;
      }
      oldfile = open(passwdf, O_RDONLY, 0);
      if (oldfile < 0) return;
  
      /* process each line of file */
      cc = read(oldfile, buf, BUFSIZ);

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