summaryrefslogtreecommitdiff
path: root/source3/smbd/negprot.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2001-08-27 08:19:43 +0000
committerAndrew Tridgell <tridge@samba.org>2001-08-27 08:19:43 +0000
commite8e98c9ea0690e3acf1126b50882e59e1056c7b3 (patch)
tree2fa75bc825f7e5da041809fe49080e3319656506 /source3/smbd/negprot.c
parent3820578473da81b7ae0dfa978605da809be59f62 (diff)
downloadsamba-e8e98c9ea0690e3acf1126b50882e59e1056c7b3.tar.gz
samba-e8e98c9ea0690e3acf1126b50882e59e1056c7b3.tar.bz2
samba-e8e98c9ea0690e3acf1126b50882e59e1056c7b3.zip
converted smbd to use NTSTATUS by default
major changes include: - added NSTATUS type - added automatic mapping between dos and nt error codes - changed all ERROR() calls to ERROR_DOS() and many to ERROR_NT() these calls auto-translate to the client error code system - got rid of the cached error code and the writebmpx code We eventually will need to also: - get rid of BOOL, so we don't lose error info - replace all ERROR_DOS() calls with ERROR_NT() calls but that is too much for one night (This used to be commit 83d9896c1ea8be796192b51a4678c2a3b87f7518)
Diffstat (limited to 'source3/smbd/negprot.c')
-rw-r--r--source3/smbd/negprot.c176
1 files changed, 89 insertions, 87 deletions
diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c
index 5bc3522506..6eda7e39db 100644
--- a/source3/smbd/negprot.c
+++ b/source3/smbd/negprot.c
@@ -157,95 +157,97 @@ reply for the nt protocol
****************************************************************************/
static int reply_nt1(char *outbuf)
{
- /* dual names + lock_and_read + nt SMBs + remote API calls */
- int capabilities = CAP_NT_FIND|CAP_LOCK_AND_READ|CAP_LEVEL_II_OPLOCKS|
- (lp_nt_smb_support() ? CAP_NT_SMBS | CAP_RPC_REMOTE_APIS : 0) |
- ((lp_large_readwrite() && (SMB_OFF_T_BITS == 64)) ?
- CAP_LARGE_READX | CAP_LARGE_WRITEX | CAP_W2K_SMBS : 0) |
- (SMB_OFF_T_BITS == 64 ? CAP_LARGE_FILES : 0);
-
-
-/*
- other valid capabilities which we may support at some time...
- CAP_LARGE_READX|CAP_STATUS32|CAP_LEVEL_II_OPLOCKS;
- */
-
- int secword=0;
- BOOL doencrypt = SMBENCRYPT();
- time_t t = time(NULL);
- struct cli_state *cli = NULL;
- char cryptkey[8];
- char crypt_len = 0;
- char *p, *q;
-
- if (lp_security() == SEC_SERVER) {
- DEBUG(5,("attempting password server validation\n"));
- cli = server_cryptkey();
- } else {
- DEBUG(5,("not attempting password server validation\n"));
- }
-
- if (cli) {
- DEBUG(3,("using password server validation\n"));
- doencrypt = ((cli->sec_mode & 2) != 0);
- } else {
- DEBUG(3,("not using password server validation\n"));
- }
-
- if (doencrypt) {
- crypt_len = 8;
- if (!cli) {
- generate_next_challenge(cryptkey);
- } else {
- memcpy(cryptkey, cli->cryptkey, 8);
- set_challenge(cli->cryptkey);
- }
- }
-
- if (lp_readraw() && lp_writeraw()) {
- capabilities |= CAP_RAW_MODE;
- }
-
-
- /* allow for disabling unicode */
- if (lp_unicode()) {
- capabilities |= CAP_UNICODE;
- }
-
+ /* dual names + lock_and_read + nt SMBs + remote API calls */
+ int capabilities = CAP_NT_FIND|CAP_LOCK_AND_READ|
+ CAP_LEVEL_II_OPLOCKS|CAP_STATUS32;
+
+ int secword=0;
+ BOOL doencrypt = SMBENCRYPT();
+ time_t t = time(NULL);
+ struct cli_state *cli = NULL;
+ char cryptkey[8];
+ char crypt_len = 0;
+ char *p, *q;
+
+ if (lp_security() == SEC_SERVER) {
+ DEBUG(5,("attempting password server validation\n"));
+ cli = server_cryptkey();
+ } else {
+ DEBUG(5,("not attempting password server validation\n"));
+ }
+
+ if (cli) {
+ DEBUG(3,("using password server validation\n"));
+ doencrypt = ((cli->sec_mode & 2) != 0);
+ } else {
+ DEBUG(3,("not using password server validation\n"));
+ }
+
+ if (doencrypt) {
+ crypt_len = 8;
+ if (!cli) {
+ generate_next_challenge(cryptkey);
+ } else {
+ memcpy(cryptkey, cli->cryptkey, 8);
+ set_challenge(cli->cryptkey);
+ }
+ }
+
+ if (lp_nt_smb_support()) {
+ capabilities |= CAP_NT_SMBS|CAP_RPC_REMOTE_APIS;
+ }
+
+ if (lp_large_readwrite() && (SMB_OFF_T_BITS == 64)) {
+ capabilities |= CAP_LARGE_READX|CAP_LARGE_WRITEX|CAP_W2K_SMBS;
+ }
+
+ if (SMB_OFF_T_BITS == 64) {
+ capabilities |= CAP_LARGE_FILES;
+ }
+
+ if (lp_readraw() && lp_writeraw()) {
+ capabilities |= CAP_RAW_MODE;
+ }
+
+ /* allow for disabling unicode */
+ if (lp_unicode()) {
+ capabilities |= CAP_UNICODE;
+ }
+
#ifdef WITH_MSDFS
- if(lp_host_msdfs())
- capabilities |= CAP_DFS;
+ if(lp_host_msdfs())
+ capabilities |= CAP_DFS;
#endif
-
- if (lp_security() >= SEC_USER) secword |= 1;
- if (doencrypt) secword |= 2;
-
- set_message(outbuf,17,0,True);
-
- CVAL(outbuf,smb_vwv1) = secword;
- SSVALS(outbuf,smb_vwv16+1,crypt_len);
-
- Protocol = PROTOCOL_NT1;
-
- SSVAL(outbuf,smb_vwv1+1,lp_maxmux()); /* maxmpx */
- SSVAL(outbuf,smb_vwv2+1,1); /* num vcs */
- SIVAL(outbuf,smb_vwv3+1,0xffff); /* max buffer. LOTS! */
- SIVAL(outbuf,smb_vwv5+1,0x10000); /* raw size. full 64k */
- SIVAL(outbuf,smb_vwv7+1,sys_getpid()); /* session key */
- SIVAL(outbuf,smb_vwv9+1,capabilities); /* capabilities */
- put_long_date(outbuf+smb_vwv11+1,t);
- SSVALS(outbuf,smb_vwv15+1,TimeDiff(t)/60);
-
- p = q = smb_buf(outbuf);
- if (doencrypt) memcpy(p, cryptkey, 8);
- p += 8;
- p += srvstr_push(outbuf, p, global_myworkgroup, -1,
- STR_UNICODE|STR_TERMINATE|STR_NOALIGN);
-
- SSVAL(outbuf,smb_vwv17, p - q); /* length of challenge+domain strings */
- set_message_end(outbuf, p);
-
- return (smb_len(outbuf)+4);
+
+ if (lp_security() >= SEC_USER) secword |= 1;
+ if (doencrypt) secword |= 2;
+
+ set_message(outbuf,17,0,True);
+
+ CVAL(outbuf,smb_vwv1) = secword;
+ SSVALS(outbuf,smb_vwv16+1,crypt_len);
+
+ Protocol = PROTOCOL_NT1;
+
+ SSVAL(outbuf,smb_vwv1+1,lp_maxmux()); /* maxmpx */
+ SSVAL(outbuf,smb_vwv2+1,1); /* num vcs */
+ SIVAL(outbuf,smb_vwv3+1,0xffff); /* max buffer. LOTS! */
+ SIVAL(outbuf,smb_vwv5+1,0x10000); /* raw size. full 64k */
+ SIVAL(outbuf,smb_vwv7+1,sys_getpid()); /* session key */
+ SIVAL(outbuf,smb_vwv9+1,capabilities); /* capabilities */
+ put_long_date(outbuf+smb_vwv11+1,t);
+ SSVALS(outbuf,smb_vwv15+1,TimeDiff(t)/60);
+
+ p = q = smb_buf(outbuf);
+ if (doencrypt) memcpy(p, cryptkey, 8);
+ p += 8;
+ p += srvstr_push(outbuf, p, global_myworkgroup, -1,
+ STR_UNICODE|STR_TERMINATE|STR_NOALIGN);
+
+ SSVAL(outbuf,smb_vwv17, p - q); /* length of challenge+domain strings */
+ set_message_end(outbuf, p);
+
+ return (smb_len(outbuf)+4);
}
/* these are the protocol lists used for auto architecture detection: