summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/smbd/nttrans.c45
-rw-r--r--source3/smbd/trans2.c43
-rw-r--r--source3/smbwrapper/shared.c1
-rw-r--r--source3/smbwrapper/smbsh.c1
-rw-r--r--source3/smbwrapper/smbw.c6
5 files changed, 79 insertions, 17 deletions
diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c
index 128a234304..d30b59f0d3 100644
--- a/source3/smbd/nttrans.c
+++ b/source3/smbd/nttrans.c
@@ -233,6 +233,39 @@ static int send_nt_replies(char *outbuf, int bufsize, char *params,
}
/****************************************************************************
+ (Hopefully) temporary call to fix bugs in NT5.0beta2. This OS sends unicode
+ strings in NT calls AND DOESN'T SET THE UNICODE BIT !!!!!!!
+****************************************************************************/
+
+static void my_wcstombs(char *dst, uint16 *src, size_t len)
+{
+ size_t i;
+
+ for(i = 0; i < len; i++)
+ dst[i] = (char)SVAL(src,i*2);
+}
+
+static void get_filename( char *fname, char *inbuf, int data_offset, int data_len, int fname_len)
+{
+ if(data_len - fname_len > 1) {
+ /*
+ * NT 5.0 Beta 2 has kindly sent us a UNICODE string
+ * without bothering to set the unicode bit. How kind.
+ *
+ * Firstly - ensure that the data offset is aligned
+ * on a 2 byte boundary - add one if not.
+ */
+ fname_len = fname_len/2;
+ if(data_offset & 1)
+ data_offset++;
+ my_wcstombs( fname, (uint16 *)(inbuf+data_offset), fname_len);
+ } else {
+ StrnCpy(fname,inbuf+data_offset,fname_len);
+ }
+ fname[fname_len] = '\0';
+}
+
+/****************************************************************************
Save case statics.
****************************************************************************/
@@ -327,7 +360,7 @@ static int map_share_mode( uint32 desired_access, uint32 share_access, uint32 fi
if(desired_access & (DELETE_ACCESS|FILE_WRITE_ATTRIBUTES|
WRITE_DAC_ACCESS|WRITE_OWNER_ACCESS))
smb_open_mode = 2;
- else if(desired_access & (FILE_EXECUTE|READ_CONTROL_ACCESS))
+ else if(desired_access & (FILE_EXECUTE|FILE_READ_ATTRIBUTES|READ_CONTROL_ACCESS))
smb_open_mode = 0;
else {
DEBUG(0,("map_share_mode: Incorrect value for desired_access = %x\n",
@@ -481,12 +514,22 @@ int reply_ntcreate_and_X(connection_struct *conn,
if(fname_len + dir_name_len >= sizeof(pstring))
return(ERROR(ERRSRV,ERRfilespecs));
+ get_filename(&fname[dir_name_len], inbuf, smb_buf(inbuf)-inbuf,
+ smb_buflen(inbuf),fname_len);
+#if 0
StrnCpy(&fname[dir_name_len], smb_buf(inbuf),fname_len);
fname[dir_name_len+fname_len] = '\0';
+#endif
} else {
+
+ get_filename(fname, inbuf, smb_buf(inbuf)-inbuf,
+ smb_buflen(inbuf),fname_len);
+
+#if 0
StrnCpy(fname,smb_buf(inbuf),fname_len);
fname[fname_len] = '\0';
+#endif
}
/* If it's an IPC, use the pipe handler. */
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index 62bfb612e5..35bd10fb13 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -1115,7 +1115,7 @@ static int call_trans2qfsinfo(connection_struct *conn,
}
case SMB_QUERY_FS_ATTRIBUTE_INFO:
data_len = 12 + 2*strlen(fstype);
- SIVAL(pdata,0,FILE_CASE_PRESERVED_NAMES); /* FS ATTRIBUTES */
+ SIVAL(pdata,0,FILE_CASE_PRESERVED_NAMES|FILE_CASE_SENSITIVE_SEARCH); /* FS ATTRIBUTES */
#if 0 /* Old code. JRA. */
SIVAL(pdata,0,0x4006); /* FS ATTRIBUTES == long filenames supported? */
#endif /* Old code. */
@@ -1238,23 +1238,45 @@ static int call_trans2qfilepathinfo(connection_struct *conn,
char *fname;
char *p;
int l;
- SMB_OFF_T pos;
+ SMB_OFF_T pos = 0;
BOOL bad_path = False;
if (tran_call == TRANSACT2_QFILEINFO) {
files_struct *fsp = file_fsp(params,0);
info_level = SVAL(params,2);
- CHECK_FSP(fsp,conn);
- CHECK_ERROR(fsp);
+ if(fsp && fsp->open && fsp->is_directory) {
+ /*
+ * This is actually a QFILEINFO on a directory
+ * handle (returned from an NT SMB). NT5.0 seems
+ * to do this call. JRA.
+ */
+ fname = fsp->fsp_name;
+ unix_convert(fname,conn,0,&bad_path,&sbuf);
+ if (!check_name(fname,conn) || (!VALID_STAT(sbuf) && dos_stat(fname,&sbuf))) {
+ DEBUG(3,("fileinfo of %s failed (%s)\n",fname,strerror(errno)));
+ if((errno == ENOENT) && bad_path)
+ {
+ unix_ERR_class = ERRDOS;
+ unix_ERR_code = ERRbadpath;
+ }
+ return(UNIXERROR(ERRDOS,ERRbadpath));
+ }
+ } else {
+ /*
+ * Original code - this is an open file.
+ */
+ CHECK_FSP(fsp,conn);
+ CHECK_ERROR(fsp);
- fname = fsp->fsp_name;
- if (sys_fstat(fsp->fd_ptr->fd,&sbuf) != 0) {
- DEBUG(3,("fstat of fnum %d failed (%s)\n",fsp->fnum, strerror(errno)));
- return(UNIXERROR(ERRDOS,ERRbadfid));
+ fname = fsp->fsp_name;
+ if (sys_fstat(fsp->fd_ptr->fd,&sbuf) != 0) {
+ DEBUG(3,("fstat of fnum %d failed (%s)\n",fsp->fnum, strerror(errno)));
+ return(UNIXERROR(ERRDOS,ERRbadfid));
+ }
+ if((pos = sys_lseek(fsp->fd_ptr->fd,0,SEEK_CUR)) == -1)
+ return(UNIXERROR(ERRDOS,ERRnoaccess));
}
- if((pos = sys_lseek(fsp->fd_ptr->fd,0,SEEK_CUR)) == -1)
- return(UNIXERROR(ERRDOS,ERRnoaccess));
} else {
/* qpathinfo */
info_level = SVAL(params,0);
@@ -1270,7 +1292,6 @@ static int call_trans2qfilepathinfo(connection_struct *conn,
}
return(UNIXERROR(ERRDOS,ERRbadpath));
}
- pos = 0;
}
diff --git a/source3/smbwrapper/shared.c b/source3/smbwrapper/shared.c
index 0e83c3704d..69fa07dba8 100644
--- a/source3/smbwrapper/shared.c
+++ b/source3/smbwrapper/shared.c
@@ -121,7 +121,6 @@ char *smbw_getshared(const char *name)
i=0;
while (i < shared_size) {
- int len;
char *n, *v;
n = &variables[i];
diff --git a/source3/smbwrapper/smbsh.c b/source3/smbwrapper/smbsh.c
index ed0ab5290f..39623dc3ed 100644
--- a/source3/smbwrapper/smbsh.c
+++ b/source3/smbwrapper/smbsh.c
@@ -38,7 +38,6 @@ int main(int argc, char *argv[])
char *p, *u;
char *libd = BINDIR;
pstring line;
- extern FILE *dbf;
int opt;
extern char *optarg;
extern int optind;
diff --git a/source3/smbwrapper/smbw.c b/source3/smbwrapper/smbw.c
index 4528518076..e43910c194 100644
--- a/source3/smbwrapper/smbw.c
+++ b/source3/smbwrapper/smbw.c
@@ -404,7 +404,7 @@ struct smbw_server *smbw_server(char *server, char *share)
DEBUG(4,("server_n=[%s] server=[%s]\n", server_n, server));
if ((p=strchr(server_n,'#')) && strcmp(p+1,"1D")==0) {
- struct in_addr ip;
+ struct in_addr sip;
pstring s;
fstrcpy(group, server_n);
@@ -414,11 +414,11 @@ struct smbw_server *smbw_server(char *server, char *share)
/* cache the workgroup master lookup */
slprintf(s,sizeof(s)-1,"MASTER_%s", group);
if (!(server_n = smbw_getshared(s))) {
- if (!find_master_ip(group, &ip)) {
+ if (!find_master_ip(group, &sip)) {
errno = ENOENT;
return NULL;
}
- fstrcpy(group, inet_ntoa(ip));
+ fstrcpy(group, inet_ntoa(sip));
server_n = group;
smbw_setshared(s,server_n);
}