From 7104dbd245f8c96f3ab90b3f4c44d6adb55ba809 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 23 Mar 2002 20:48:45 +0000 Subject: Set default recycle directory permissions as 0770. Unlink on rename fail. Jeremy. (This used to be commit 42981c819a07dd35296ecc1ee733ea587f69bcce) --- examples/VFS/recycle.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'examples/VFS') diff --git a/examples/VFS/recycle.c b/examples/VFS/recycle.c index 4e032bb813..74d3657895 100644 --- a/examples/VFS/recycle.c +++ b/examples/VFS/recycle.c @@ -177,13 +177,13 @@ static void recycle_disconnect(struct connection_struct *conn) static BOOL recycle_XXX_exist(connection_struct *conn, const char *dname, BOOL isdir) { - SMB_STRUCT_STAT st; + SMB_STRUCT_STAT st; - if (default_vfs_ops.stat(conn,dname,&st) != 0) - return(False); + if (default_vfs_ops.stat(conn,dname,&st) != 0) + return(False); if (isdir) - return S_ISDIR(st.st_mode) ? True : False; + return S_ISDIR(st.st_mode) ? True : False; else return S_ISREG(st.st_mode) ? True : False; } @@ -200,9 +200,9 @@ static BOOL recycle_file_exist(connection_struct *conn, const char *fname) static SMB_OFF_T recycle_get_file_size(connection_struct *conn, const char *fname) { - SMB_STRUCT_STAT st; + SMB_STRUCT_STAT st; - if (default_vfs_ops.stat(conn,fname,&st) != 0) + if (default_vfs_ops.stat(conn,fname,&st) != 0) return (SMB_OFF_T)-1; return(st.st_size); @@ -219,7 +219,7 @@ static int recycle_unlink(connection_struct *conn, const char *inname) char *base, *ext; pstring bin; int i=1, len, addlen; - int dir_mask=0700; + int dir_mask=0770; SMB_BIG_UINT dfree,dsize,bsize; *recycle_bin = '\0'; @@ -274,8 +274,11 @@ static int recycle_unlink(connection_struct *conn, const char *inname) DEBUG(3, ("recycle bin: move %s -> %s\n", fname, bin)); ret = default_vfs_ops.rename(conn, fname, bin); - if (ret == -1) + if (ret == -1) { DEBUG(3, ("recycle bin: move error %d (%s)\n", errno, strerror(errno) )); + DEBUG(3, ("recycle bin: move failed, purging...\n")); + return default_vfs_ops.unlink(conn,fname); + } return ret; } else { DEBUG(3, ("recycle bin: move failed, purging...\n")); -- cgit