literal '%' in smb.conf
Alison Winters
alisonw at sgi.com
Thu Mar 8 03:50:21 GMT 2007
Andrew Bartlett wrote:
> On Thu, 2007-03-08 at 12:28 +1100, Alison Winters wrote:
>> I've been looking at the alloc_sub_basic() case statement in
>> source/lib/substitute.c and i can't see a way to insert a literal '%'.
>> I think this means that if you have a '%' followed by a 'U' you will
>> always get a username substitution regardless of if it was desired or
>> not. Would it make sense to add a facility to do literal '%' characters
>> in the config file? I wonder because characters like '%' are valid
>> characters for AD logon names, filenames etc.
> Doesn't %% work?
>
It doesn't appear to. Here's an example:
# ls -l /tmp/test*
-rw-r--r-- 1 root root 0 2007-03-08 14:40 /tmp/test-alisonw
-rw-r--r-- 1 root root 0 2007-03-08 14:45 /tmp/test-%alisonw
-rw-r--r-- 1 root root 0 2007-03-08 14:39 /tmp/test-%U
-rw-r--r-- 1 root root 0 2007-03-08 14:40 /tmp/test-%%U
In smb.conf:
[alisontest]
comment = alisontest
path = /tmp
veto files = /test-%U/
In smbclient:
smb: \> ls test*
test-%alisonw 0 Thu Mar 8 14:45:26 2007
test-%%U 0 Thu Mar 8 14:40:01 2007
test-%U 0 Thu Mar 8 14:39:59 2007
As expected, test-alisonw is hidden, because that's the username i
connected as. Now if i change the smb.conf to veto test-%%U:
smb: \> ls test*
test-alisonw 0 Thu Mar 8 14:40:05 2007
test-%%U 0 Thu Mar 8 14:40:01 2007
test-%U 0 Thu Mar 8 14:39:59 2007
At this point you would expect test-%U to be hidden, but unfortunately
it seems it's expanded itself to test-%alisonw.
Judging by what's in substitute.c it looks like it will always
substitute known macros regardless, otherwise it will use a literal '%'.
That's kinda wonky behavior if you need to use a literal '%' next to a
character reserved for macros. We could add '%%' a la printf, but that
may regress people's existing smb.confs that expect it to work otherwise.
Alison
More information about the samba-technical
mailing list