1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

r7842: With the patch I sent Steve yesterday this gives us complete POSIX pathnames.

ie. files containing : and \ can be accessed from Linux.
Jeremy.
This commit is contained in:
Jeremy Allison 2005-06-22 21:20:41 +00:00 committed by Gerald (Jerry) Carter
parent e04fd56e00
commit e9b8d23d61
8 changed files with 101 additions and 5 deletions

View File

@ -2451,6 +2451,12 @@ char *parent_dirname(const char *path)
BOOL ms_has_wild(const char *s)
{
char c;
if (lp_posix_pathnames()) {
/* With posix pathnames no characters are wild. */
return False;
}
while ((c = *s++)) {
switch (c) {
case '*':

View File

@ -4523,3 +4523,29 @@ void set_store_dos_attributes(int snum, BOOL val)
return;
ServicePtrs[(snum)]->bStoreDosAttributes = val;
}
void lp_set_mangling_method(const char *new_method)
{
string_set(&Globals.szManglingMethod, new_method);
}
/*******************************************************************
Global state for POSIX pathname processing.
********************************************************************/
static BOOL posix_pathnames;
BOOL lp_posix_pathnames(void)
{
return posix_pathnames;
}
/*******************************************************************
Change everything needed to ensure POSIX pathname processing (currently
not much).
********************************************************************/
void lp_set_posix_pathnames(void)
{
posix_pathnames = True;
}

View File

@ -238,7 +238,7 @@ BOOL dptr_set_wcard_and_attributes(int key, const char *wcard, uint16 attr)
dptr->wcard = SMB_STRDUP(wcard);
if (!dptr->wcard)
return False;
if (wcard[0] == '.' && wcard[1] == 0) {
if (lp_posix_pathnames() || (wcard[0] == '.' && wcard[1] == 0)) {
dptr->has_wild = True;
} else {
dptr->has_wild = ms_has_wild(wcard);

View File

@ -29,6 +29,7 @@ static const struct {
} mangle_backends[] = {
{ "hash", mangle_hash_init },
{ "hash2", mangle_hash2_init },
{ "posix", posix_mangle_init },
/*{ "tdb", mangle_tdb_init }, */
{ NULL, NULL }
};
@ -39,7 +40,7 @@ static const struct {
static void mangle_init(void)
{
int i;
char *method;
const char *method;
if (mangle_fns)
return;
@ -70,6 +71,13 @@ void mangle_reset_cache(void)
mangle_fns->reset();
}
void mangle_change_to_posix(void)
{
mangle_fns = NULL;
lp_set_mangling_method("posix");
mangle_reset_cache();
}
/*
see if a filename has come out of our mangling code
*/

View File

@ -716,3 +716,42 @@ struct mangle_fns *mangle_hash2_init(void)
return &mangle_fns;
}
static void posix_mangle_reset(void)
{;}
static BOOL posix_is_mangled(const char *s, int snum)
{
return False;
}
static BOOL posix_is_8_3(const char *fname, BOOL check_case, BOOL allow_wildcards, int snum)
{
return False;
}
static BOOL posix_check_cache( char *s, size_t maxlen, int snum )
{
return False;
}
static void posix_name_map(char *OutName, BOOL need83, BOOL cache83, int default_case, int snum)
{
if (need83) {
memset(OutName, '\0', 13);
}
}
/* POSIX paths backend - no mangle. */
static struct mangle_fns posix_mangle_fns = {
posix_mangle_reset,
posix_is_mangled,
posix_is_8_3,
posix_check_cache,
posix_name_map
};
struct mangle_fns *posix_mangle_init(void)
{
return &posix_mangle_fns;
}

View File

@ -267,6 +267,9 @@ static int send_nt_replies(char *inbuf, char *outbuf, int bufsize, NTSTATUS nt_e
BOOL is_ntfs_stream_name(const char *fname)
{
if (lp_posix_pathnames()) {
return False;
}
return (strchr_m(fname, ':') != NULL) ? True : False;
}

View File

@ -398,7 +398,9 @@ size_t srvstr_get_path(char *inbuf, char *dest, const char *src, size_t dest_len
} else {
ret = srvstr_pull( inbuf, tmppath_ptr, src, dest_len, src_len, flags);
}
if (allow_wcard_names) {
if (lp_posix_pathnames()) {
*err = check_path_syntax_posix(dest, tmppath);
} else if (allow_wcard_names) {
*err = check_path_syntax_wcard(dest, tmppath);
} else {
*err = check_path_syntax(dest, tmppath);
@ -1032,6 +1034,10 @@ int reply_search(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
NTSTATUS nt_status;
BOOL allow_long_path_components = (SVAL(inbuf,smb_flg2) & FLAGS2_LONG_PATH_COMPONENTS) ? True : False;
if (lp_posix_pathnames()) {
return reply_unknown(inbuf, outbuf);
}
START_PROFILE(SMBsearch);
*mask = *directory = *fname = 0;
@ -1228,6 +1234,10 @@ int reply_fclose(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
char *p;
NTSTATUS err;
if (lp_posix_pathnames()) {
return reply_unknown(inbuf, outbuf);
}
START_PROFILE(SMBfclose);
outsize = set_message(outbuf,1,0,True);

View File

@ -2390,7 +2390,8 @@ cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)bsize, (unsigned
data_len = 12;
SSVAL(pdata,0,CIFS_UNIX_MAJOR_VERSION);
SSVAL(pdata,2,CIFS_UNIX_MINOR_VERSION);
SBIG_UINT(pdata,4,((SMB_BIG_UINT)CIFS_UNIX_POSIX_ACLS_CAP)); /* We have POSIX ACLs. */
SBIG_UINT(pdata,4,((SMB_BIG_UINT)(CIFS_UNIX_POSIX_ACLS_CAP|
CIFS_UNIX_POSIX_PATHNAMES_CAP))); /* We have POSIX ACLs and pathname capability. */
break;
case SMB_MAC_QUERY_FS_INFO:
@ -2461,13 +2462,16 @@ static int call_trans2setfsinfo(connection_struct *conn, char *inbuf, char *outb
client_unix_cap_low = IVAL(pdata,4);
client_unix_cap_high = IVAL(pdata,8);
/* Just print these values for now. */
DEBUG(10,("call_trans2setfsinfo: set unix info. major = %u, minor = %u\
DEBUG(10,("call_trans2setfsinfo: set unix info. major = %u, minor = %u \
cap_low = 0x%x, cap_high = 0x%x\n",
(unsigned int)client_unix_major,
(unsigned int)client_unix_minor,
(unsigned int)client_unix_cap_low,
(unsigned int)client_unix_cap_high ));
/* Here is where we must switch to posix pathname processing... */
lp_set_posix_pathnames();
mangle_change_to_posix();
break;
}
case SMB_FS_QUOTA_INFORMATION: