summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>1998-07-01 21:49:49 +0000
committerJeremy Allison <jra@samba.org>1998-07-01 21:49:49 +0000
commit139a34157eba50f70c86f2dd07fb384a7cbaf9cc (patch)
tree4f69d1986e53fdd7bf805038b8f54bd2b19cd136 /source3
parent1829528d1fb2b87c726341aaf8d69d1190f83d6b (diff)
downloadsamba-139a34157eba50f70c86f2dd07fb384a7cbaf9cc.tar.gz
samba-139a34157eba50f70c86f2dd07fb384a7cbaf9cc.tar.bz2
samba-139a34157eba50f70c86f2dd07fb384a7cbaf9cc.zip
includes.h: AIX fix.
nttrans.c: More NT SMB work. smb.h: More NT SMB defines. trans2.c: Change call response as I now have docs on what the flags mean. #ifdef it with JRATEST until I'm sure it's ok though. Jeremy. (This used to be commit ce2503fddd7ef9eed89e1a63fd834f13432a9cd6)
Diffstat (limited to 'source3')
-rw-r--r--source3/include/includes.h2
-rw-r--r--source3/include/smb.h8
-rw-r--r--source3/smbd/nttrans.c133
-rw-r--r--source3/smbd/trans2.c4
4 files changed, 119 insertions, 28 deletions
diff --git a/source3/include/includes.h b/source3/include/includes.h
index ea09dcb367..6eab1a1641 100644
--- a/source3/include/includes.h
+++ b/source3/include/includes.h
@@ -600,6 +600,8 @@ char *mktemp(char *); /* No standard include */
#include <arpa/inet.h>
#include <netinet/tcp.h>
#include <locale.h>
+#include <grp.h>
+#define HAVE_GETGRNAM 1
#define SYSV
#define USE_WAITPID
#define USE_SIGBLOCK
diff --git a/source3/include/smb.h b/source3/include/smb.h
index 734dddff14..9cedc890b8 100644
--- a/source3/include/smb.h
+++ b/source3/include/smb.h
@@ -1090,6 +1090,8 @@ struct parm_struct
#define FILE_ATTRIBUTE_NORMAL 0x80L
#define FILE_ATTRIBUTE_TEMPORARY 0x100L
#define FILE_ATTRIBUTE_COMPRESSED 0x800L
+#define SAMBA_ATTRIBUTES_MASK 0x7F
+
/* Flags - combined with attributes. */
#define FILE_FLAG_WRITE_THROUGH 0x80000000L
#define FILE_FLAG_NO_BUFFERING 0x20000000L
@@ -1106,6 +1108,12 @@ struct parm_struct
#define OPEN_ALWAYS 4
#define TRUNCATE_EXISTING 5
+/* Filesystem Attributes. */
+#define FILE_CASE_SENSITIVE_SEARCH 0x1
+#define FILE_CASE_PRESERVED_NAMES 0x2
+#define FILE_UNICODE_ON_DISK 0x4
+#define FILE_PERISITANT_ACLS 0x8
+
/* where to find the base of the SMB packet proper */
#define smb_base(buf) (((char *)(buf))+4)
diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c
index 9d6f0d4021..1cde27a9ff 100644
--- a/source3/smbd/nttrans.c
+++ b/source3/smbd/nttrans.c
@@ -29,6 +29,9 @@ extern int Client;
extern int oplock_sock;
extern int smb_read_error;
extern int global_oplock_break;
+extern BOOL case_sensitive;
+extern BOOL case_preserve;
+extern BOOL short_case_preserve;
static char *known_nt_pipes[] = {
"\\LANMAN",
@@ -43,12 +46,46 @@ static char *known_nt_pipes[] = {
NULL
};
+static BOOL saved_case_sensitive;
+static BOOL saved_case_preserve;
+static BOOL saved_short_case_preserve;
+
/****************************************************************************
- reply to an NT create and X call.
+ Save case semantics.
+****************************************************************************/
+
+static void set_posix_case_semantics(uint32 file_attributes)
+{
+ if(!(file_attributes & FILE_FLAG_POSIX_SEMANTICS))
+ return;
+
+ saved_case_sensitive = case_sensitive;
+ saved_case_preserve = case_preserve;
+ saved_short_case_preserve = short_case_preserve;
+
+ /* Set to POSIX. */
+ case_sensitive = True;
+ case_preserve = True;
+ short_case_preserve = True;
+}
+
+/****************************************************************************
+ Restore case semantics.
****************************************************************************/
-THIS IS JUST CRIBBED FROM REPLY.C AT PRESENT AND IS A WORK
-IN PROGRESS. JRA.
+static void restore_case_semantics(uint32 file_attributes)
+{
+ if(!(file_attributes & FILE_FLAG_POSIX_SEMANTICS))
+ return;
+
+ case_sensitive = saved_case_sensitive;
+ case_preserve = saved_case_preserve;
+ short_case_preserve = saved_short_case_preserve;
+}
+
+/****************************************************************************
+ reply to an NT create and X call.
+****************************************************************************/
int reply_ntcreate_and_X(char *inbuf,char *outbuf,int length,int bufsize)
{
@@ -60,29 +97,29 @@ int reply_ntcreate_and_X(char *inbuf,char *outbuf,int length,int bufsize)
uint32 file_attributes = SIVAL(inbuf,smb_ntcreate_FileAttributes);
uint32 share_access = SIVAL(inbuf,smb_ntcreate_ShareAccess);
uint32 create_disposition = SIVAL(inbuf,smb_ntcreate_CreateDisposition);
-
+ uint32 fname_len = MIN(((uint32)SSVAL(inbuf,smb_ntcreate_NameLength)),
+ ((uint32)sizeof(fname)-1));
int smb_ofun;
int smb_open_mode;
- int smb_attr = SVAL(inbuf,smb_vwv5);
+ int smb_attr = file_attributes & SAMBA_ATTRIBUTES_MASK;
/* Breakout the oplock request bits so we can set the
reply bits separately. */
- BOOL ex_oplock_request = flags &
- BOOL core_oplock_request = CORE_OPLOCK_REQUEST(inbuf);
- BOOL oplock_request = ex_oplock_request | core_oplock_request;
+ int oplock_request = flags & (REQUEST_OPLOCK|REQUEST_BATCH_OPLOCK);
int unixmode;
int size=0,fmode=0,mtime=0,rmode=0;
struct stat sbuf;
int smb_action = 0;
BOOL bad_path = False;
files_struct *fsp;
-
+ char *p = NULL;
+
/* If it's an IPC, pass off the pipe handler. */
if (IS_IPC(cnum))
return nt_open_pipe_and_X(inbuf,outbuf,length,bufsize);
/* If it's a request for a directory open, fail it. */
if(flags & OPEN_DIRECTORY)
- return(ERROR(ERRSRV,ERRfilespecs));
+ return(ERROR(ERRDOS,ERRnoaccess));
/*
* We need to construct the open_and_X ofun value from the
@@ -159,12 +196,22 @@ int reply_ntcreate_and_X(char *inbuf,char *outbuf,int length,int bufsize)
if(file_attributes & FILE_FLAG_WRITE_THROUGH)
smb_open_mode |= (1<<14);
- pstrcpy(fname,smb_buf(inbuf));
+ /*
+ * Check if POSIX semantics are wanted.
+ */
+
+ set_posix_case_semantics(file_attributes);
+
+ StrnCpy(fname,smb_buf(inbuf),fname_len);
unix_convert(fname,cnum,0,&bad_path);
fnum = find_free_file();
if (fnum < 0)
+ {
+ restore_case_semantics(file_attributes);
return(ERROR(ERRSRV,ERRnofids));
+ }
+
if (!check_name(fname,cnum))
{
if((errno == ENOENT) && bad_path)
@@ -173,6 +220,9 @@ int reply_ntcreate_and_X(char *inbuf,char *outbuf,int length,int bufsize)
unix_ERR_code = ERRbadpath;
}
Files[fnum].reserved = False;
+
+ restore_case_semantics(file_attributes);
+
return(UNIXERROR(ERRDOS,ERRnoaccess));
}
@@ -191,11 +241,17 @@ int reply_ntcreate_and_X(char *inbuf,char *outbuf,int length,int bufsize)
unix_ERR_code = ERRbadpath;
}
Files[fnum].reserved = False;
+
+ restore_case_semantics(file_attributes);
+
return(UNIXERROR(ERRDOS,ERRnoaccess));
}
if (fstat(fsp->fd_ptr->fd,&sbuf) != 0) {
close_file(fnum,False);
+
+ restore_case_semantics(file_attributes);
+
return(ERROR(ERRDOS,ERRnoaccess));
}
@@ -204,6 +260,9 @@ int reply_ntcreate_and_X(char *inbuf,char *outbuf,int length,int bufsize)
mtime = sbuf.st_mtime;
if (fmode & aDIR) {
close_file(fnum,False);
+
+ restore_case_semantics(file_attributes);
+
return(ERROR(ERRDOS,ERRnoaccess));
}
@@ -212,29 +271,45 @@ int reply_ntcreate_and_X(char *inbuf,char *outbuf,int length,int bufsize)
correct bit for extended oplock reply.
*/
- if (ex_oplock_request && lp_fake_oplocks(SNUM(cnum))) {
+ if (oplock_request && lp_fake_oplocks(SNUM(cnum))) {
smb_action |= EXTENDED_OPLOCK_GRANTED;
}
- if(ex_oplock_request && fsp->granted_oplock) {
+ if(oplock_request && fsp->granted_oplock) {
smb_action |= EXTENDED_OPLOCK_GRANTED;
}
- /* If the caller set the core oplock request bit
- and we granted one (by whatever means) - set the
- correct bit for core oplock reply.
- */
-
- if (core_oplock_request && lp_fake_oplocks(SNUM(cnum))) {
- CVAL(outbuf,smb_flg) |= CORE_OPLOCK_GRANTED;
- }
-
- if(core_oplock_request && fsp->granted_oplock) {
- CVAL(outbuf,smb_flg) |= CORE_OPLOCK_GRANTED;
- }
+ set_message(outbuf,34,0,True);
+
+ p = outbuf + smb_vwv2;
+
+ SCVAL(p,0, (smb_action & EXTENDED_OPLOCK_GRANTED ? );
+ p++;
+ SSVAL(p,0,fnum);
+ p += 2;
+ SIVAL(p,0,smb_action);
+ p += 4;
- set_message(outbuf,15,0,True);
- SSVAL(outbuf,smb_vwv2,fnum);
+ CreationTime
+ p += 8;
+ LastAccessTime;
+ p += 8;
+ LastWriteTime;
+ p += 8;
+ ChangeTime;
+ p += 8;
+ FileAttributes;
+ p += 4;
+ AllocationSize;
+ p += 8;
+ EndOfFile;
+ p += 8;
+ SSVAL(p,0,0); /* File Type */
+ p += 2;
+ SSVAL(p,0,0); /* Device State */
+ p += 1;
+ SCVAL(p,0,0); /* Not Directory. */
+
SSVAL(outbuf,smb_vwv3,fmode);
if(lp_dos_filetime_resolution(SNUM(cnum)) )
put_dos_date3(outbuf,smb_vwv4,mtime & ~1);
@@ -246,8 +321,10 @@ int reply_ntcreate_and_X(char *inbuf,char *outbuf,int length,int bufsize)
chain_fnum = fnum;
+ restore_case_semantics(file_attributes);
+
return chain_reply(inbuf,outbuf,length,bufsize);
-}
+}
/****************************************************************************
reply to an unsolicited SMBNTtranss - just ignore it!
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index 4fefb4b39c..6cf7dd3949 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -1069,7 +1069,11 @@ static int call_trans2qfsinfo(char *inbuf, char *outbuf, int length, int bufsize
}
case SMB_QUERY_FS_ATTRIBUTE_INFO:
data_len = 12 + 2*strlen(FSTYPE_STRING);
+#if 1 /* JRATEST */
+ SIVAL(pdata,0,FILE_CASE_PRESERVED_NAMES); /* FS ATTRIBUTES */
+#else /* JRATEST */
SIVAL(pdata,0,0x4006); /* FS ATTRIBUTES == long filenames supported? */
+#endif /* JRATEST */
SIVAL(pdata,4,128); /* Max filename component length */
SIVAL(pdata,8,2*strlen(FSTYPE_STRING));
PutUniCode(pdata+12,FSTYPE_STRING);