Check if a user is allowed to delete a file.
********************************************************************/
-static NTSTATUS can_delete(char *fname,connection_struct *conn, int dirtype)
+static NTSTATUS can_delete(char *fname,connection_struct *conn, int dirtype, BOOL bad_path)
{
SMB_STRUCT_STAT sbuf;
int fmode;
if (!CAN_WRITE(conn))
return NT_STATUS_MEDIA_WRITE_PROTECTED;
- if (SMB_VFS_LSTAT(conn,fname,&sbuf) != 0)
- return NT_STATUS_OBJECT_NAME_NOT_FOUND;
+ if (SMB_VFS_LSTAT(conn,fname,&sbuf) != 0) {
+ if(errno == ENOENT) {
+ if (bad_path)
+ return NT_STATUS_OBJECT_PATH_NOT_FOUND;
+ else
+ return NT_STATUS_OBJECT_NAME_NOT_FOUND;
+ }
+ return map_nt_error_from_unix(errno);
+ }
fmode = dos_mode(conn,fname,&sbuf);
if (!has_wild) {
pstrcat(directory,"/");
pstrcat(directory,mask);
- error = can_delete(directory,conn,dirtype);
+ error = can_delete(directory,conn,dirtype,bad_path);
if (!NT_STATUS_IS_OK(error))
return error;
continue;
slprintf(fname,sizeof(fname)-1, "%s/%s",directory,dname);
- error = can_delete(fname,conn,dirtype);
+ error = can_delete(fname,conn,dirtype,bad_path);
if (!NT_STATUS_IS_OK(error))
continue;
if (SMB_VFS_UNLINK(conn,fname) == 0)
dirptr = OpenDir(conn, directory, True);
if (dirptr) {
- error = NT_STATUS_OBJECT_NAME_NOT_FOUND;
+ error = NT_STATUS_NO_SUCH_FILE;
+/* Was error = NT_STATUS_OBJECT_NAME_NOT_FOUND; - gentest fix. JRA */
if (strequal(mask,"????????.???"))
pstrcpy(mask,"*");
pstrcpy(fname,dname);
+ if((strcmp(fname, ".") == 0) || (strcmp(fname, "..")==0))
+ continue;
+
if(!mask_match(fname, mask, case_sensitive))
continue;