Bug 4536 - Symlinks to dirs not being deleted
Summary: Symlinks to dirs not being deleted
Alias: None
Product: Samba 3.0
Classification: Unclassified
Component: File Services (show other bugs)
Version: 3.0.25
Hardware: x64 Windows XP
: P3 normal
Target Milestone: none
Assignee: Samba Bugzilla Account
QA Contact: Samba QA Contact
Depends on:
Reported: 2007-04-24 05:13 UTC by Alexander (dead mail address)
Modified: 2024-01-06 01:33 UTC (History)
0 users

See Also:

Patch (817 bytes, patch)
2007-04-24 07:52 UTC, Jeremy Allison
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander (dead mail address) 2007-04-24 05:13:13 UTC
When trying to delete a directory which is actually a symlink to real directory it is not being deleted. Data _in_ the directory is deleted, however, but not the link/dir itself.  Checked on 3.0.20b, 3.0.22, 3.0.25rc2. Windows Explorer gives smth like "Cannot delete - wrong directory name", in Samba logs you see this:
[2007/04/24 09:52:43, 3] smbd/process.c:switch_message(926)
  switch message SMBrmdir (pid 19730) conn 0x80414a30
[2007/04/24 09:52:43, 4] smbd/uid.c:change_to_user(181)
  change_to_user: Skipping user change - already user
[2007/04/24 09:52:43, 5] smbd/filename.c:unix_convert(147)
  unix_convert called on file "my_test_link"
[2007/04/24 09:52:43, 10] smbd/statcache.c:stat_cache_lookup(248)
  stat_cache_lookup: lookup succeeded for name [MY_TEST_LINK] -> [my_test_link]
[2007/04/24 09:52:43, 3] smbd/reply.c:rmdir_internals(3947)
  rmdir_internals: couldn't remove directory my_test_link : Not a directory
[2007/04/24 09:52:43, 3] smbd/error.c:error_packet_set(106)
  error packet at smbd/reply.c(4001) cmd=1 (SMBrmdir) NT_STATUS_NOT_A_DIRECTORY

Steps to reproduce:
1. Create some share
2. mkdir my_test
3. ln -s my_test my_test_link
4. Give adequate read/write permissions for user
5. Open share in Win Explorer and try to delete my_test_link
6. Data from the directory will be gone and then you'll get the error message about wrong dir name.

Checking with strace (on 3.0.20b and 3.0.22) shows that Samba tries to use rmdir() syscall to delete the link which naturally fails with "Not a directory" as it should according to man.

Please feel free to request any additional info you need.
Comment 1 Jeremy Allison 2007-04-24 07:52:55 UTC
Created attachment 2405 [details]

Please try this patch. I think this will fix it.
Comment 2 Alexander (dead mail address) 2007-04-24 08:31:04 UTC
Yes, seems like it works now - at least in my test setup link and data within the symlinked dir were deleted without any problems.

Thanks! And I believe we can close this bug.


> Created an attachment (id=2405) [edit]
> Patch
> Please try this patch. I think this will fix it.
> Jeremy.