There are certain situations where cvs will allow the user
to checkout a module inside of the repository when a nfs server
and auto mounting is done.  Here's a small patch that will 
fix this issue.

This patch modifies the current behaviour of checkout.c, safe_location()
to assume that you are not inside of the repository if you are using cvs
in a remote manner.

I did not include a change to sanity.sh as that it would need root
access, a nfs server and access to a automounting system on your
test machine.

The patch is included as a attachment.

Thanks!

donald
Index: ChangeLog
===================================================================
RCS file: /home2/cvsroot/ccvs/src/ChangeLog,v
retrieving revision 1.2117
diff -c -r1.2117 ChangeLog
*** ChangeLog   27 Apr 2001 20:45:17 -0000      1.2117
--- ChangeLog   23 May 2001 20:40:18 -0000
***************
*** 1,3 ****
--- 1,8 ----
+ 2001-05-23  Donald Sharp <[EMAIL PROTECTED]>
+ 
+       * checkout.c: Fixed problem where it was possible to checkout code
+     inside of a repository due to automounter and nfs issues.
+ 
  2001-04-27  Derek Price  <[EMAIL PROTECTED]>
  
        * version.c: Regenerated.
Index: checkout.c
===================================================================
RCS file: /home2/cvsroot/ccvs/src/checkout.c,v
retrieving revision 1.98
diff -c -r1.98 checkout.c
*** checkout.c  16 Apr 2001 17:53:10 -0000      1.98
--- checkout.c  23 May 2001 20:40:18 -0000
***************
*** 387,392 ****
--- 387,398 ----
      int  x;
      int retval;
  
+     /* If the parsed_root is a remote connection *assume* that
+        everything is ok, and let the chips fall where they may. */
+     if( current_parsed_root->isremote )
+     {
+       return( 1 );
+     }
  #ifdef HAVE_READLINK
      /* FIXME-arbitrary limit: should be retrying this like xgetwd.
         But how does readlink let us know that the buffer was too small?
***************
*** 422,428 ****
            retval = 1;
      }
      else
!       retval = 1;
      free (current);
      return retval;
  }
--- 428,466 ----
            retval = 1;
      }
      else
!     {
!         char *root_hardpath;
!         size_t root_hardpath_len;  
!         if( chdir( hardpath ) == -1 )
!             error( 1, errno, "Unable to change Directory into Repository" );
!       
!         root_hardpath = xgetwd();
!         if( root_hardpath == NULL )
!             error( 1, errno, "could not get working directory" );
!         root_hardpath_len = strlen( root_hardpath );
!         if( strlen( current ) >= root_hardpath_len
!             && strncmp( current, root_hardpath, root_hardpath_len ) == 0 )
!         {
!             if( /* Current is a subdirectory of hardpath.  */
!                 current[root_hardpath_len] == '/'
!                   
!                 /* Current is hardpath itself.  */
!                 || current[root_hardpath_len] == '\0')
!                 retval = 0;
!             else
!                 /* It isn't a problem.  For example, current is
!                    "/foo/cvsroot-bar" and hardpath is "/foo/cvsroot".  */
!                 retval = 1;
!         }
!         else
!             retval = 1;
!       
!         if( chdir( current ) == -1 )
!             error( 1, errno, "Unable to change back into Correct Current Working 
Directory" );
! 
!         free( root_hardpath );
!     }
! 
      free (current);
      return retval;
  }

Reply via email to