bug-cvs
[Top][All Lists]
Advanced

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

assertion error using LockDir and repository with symlinks


From: mch
Subject: assertion error using LockDir and repository with symlinks
Date: Sun, 29 Sep 2002 21:44:57 -0500

>Submitter-Id:   net
>Originator:     Matthew Howard
>Organization:
net
>Confidential:  no
>Synopsis:      assertion error when using LockDir and the repository has 
>symlinks 
>Severity:      non-critical
>Priority:      low
>Category:      cvs
>Class:         sw-bug
>Release:       1.11.2
>Environment:
        
System: Linux 2.4.18-10 #1 Wed Aug 7 11:39:21 EDT 2002 i686 unknown
Architecture: i686

>Description:

When specifying a LockDir other than the repository, and the repository is 
accessed with symbolic links in the path, an assertion error will cause cvs to 
exit
while attempting a 'cvs rtag'.

The assertion spits out the following line:

cvs: lock.c:177: lock_name: Assertion `(__extension__ (__builtin_constant_p 
(strlen (current_parsed_root->directory)) && ((__builtin_constant_p 
(repository) && strlen (repository) < ((size_t) (strlen 
(current_parsed_root->directory)))) || (__builtin_constant_p 
(current_parsed_root->directory) && strlen (current_parsed_root->directory) < 
((size_t) (strlen (current_parsed_root->directory))))) ? __extension__ etc. 
etc. etc. ...

This problem was causing me headaches when the repository I used, which I 
commonly refered to using /home/cvs/cvsroot, was moved onto a newly mounted 
drive, with symbolic links used to keep the same CVSROOT.

>How-To-Repeat:

        1) initialize a repository, let's say in: /mnt/disk/cvs/testroot
        2) create a symbolic link to this: 'ln -s /mnt/disk/cvs/testroot 
/home/cvs/testroot'
        3) configure cvs to use a LockDir=/var/lock/cvs/testroot
        4) create a project with some files in it
        5) attempt an rtag as follows:
                cvs -d/home/cvs/testroot rtag SOME_TAG some_project
                
>Fix:

The fix appears to be to expand symbolic links in the repository directory that 
is passed to the cvs server.

I have been using the following patch, which is working fine for me under 
linux, 
although I realize that the patch is not portable.  I'm providing it simply in 
the hope
that it may help in finding a permanent solution.

I have not included the files: expand_symlinks.[ch], but would be happy to 
submit
them upon request.

Regards,

Matthew Howard


--- cvs-1.11.2/src/root.c       Thu Jul  5 14:11:39 2001
+++ cvs-1.11.2.new/src/root.c   Sun Sep 29 21:11:38 2002
@@ -12,6 +12,8 @@
 #include "cvs.h"
 #include "getline.h"
 
+#include "expand_symlinks.h"
+
 /* Printable names for things in the current_parsed_root->method enum variable.
    Watch out if the enum is changed in cvs.h! */
 
@@ -661,6 +663,23 @@
        error (0, 0, "Missing directory in CVSROOT.");
        goto error_exit;
     }
+
+    /* MCH: expand any symbolic links in newroot->directory */
+#ifdef CLIENT_SUPPORT
+    if (!newroot->isremote)
+#endif
+    {
+       char *expanded = NULL;
+
+       if (expand_symlinks(newroot->directory, &expanded, NULL)) {
+               error (0, 0, "failed to expand symlinks for: %s", 
newroot->directory);
+               goto error_exit;
+       }
+
+       free(newroot->directory);
+       newroot->directory = expanded;
+    }
+
     
     /* Hooray!  We finally parsed it! */
     return newroot;
@@ -733,7 +752,12 @@
 
     newroot->original = xstrdup(dir);
     newroot->method = local_method;
-    newroot->directory = xstrdup(dir);
+    newroot->directory = NULL;
+
+    if (expand_symlinks(dir, &newroot->directory, NULL)) {
+       free_cvsroot_t(newroot);
+       return NULL;
+    }
 
     return newroot;
 }
--- cvs-1.11.2/src/server.c     Tue Mar 19 13:15:45 2002
+++ cvs-1.11.2.new/src/server.c Sun Sep 29 21:11:47 2002
@@ -16,6 +16,8 @@
 #include "getline.h"
 #include "buffer.h"
 
+#include "expand_symlinks.h"
+
 #if defined(SERVER_SUPPORT) || defined(CLIENT_SUPPORT)
 # ifdef HAVE_GSSAPI
 /* This stuff isn't included solely with SERVER_SUPPORT since some of these
@@ -1158,8 +1160,23 @@
     status = buf_read_line (buf_from_net, &repos, (int *) NULL);
     if (status == 0)
     {
+       char *expanded_repos = NULL;
+
+       if (expand_symlinks(repos, &expanded_repos, NULL))
+       {
+               if (alloc_pending (80 + strlen(repos)))
+                       sprintf(pending_error_text, "E failed to expand 
repository: %s", repos);
+               else
+                       pending_error = ENOMEM;
+               return;
+       }
+
+       free(repos);
+       repos = expanded_repos;
+
        if (!outside_root (repos))
            dirswitch (arg, repos);
+
        free (repos);
     }
     else if (status == -2)




reply via email to

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