[2828] in Release_Engineering

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

Re: Problem with setpag and login/xlogin

daemon@ATHENA.MIT.EDU (Richard Basch)
Sun May 17 21:18:11 1992

Date: Sun, 17 May 92 21:17:36 -0400
To: epeisach@MIT.EDU
Cc: builder@MIT.EDU, rel-eng@MIT.EDU
In-Reply-To: Ezra Peisach's message of Sun, 17 May 92 11:35:06 -0400,
From: "Richard Basch" <basch@MIT.EDU>


This may be a solution...
Someone should definitely check it over...

Please note that I did not trust some of the previous tests in some
cases; I felt that it may be possible for certain conditions to arise
where various errors might return "local" rather than remote.  I was
able to demonstrate that open(dir,...) would fail on NFS filesystems if
permission did not exist and it was still mounted, so I included the
device check whenever possible.

-Richard

*** /tmp/,RCSt1UloAK1	Sun May 17 21:16:22 1992
--- verify.c	Sun May 17 21:16:18 1992
***************
*** 879,926 ****
  
  
  /* Function Name: IsRemoteDir
!  * Description: Stolen form athena's version of /bin/login
!  *              returns true of this is an NFS directory.
!  * Arguments: dname - name of the directory.
   * Returns: true or false to the question (is remote dir).
   *
!  * The following lines rely on the behavior of Sun's NFS (present in
!  * 3.0 and 3.2) which causes a read on an NFS directory (actually any
!  * non-reg file) to return -1, and AFS which also returns a -1 on
!  * read (although with a different errno).  This is a fast, cheap
!  * way to discover whether a user's homedir is a remote filesystem.
!  * Naturally, if the NFS and/or AFS semantics change, this must also change.
   */
  
  IsRemoteDir(dir)
  char *dir;
  {
! #if !defined(_AIX)
      int f;
      char c;
      struct stat stbuf;
    
!     if (lstat(dir, &stbuf))
! 	return(FALSE);
!     if (!(stbuf.st_mode & S_IFDIR))
  	return(TRUE);
  
!     if ((f = open(dir, O_RDONLY, 0)) < 0)
! 	return(FALSE);
! 
!     if (read(f, &c, 1) < 0) {
  	close(f);
  	return(TRUE);
      }
- 
      close(f);
      return(FALSE);
- #else /* AIX */
-     struct stat stbuf;
- 
-     if (statx(dir, &stbuf, 0, STX_NORMAL))
- 	return(FALSE);
-     return((stbuf.st_flag & FS_REMOTE) ? TRUE : FALSE);
  #endif
  }
  
--- 879,946 ----
  
  
  /* Function Name: IsRemoteDir
!  * Arguments: dir - name of the directory.
   * Returns: true or false to the question (is remote dir).
+  *    false may also indicate that no directory exists.
   *
!  * If we cannot stat/open the directory, and the error was not ENOENT,
!  * we will assume the directory is remote.  Getting information about
!  * a directory may not be possible if the pre-requisite authentication
!  * has not yet been performed.
!  *
!  * With AIX, we only need to check the FS_REMOTE flag.
!  *
!  * Under other systems, we rely on the behavior of Sun's NFS
!  * which causes a read on an NFS directory (or any non-regular file)
!  * to return -1.  However, because this doesn't work with AFS, we
!  * also check the device number.
!  * 
!  * If the semantics change, this function has to be revised!!!
   */
  
  IsRemoteDir(dir)
  char *dir;
  {
! #if defined(_AIX)
! #define REMOTEDONE
!     struct stat stbuf;
! 
!     if (statx(dir, &stbuf, 0, STX_NORMAL))
! 	return((errno==ENOENT) ? FALSE : TRUE);
!     return((stbuf.st_flag & FS_REMOTE) ? TRUE : FALSE);
! #endif
! 
! #if !defined(REMOTEDONE)
! 
! #if (defined(vax) && !defined(ultrix)) || defined(ibm032)
! #define CHECK_NFSDEV
! #endif
! 
      int f;
      char c;
      struct stat stbuf;
    
!     if (stat(dir, &stbuf))
! 	return((errno==ENOENT) ? FALSE : TRUE);
! 
!     switch(stbuf.st_rdev) {
!     case 0x0001:				/* AFS */
! #ifdef CHECK_NFSDEV
!     case 0xff00:				/* NFS */
! #endif
  	return(TRUE);
+ 	break;
+     }
  
! #ifndef CHECK_NFSDEV
!     if ((f = open(dir, O_RDONLY, 0)) < 0 ||
! 	read(f, &c, 1) < 0) {
  	close(f);
  	return(TRUE);
      }
      close(f);
+ #endif
      return(FALSE);
  #endif
  }
  

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