You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Bastiaan Bakker <ba...@lifeline.nl> on 2005/02/11 15:46:39 UTC

PATCH: symlink support for svn_load_dirs.pl

Hi,

While importing Postfix sources with svn_load_dirs.pl I noticed that it
doesn't support importing symlinks yet, ignoring them instead. However
symlink support turned out to be easy to add, see attached patch against
TRUNK.
Some notes:
a) the patch uses system('cp -d ...') to recreate the symlink in the
temporary dir. This may not be avaiable on all platforms that have
symlink support?
b) I've not checked the cases were symlinks have been changed into
regular files and vice versa or where the link targets have been
changed. The code follows the 'regular file' case here.

Regards,

Bastiaan Bakker
E.Novation LifeLine Networks bv

PS. I'm not subscribed to the list, so could you please CC me directly
in replies.


  

Re: PATCH: symlink support for svn_load_dirs.pl

Posted by Bastiaan Bakker <ba...@lifeline.nl>.
On Mon, 2005-02-14 at 14:32 -0600, Travis P wrote:
> On Feb 11, 2005, at 9:46 AM, Bastiaan Bakker wrote:
> 
> > Some notes:
> > a) the patch uses system('cp -d ...') to recreate the symlink in the
> > temporary dir. This may not be avaiable on all platforms that have
> > symlink support?
> 
> The '-d' flag is not portable.  I see that AIX 5.1 and MacOS X 10.3.7
> don't support that flag.  Both systems do support Un*x style symlinks
> of course.
> 
> Unfortunately, I've observed that 'cp' flags are very inconsistent 
> across
> systems.  The only flags that appear consistent to me across AIX 5.2,
> MacOS 10.3.7, and a Linux RH 7.3 system are '-p', '-R', '-i', and '-f'.
> 
> -Travis
> 

Right, system("cp ...") was a lazy shortcut to get the thing working.
Attached is a new version which uses the internal Perl functions
readlink and symlink. Should be portable for all platforms that support
symlinks. 

Regards,

Bastiaan Bakker
E.Novation LifeLine Networks bv


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

PATCH: simple regexp support in mod_authz_svn

Posted by Josh Siegel <jo...@stormbirds.org>.
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: symlink support for svn_load_dirs.pl

Posted by Michael W Thelen <mi...@pietdepsi.com>.
Bastiaan Bakker wrote:
> After looking at svn_load_dirs.pl some more, I realized that the way it
> detects updated files doesn't work for symlinks: rather than comparing
> the contents of the old and new revision of the file it should compare
> where the old and new symlinks point to.
> Attached is version 1.2 of the symlink patch which solves this by
> adapting digest_hash_file: for symlinks it returns the link as digest
> instead of an MD5 over the contents of the file.
> Limitations of the current patch:
> 1) can't handle dangling symlink. Mainly caused by the fact that the
> diff util can't handle them
> 2) can't handle regularing files becoming symlinks and vice versa.

Thank you for the patch, I've filed it as issue #2241:
http://subversion.tigris.org/issues/show_bug.cgi?id=2241

--
Michael W Thelen
It is a mistake to think you can solve any major problems just with
potatoes.       -- Douglas Adams

Re: PATCH: symlink support for svn_load_dirs.pl

Posted by Bastiaan Bakker <ba...@lifeline.nl>.
Hi,

After looking at svn_load_dirs.pl some more, I realized that the way it
detects updated files doesn't work for symlinks: rather than comparing
the contents of the old and new revision of the file it should compare
where the old and new symlinks point to. 
Attached is version 1.2 of the symlink patch which solves this by
adapting digest_hash_file: for symlinks it returns the link as digest
instead of an MD5 over the contents of the file.
Limitations of the current patch:
1) can't handle dangling symlink. Mainly caused by the fact that the
diff util can't handle them
2) can't handle regularing files becoming symlinks and vice versa.

Regards,

Bastiaan Bakker
E.Novation LifeLine Networks bv


Re: PATCH: symlink support for svn_load_dirs.pl

Posted by Travis P <sv...@castle.fastmail.fm>.
On Feb 11, 2005, at 9:46 AM, Bastiaan Bakker wrote:

> Some notes:
> a) the patch uses system('cp -d ...') to recreate the symlink in the
> temporary dir. This may not be avaiable on all platforms that have
> symlink support?

The '-d' flag is not portable.  I see that AIX 5.1 and MacOS X 10.3.7
don't support that flag.  Both systems do support Un*x style symlinks
of course.

Unfortunately, I've observed that 'cp' flags are very inconsistent 
across
systems.  The only flags that appear consistent to me across AIX 5.2,
MacOS 10.3.7, and a Linux RH 7.3 system are '-p', '-R', '-i', and '-f'.

-Travis


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