summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/include/proto.h4
-rw-r--r--source3/param/loadparm.c4
-rw-r--r--source3/smbd/reply.c67
3 files changed, 71 insertions, 4 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 8163777137..3ea589565c 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -261,6 +261,7 @@ BOOL lp_syncalways(int );
BOOL lp_map_system(int );
BOOL lp_delete_readonly(int );
BOOL lp_fake_oplocks(int );
+BOOL lp_recursive_veto_delete(int );
int lp_create_mode(int );
int lp_force_create_mode(int );
int lp_dir_mode(int );
@@ -807,9 +808,6 @@ struct smb_passwd *get_smbpwnam(char *name);
/*The following definitions come from smbrun.c */
-/*The following definitions come from smbwizard.c */
-
-
/*The following definitions come from status.c */
void Ucrit_addUsername(pstring username);
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index b6eabcd727..7172eb2b0a 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -265,6 +265,7 @@ typedef struct
BOOL *copymap;
BOOL bDeleteReadonly;
BOOL bFakeOplocks;
+ BOOL bDeleteVetoFiles;
char dummy[3]; /* for alignment */
} service;
@@ -345,6 +346,7 @@ static service sDefault =
NULL, /* copymap */
False, /* bDeleteReadonly */
False, /* bFakeOplocks */
+ False, /* bDeleteVetoFiles */
"" /* dummy */
};
@@ -521,6 +523,7 @@ struct parm_struct
{"set directory", P_BOOLREV, P_LOCAL, &sDefault.bNo_set_dir, NULL},
{"status", P_BOOL, P_LOCAL, &sDefault.status, NULL},
{"hide dot files", P_BOOL, P_LOCAL, &sDefault.bHideDotFiles, NULL},
+ {"delete veto files",P_BOOL, P_LOCAL, &sDefault.bDeleteVetoFiles, NULL},
{"veto files", P_STRING, P_LOCAL, &sDefault.szVetoFiles, NULL},
{"hide files", P_STRING, P_LOCAL, &sDefault.szHideFiles, NULL},
{"guest only", P_BOOL, P_LOCAL, &sDefault.bGuest_only, NULL},
@@ -936,6 +939,7 @@ FN_LOCAL_BOOL(lp_syncalways,bSyncAlways)
FN_LOCAL_BOOL(lp_map_system,bMap_system)
FN_LOCAL_BOOL(lp_delete_readonly,bDeleteReadonly)
FN_LOCAL_BOOL(lp_fake_oplocks,bFakeOplocks)
+FN_LOCAL_BOOL(lp_recursive_veto_delete,bDeleteVetoFiles)
FN_LOCAL_INTEGER(lp_create_mode,iCreate_mask)
FN_LOCAL_INTEGER(lp_force_create_mode,iCreate_force_mode)
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;
}