summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-04-24 12:56:23 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:19:40 -0500
commit2ad66881dfd0fb8a03efc409af7f5bb6d3d204b2 (patch)
treed4f9225c52e8e13f164c6ef80077ad97bf838019
parentb93f78025db8fe0e38a9a9bdac27c53309e3ec4a (diff)
downloadsamba-2ad66881dfd0fb8a03efc409af7f5bb6d3d204b2.tar.gz
samba-2ad66881dfd0fb8a03efc409af7f5bb6d3d204b2.tar.bz2
samba-2ad66881dfd0fb8a03efc409af7f5bb6d3d204b2.zip
r22502: Fix bug #4536 - delete symlinks to a directory correctly.
Jeremy. (This used to be commit dcc6517d9d349c65b045160e8a1358af088ae97a)
-rw-r--r--source3/smbd/reply.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index bf739aa643..1acd78a106 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -3867,7 +3867,23 @@ NTSTATUS rmdir_internals(connection_struct *conn, const char *directory)
int ret;
SMB_STRUCT_STAT st;
- ret = SMB_VFS_RMDIR(conn,directory);
+ /* Might be a symlink. */
+ if(SMB_VFS_LSTAT(conn, directory, &st) != 0) {
+ return map_nt_error_from_unix(errno);
+ }
+
+ if (S_ISLNK(st.st_mode)) {
+ /* Is what it points to a directory ? */
+ if(SMB_VFS_STAT(conn, directory, &st) != 0) {
+ return map_nt_error_from_unix(errno);
+ }
+ if (!(S_ISDIR(st.st_mode))) {
+ return NT_STATUS_NOT_A_DIRECTORY;
+ }
+ ret = SMB_VFS_UNLINK(conn,directory);
+ } else {
+ ret = SMB_VFS_RMDIR(conn,directory);
+ }
if (ret == 0) {
notify_fname(conn, NOTIFY_ACTION_REMOVED,
FILE_NOTIFY_CHANGE_DIR_NAME,