mirror of
https://github.com/samba-team/samba.git
synced 2024-12-25 23:21:54 +03:00
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 commit is contained in:
parent
59ee0d0c7e
commit
29c6c037dc
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user