diff options
author | Jeremy Allison <jra@samba.org> | 1997-09-17 01:29:53 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 1997-09-17 01:29:53 +0000 |
commit | 1590983eb0849130962cb0a08198cf8ad3d49380 (patch) | |
tree | 4e0786936672036ef2b0477d1ef7b6ff8d990d56 /source3/smbd | |
parent | 6449fc3b22284cea0aa186b0c6468696a1d8c1b4 (diff) | |
download | samba-1590983eb0849130962cb0a08198cf8ad3d49380.tar.gz samba-1590983eb0849130962cb0a08198cf8ad3d49380.tar.bz2 samba-1590983eb0849130962cb0a08198cf8ad3d49380.zip |
Added 'delete veto files' paremeter. Ugly - but the only
way to allow Samba client users to delete directories
containing Mac metafile information (.AppleDouble directories).
Needed for clean integration with netatalk.
Jeremy (jallison@whistle.com)
(This used to be commit 29c6c037dc62e44784e9d127d1e7ef3dd1506733)
Diffstat (limited to 'source3/smbd')
-rw-r--r-- | source3/smbd/reply.c | 67 |
1 files changed, 66 insertions, 1 deletions
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index 228d8ad669..cb0e5d7628 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -2594,6 +2594,66 @@ int reply_mkdir(char *inbuf,char *outbuf) return(outsize); } +/**************************************************************************** +Static function used by reply_rmdir to delete an entire directory +tree recursively. +****************************************************************************/ +static BOOL recursive_rmdir(char *directory) +{ + char *dname = NULL; + BOOL ret = False; + void *dirptr = OpenDir(-1, directory, False); + + if(dirptr == NULL) + return True; + + while((dname = ReadDirName(dirptr))) + { + pstring fullname; + struct stat st; + + if((strcmp(dname, ".") == 0) || (strcmp(dname, "..")==0)) + continue; + + /* Construct the full name. */ + if(strlen(directory) + strlen(dname) + 1 >= sizeof(fullname)) + { + errno = ENOMEM; + ret = True; + break; + } + strcpy(fullname, directory); + strcat(fullname, "/"); + strcat(fullname, dname); + + if(sys_lstat(fullname, &st) != 0) + { + ret = True; + break; + } + + if(st.st_mode & S_IFDIR) + { + if(recursive_rmdir(fullname)!=0) + { + ret = True; + break; + } + if(sys_rmdir(fullname) != 0) + { + ret = True; + break; + } + } + else if(sys_unlink(fullname) != 0) + { + ret = True; + break; + } + } + CloseDir(dirptr); + return ret; +} /**************************************************************************** reply to a rmdir @@ -2662,10 +2722,15 @@ int reply_rmdir(char *inbuf,char *outbuf) if(sys_lstat(fullname, &st) != 0) break; if(st.st_mode & S_IFDIR) + { + if(lp_recursive_veto_delete(SNUM(cnum))) { - if(sys_rmdir(fullname) != 0) + if(recursive_rmdir(fullname) != 0) break; } + if(sys_rmdir(fullname) != 0) + break; + } else if(sys_unlink(fullname) != 0) break; } |