Bug 6781 - Cannot rename subfolders in Explorer view with recent versions of Samba
Summary: Cannot rename subfolders in Explorer view with recent versions of Samba
Status: RESOLVED FIXED
Alias: None
Product: Samba 3.3
Classification: Unclassified
Component: File services (show other bugs)
Version: 3.3.8
Hardware: x86 Linux
: P3 normal
Target Milestone: ---
Assignee: Karolin Seeger
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-10-06 14:27 UTC by Nicholas Baldridge
Modified: 2009-10-09 01:44 UTC (History)
1 user (show)

See Also:


Attachments
Log level 10 while renaming folder (558.23 KB, text/plain)
2009-10-06 15:00 UTC, Nicholas Baldridge
no flags Details
Test debug patch. (1.49 KB, patch)
2009-10-07 15:26 UTC, Jeremy Allison
no flags Details
Log level 10 while renaming folder with debug patch applied (469.01 KB, text/plain)
2009-10-07 15:54 UTC, Nicholas Baldridge
no flags Details
Test debug patch with more info on open files. (2.01 KB, patch)
2009-10-07 16:20 UTC, Jeremy Allison
no flags Details
Try this patch instead... (2.00 KB, patch)
2009-10-07 16:49 UTC, Jeremy Allison
no flags Details
git-am patch for 3.4.3. (1.08 KB, patch)
2009-10-07 17:24 UTC, Jeremy Allison
no flags Details
git-am patch for 3.4.3 with simplified logic. (1.95 KB, patch)
2009-10-07 17:49 UTC, Jeremy Allison
vl: review+
Details
git-am patch for 3.3.9 (1.12 KB, patch)
2009-10-07 17:52 UTC, Jeremy Allison
vl: review+
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nicholas Baldridge 2009-10-06 14:27:42 UTC
Running Samba 3.3.8 - it seems that 3.3.2 - 3.4.0 are affected. Users are unable to rename subfolders in the Folder pane of the Explorer view (left-hand side).  Only tested in Windows XP against x86 and x86_64.

Renaming parent folders works as expected, but any attempt to rename a subfolder on the Folder pane causes the (really generic) Windows error:

Cannot rename 'x': Access is Denied
Make sure that the disk is not full or write-protected and that the file is not currently in use.

Tested with multiple shares in multiple configurations - common to all servers are the following:

ldapsam backend on another server
All servers tested are member servers

Shares use different configuration options, have different names, etc.

Here is a sample share configuration:
[paperless]
    path = /paperless/file_room/
    read only = No
    create mask = 07775 #Set temporarily
    security mask = 07775 # Set temporarily
    directory mask = 07775 # Set temporarily
    directory security mask = 07775 #Set temporarily
    inherit permissions = Yes
    inherit owner = Yes
    guest ok = Yes #Set temporarily
    delete readonly = Yes


Log level 25 log follows - restarted the service, accessed the share and attempted to rename, which provoked the error message:

[2009/10/06 15:21:08,  5] lib/debug.c:debug_dump_status(407)
  INFO: Current debug levels:
    all: True/25
    tdb: False/0
    printdrivers: False/0
    lanman: False/0
    smb: False/0
    rpc_parse: False/0
    rpc_srv: False/0
    rpc_cli: False/0
    passdb: False/0
    sam: False/0
    auth: False/0
    winbind: False/0
    vfs: False/0
    idmap: False/0
    quota: False/0
    acls: False/0
    locking: False/0
    msdfs: False/0
    dmapi: False/0
    registry: False/0
  doing parameter max log size = 1000
  doing parameter syslog = 0
  doing parameter panic action = /usr/share/samba/panic-action %d
  doing parameter security = domain
  doing parameter encrypt passwords = true
  doing parameter passdb backend = ldapsam:ldap://fuzzed_host_name
  doing parameter ldap suffix = dc=commund, dc=com
  doing parameter ldap machine suffix = ou=Computers
  doing parameter ldap user suffix = ou=Users
  doing parameter ldap group suffix = ou=Groups
  doing parameter ldap idmap suffix = ou=Users
  doing parameter ldap admin dn = cn=admin,dc=fuzzed_domain,dc=com
  doing parameter idmap backend = ldap:ldap://fuzzed_host_name
  doing parameter idmap uid = 10000-20000
  doing parameter idmap gid = 10000-20000
  doing parameter winbind trusted domains only = yes
  doing parameter obey pam restrictions = no
  doing parameter invalid users = root
  doing parameter ldap ssl = off
  doing parameter usershare allow guests = yes
[2009/10/06 15:21:08,  4] param/loadparm.c:lp_load_ex(8873)
  pm_process() returned Yes
[2009/10/06 15:21:08,  7] param/loadparm.c:lp_servicenumber(9078)
  lp_servicenumber: couldn't find homes
[2009/10/06 15:21:08, 10] param/loadparm.c:set_server_role(8051)
  set_server_role: role = ROLE_DOMAIN_MEMBER
[2009/10/06 15:21:08,  5] lib/iconv.c:smb_register_charset(104)
  Attempting to register new charset UCS-2LE
[2009/10/06 15:21:08,  5] lib/iconv.c:smb_register_charset(112)
  Registered charset UCS-2LE
[2009/10/06 15:21:08,  5] lib/iconv.c:smb_register_charset(104)
  Attempting to register new charset UTF-16LE
[2009/10/06 15:21:08,  5] lib/iconv.c:smb_register_charset(112)
  Registered charset UTF-16LE
[2009/10/06 15:21:08,  5] lib/iconv.c:smb_register_charset(104)
  Attempting to register new charset UCS-2BE
[2009/10/06 15:21:08,  5] lib/iconv.c:smb_register_charset(112)
  Registered charset UCS-2BE
[2009/10/06 15:21:08,  5] lib/iconv.c:smb_register_charset(104)
  Attempting to register new charset UTF-16BE
[2009/10/06 15:21:08,  5] lib/iconv.c:smb_register_charset(112)
  Registered charset UTF-16BE
[2009/10/06 15:21:08,  5] lib/iconv.c:smb_register_charset(104)
  Attempting to register new charset UTF8
[2009/10/06 15:21:08,  5] lib/iconv.c:smb_register_charset(112)
  Registered charset UTF8
[2009/10/06 15:21:08,  5] lib/iconv.c:smb_register_charset(104)
  Attempting to register new charset UTF-8
[2009/10/06 15:21:08,  5] lib/iconv.c:smb_register_charset(112)
  Registered charset UTF-8
[2009/10/06 15:21:08,  5] lib/iconv.c:smb_register_charset(104)
  Attempting to register new charset ASCII
[2009/10/06 15:21:08,  5] lib/iconv.c:smb_register_charset(112)
  Registered charset ASCII
[2009/10/06 15:21:08,  5] lib/iconv.c:smb_register_charset(104)
  Attempting to register new charset 646
[2009/10/06 15:21:08,  5] lib/iconv.c:smb_register_charset(112)
  Registered charset 646
[2009/10/06 15:21:08,  5] lib/iconv.c:smb_register_charset(104)
  Attempting to register new charset ISO-8859-1
[2009/10/06 15:21:08,  5] lib/iconv.c:smb_register_charset(112)
  Registered charset ISO-8859-1
[2009/10/06 15:21:08,  5] lib/iconv.c:smb_register_charset(104)
  Attempting to register new charset UCS2-HEX
[2009/10/06 15:21:08,  5] lib/iconv.c:smb_register_charset(112)
  Registered charset UCS2-HEX
[2009/10/06 15:21:08,  5] lib/charcnv.c:charset_name(82)
  Substituting charset 'UTF-8' for LOCALE
[2009/10/06 15:21:08,  5] lib/charcnv.c:charset_name(82)
  Substituting charset 'UTF-8' for LOCALE
[2009/10/06 15:21:08,  5] lib/charcnv.c:charset_name(82)
  Substituting charset 'UTF-8' for LOCALE
[2009/10/06 15:21:08,  5] lib/charcnv.c:charset_name(82)
  Substituting charset 'UTF-8' for LOCALE
[2009/10/06 15:21:08,  5] lib/charcnv.c:charset_name(82)
  Substituting charset 'UTF-8' for LOCALE
[2009/10/06 15:21:08,  5] lib/charcnv.c:charset_name(82)
  Substituting charset 'UTF-8' for LOCALE
[2009/10/06 15:21:08,  5] lib/charcnv.c:charset_name(82)
  Substituting charset 'UTF-8' for LOCALE
[2009/10/06 15:21:08,  5] lib/charcnv.c:charset_name(82)
  Substituting charset 'UTF-8' for LOCALE
[2009/10/06 15:21:08,  5] lib/charcnv.c:charset_name(82)
  Substituting charset 'UTF-8' for LOCALE
[2009/10/06 15:21:08,  5] lib/charcnv.c:charset_name(82)
  Substituting charset 'UTF-8' for LOCALE
[2009/10/06 15:21:08,  5] lib/charcnv.c:charset_name(82)
  Substituting charset 'UTF-8' for LOCALE
[2009/10/06 15:21:08,  5] lib/charcnv.c:charset_name(82)
  Substituting charset 'UTF-8' for LOCALE
[2009/10/06 15:21:08,  2] lib/tallocmsg.c:register_msg_pool_usage(106)
  Registered MSG_REQ_POOL_USAGE
[2009/10/06 15:21:08,  2] lib/dmallocmsg.c:register_dmalloc_msgs(77)
  Registered MSG_REQ_DMALLOC_MARK and LOG_CHANGED


Please let me know if any additional information is needed.  I am happy to help where possible.
Comment 1 Jeremy Allison 2009-10-06 14:46:29 UTC
This is not reproducible with the 3.4.x code in the git tree. I don't think there have been any changes here w.r.t. subfolder renaming. This might be a config error.

Please run Samba at debug level 10 and upload a log file containing the rename request. If you can name the folder a more descriptive name than 'x' (like folder_to_rename) that would help in finding the exact point in the log you're getting the error.

Jeremy.
Comment 2 Nicholas Baldridge 2009-10-06 15:00:08 UTC
Created attachment 4791 [details]
Log level 10 while renaming folder

Attached is log level from client renaming a folder called folder_to_rename to folder_to_rename - renaming.

Thank you for your assistance.  I hope I have made a config error. :-)
Comment 3 Jeremy Allison 2009-10-06 15:26:47 UTC
Ok, I can't see any logic error in the log here. Looks like the OS is simply denying the rename. What do the UNIX ownership and permissions on the directory:

Quotes/Online/

and the directory:

Quotes/Online/folder_to_rename

look like ?

Jeremy.
Comment 4 Nicholas Baldridge 2009-10-06 15:35:39 UTC
(In reply to comment #3) 
> What do the UNIX ownership and permissions on the
> directory:
> 
> Quotes/Online/
 
drwxrwxrwx 7 nbaldridge Domain Users 4096 2009-10-06 15:54 Online

> and the directory:
> 
> Quotes/Online/folder_to_rename
 
drwxrwxrwx 2 nbaldridge Domain Users 4096 2009-10-06 15:54 folder_to_rename

> look like ?

Thanks,
-Nick
Comment 5 Jeremy Allison 2009-10-06 16:16:56 UTC
Ok, there's no conceivable reason that renaming fails here - all permissions allow it and the logic is correct in the server, it gets to the underlying VFS_RENAME call which just fails. Is this mounted on a read-only filesystem ? Do you have apparmour or SeLinux turned on ? To debug this further I'll need an strace output of the smbd trying to do the rename.
Jeremy.
Comment 6 Nicholas Baldridge 2009-10-06 16:24:51 UTC
(In reply to comment #5)
> Is this mounted on a read-only filesystem ?
Nope.
> Do you have apparmour or SeLinux turned on ? 

I do have apparmour on, no selinux.  There is no samba profile and running with apparmour off entirely still causes the problem.

> To debug this further I'll need an
> strace output of the smbd trying to do the rename.
I'll attach that next.

Thanks again!
-Nick
Comment 7 Nicholas Baldridge 2009-10-06 16:28:22 UTC
I've set the strace in the URL of the bug.  Once closed, I'll remove the link from my server.
Comment 8 Jeremy Allison 2009-10-06 16:50:21 UTC
That file isn't an strace output, it's another smbd log. However, I have seen another possibility. Do you have any files open from the same client inside the directory you're trying to rename ? That would cause the access denied error.

Can you compile Samba from source code ? If so, I'll send you a patch file that adds a lot more debugging info to the log file so I can understand what is going on here.

Jeremy.
Comment 9 Nicholas Baldridge 2009-10-06 20:53:08 UTC
(In reply to comment #8)
> That file isn't an strace output, it's another smbd log. 

Hmm. Interesting - I just ran strace smbd > strace.out and went through attempting to rename again.  Sorry I put up the wrong info.  I've taken it down.

> Do you have any files open from the same client inside the
> directory you're trying to rename ? That would cause the access denied error.

That would be great, but no - I was wondering if Windows treated Explorer's folder view as two separate connections - the one on the left screen and the one on the right, as they interoperate semi-independently, which might be causing the confusion.

> Can you compile Samba from source code ? 
Yep, this is the latest 3.3.8 from the Samba website downloaded today per your earlier recommendation.

Thanks again!
-Nick
Comment 10 Jeremy Allison 2009-10-06 23:15:22 UTC
No I already checked that myself (the explorer windows operating semi-independently). I had a view open in the right pane and renamed the left pane. If you're able to build from source I'll send a custom patch to add debug messages tomorrow so we can track down what is generating ACCESS_DENIED (too late here now).
Jeremy.
Comment 11 Nicholas Baldridge 2009-10-07 09:55:08 UTC
Yep - ready, willing, and able - send it on!
Comment 12 Jeremy Allison 2009-10-07 15:26:21 UTC
Created attachment 4803 [details]
Test debug patch.

Please apply this patch, reproduce the problem then attach the debug level 10. This should give me more info.
Thanks,
Jeremy.
Comment 13 Nicholas Baldridge 2009-10-07 15:54:34 UTC
Created attachment 4804 [details]
Log level 10 while renaming folder with debug patch applied

Attached is the requested log.

It's saying it found an open file, if I'm reading this correctly:

can_rename: file_find_subpath found an open file below Quotes/Online/folder_to_rename

But the interesting thing is that there are no files inside this folder (outside of . and ..), so I'm curious as to what it's seeing as locked...

I very much appreciate your help,
-Nick
Comment 14 Jeremy Allison 2009-10-07 16:20:23 UTC
Created attachment 4805 [details]
Test debug patch with more info on open files.

Ok, try this patch instead - will give more info about the open file it thinks matches. Please post the debug level 10 again. Should be enough to nail this.
Jeremy.
Comment 15 Jeremy Allison 2009-10-07 16:49:40 UTC
Created attachment 4806 [details]
Try this patch instead...

Ooops sorry. Don't reference memory we just freed :-).

Jeremy.
Comment 16 Jeremy Allison 2009-10-07 17:09:41 UTC
Ok, I've found the error. The client has the same directory open already, so the open for rename is an identical open. The code in file_find_subpath() was not handling this correctly (ie. it was returning "true" for an identical name, rather than only returning "true" for a name longer than the directory name).

I have a fix for this that I'm checking into master and 3.5, and will add git-am patches for 3.3.9 and 3.4.2.

Jeremy.
Comment 17 Jeremy Allison 2009-10-07 17:19:15 UTC
FYI. I'm guessing you have an anti-virus scanner on your XP box ?
Jeremy.
Comment 18 Jeremy Allison 2009-10-07 17:24:26 UTC
Created attachment 4807 [details]
git-am patch for 3.4.3.

Version of the fix for 3.4.3. The current code there was better than the 3.3.x code, but still had the problem with a rename of ./a -> ./b failing when directory ./aa was already open.
Jeremy.
Comment 19 Jeremy Allison 2009-10-07 17:49:34 UTC
Created attachment 4808 [details]
git-am patch for 3.4.3 with simplified logic.

Patch that should be in 3.4.3 (once vl reviews).
Jeremy.
Comment 20 Jeremy Allison 2009-10-07 17:52:40 UTC
Created attachment 4809 [details]
git-am patch for 3.3.9

Fix for 3.3.9, if vl approves. Without it XP clients will fail directory renames (my guess is when they have an active virus scanner).
Jeremy.
Comment 21 Jeremy Allison 2009-10-07 18:55:13 UTC
Added regression test to smbtorture4 RAW-RENAME test - git log:
46d193324082000f19221f1b1ac679512aff96ed
Jeremy.
Comment 22 Volker Lendecke 2009-10-08 05:33:36 UTC
Comment on attachment 4809 [details]
git-am patch for 3.3.9

Looks good.

Volker
Comment 23 Volker Lendecke 2009-10-08 05:42:04 UTC
Comment on attachment 4808 [details]
git-am patch for 3.4.3 with simplified logic.

Sorry, here I do not see the logic to deny a rename if a stream of the file in question is open.

Can you explain how that would work?

Thanks,

Volker
Comment 24 Nicholas Baldridge 2009-10-08 07:37:23 UTC
(In reply to comment #17)
> FYI. I'm guessing you have an anti-virus scanner on your XP box ?

No, not an active virus scanner - I use clamwin on this box, which is an on-demand virus scanner.  It was not scanning anywhere near the time.

I also am not running any service that indexes any drive - not Windows search, not Windows Defender, nothing but plain vanilla services.

Thanks for all your help!  I'm going to test the fix today.
-Nick

> Jeremy.
> 

Comment 25 Jeremy Allison 2009-10-08 12:05:14 UTC
(In reply to comment #23)
> (From update of attachment 4808 [details])
> Sorry, here I do not see the logic to deny a rename if a stream of the file in
> question is open.
> 
> Can you explain how that would work?

Renames with open streams are not denied. See: source4/torture/raw/rename.c:665
in master.

664         /*
665          * Now try opening a stream on the directory and holding it open
666          * across a rename.  This should be allowed.
667          */
668         io.ntcreatex.in.fname = sname;
669 
670         status = smb_raw_open(cli->tree, tctx, &io);
671         CHECK_STATUS(status, NT_STATUS_OK);
672         fnum = io.ntcreatex.out.file.fnum;
673 
674         ren_io.generic.level = RAW_RENAME_RENAME;
675         ren_io.rename.in.pattern1 = dname2;
676         ren_io.rename.in.pattern2 = dname1;
677         ren_io.rename.in.attrib = 0;
678 
679         status = smb_raw_rename(cli->tree, &ren_io);
680         CHECK_STATUS(status, NT_STATUS_OK);

Jeremy.
Comment 26 Jeremy Allison 2009-10-08 12:41:57 UTC
Re-assigning to Karolin for inclusion in 3.3.9 and 3.4.3.
Jeremy.
Comment 27 Karolin Seeger 2009-10-09 01:42:26 UTC
Pushed to v3-3-test and v3-4-test.
Will be included in the next bug fix releases.
Closing out bug report.

Thanks!