bug-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Patch to lock.c


From: Ulrich Kunitz
Subject: Patch to lock.c
Date: Tue, 24 Jul 2001 01:30:12 +0200
User-agent: Mutt/1.2.5i

Hello,

I hope that mailing list is still active, it's still in the HACKING file
in the CVS tree. The website www.cvshome.org seems to have problems.

I'm using cvs-1.11.1.p1 from the source. I'm using also the LockDir
parameter in CVSROOT/config.

Im using :local:/home/kunitz/CVS but /home is a symbolic link to
/vol/2/home. The code in lock_name() from lock.c gets trouble with cvs
rtag, because the input parameter repository is containing the full
resolved path /vol/2/home/kunitz/CVS/<module> but
current_parsed_root->directory contains /home/kunitz/CVS. For cvs co or
cvs release that doesn't seem to be a problem.

I decided to normalize both parameters using xgetwd(). Here is the
patch:

--- lock.c.orig Mon Jul 23 23:52:13 2001
+++ lock.c      Tue Jul 24 01:27:00 2001
@@ -75,6 +75,8 @@
 #include "cvs.h"
 #include <assert.h>
 
+#include <savecwd.h>
+
 struct lock {
     /* This is the directory in which we may have a lock named by the
        readlock variable, a lock named by the writelock variable, and/or
@@ -169,19 +171,49 @@
     {
        struct stat sb;
        mode_t new_mode = 0;
+       char* normal_repository = 0;
+
+       {
+           char* normal_cvsroot_dir;
+           struct saved_cwd cwd;
 
-       /* The interesting part of the repository is the part relative
-          to CVSROOT.  */
-       assert (current_parsed_root != NULL);
-       assert (current_parsed_root->directory != NULL);
-       assert (strncmp (repository, current_parsed_root->directory,
-                        strlen (current_parsed_root->directory)) == 0);
-       short_repos = repository + strlen (current_parsed_root->directory) + 1;
+           /* The interesting part of the repository is the part relative
+           to CVSROOT.  */
+           assert (current_parsed_root != NULL);
+           assert (current_parsed_root->directory != NULL);
+
+           /* Assume CVSROOT is on /home/user/CVS and home is a symbolic
+            * link to /vol/2/home.
+            * Under different circumstances repository and
+            * current_parsed_root->directory might use /home/user/..
+            * or /vol/2/home/user.
+            *
+            * We normalize by using xgetwd().
+            */
+           if (save_cwd(&cwd))
+               error(1, 0, "can't save cwd");
+           if (chdir(repository) < 0)
+               error(1, errno, "can't change to %s", repository);
+           normal_repository = xgetwd();
+           if (chdir(current_parsed_root->directory) < 0)
+               error(1, errno, "can't change to %s",
+                           current_parsed_root->directory);
+           normal_cvsroot_dir = xgetwd();
+           if (restore_cwd(&cwd, 0))
+               error(1, 0, "can't restore cwd");
+           free_cwd(&cwd);
+
+           assert (strncmp (normal_repository, normal_cvsroot_dir,
+                       strlen (normal_cvsroot_dir)) == 0);
+           short_repos = normal_repository + strlen (normal_cvsroot_dir) + 1;
 
-       if (strcmp (repository, current_parsed_root->directory) == 0)
-           short_repos = ".";
-       else
-           assert (short_repos[-1] == '/');
+           if (strcmp (normal_repository, normal_cvsroot_dir) == 0)
+               short_repos = ".";
+           else
+               assert (short_repos[-1] == '/');
+
+           free(normal_cvsroot_dir);
+       }
 
        retval = xmalloc (strlen (lock_dir)
                          + strlen (short_repos)
@@ -275,6 +307,8 @@
            assert (umask (save_umask) == 0000);
            saved_umask = 0;
        }
+
+       free(normal_repository);
     }
     return retval;
 }

Being conform with your HACKING file, I grant permission to distribute
this patch under the terms of the GNU Public License. And here is the
patch to the ChangeLog file:

--- ChangeLog.orig      Thu Apr 26 20:12:56 2001
+++ ChangeLog   Tue Jul 24 01:09:42 2001
@@ -1,3 +1,7 @@
+2001-07-24  Ulrich Kunitz <gefm21@uumail.de>
+
+       * patch to lock.c for handling symbolic links in CVSROOT path
+
 2001-04-26  Derek Price  <dprice@collab.net>
 
        * cvs.spec.in: Don't include %{_infodir}/dir.

Ciao,

Uli Kunitz

-- 
Ulrich Kunitz (gefm21@uumail.de)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]