summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-03-21 23:49:57 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:18:49 -0500
commit8c395be5e514a28f13608a462c0c0e8417e21160 (patch)
tree2e3703e825b1e2b35225b7b7fd75b1e43f8b5438 /source3/lib
parenta38b34aa3b239cb6037063787531b1dde9e414f2 (diff)
downloadsamba-8c395be5e514a28f13608a462c0c0e8417e21160.tar.gz
samba-8c395be5e514a28f13608a462c0c0e8417e21160.tar.bz2
samba-8c395be5e514a28f13608a462c0c0e8417e21160.zip
r21922: Fixed the build by rather horrid means. I really need
to restructure libsmb/smb_signing.c so it isn't in the base libs path but lives in libsmb instead (like smb_seal.c does). Jeremy. (This used to be commit 1b828f051d0782201f697de15ff973bd6b097d5b)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/util_sock.c57
1 files changed, 29 insertions, 28 deletions
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c
index 755ad39261..a58fb03e77 100644
--- a/source3/lib/util_sock.c
+++ b/source3/lib/util_sock.c
@@ -732,32 +732,32 @@ BOOL receive_smb_raw(int fd, char *buffer, unsigned int timeout)
BOOL receive_smb(int fd, char *buffer, unsigned int timeout)
{
- NTSTATUS status;
-
if (!receive_smb_raw(fd, buffer, timeout)) {
return False;
}
- status = srv_decrypt_buffer(buffer);
- if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0, ("receive_smb: SMB decryption failed on incoming packet! Error %s\n",
- nt_errstr(status) ));
- if (smb_read_error == 0) {
- smb_read_error = READ_BAD_DECRYPT;
+ if (srv_encryption_on()) {
+ NTSTATUS status = srv_decrypt_buffer(buffer);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0, ("receive_smb: SMB decryption failed on incoming packet! Error %s\n",
+ nt_errstr(status) ));
+ if (smb_read_error == 0) {
+ smb_read_error = READ_BAD_DECRYPT;
+ }
+ return False;
}
- return False;
- }
-
- /* Check the incoming SMB signature. */
- if (!srv_check_sign_mac(buffer, True)) {
- DEBUG(0, ("receive_smb: SMB Signature verification failed on incoming packet!\n"));
- if (smb_read_error == 0) {
- smb_read_error = READ_BAD_SIG;
+ } else {
+ /* Check the incoming SMB signature. */
+ if (!srv_check_sign_mac(buffer, True)) {
+ DEBUG(0, ("receive_smb: SMB Signature verification failed on incoming packet!\n"));
+ if (smb_read_error == 0) {
+ smb_read_error = READ_BAD_SIG;
+ }
+ return False;
}
- return False;
- };
+ }
- return(True);
+ return True;
}
/****************************************************************************
@@ -766,20 +766,21 @@ BOOL receive_smb(int fd, char *buffer, unsigned int timeout)
BOOL send_smb(int fd, char *buffer)
{
- NTSTATUS status;
size_t len;
size_t nwritten=0;
ssize_t ret;
- char *buf_out;
+ char *buf_out = buffer;
/* Sign the outgoing packet if required. */
- srv_calculate_sign_mac(buffer);
-
- status = srv_encrypt_buffer(buffer, &buf_out);
- if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0, ("send_smb: SMB encryption failed on outgoing packet! Error %s\n",
- nt_errstr(status) ));
- return False;
+ if (!srv_encryption_on()) {
+ srv_calculate_sign_mac(buf_out);
+ } else {
+ NTSTATUS status = srv_encrypt_buffer(buffer, &buf_out);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0, ("send_smb: SMB encryption failed on outgoing packet! Error %s\n",
+ nt_errstr(status) ));
+ return False;
+ }
}
len = smb_len(buf_out) + 4;