You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Josh Siegel <jo...@stormbirds.org> on 2005/02/17 19:25:07 UTC

PATCH: simple regexp support in mod_authz_svn

These patches give you both simple regular expression support (unix 
shell like) in mod_authz_svn as well as the ability to make all string 
comparisons case insensitive. You turn on regular expression support by 
setting AuthzSVNRegexp in your apache.conf file.  Setting 
AuthzSVNCaseInsensitiveNameMatches to On makes all checks case 
insensitive. 

Once you've done this,  you can do things like

[foo:/tags/*/bar]
@group1 = r

[foo:/branches/*/bar]
@group1 = rw

Currently, the only shell regexp's it supports are * and ?.  It does not 
support {a,b,c}

Regards,
Josh Siegel


Re: PATCH: simple regexp support in mod_authz_svn

Posted by Martin Furter <mf...@rola.ch>.
On Thu, 19 Feb 2009, Gabriel Ferreira Teles Gomes wrote:

> Hi there,
>
> I don't know where to look at, but have you sent the updated patch you said you would?
>
> If you haven't, I would like to try and contribute with this.
>
> My CEO asked me to block some of the repository contents, and it would be very nice to have the wildcard matching functionality working.
>
> Can you help me out with that?

There's a patch in the issue tracker which adds wildcards:
http://subversion.tigris.org/issues/show_bug.cgi?id=2662

It's sitting there since more than two years, so it probably doesn't apply 
cleanly anymore and needs some work to get it running again...

HTH
Martin

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=1205834

Re: PATCH: simple regexp support in mod_authz_svn

Posted by Gabriel Ferreira Teles Gomes <ga...@gmail.com>.
Hi there,

I don't know where to look at, but have you sent the updated patch you said you would?

If you haven't, I would like to try and contribute with this.

My CEO asked me to block some of the repository contents, and it would be very nice to have the wildcard matching functionality working.

Can you help me out with that?
I don't know exactly how to patch anything, but I could learn.

Thanks,
Gabriel

PS: Sorry for the poor English, it's not my native language.

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=1192176

Re: PATCH: simple regexp support in mod_authz_svn

Posted by Josh Siegel <jo...@stormbirds.org>.
*doah*  apr_fnmatch...  I will send out a updated patch with these 
suggestions

        --josh siegel


André Malo wrote:

>* Josh Siegel wrote:
>
>  
>
>>These patches give you both simple regular expression support (unix
>>shell like) in mod_authz_svn as well as the ability to make all string
>>comparisons case insensitive. You turn on regular expression support by
>>setting AuthzSVNRegexp in your apache.conf file.  Setting
>>AuthzSVNCaseInsensitiveNameMatches to On makes all checks case
>>insensitive.
>>    
>>
>
>Uuh. First I wouldn't call it regex. The stuff is called wildcards :)
>Second, I wouldn't name the directives that long (Further I'd compress them 
>into one directive AuthzSVNOptions or so). And last but not least, apache 
>itself provides full featured regexps (PCRE) and fnmatch functions, which 
>should be used. I could help to rework the patch accordingly, if you like.
>
>nd
>  
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: PATCH: simple regexp support in mod_authz_svn

Posted by André Malo <nd...@perlig.de>.
* Josh Siegel wrote:

> These patches give you both simple regular expression support (unix
> shell like) in mod_authz_svn as well as the ability to make all string
> comparisons case insensitive. You turn on regular expression support by
> setting AuthzSVNRegexp in your apache.conf file.  Setting
> AuthzSVNCaseInsensitiveNameMatches to On makes all checks case
> insensitive.

Uuh. First I wouldn't call it regex. The stuff is called wildcards :)
Second, I wouldn't name the directives that long (Further I'd compress them 
into one directive AuthzSVNOptions or so). And last but not least, apache 
itself provides full featured regexps (PCRE) and fnmatch functions, which 
should be used. I could help to rework the patch accordingly, if you like.

nd
-- 
"Das Verhalten von Gates hatte mir bewiesen, dass ich auf ihn und seine
beiden Gefährten nicht zu zählen brauchte" -- Karl May, "Winnetou III"

Im Westen was neues: <http://pub.perlig.de/books.html#apache2>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org


Re: PATCH: simple regexp support in mod_authz_svn

Posted by Branko Čibej <br...@xbc.nu>.
Josh Siegel wrote:

>
> These patches give you both simple regular expression support (unix 
> shell like) in mod_authz_svn as well as the ability to make all string 
> comparisons case insensitive. You turn on regular expression support 
> by setting AuthzSVNRegexp in your apache.conf file.  Setting 
> AuthzSVNCaseInsensitiveNameMatches to On makes all checks case 
> insensitive.
> Once you've done this,  you can do things like
>
> [foo:/tags/*/bar]
> @group1 = r
>
> [foo:/branches/*/bar]
> @group1 = rw
>
> Currently, the only shell regexp's it supports are * and ?.  It does 
> not support {a,b,c}
>
> Regards,
> Josh Siegel
>
>------------------------------------------------------------------------
>
>Index: subversion/mod_authz_svn/mod_authz_svn.c
>===================================================================
>--- subversion/mod_authz_svn/mod_authz_svn.c	(revision 13038)
>+++ subversion/mod_authz_svn/mod_authz_svn.c	(working copy)
>@@ -27,6 +27,7 @@
> #include <http_log.h>
> #include <ap_config.h>
> #include <apr_uri.h>
>+#include <apr_hash.h>
> #include <mod_dav.h>
> 
> #include "mod_dav_svn.h"
>@@ -47,6 +48,8 @@
> typedef struct {
>     int authoritative;
>     int anonymous;
>+    int regexp;
>  
>
The way you describe this, it's not regexp matching but wildcard matching.

>+    int caseInsensitiveNameMatches;
>  
>
Follow Subversion naming conventions, please. This name is way too long, 
and shouldn't contain uppercase letters. I suggest "case_folding", or 
just "fold_case".

>@@ -105,7 +118,7 @@
>  * Access checking
>  */
> 
>-static int group_contains_user_internal(svn_config_t *cfg,
>+static int group_contains_user_internal(svn_config_t *cfg, const int caseInsensitive,
>  
>
Don't declare "const int" parameters. This is a call-by-value, so the 
caller doesn't care about the const anyway. again, the name of the 
parameter doesn't conform; "fold_case" woudl do here, too.


>@@ -204,12 +218,18 @@
> 
>     baton.pool = pool;
>     baton.config = cfg;
>+    baton.aconfig = acfg;
>     baton.user = user;
> 
>     /* First try repos specific */
>     qualified_repos_path = apr_pstrcat(pool, repos_name, ":", repos_path,
>                                        NULL);
>-    svn_config_enumerate(cfg, qualified_repos_path,
>+
>+    if (acfg->regexp)
>+      svn_config_enumerate_regexp(cfg, qualified_repos_path,
>+        acfg->caseInsensitiveNameMatches ? 0x5 : 0x4, parse_authz_line, &baton);
>  
>
Hello? Whata are these magic numbers doing here?

>+    else
>+      svn_config_enumerate(cfg, qualified_repos_path,
>                          parse_authz_line, &baton);
>     *granted_access = !(baton.deny & required_access)
>                       || (baton.allow & required_access);
>@@ -218,7 +238,11 @@
>         || (baton.allow & required_access))
>         return TRUE;
> 
>-    svn_config_enumerate(cfg, repos_path,
>+    if (acfg->regexp)
>+      svn_config_enumerate_regexp(cfg, repos_path,
>+        acfg->caseInsensitiveNameMatches ? 0x5 : 0x4, parse_authz_line, &baton);
>  
>
and here?

>Index: subversion/include/svn_config.h
>===================================================================
>--- subversion/include/svn_config.h	(revision 13038)
>+++ subversion/include/svn_config.h	(working copy)
>@@ -235,6 +235,43 @@
>                           svn_config_enumerator_t callback, void *baton);
> 
> 
>+/** 
>+ * The regular expression matcher used by svn_config_enumerate_regexp 
>+ *
>+ * This uses regular expressions similer to directory paths.  It supports
>+ * the '*' and the '?' modifier.  It does not support the bracket "{a,b,c}" notation
>+ * yet.
>+ *
>+ * flags:
>+ *   0x1 - case insensitive search
>+ *
>+ * returns:
>+ *   0 - does not match
>+ *   1 - matches entire string
>+ *   2 - left text after matching the pattern
>+ */
>+int svn_config_regexp(const char * str, const char *pattern, const int flags);
>+
>+/** Enumerate the sections, treating each section header as a regular expressio, 
>+ * passing @a baton and the current section's name to
>+ * @a callback.
>+ *
>+ * Return the number of times @a callback was called.
>+ *
>+ * ### See kff's comment to @c svn_config_enumerate.  It applies to this
>+ * function, too. ###
>+ *
>+ * @a callback's @a name and @a name parameters are only valid for the
>+ * duration of the call.
>+ *
>+ * flags:
>+ *   0x1 - case insensitive search
>+ *   0x2 - stop on first match
>+ *   0x4 - only match entire string
>+ */
>+int svn_config_enumerate_regexp (svn_config_t *cfg, const char *section, const int flags,
>+                               svn_config_enumerator_t callback, void *baton);
>+
>  
>

Sigh. Second of all, you completely missed the fact that there's an 
apr_fnmatch API that does what you're duplicating here, and more.

But first of all, you've committed the deadly sin of Not Defining Named 
Constants For Magic Numbers.

And I'm pretty sure we don't want this functionality in svn_config. You 
can do the same in an enumerator callback in mod_dav_svn, using Apache's 
wildcard (or even regexp) matching functions. This isn't even faster, 
because you can filter the section names in the callback from 
svn_config_enumerate_sections.

-- Brane


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org