You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by Jason Heeris <ja...@gmail.com> on 2012/07/11 07:13:09 UTC
Square brackets in file names and authz (in VisualSVN 2.5.5)
(Please CC me on replies, I'm not subscribed to the list.)
My basic problem is: I want to restrict access (read and/or write) to paths
that contain spaces, square brackets and '#'s.
The details: I have an application that uses an SVN repo to store file
attachments. The paths to these attachments are also recorded in a MySQL
database — the path and revision information are used by the app. In order
to maintain uniqueness of paths, and to allow people to identify files in
the repository when working outside the app, all files are prefixed with an
ID, so the filenames have the form:
[12345] some file name.ext
Recently the requirement was added to impose SVN-level access control, so
after looking at the options I went with VisualSVN Server 2.5.5, which is
built on Apache Subversion 1.7.5. It gives me (and more importantly, my
manager) a GUI to manage access control. Under the hood, however, VisualSVN
seems to use an "authz-windows" file identical in format to the typical
"authz" file to maintain access control information.
The problem is this: it doesn't seem to work on files with the '[' or ']'
characters in their name. Ignoring VisualSVN's GUI for now, I've tried
going one step further and editing the "authz-windows" file by hand and I
just can't seem to get it to work. I've tried variations like:
[repo:/path/to/[12345] file.ext]
[repo:/path/to/%5B12345%5D%20file.ext]
[repo:"/path/to/[12345] file.ext"]
[repo:/path/to/\[12345\] file.ext]
...but none of them actually restrict access to the file in question. I can
restrict access to other files or paths in the same repository with the
same file, so I know that ACL works to some extent. I just can't find any
documentation that says that '[' or ']' are illegal in SVN, or that "authz"
style access control adds restrictions to characters. Also,
"svnauthz-validate" returns 0 for all of the above forms.
It's also worth pointing out that some paths have the "#" character in
them. What do I do when I get to those?
— Jason
Re: Square brackets in file names and authz (in VisualSVN 2.5.5)
Posted by Daniel Shahaf <d....@daniel.shahaf.name>.
Johan Corveleyn wrote on Thu, Jul 12, 2012 at 16:45:36 +0200:
> On Thu, Jul 12, 2012 at 2:06 PM, Daniel Shahaf <d....@daniel.shahaf.name> wrote:
> > Johan Corveleyn wrote on Thu, Jul 12, 2012 at 12:06:07 +0200:
> >> I think ']]' would be the best choice, but still not 100% backwards
> >> compatible. But I mean, who in their right mind would write sections
> >> like this:
> >>
> >> [repo:/path/to/file.ext]]haha, this isn't parsed
> >
> > We document the format as "ini format" and more specifically "same as
> > Python's ConfigParser", and the above isn't valid in either of those, so
> > we needn't provide back compat for it.
>
> Where is this documented?
>
ch07 #svn.advanced.confarea mentions that ~/.subversion/config is in
INI. I suppose the rest is "dev@ folks wisdom", aka: undocumented.
> Besides: for Python's ConfigParser (if I understand the code
> correctly) I think the above is valid in the way that it doesn't
> generate errors: everything after the first ']' is simply ignored.
>
Also everything before the first [. I suppose there might be logic
elsefile that allows only whitespace before/after the \[[^]]*\], but I
can't spend much time on that now (have $WORK, etc)
> --
> Johan
Re: Square brackets in file names and authz (in VisualSVN 2.5.5)
Posted by Johan Corveleyn <jc...@gmail.com>.
On Thu, Jul 12, 2012 at 2:05 PM, Daniel Shahaf <d....@daniel.shahaf.name> wrote:
> Johan Corveleyn wrote on Thu, Jul 12, 2012 at 11:28:18 +0200:
>> I think the only character that causes problems is ']' (which ends the
>> section name parsing). It seems not too hard to change that parsing
>
> Technically, 0x0A (newline) would likely be a problem too. Not sure
> that anyone uses it...
>
>> function to make it handle some kind of escape sequence for ']'
>
> What escape syntax does http://docs.python.org/library/configparser use?
I think it uses none.
I've just checked the source of ConfigParser.py in my Python 2.7
distribution, which contains this:
[[[
SECTCRE = re.compile(
r'\[' # [
r'(?P<header>[^]]+)' # very permissive!
r'\]' # ]
)
]]]
This regex is matched against lines, and the group named "header" is
taken as section name. So this seems to be effectively the same as our
parsing routine: after the '[', we take all non-']' until we encounter
']'.
On Thu, Jul 12, 2012 at 2:06 PM, Daniel Shahaf <d....@daniel.shahaf.name> wrote:
> Johan Corveleyn wrote on Thu, Jul 12, 2012 at 12:06:07 +0200:
>> I think ']]' would be the best choice, but still not 100% backwards
>> compatible. But I mean, who in their right mind would write sections
>> like this:
>>
>> [repo:/path/to/file.ext]]haha, this isn't parsed
>
> We document the format as "ini format" and more specifically "same as
> Python's ConfigParser", and the above isn't valid in either of those, so
> we needn't provide back compat for it.
Where is this documented?
Besides: for Python's ConfigParser (if I understand the code
correctly) I think the above is valid in the way that it doesn't
generate errors: everything after the first ']' is simply ignored.
--
Johan
Re: Square brackets in file names and authz (in VisualSVN 2.5.5)
Posted by Daniel Shahaf <d....@daniel.shahaf.name>.
Johan Corveleyn wrote on Thu, Jul 12, 2012 at 11:28:18 +0200:
> I think the only character that causes problems is ']' (which ends the
> section name parsing). It seems not too hard to change that parsing
Technically, 0x0A (newline) would likely be a problem too. Not sure
that anyone uses it...
> function to make it handle some kind of escape sequence for ']'
What escape syntax does http://docs.python.org/library/configparser use?
> (perhaps ']]'). Would you care to write a patch [2]?
>
> [1] http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/config_file.c?view=markup
> from line 315 onward (the comment says "Read chars until enounter ']' ...").
> [2] http://subversion.apache.org/docs/community-guide/general.html#patches
>
> --
> Johan
Re: Square brackets in file names and authz (in VisualSVN 2.5.5)
Posted by Jason Heeris <ja...@gmail.com>.
On 12 July 2012 17:51, Jason Heeris <ja...@gmail.com> wrote:
> I don't really know *what* constraints there are on honouring existing
> authz file syntax, whether or not it's explicitly specified.
Thorsten Schöning said: "How about just telling svn explicitly which
parse mode for section names one wants?"
I'd suggest that if you go down that road, URL escaping would be a
good idea and might avoid future pathological corner cases.
— Jason
Re: Square brackets in file names and authz (in VisualSVN 2.5.5)
Posted by Thorsten Schöning <ts...@am-soft.de>.
Guten Tag Jason Heeris,
am Donnerstag, 12. Juli 2012 um 11:51 schrieben Sie:
> I don't really know *what* constraints there are on honouring existing
> authz file syntax, whether or not it's explicitly specified.
How about just telling svn explicitly which parse mode for section
names one wants? If the current problem is that file name characters
interfere with authz configuration syntax and backwards compatibility
may become a problem because of relatively easy/weak rules for section
names before, just create a new, better defined and documented rule.
This rule may be that everything between the first [ and the last ] is
used as section name and because it's a new rule every new user would
prevent adding some sorts of comments in the same line as the section
name or one would add them according to the new rule. Comments on the
same line as the section names won't occur on complex section names,
though, because complex section names will force complex comments, if
any.
From my point of view the only problem is to find something which tells
svn about the new parse mode and when I look at parse_section_name I
would just choose something which is not allowed as a repository name
in the context where authz could be used and add that to a section
name to indicate a new rule. This way old syntax and behaviour won't
break, one could fit each path's needs to whatever processing rule
may be added in the future and everything can be handled directly in
parse_section_name without even breaking internal interfaces. I would
just try to add something like a version number, like in the following
examples.
configured: [repo:/path/to/[12345] file.ext] # Comment comment [comment]
rule version: 1
section name: repo:/path/to/[12345]
configured: [^2^repo:/path/to/[12345] file.ext] # Comment comment [comment]
rule version: 2
section name: repo:/path/to/[12345] file.ext] # Comment comment [comment
But on a second look, seems a bit ugly... :-/
Mit freundlichen Grüßen,
Thorsten Schöning
--
Thorsten Schöning E-Mail:Thorsten.Schoening@AM-SoFT.de
AM-SoFT IT-Systeme http://www.AM-SoFT.de/
Telefon.............030-2 1001-310
Fax...............05151- 9468- 88
Mobil..............0178-8 9468- 04
AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
AG Hanover HRB 207 694 - Geschäftsführer: Andreas Muchow
Re: Square brackets in file names and authz (in VisualSVN 2.5.5)
Posted by Daniel Shahaf <d....@daniel.shahaf.name>.
Johan Corveleyn wrote on Thu, Jul 12, 2012 at 12:06:07 +0200:
> I think ']]' would be the best choice, but still not 100% backwards
> compatible. But I mean, who in their right mind would write sections
> like this:
>
> [repo:/path/to/file.ext]]haha, this isn't parsed
We document the format as "ini format" and more specifically "same as
Python's ConfigParser", and the above isn't valid in either of those, so
we needn't provide back compat for it.
Re: Square brackets in file names and authz (in VisualSVN 2.5.5)
Posted by Johan Corveleyn <jc...@gmail.com>.
On Thu, Jul 12, 2012 at 11:51 AM, Jason Heeris <ja...@gmail.com> wrote:
> On 12 July 2012 17:45, Bert Huijben <be...@qqmail.nl> wrote:
>> [Please try to keep the mails in plain-text]
>
> Oops, my apologies!
>
>> Things might be simpler when defining that lines that start with ‘[‘ and
>> end with ‘]’ should parse everything in between as section markers.
>
>> But then, I don’t know how that affects the current comment syntax.
>
> Ah, yes, something like this might prove problematic:
>
> [repo:/path/to/[12345] file.ext] # Comment comment [comment]
>
> Then again, the file *could*, in theory, be named "[12345] file.ext] #
> Comment [comment comment"!
>
> I don't really know *what* constraints there are on honouring existing
> authz file syntax, whether or not it's explicitly specified.
Or even:
[repo:/path/to/file.ext] Comment [comment]
(no need for # -- this currently works as well, because everything
after the first ']' is ignored)
I think ']]' would be the best choice, but still not 100% backwards
compatible. But I mean, who in their right mind would write sections
like this:
[repo:/path/to/file.ext]]haha, this isn't parsed
:-)
(ok, maybe in some cases as a typo, which is currently ignored and
which would then cause a behavior change)
--
Johan
Re: Square brackets in file names and authz (in VisualSVN 2.5.5)
Posted by Jason Heeris <ja...@gmail.com>.
The issue is filed as #4204:
http://subversion.tigris.org/issues/show_bug.cgi?id=4204
— Jason
Re: Square brackets in file names and authz (in VisualSVN 2.5.5)
Posted by Jason Heeris <ja...@gmail.com>.
On 12 July 2012 17:45, Bert Huijben <be...@qqmail.nl> wrote:
> [Please try to keep the mails in plain-text]
Oops, my apologies!
> Things might be simpler when defining that lines that start with ‘[‘ and
> end with ‘]’ should parse everything in between as section markers.
> But then, I don’t know how that affects the current comment syntax.
Ah, yes, something like this might prove problematic:
[repo:/path/to/[12345] file.ext] # Comment comment [comment]
Then again, the file *could*, in theory, be named "[12345] file.ext] #
Comment [comment comment"!
I don't really know *what* constraints there are on honouring existing
authz file syntax, whether or not it's explicitly specified.
— Jason
RE: Square brackets in file names and authz (in VisualSVN 2.5.5)
Posted by Bert Huijben <be...@qqmail.nl>.
[Please try to keep the mails in plain-text]
The problem with using a ‘\’ would be that you break the ‘\’ character in existing files to fix ‘]’.
Things might be simpler when defining that lines that start with ‘[‘ and end with ‘]’ should parse everything in between as section markers.
But then, I don’t know how that affects the current comment syntax.
We should really check the source before making a decision.
Bert
From: Jason Heeris [mailto:jason.heeris@gmail.com]
Sent: donderdag 12 juli 2012 11:37
To: Johan Corveleyn
Cc: Matthew Pounsett; users@subversion.apache.org
Subject: Re: Square brackets in file names and authz (in VisualSVN 2.5.5)
On 12 July 2012 17:28, Johan Corveleyn <jc...@gmail.com> wrote:
I think the only character that causes problems is ']' (which ends the
section name parsing). It seems not too hard to change that parsing
function to make it handle some kind of escape sequence for ']'
(perhaps ']]'). Would you care to write a patch [2]?
I doubt I'll have time to write a patch any time in the next few days, but I'll file the bug now and take a look at writing a patch next week.
I'd suggest avoiding inconsistencies like the double-]. I certainly wouldn't think to try that. It might be better to use a backslash sequence, or simply capture everything up to the *last* "]" on a line instead of the first. I don't think that would be more complex than needing to detect a "]]" ...but then, I haven't written the patch :P
— Jason
Re: Square brackets in file names and authz (in VisualSVN 2.5.5)
Posted by Jason Heeris <ja...@gmail.com>.
On 12 July 2012 17:28, Johan Corveleyn <jc...@gmail.com> wrote:
> I think the only character that causes problems is ']' (which ends the
> section name parsing). It seems not too hard to change that parsing
> function to make it handle some kind of escape sequence for ']'
> (perhaps ']]'). Would you care to write a patch [2]?
>
I doubt I'll have time to write a patch any time in the next few days, but
I'll file the bug now and take a look at writing a patch next week.
I'd suggest avoiding inconsistencies like the double-]. I certainly
wouldn't think to try that. It might be better to use a backslash sequence,
or simply capture everything up to the *last* "]" on a line instead of the
first. I don't think that would be more complex than needing to detect a
"]]" ...but then, I haven't written the patch :P
— Jason
Re: Square brackets in file names and authz (in VisualSVN 2.5.5)
Posted by Johan Corveleyn <jc...@gmail.com>.
On Thu, Jul 12, 2012 at 6:59 AM, Jason Heeris <ja...@gmail.com> wrote:
> On 12 July 2012 08:03, Jason Heeris <ja...@gmail.com> wrote:
>>
>> I'll file it later today and see what response I get.
>
>
> Apparently I need a buddy with whom to file the bug. If anyone would be
> willing, I'd appreciate it.
>
> I've attached a bash script that reproduces the problem under SVN 1.7.4.
> Please read the script before running it, I make no assurances that it's not
> accidentally going to do something awful...
Thanks for the thoroughness, writing a reproduction script etc. Please
go ahead and file an issue in the issue tracker.
I've taken a quick look in the source code: the problem is the config
parsing code, which parses the "repos:path" thing as a section name
(everything between the square brackets in de config file). See the
function parse_section_name in libsvn_subr/config_file.c [1].
I think the only character that causes problems is ']' (which ends the
section name parsing). It seems not too hard to change that parsing
function to make it handle some kind of escape sequence for ']'
(perhaps ']]'). Would you care to write a patch [2]?
[1] http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/config_file.c?view=markup
from line 315 onward (the comment says "Read chars until enounter ']' ...").
[2] http://subversion.apache.org/docs/community-guide/general.html#patches
--
Johan
Re: Square brackets in file names and authz (in VisualSVN 2.5.5)
Posted by Jason Heeris <ja...@gmail.com>.
On 12 July 2012 08:03, Jason Heeris <ja...@gmail.com> wrote:
> I'll file it later today and see what response I get.
>
Apparently I need a buddy with whom to file the bug. If anyone would be
willing, I'd appreciate it.
I've attached a bash script that reproduces the problem under SVN 1.7.4.
Please read the script before running it, I make no assurances that it's
not accidentally going to do something awful...
— Jason
Re: Square brackets in file names and authz (in VisualSVN 2.5.5)
Posted by Jason Heeris <ja...@gmail.com>.
On 11 July 2012 23:01, Matthew Pounsett <ma...@conundrum.com> wrote:
> I note by your examples that you're using a unix filesystem (as opposed to
> Windows). I would be a little surprised if this worked there, since the
> square brackets are normally used by unix shells as glob metacharacters,
> similarly to * and ?.
>
The app runs on a Windows Server 2003 system, and creates and commits the
files on NTFS.
> Sorry, I'm not sure how to help you make this work. If you can avoid
> using those characters in file names, please do so at all costs.
Well... not without a rewrite of the application, and the ability to
somehow replay the entire repository with different filenames while
maintaining revision numbers. Simply renaming them in the repository won't
work, since then (a) the app will break, and (b) the files could still be
accessed at previous revisions. Maybe possible with "svnadmin dump" or a
PySVN script, but not easy.
> A good rule of thumb is that if you can't create the file from a command
> line in a shell without escaping characters, then don't use those
> characters.
>
Only the app is able to create and delete the files — any other user can
only modify them through SVN. Hence, I've always used tab completion or a
GUI (on both Linux and Windows) to work with them.
In my defense, I did what I thought was due diligence when this was set up.
I looked for characters that were deemed illegal in SVN paths, and I made
sure these characters would work on all the filesystems we use here. I
didn't expect any of this to be an issue, any more than spaces or non-ASCII
characters.
> If svn can't deal with this one you might have a case for it being a bug,
> since it is technically a legal file name.
>
So are the square brackets...
Look, I realise this is an edge case, but if SVN can handle non-ASCII,
shouldn't it handle punctuation? IMO there is at least one bug here: either
the authz file spec should include escape sequences "[", "]", "#" and maybe
others, or it should be documented that they are disallowed characters for
SVN (or maybe more specifically, authz). I'll file it later today and see
what response I get.
Cheers,
Jason
Re: Square brackets in file names and authz (in VisualSVN 2.5.5)
Posted by Matthew Pounsett <ma...@conundrum.com>.
On 2012/07/11, at 20:20, David Brodbeck wrote:
> On Wed, Jul 11, 2012 at 8:01 AM, Matthew Pounsett <ma...@conundrum.com> wrote:
>> I note by your examples that you're using a unix filesystem (as opposed to Windows). I would be a little surprised if this worked there, since the square brackets are normally used by unix shells as glob metacharacters, similarly to * and ?.
>
> Just because they're used as shell metacharacters doesn't mean they
> aren't legal in filenames:
Right, but anything using simple methods of globbing may not react well to their use, as the OP seems to have discovered. I didn't say you couldn't force the files to be created, just that I'd be a little surprised if those characters worked in authz configs.
That said.. it turns out the OP is on Windows after all, and I was just fooled by the non-windows notation for the file names. I'm no authority on what is or isn't possible on NTFS since I haven't touched it in a good 10+ years so it's likely none of what I had to say applies to his problem.
>
>>> It's also worth pointing out that some paths have the "#" character in them. What do I do when I get to those?
>>
>> This is commonly comment character. It's possible to create a file with this character in it, but personally I'd avoid it. It's possible you could escape it like so: "tmp\#1.txt", but I'm not confident that will work. If svn can't deal with this one you might have a case for it being a bug, since it is technically a legal file name.
>
> emacs uses files starting and ending in "#" extensively for autosave
> recovery data, FWIW.
Again, didn't say it wasn't possible.. just that it might not be well advised.
Re: Square brackets in file names and authz (in VisualSVN 2.5.5)
Posted by David Brodbeck <br...@uw.edu>.
On Wed, Jul 11, 2012 at 8:01 AM, Matthew Pounsett <ma...@conundrum.com> wrote:
> I note by your examples that you're using a unix filesystem (as opposed to Windows). I would be a little surprised if this worked there, since the square brackets are normally used by unix shells as glob metacharacters, similarly to * and ?.
Just because they're used as shell metacharacters doesn't mean they
aren't legal in filenames:
brodbd@patas:~/foo$ touch \*foo\*
brodbd@patas:~/foo$ touch \?bar\?
brodbd@patas:~/foo$ touch \[biz\]
brodbd@patas:~/foo$ ls -l
total 2
-rw-r--r-- 1 brodbd brodbd 0 Jul 11 17:17 ?bar?
-rw-r--r-- 1 brodbd brodbd 0 Jul 11 17:17 [biz]
-rw-r--r-- 1 brodbd brodbd 0 Jul 11 17:17 *foo*
That's not to say they're a good *idea*, as they tend to make
scripting tricky, but the filesystem won't complain.
>> It's also worth pointing out that some paths have the "#" character in them. What do I do when I get to those?
>
> This is commonly comment character. It's possible to create a file with this character in it, but personally I'd avoid it. It's possible you could escape it like so: "tmp\#1.txt", but I'm not confident that will work. If svn can't deal with this one you might have a case for it being a bug, since it is technically a legal file name.
emacs uses files starting and ending in "#" extensively for autosave
recovery data, FWIW.
--
David Brodbeck
System Administrator, Linguistics
University of Washington
Re: Square brackets in file names and authz (in VisualSVN 2.5.5)
Posted by Matthew Pounsett <ma...@conundrum.com>.
On 2012/07/11, at 01:13, Jason Heeris wrote:
> The problem is this: it doesn't seem to work on files with the '[' or ']' characters in their name. Ignoring VisualSVN's GUI for now, I've tried going one step further and editing the "authz-windows" file by hand and I just can't seem to get it to work. I've tried variations like:
I note by your examples that you're using a unix filesystem (as opposed to Windows). I would be a little surprised if this worked there, since the square brackets are normally used by unix shells as glob metacharacters, similarly to * and ?.
For example, 'tmp[123].txt' is a glob pattern to match tmp1.txt, tmp2.txt and tmp3.txt.
Sorry, I'm not sure how to help you make this work. If you can avoid using those characters in file names, please do so at all costs. A good rule of thumb is that if you can't create the file from a command line in a shell without escaping characters, then don't use those characters.
> It's also worth pointing out that some paths have the "#" character in them. What do I do when I get to those?
This is commonly comment character. It's possible to create a file with this character in it, but personally I'd avoid it. It's possible you could escape it like so: "tmp\#1.txt", but I'm not confident that will work. If svn can't deal with this one you might have a case for it being a bug, since it is technically a legal file name.