bug-cvs
[Top][All Lists]
Advanced

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

RE: Allowing regular expression in --allow-root option


From: Hier, Steve
Subject: RE: Allowing regular expression in --allow-root option
Date: Thu, 4 Oct 2001 14:44:44 -0700

I've been using a patch like this for years -- it is quite handy to be able
to specify a "family" of directories that are valid instead of creating
some huge (in many cases too large to pass) command line...

Regular expressions would be an improvement from what I'm using.
My patch allows one to specify the a "root node" from which repositories
can be used under.

-----Original Message-----
From: Christian BAYLE [mailto:christian.bayle@rd.francetelecom.com]
Sent: Thursday, October 04, 2001 2:23 PM
To: bug-cvs@gnu.org
Subject: Allowing regular expression in --allow-root option


This is not a bug, but as my message was rejected by the dev list
with recommendation to send there 
I do it

I found this patch that allow the use of regular expression with 
--allow-root option
These have been done by Gavin Walker
I find this usefull
Can this be added in cvs?

--- root.c.orig Sun Mar  7 21:17:02 1999
+++ root.c      Thu Dec 14 11:53:55 2000
@@ -261,9 +261,34 @@
     }
 
     for (i = 0; i < root_allow_count; ++i)
-       if (strcmp (root_allow_vector[i], arg) == 0)
+       if (strncmp (root_allow_vector[i], arg, strlen
(root_allow_vector[i]) ) == 0
+           && root_allow_ok_match(&arg[strlen(root_allow_vector[i])],
"^/[a-zA-Z][a-zA-Z0-9 -]+$"))
            return 1;
     return 0;
+}
+
+/*
+ * Match string against the extended regular expression in
+ * pattern, treating errors as no match.
+ *
+ * return 1 for match, 0 for no match
+ */
+
+int
+root_allow_ok_match (char * string, char * pattern)
+{
+     int  status;
+     regex_t   re;
+
+     if (regcomp(&re, pattern, REG_EXTENDED|REG_NOSUB) != 0) {
+         return 0;       /* report error */
+     }
+     status = regexec(&re, string, (size_t) 0, NULL, 0);
+     regfree(&re);
+     if (status != 0) {
+         return 0;       /* report error */
+     }
+     return 1;
 }
 
 /* This global variable holds the global -d option.  It is NULL if -d


Many thank if it's possible

Christian Bayle

_______________________________________________
Bug-cvs mailing list
Bug-cvs@gnu.org
http://mail.gnu.org/mailman/listinfo/bug-cvs



reply via email to

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