On Wed, May 23, 2001 at 05:03:58PM -0400, Larry Jones wrote:
> Donald Sharp writes:
> > 
> > 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.
> [...]
> 
> Doesn't the chdir into the root directory and xgetwd obviate the need
> for the old readlink call?  In other words, shouldn't the new code deal

Your right.  New patch attached.

donald
> with symlinks as well as mount points?  If so, it should just replace
> the old code rather than augmenting it.
> 
> -Larry Jones
> 
> They can make me do it, but they can't make me do it with dignity. -- Calvin
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   24 May 2001 11:49:40 -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  24 May 2001 11:49:40 -0000
***************
*** 382,412 ****
  safe_location ()
  {
      char *current;
!     char hardpath[PATH_MAX+5];
      size_t hardpath_len;
-     int  x;
      int retval;
  
! #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?
!        (by returning sizeof hardpath - 1?).  */
!     x = readlink(current_parsed_root->directory, hardpath, sizeof hardpath - 1);
! #else
!     x = -1;
! #endif
!     if (x == -1)
      {
!         strcpy(hardpath, current_parsed_root->directory);
!     }
!     else
!     {
!         hardpath[x] = '\0';
      }
      current = xgetwd ();
      if (current == NULL)
        error (1, errno, "could not get working directory");
      hardpath_len = strlen (hardpath);
      if (strlen (current) >= hardpath_len
        && strncmp (current, hardpath, hardpath_len) == 0)
      {
--- 382,408 ----
  safe_location ()
  {
      char *current;
!     char *hardpath;
      size_t hardpath_len;
      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 );
      }
+ 
      current = xgetwd ();
      if (current == NULL)
        error (1, errno, "could not get working directory");
+ 
+     if( chdir( current_parsed_root->directory ) == -1 )
+       error( 1, errno, "could not change directory into repository" );
+ 
+     hardpath = xgetwd();
      hardpath_len = strlen (hardpath);
+ 
      if (strlen (current) >= hardpath_len
        && strncmp (current, hardpath, hardpath_len) == 0)
      {
***************
*** 422,429 ****
            retval = 1;
      }
      else
!       retval = 1;
!     free (current);
      return retval;
  }
  
--- 418,430 ----
            retval = 1;
      }
      else
!         retval = 1;
!       
!     if( chdir( current ) == -1 )
!         error( 1, errno, "Unable to change back into Correct Current Working 
Directory" );
! 
!     free( current );
!     free( hardpath );
      return retval;
  }
  

Reply via email to