summaryrefslogtreecommitdiff
path: root/source4/libcli
diff options
context:
space:
mode:
Diffstat (limited to 'source4/libcli')
-rw-r--r--source4/libcli/auth/credentials.c12
-rw-r--r--source4/libcli/auth/session.c10
-rw-r--r--source4/libcli/auth/smbencrypt.c56
-rw-r--r--source4/libcli/cldap/cldap.c24
-rw-r--r--source4/libcli/cliconnect.c35
-rw-r--r--source4/libcli/clideltree.c10
-rw-r--r--source4/libcli/clifile.c9
-rw-r--r--source4/libcli/clilist.c38
-rw-r--r--source4/libcli/climessage.c19
-rw-r--r--source4/libcli/clireadwrite.c9
-rw-r--r--source4/libcli/clitrans2.c1
-rw-r--r--source4/libcli/composite/composite.c14
-rw-r--r--source4/libcli/config.mk16
-rw-r--r--source4/libcli/dgram/browse.c3
-rw-r--r--source4/libcli/dgram/mailslot.c3
-rw-r--r--source4/libcli/dgram/netlogon.c3
-rw-r--r--source4/libcli/dgram/ntlogon.c3
-rw-r--r--source4/libcli/finddcs.c6
-rw-r--r--source4/libcli/ldap/ldap.c38
-rw-r--r--source4/libcli/ldap/ldap.h1
-rw-r--r--source4/libcli/ldap/ldap_bind.c2
-rw-r--r--source4/libcli/ldap/ldap_client.c6
-rw-r--r--source4/libcli/ldap/ldap_controls.c530
-rw-r--r--source4/libcli/ldap/ldap_ildap.c6
-rw-r--r--source4/libcli/ldap/ldap_msg.c18
-rw-r--r--source4/libcli/libcli.h2
-rw-r--r--source4/libcli/nbt/namequery.c9
-rw-r--r--source4/libcli/nbt/namerefresh.c10
-rw-r--r--source4/libcli/nbt/nameregister.c21
-rw-r--r--source4/libcli/nbt/namerelease.c5
-rw-r--r--source4/libcli/nbt/nbtname.c6
-rw-r--r--source4/libcli/nbt/nbtsocket.c14
-rw-r--r--source4/libcli/raw/clierror.c (renamed from source4/libcli/util/clierror.c)2
-rw-r--r--source4/libcli/raw/clioplock.c6
-rw-r--r--source4/libcli/raw/clisession.c2
-rw-r--r--source4/libcli/raw/clisocket.c5
-rw-r--r--source4/libcli/raw/clitransport.c27
-rw-r--r--source4/libcli/raw/clitree.c7
-rw-r--r--source4/libcli/raw/interfaces.h1
-rw-r--r--source4/libcli/raw/raweas.c7
-rw-r--r--source4/libcli/raw/rawfile.c4
-rw-r--r--source4/libcli/raw/rawfileinfo.c2
-rw-r--r--source4/libcli/raw/rawlpq.c1
-rw-r--r--source4/libcli/raw/rawnegotiate.c11
-rw-r--r--source4/libcli/raw/rawreadwrite.c10
-rw-r--r--source4/libcli/raw/rawrequest.c40
-rw-r--r--source4/libcli/raw/rawsetfileinfo.c40
-rw-r--r--source4/libcli/raw/rawshadow.c2
-rw-r--r--source4/libcli/raw/rawtrans.c12
-rw-r--r--source4/libcli/raw/smb_signing.c93
-rw-r--r--source4/libcli/resolve/bcast.c2
-rw-r--r--source4/libcli/resolve/nbtlist.c9
-rw-r--r--source4/libcli/resolve/resolve.c6
-rw-r--r--source4/libcli/resolve/wins.c12
-rw-r--r--source4/libcli/security/dom_sid.c15
-rw-r--r--source4/libcli/security/privilege.c11
-rw-r--r--source4/libcli/security/sddl.c48
-rw-r--r--source4/libcli/security/security_descriptor.c78
-rw-r--r--source4/libcli/security/security_token.c32
-rw-r--r--source4/libcli/smb2/cancel.c2
-rw-r--r--source4/libcli/smb2/close.c4
-rw-r--r--source4/libcli/smb2/connect.c8
-rw-r--r--source4/libcli/smb2/create.c10
-rw-r--r--source4/libcli/smb2/find.c4
-rw-r--r--source4/libcli/smb2/flush.c4
-rw-r--r--source4/libcli/smb2/getinfo.c4
-rw-r--r--source4/libcli/smb2/ioctl.c4
-rw-r--r--source4/libcli/smb2/keepalive.c4
-rw-r--r--source4/libcli/smb2/lock.c4
-rw-r--r--source4/libcli/smb2/logoff.c4
-rw-r--r--source4/libcli/smb2/negprot.c4
-rw-r--r--source4/libcli/smb2/notify.c4
-rw-r--r--source4/libcli/smb2/read.c4
-rw-r--r--source4/libcli/smb2/request.c27
-rw-r--r--source4/libcli/smb2/session.c6
-rw-r--r--source4/libcli/smb2/setinfo.c4
-rw-r--r--source4/libcli/smb2/tcon.c6
-rw-r--r--source4/libcli/smb2/tdis.c4
-rw-r--r--source4/libcli/smb2/transport.c2
-rw-r--r--source4/libcli/smb2/write.c4
-rw-r--r--source4/libcli/smb_composite/appendacl.c2
-rw-r--r--source4/libcli/smb_composite/connect.c20
-rw-r--r--source4/libcli/smb_composite/fetchfile.c2
-rw-r--r--source4/libcli/smb_composite/fsinfo.c2
-rw-r--r--source4/libcli/smb_composite/loadfile.c4
-rw-r--r--source4/libcli/smb_composite/savefile.c2
-rw-r--r--source4/libcli/smb_composite/sesssetup.c21
-rw-r--r--source4/libcli/swig/libcli_nbt.i23
-rw-r--r--source4/libcli/swig/libcli_smb.i18
-rw-r--r--source4/libcli/util/asn1.c303
-rw-r--r--source4/libcli/util/clilsa.c3
-rw-r--r--source4/libcli/util/doserr.c3
-rw-r--r--source4/libcli/util/doserr.h125
-rw-r--r--source4/libcli/util/error.h29
-rw-r--r--source4/libcli/util/errormap.c5
-rw-r--r--source4/libcli/util/nt_status.h122
-rw-r--r--source4/libcli/util/nterr.c3
-rw-r--r--source4/libcli/util/ntstatus.h (renamed from source4/libcli/util/nterr.h)93
-rw-r--r--source4/libcli/util/werror.h193
-rw-r--r--source4/libcli/wrepl/winsrepl.c18
-rw-r--r--source4/libcli/wrepl/winsrepl.h2
101 files changed, 1338 insertions, 1196 deletions
diff --git a/source4/libcli/auth/credentials.c b/source4/libcli/auth/credentials.c
index feb8c92a0b..a6cb17c12e 100644
--- a/source4/libcli/auth/credentials.c
+++ b/source4/libcli/auth/credentials.c
@@ -235,15 +235,15 @@ void creds_client_authenticator(struct creds_CredentialState *creds,
/*
check that a credentials reply from a server is correct
*/
-BOOL creds_client_check(struct creds_CredentialState *creds,
+bool creds_client_check(struct creds_CredentialState *creds,
const struct netr_Credential *received_credentials)
{
if (!received_credentials ||
memcmp(received_credentials->data, creds->server.data, 8) != 0) {
DEBUG(2,("credentials check failed\n"));
- return False;
+ return false;
}
- return True;
+ return true;
}
@@ -278,16 +278,16 @@ void creds_server_init(struct creds_CredentialState *creds,
/*
check that a credentials reply from a server is correct
*/
-BOOL creds_server_check(const struct creds_CredentialState *creds,
+bool creds_server_check(const struct creds_CredentialState *creds,
const struct netr_Credential *received_credentials)
{
if (memcmp(received_credentials->data, creds->client.data, 8) != 0) {
DEBUG(2,("credentials check failed\n"));
dump_data_pw("client creds", creds->client.data, 8);
dump_data_pw("calc creds", received_credentials->data, 8);
- return False;
+ return false;
}
- return True;
+ return true;
}
NTSTATUS creds_server_step_check(struct creds_CredentialState *creds,
diff --git a/source4/libcli/auth/session.c b/source4/libcli/auth/session.c
index 7f44b6b5a9..29af7fafe8 100644
--- a/source4/libcli/auth/session.c
+++ b/source4/libcli/auth/session.c
@@ -30,7 +30,7 @@
as the in blob
*/
static void sess_crypt_blob(DATA_BLOB *out, const DATA_BLOB *in, const DATA_BLOB *session_key,
- BOOL forward)
+ bool forward)
{
int i, k;
@@ -84,7 +84,7 @@ DATA_BLOB sess_encrypt_string(const char *str, const DATA_BLOB *session_key)
memset(src.data+8, 0, dlen);
memcpy(src.data+8, str, slen);
- sess_crypt_blob(&ret, &src, session_key, True);
+ sess_crypt_blob(&ret, &src, session_key, true);
data_blob_free(&src);
@@ -112,7 +112,7 @@ char *sess_decrypt_string(TALLOC_CTX *mem_ctx,
return NULL;
}
- sess_crypt_blob(&out, blob, session_key, False);
+ sess_crypt_blob(&out, blob, session_key, false);
if (IVAL(out.data, 4) != 1) {
DEBUG(0,("Unexpected revision number %d in session crypted string\n",
@@ -166,7 +166,7 @@ DATA_BLOB sess_encrypt_blob(TALLOC_CTX *mem_ctx, DATA_BLOB *blob_in, const DATA_
memset(src.data+8, 0, dlen);
memcpy(src.data+8, blob_in->data, blob_in->length);
- sess_crypt_blob(&ret, &src, session_key, True);
+ sess_crypt_blob(&ret, &src, session_key, true);
data_blob_free(&src);
@@ -193,7 +193,7 @@ NTSTATUS sess_decrypt_blob(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob, const DAT
return NT_STATUS_NO_MEMORY;
}
- sess_crypt_blob(&out, blob, session_key, False);
+ sess_crypt_blob(&out, blob, session_key, false);
if (IVAL(out.data, 4) != 1) {
DEBUG(2,("Unexpected revision number %d in session crypted secret (BLOB)\n",
diff --git a/source4/libcli/auth/smbencrypt.c b/source4/libcli/auth/smbencrypt.c
index 1f940fb79d..bfac395ef9 100644
--- a/source4/libcli/auth/smbencrypt.c
+++ b/source4/libcli/auth/smbencrypt.c
@@ -34,11 +34,11 @@
It takes a password ('unix' string), a 8 byte "crypt key"
and puts 24 bytes of encrypted password into p24
- Returns False if password must have been truncated to create LM hash
+ Returns false if password must have been truncated to create LM hash
*/
-BOOL SMBencrypt(const char *passwd, const uint8_t *c8, uint8_t p24[24])
+bool SMBencrypt(const char *passwd, const uint8_t *c8, uint8_t p24[24])
{
- BOOL ret;
+ bool ret;
uint8_t p21[21];
memset(p21,'\0',21);
@@ -62,7 +62,7 @@ BOOL SMBencrypt(const char *passwd, const uint8_t *c8, uint8_t p24[24])
* @param p16 return password hashed with md4, caller allocated 16 byte buffer
*/
-_PUBLIC_ BOOL E_md4hash(const char *passwd, uint8_t p16[16])
+_PUBLIC_ bool E_md4hash(const char *passwd, uint8_t p16[16])
{
int len;
void *wpwd;
@@ -72,27 +72,27 @@ _PUBLIC_ BOOL E_md4hash(const char *passwd, uint8_t p16[16])
/* We don't want to return fixed data, as most callers
* don't check */
mdfour(p16, (const uint8_t *)passwd, strlen(passwd));
- return False;
+ return false;
}
len -= 2;
mdfour(p16, wpwd, len);
talloc_free(wpwd);
- return True;
+ return true;
}
/**
* Creates the DES forward-only Hash of the users password in DOS ASCII charset
* @param passwd password in 'unix' charset.
* @param p16 return password hashed with DES, caller allocated 16 byte buffer
- * @return False if password was > 14 characters, and therefore may be incorrect, otherwise True
+ * @return false if password was > 14 characters, and therefore may be incorrect, otherwise true
* @note p16 is filled in regardless
*/
-_PUBLIC_ BOOL E_deshash(const char *passwd, uint8_t p16[16])
+_PUBLIC_ bool E_deshash(const char *passwd, uint8_t p16[16])
{
- BOOL ret = True;
+ bool ret = true;
fstring dospwd;
ZERO_STRUCT(dospwd);
@@ -103,7 +103,7 @@ _PUBLIC_ BOOL E_deshash(const char *passwd, uint8_t p16[16])
E_P16((const uint8_t *)dospwd, p16);
if (strlen(dospwd) > 14) {
- ret = False;
+ ret = false;
}
ZERO_STRUCT(dospwd);
@@ -112,9 +112,9 @@ _PUBLIC_ BOOL E_deshash(const char *passwd, uint8_t p16[16])
}
/* Does both the NTLMv2 owfs of a user's password */
-BOOL ntv2_owf_gen(const uint8_t owf[16],
+bool ntv2_owf_gen(const uint8_t owf[16],
const char *user_in, const char *domain_in,
- BOOL upper_case_domain, /* Transform the domain into UPPER case */
+ bool upper_case_domain, /* Transform the domain into UPPER case */
uint8_t kr_buf[16])
{
void *user;
@@ -125,7 +125,7 @@ BOOL ntv2_owf_gen(const uint8_t owf[16],
HMACMD5Context ctx;
TALLOC_CTX *mem_ctx = talloc_init("ntv2_owf_gen for %s\\%s", domain_in, user_in);
if (!mem_ctx) {
- return False;
+ return false;
}
if (!user_in) {
@@ -139,14 +139,14 @@ BOOL ntv2_owf_gen(const uint8_t owf[16],
user_in = strupper_talloc(mem_ctx, user_in);
if (user_in == NULL) {
talloc_free(mem_ctx);
- return False;
+ return false;
}
if (upper_case_domain) {
domain_in = strupper_talloc(mem_ctx, domain_in);
if (domain_in == NULL) {
talloc_free(mem_ctx);
- return False;
+ return false;
}
}
@@ -154,14 +154,14 @@ BOOL ntv2_owf_gen(const uint8_t owf[16],
if (user_byte_len == (ssize_t)-1) {
DEBUG(0, ("push_uss2_talloc() for user returned -1 (probably talloc() failure)\n"));
talloc_free(mem_ctx);
- return False;
+ return false;
}
domain_byte_len = push_ucs2_talloc(mem_ctx, &domain, domain_in);
if (domain_byte_len == (ssize_t)-1) {
DEBUG(0, ("push_ucs2_talloc() for domain returned -1 (probably talloc() failure)\n"));
talloc_free(mem_ctx);
- return False;
+ return false;
}
SMB_ASSERT(user_byte_len >= 2);
@@ -185,7 +185,7 @@ BOOL ntv2_owf_gen(const uint8_t owf[16],
#endif
talloc_free(mem_ctx);
- return True;
+ return true;
}
/* Does the des encryption from the NT or LM MD4 hash. */
@@ -393,7 +393,7 @@ static DATA_BLOB LMv2_generate_response(TALLOC_CTX *mem_ctx,
return final_response;
}
-BOOL SMBNTLMv2encrypt_hash(TALLOC_CTX *mem_ctx,
+bool SMBNTLMv2encrypt_hash(TALLOC_CTX *mem_ctx,
const char *user, const char *domain, const uint8_t nt_hash[16],
const DATA_BLOB *server_chal,
const DATA_BLOB *names_blob,
@@ -406,8 +406,8 @@ BOOL SMBNTLMv2encrypt_hash(TALLOC_CTX *mem_ctx,
the username and domain.
This prevents username swapping during the auth exchange
*/
- if (!ntv2_owf_gen(nt_hash, user, domain, True, ntlm_v2_hash)) {
- return False;
+ if (!ntv2_owf_gen(nt_hash, user, domain, true, ntlm_v2_hash)) {
+ return false;
}
if (nt_response) {
@@ -437,10 +437,10 @@ BOOL SMBNTLMv2encrypt_hash(TALLOC_CTX *mem_ctx,
}
}
- return True;
+ return true;
}
-BOOL SMBNTLMv2encrypt(TALLOC_CTX *mem_ctx,
+bool SMBNTLMv2encrypt(TALLOC_CTX *mem_ctx,
const char *user, const char *domain,
const char *password,
const DATA_BLOB *server_chal,
@@ -460,7 +460,7 @@ BOOL SMBNTLMv2encrypt(TALLOC_CTX *mem_ctx,
encode a password buffer with a unicode password. The buffer
is filled with random data to make it harder to attack.
************************************************************/
-BOOL encode_pw_buffer(uint8_t buffer[516], const char *password, int string_flags)
+bool encode_pw_buffer(uint8_t buffer[516], const char *password, int string_flags)
{
uint8_t new_pw[512];
size_t new_pw_len;
@@ -482,7 +482,7 @@ BOOL encode_pw_buffer(uint8_t buffer[516], const char *password, int string_flag
*/
SIVAL(buffer, 512, new_pw_len);
ZERO_STRUCT(new_pw);
- return True;
+ return true;
}
@@ -491,7 +491,7 @@ BOOL encode_pw_buffer(uint8_t buffer[516], const char *password, int string_flag
*new_pw_len is the length in bytes of the possibly mulitbyte
returned password including termination.
************************************************************/
-BOOL decode_pw_buffer(uint8_t in_buffer[516], char *new_pwrd,
+bool decode_pw_buffer(uint8_t in_buffer[516], char *new_pwrd,
int new_pwrd_size, uint32_t *new_pw_len,
int string_flags)
{
@@ -517,7 +517,7 @@ BOOL decode_pw_buffer(uint8_t in_buffer[516], char *new_pwrd,
/* Password cannot be longer than the size of the password buffer */
if ( (byte_len < 0) || (byte_len > 512)) {
- return False;
+ return false;
}
/* decode into the return buffer. Buffer length supplied */
@@ -531,5 +531,5 @@ BOOL decode_pw_buffer(uint8_t in_buffer[516], char *new_pwrd,
DEBUG(100,("original char len:%d\n", byte_len/2));
#endif
- return True;
+ return true;
}
diff --git a/source4/libcli/cldap/cldap.c b/source4/libcli/cldap/cldap.c
index 33d6e88a30..f2f661acaa 100644
--- a/source4/libcli/cldap/cldap.c
+++ b/source4/libcli/cldap/cldap.c
@@ -39,6 +39,7 @@
#include "lib/socket/socket.h"
#include "libcli/security/security.h"
#include "librpc/gen_ndr/ndr_nbt.h"
+#include "param/param.h"
/*
destroy a pending request
@@ -308,14 +309,15 @@ struct cldap_request *cldap_search_send(struct cldap_socket *cldap,
req->state = CLDAP_REQUEST_SEND;
req->timeout = io->in.timeout;
req->num_retries = io->in.retries;
- req->is_reply = False;
+ req->is_reply = false;
req->asn1 = asn1_init(req);
if (!req->asn1) {
goto failed;
}
req->dest = socket_address_from_strings(req, cldap->sock->backend_name,
- io->in.dest_address, lp_cldap_port());
+ io->in.dest_address,
+ lp_cldap_port(global_loadparm));
if (!req->dest) goto failed;
req->message_id = idr_get_new_random(cldap->idr, req, UINT16_MAX);
@@ -335,7 +337,7 @@ struct cldap_request *cldap_search_send(struct cldap_socket *cldap,
search->deref = LDAP_DEREFERENCE_NEVER;
search->timelimit = 0;
search->sizelimit = 0;
- search->attributesonly = False;
+ search->attributesonly = false;
search->num_attributes = str_list_length(io->in.attributes);
search->attributes = io->in.attributes;
search->tree = ldb_parse_tree(req, io->in.filter);
@@ -376,7 +378,7 @@ NTSTATUS cldap_reply_send(struct cldap_socket *cldap, struct cldap_reply *io)
req->cldap = cldap;
req->state = CLDAP_REQUEST_SEND;
- req->is_reply = True;
+ req->is_reply = true;
req->asn1 = asn1_init(req);
if (!req->asn1) {
goto failed;
@@ -534,26 +536,26 @@ struct cldap_request *cldap_netlogon_send(struct cldap_socket *cldap,
ldap_encode_ndr_uint32(tmp_ctx, io->in.version));
if (filter == NULL) goto failed;
if (io->in.user) {
- filter = talloc_asprintf_append(filter, "(User=%s)", io->in.user);
+ filter = talloc_asprintf_append_buffer(filter, "(User=%s)", io->in.user);
if (filter == NULL) goto failed;
}
if (io->in.host) {
- filter = talloc_asprintf_append(filter, "(Host=%s)", io->in.host);
+ filter = talloc_asprintf_append_buffer(filter, "(Host=%s)", io->in.host);
if (filter == NULL) goto failed;
}
if (io->in.realm) {
- filter = talloc_asprintf_append(filter, "(DnsDomain=%s)", io->in.realm);
+ filter = talloc_asprintf_append_buffer(filter, "(DnsDomain=%s)", io->in.realm);
if (filter == NULL) goto failed;
}
if (io->in.acct_control != -1) {
- filter = talloc_asprintf_append(filter, "(AAC=%s)",
+ filter = talloc_asprintf_append_buffer(filter, "(AAC=%s)",
ldap_encode_ndr_uint32(tmp_ctx, io->in.acct_control));
if (filter == NULL) goto failed;
}
if (io->in.domain_sid) {
struct dom_sid *sid = dom_sid_parse_talloc(tmp_ctx, io->in.domain_sid);
if (sid == NULL) goto failed;
- filter = talloc_asprintf_append(filter, "(domainSid=%s)",
+ filter = talloc_asprintf_append_buffer(filter, "(domainSid=%s)",
ldap_encode_ndr_dom_sid(tmp_ctx, sid));
if (filter == NULL) goto failed;
}
@@ -562,11 +564,11 @@ struct cldap_request *cldap_netlogon_send(struct cldap_socket *cldap,
NTSTATUS status;
status = GUID_from_string(io->in.domain_guid, &guid);
if (!NT_STATUS_IS_OK(status)) goto failed;
- filter = talloc_asprintf_append(filter, "(DomainGuid=%s)",
+ filter = talloc_asprintf_append_buffer(filter, "(DomainGuid=%s)",
ldap_encode_ndr_GUID(tmp_ctx, &guid));
if (filter == NULL) goto failed;
}
- filter = talloc_asprintf_append(filter, ")");
+ filter = talloc_asprintf_append_buffer(filter, ")");
if (filter == NULL) goto failed;
search.in.dest_address = io->in.dest_address;
diff --git a/source4/libcli/cliconnect.c b/source4/libcli/cliconnect.c
index e0f3c598b4..a56100fc80 100644
--- a/source4/libcli/cliconnect.c
+++ b/source4/libcli/cliconnect.c
@@ -25,28 +25,29 @@
#include "libcli/raw/libcliraw.h"
#include "libcli/auth/libcli_auth.h"
#include "libcli/smb_composite/smb_composite.h"
+#include "param/param.h"
/*
wrapper around smbcli_sock_connect()
*/
-BOOL smbcli_socket_connect(struct smbcli_state *cli, const char *server)
+bool smbcli_socket_connect(struct smbcli_state *cli, const char *server)
{
struct smbcli_socket *sock;
sock = smbcli_sock_connect_byname(server, 0, NULL, NULL);
- if (sock == NULL) return False;
+ if (sock == NULL) return false;
- cli->transport = smbcli_transport_init(sock, cli, True);
+ cli->transport = smbcli_transport_init(sock, cli, true);
if (!cli->transport) {
- return False;
+ return false;
}
- return True;
+ return true;
}
/* wrapper around smbcli_transport_connect() */
-BOOL smbcli_transport_establish(struct smbcli_state *cli,
+bool smbcli_transport_establish(struct smbcli_state *cli,
struct nbt_name *calling,
struct nbt_name *called)
{
@@ -56,7 +57,8 @@ BOOL smbcli_transport_establish(struct smbcli_state *cli,
/* wrapper around smb_raw_negotiate() */
NTSTATUS smbcli_negprot(struct smbcli_state *cli)
{
- return smb_raw_negotiate(cli->transport, lp_cli_maxprotocol());
+ return smb_raw_negotiate(cli->transport,
+ lp_cli_maxprotocol(global_loadparm));
}
/* wrapper around smb_raw_sesssetup() */
@@ -66,13 +68,13 @@ NTSTATUS smbcli_session_setup(struct smbcli_state *cli,
struct smb_composite_sesssetup setup;
NTSTATUS status;
- cli->session = smbcli_session_init(cli->transport, cli, True);
+ cli->session = smbcli_session_init(cli->transport, cli, true);
if (!cli->session) return NT_STATUS_UNSUCCESSFUL;
setup.in.sesskey = cli->transport->negotiate.sesskey;
setup.in.capabilities = cli->transport->negotiate.capabilities;
setup.in.credentials = credentials;
- setup.in.workgroup = lp_workgroup();
+ setup.in.workgroup = lp_workgroup(global_loadparm);
status = smb_composite_sesssetup(cli->session, &setup);
@@ -89,7 +91,7 @@ NTSTATUS smbcli_tconX(struct smbcli_state *cli, const char *sharename,
TALLOC_CTX *mem_ctx;
NTSTATUS status;
- cli->tree = smbcli_tree_init(cli->session, cli, True);
+ cli->tree = smbcli_tree_init(cli->session, cli, true);
if (!cli->tree) return NT_STATUS_UNSUCCESSFUL;
mem_ctx = talloc_init("tcon");
@@ -205,7 +207,7 @@ terminate_path_at_separator(char * path)
/*
parse a //server/share type UNC name
*/
-BOOL smbcli_parse_unc(const char *unc_name, TALLOC_CTX *mem_ctx,
+bool smbcli_parse_unc(const char *unc_name, TALLOC_CTX *mem_ctx,
char **hostname, char **sharename)
{
char *p;
@@ -214,28 +216,25 @@ BOOL smbcli_parse_unc(const char *unc_name, TALLOC_CTX *mem_ctx,
if (strncmp(unc_name, "\\\\", 2) &&
strncmp(unc_name, "//", 2)) {
- return False;
+ return false;
}
*hostname = talloc_strdup(mem_ctx, &unc_name[2]);
p = terminate_path_at_separator(*hostname);
- if (p && *p) {
+ if (p != NULL && *p) {
*sharename = talloc_strdup(mem_ctx, p);
terminate_path_at_separator(*sharename);
- } else {
- *sharename = talloc_strdup(mem_ctx,
- lp_parm_string(-1, "torture", "share"));
}
if (*hostname && *sharename) {
- return True;
+ return true;
}
talloc_free(*hostname);
talloc_free(*sharename);
*hostname = *sharename = NULL;
- return False;
+ return false;
}
diff --git a/source4/libcli/clideltree.c b/source4/libcli/clideltree.c
index 33c39ea093..2c306e501e 100644
--- a/source4/libcli/clideltree.c
+++ b/source4/libcli/clideltree.c
@@ -25,7 +25,7 @@
struct delete_state {
struct smbcli_tree *tree;
int total_deleted;
- BOOL failed;
+ bool failed;
};
/*
@@ -33,7 +33,7 @@ struct delete_state {
*/
static void delete_fn(struct clilist_file_info *finfo, const char *name, void *state)
{
- struct delete_state *dstate = state;
+ struct delete_state *dstate = (struct delete_state *)state;
char *s, *n;
if (ISDOT(finfo->name) || ISDOTDOT(finfo->name)) {
return;
@@ -61,14 +61,14 @@ static void delete_fn(struct clilist_file_info *finfo, const char *name, void *s
if (NT_STATUS_IS_ERR(smbcli_rmdir(dstate->tree, s))) {
DEBUG(2,("Failed to delete %s - %s\n",
s, smbcli_errstr(dstate->tree)));
- dstate->failed = True;
+ dstate->failed = true;
}
dstate->total_deleted++;
} else {
if (NT_STATUS_IS_ERR(smbcli_unlink(dstate->tree, s))) {
DEBUG(2,("Failed to delete %s - %s\n",
s, smbcli_errstr(dstate->tree)));
- dstate->failed = True;
+ dstate->failed = true;
}
dstate->total_deleted++;
}
@@ -87,7 +87,7 @@ int smbcli_deltree(struct smbcli_tree *tree, const char *dname)
dstate.tree = tree;
dstate.total_deleted = 0;
- dstate.failed = False;
+ dstate.failed = false;
/* it might be a file */
if (NT_STATUS_IS_OK(smbcli_unlink(tree, dname))) {
diff --git a/source4/libcli/clifile.c b/source4/libcli/clifile.c
index b30b82bd79..e59b7f9af3 100644
--- a/source4/libcli/clifile.c
+++ b/source4/libcli/clifile.c
@@ -30,7 +30,7 @@
static NTSTATUS smbcli_link_internal(struct smbcli_tree *tree,
const char *fname_src,
- const char *fname_dst, BOOL hard_link)
+ const char *fname_dst, bool hard_link)
{
union smb_setfileinfo parms;
NTSTATUS status;
@@ -84,7 +84,7 @@ uint32_t unix_perms_to_wire(mode_t perms)
NTSTATUS smbcli_unix_symlink(struct smbcli_tree *tree, const char *fname_src,
const char *fname_dst)
{
- return smbcli_link_internal(tree, fname_src, fname_dst, False);
+ return smbcli_link_internal(tree, fname_src, fname_dst, false);
}
/****************************************************************************
@@ -93,7 +93,7 @@ NTSTATUS smbcli_unix_symlink(struct smbcli_tree *tree, const char *fname_src,
NTSTATUS smbcli_unix_hardlink(struct smbcli_tree *tree, const char *fname_src,
const char *fname_dst)
{
- return smbcli_link_internal(tree, fname_src, fname_dst, True);
+ return smbcli_link_internal(tree, fname_src, fname_dst, true);
}
@@ -206,7 +206,8 @@ NTSTATUS smbcli_rmdir(struct smbcli_tree *tree, const char *dname)
/****************************************************************************
Set or clear the delete on close flag.
****************************************************************************/
-NTSTATUS smbcli_nt_delete_on_close(struct smbcli_tree *tree, int fnum, BOOL flag)
+NTSTATUS smbcli_nt_delete_on_close(struct smbcli_tree *tree, int fnum,
+ bool flag)
{
union smb_setfileinfo parms;
NTSTATUS status;
diff --git a/source4/libcli/clilist.c b/source4/libcli/clilist.c
index ba85ec397a..07393a3491 100644
--- a/source4/libcli/clilist.c
+++ b/source4/libcli/clilist.c
@@ -37,7 +37,7 @@ struct search_private {
/****************************************************************************
Interpret a long filename structure.
****************************************************************************/
-static BOOL interpret_long_filename(enum smb_search_data_level level,
+static bool interpret_long_filename(enum smb_search_data_level level,
const union smb_search_data *info,
struct clilist_file_info *finfo)
{
@@ -65,14 +65,14 @@ static BOOL interpret_long_filename(enum smb_search_data_level level,
default:
DEBUG(0,("Unhandled level %d in interpret_long_filename\n", (int)level));
- return False;
+ return false;
}
- return True;
+ return true;
}
/* callback function used for trans2 search */
-static BOOL smbcli_list_new_callback(void *private, const union smb_search_data *file)
+static bool smbcli_list_new_callback(void *private, const union smb_search_data *file)
{
struct search_private *state = (struct search_private*) private;
struct clilist_file_info *tdl;
@@ -83,7 +83,7 @@ static BOOL smbcli_list_new_callback(void *private, const union smb_search_data
struct clilist_file_info,
state->dirlist_len + 1);
if (!tdl) {
- return False;
+ return false;
}
state->dirlist = tdl;
state->dirlist_len++;
@@ -94,7 +94,7 @@ static BOOL smbcli_list_new_callback(void *private, const union smb_search_data
state->total_received++;
state->ff_searchcount++;
- return True;
+ return true;
}
int smbcli_list_new(struct smbcli_tree *tree, const char *Mask, uint16_t attribute,
@@ -106,7 +106,7 @@ int smbcli_list_new(struct smbcli_tree *tree, const char *Mask, uint16_t attribu
union smb_search_next next_parms;
struct search_private state; /* for callbacks */
int received = 0;
- BOOL first = True;
+ bool first = true;
int num_received = 0;
int max_matches = 512;
char *mask;
@@ -118,7 +118,8 @@ int smbcli_list_new(struct smbcli_tree *tree, const char *Mask, uint16_t attribu
state.dirlist_len = 0;
state.total_received = 0;
- state.dirlist = talloc_new(state.mem_ctx);
+ state.dirlist = talloc_array(state.mem_ctx,
+ struct clilist_file_info, 0);
mask = talloc_strdup(state.mem_ctx, Mask);
if (level == RAW_SEARCH_DATA_GENERIC) {
@@ -158,7 +159,7 @@ int smbcli_list_new(struct smbcli_tree *tree, const char *Mask, uint16_t attribu
received = first_parms.t2ffirst.out.count;
if (received <= 0) break;
if (ff_eos) break;
- first = False;
+ first = false;
} else {
NTSTATUS status;
@@ -202,7 +203,7 @@ int smbcli_list_new(struct smbcli_tree *tree, const char *Mask, uint16_t attribu
Interpret a short filename structure.
The length of the structure is returned.
****************************************************************************/
-static BOOL interpret_short_filename(enum smb_search_data_level level,
+static bool interpret_short_filename(enum smb_search_data_level level,
const union smb_search_data *info,
struct clilist_file_info *finfo)
{
@@ -222,14 +223,14 @@ static BOOL interpret_short_filename(enum smb_search_data_level level,
default:
DEBUG(0,("Unhandled level %d in interpret_short_filename\n", (int)level));
- return False;
+ return false;
}
- return True;
+ return true;
}
/* callback function used for smb_search */
-static BOOL smbcli_list_old_callback(void *private, const union smb_search_data *file)
+static bool smbcli_list_old_callback(void *private, const union smb_search_data *file)
{
struct search_private *state = (struct search_private*) private;
struct clilist_file_info *tdl;
@@ -241,7 +242,7 @@ static BOOL smbcli_list_old_callback(void *private, const union smb_search_data
state->dirlist_len + 1);
if (!tdl) {
- return False;
+ return false;
}
state->dirlist = tdl;
state->dirlist_len++;
@@ -252,7 +253,7 @@ static BOOL smbcli_list_old_callback(void *private, const union smb_search_data
state->ff_searchcount++;
state->id = file->search.id; /* return resume info */
- return True;
+ return true;
}
int smbcli_list_old(struct smbcli_tree *tree, const char *Mask, uint16_t attribute,
@@ -264,7 +265,7 @@ int smbcli_list_old(struct smbcli_tree *tree, const char *Mask, uint16_t attribu
struct search_private state; /* for callbacks */
const int num_asked = 500;
int received = 0;
- BOOL first = True;
+ bool first = true;
int num_received = 0;
char *mask;
int i;
@@ -275,7 +276,8 @@ int smbcli_list_old(struct smbcli_tree *tree, const char *Mask, uint16_t attribu
state.total_received = 0;
state.data_level = RAW_SEARCH_DATA_SEARCH;
- state.dirlist = talloc_new(state.mem_ctx);
+ state.dirlist = talloc_array(state.mem_ctx, struct clilist_file_info,
+ 0);
mask = talloc_strdup(state.mem_ctx, Mask);
while (1) {
@@ -301,7 +303,7 @@ int smbcli_list_old(struct smbcli_tree *tree, const char *Mask, uint16_t attribu
received = first_parms.search_first.out.count;
if (received <= 0) break;
- first = False;
+ first = false;
} else {
NTSTATUS status;
diff --git a/source4/libcli/climessage.c b/source4/libcli/climessage.c
index 3d4d9da96c..6002ccfc59 100644
--- a/source4/libcli/climessage.c
+++ b/source4/libcli/climessage.c
@@ -20,12 +20,13 @@
#include "includes.h"
#include "libcli/raw/libcliraw.h"
+#include "libcli/libcli.h"
/****************************************************************************
start a message sequence
****************************************************************************/
-BOOL smbcli_message_start(struct smbcli_tree *tree, const char *host, const char *username,
+bool smbcli_message_start(struct smbcli_tree *tree, const char *host, const char *username,
int *grp)
{
struct smbcli_request *req;
@@ -37,20 +38,20 @@ BOOL smbcli_message_start(struct smbcli_tree *tree, const char *host, const char
!smbcli_request_receive(req) ||
smbcli_is_error(tree)) {
smbcli_request_destroy(req);
- return False;
+ return false;
}
*grp = SVAL(req->in.vwv, VWV(0));
smbcli_request_destroy(req);
- return True;
+ return true;
}
/****************************************************************************
send a message
****************************************************************************/
-BOOL smbcli_message_text(struct smbcli_tree *tree, char *msg, int len, int grp)
+bool smbcli_message_text(struct smbcli_tree *tree, char *msg, int len, int grp)
{
struct smbcli_request *req;
@@ -63,17 +64,17 @@ BOOL smbcli_message_text(struct smbcli_tree *tree, char *msg, int len, int grp)
!smbcli_request_receive(req) ||
smbcli_is_error(tree)) {
smbcli_request_destroy(req);
- return False;
+ return false;
}
smbcli_request_destroy(req);
- return True;
+ return true;
}
/****************************************************************************
end a message
****************************************************************************/
-BOOL smbcli_message_end(struct smbcli_tree *tree, int grp)
+bool smbcli_message_end(struct smbcli_tree *tree, int grp)
{
struct smbcli_request *req;
@@ -84,10 +85,10 @@ BOOL smbcli_message_end(struct smbcli_tree *tree, int grp)
!smbcli_request_receive(req) ||
smbcli_is_error(tree)) {
smbcli_request_destroy(req);
- return False;
+ return false;
}
smbcli_request_destroy(req);
- return True;
+ return true;
}
diff --git a/source4/libcli/clireadwrite.c b/source4/libcli/clireadwrite.c
index 10a1c75308..f5ba799bbc 100644
--- a/source4/libcli/clireadwrite.c
+++ b/source4/libcli/clireadwrite.c
@@ -20,6 +20,7 @@
#include "includes.h"
#include "libcli/raw/libcliraw.h"
+#include "libcli/libcli.h"
/****************************************************************************
Read size bytes at offset offset using SMBreadX.
@@ -27,7 +28,7 @@
ssize_t smbcli_read(struct smbcli_tree *tree, int fnum, void *_buf, off_t offset,
size_t size)
{
- uint8_t *buf = _buf;
+ uint8_t *buf = (uint8_t *)_buf;
union smb_read parms;
int readsize;
ssize_t total = 0;
@@ -55,7 +56,7 @@ ssize_t smbcli_read(struct smbcli_tree *tree, int fnum, void *_buf, off_t offset
parms.readx.in.mincnt = readsize;
parms.readx.in.maxcnt = readsize;
parms.readx.in.remaining = size - total;
- parms.readx.in.read_for_execute = False;
+ parms.readx.in.read_for_execute = false;
parms.readx.out.data = buf + total;
status = smb_raw_read(tree, &parms);
@@ -87,7 +88,7 @@ ssize_t smbcli_write(struct smbcli_tree *tree,
int fnum, uint16_t write_mode,
const void *_buf, off_t offset, size_t size)
{
- const uint8_t *buf = _buf;
+ const uint8_t *buf = (const uint8_t *)_buf;
union smb_write parms;
int block = (tree->session->transport->negotiate.max_xmit - (MIN_SMB_SIZE+32));
ssize_t total = 0;
@@ -133,7 +134,7 @@ ssize_t smbcli_write(struct smbcli_tree *tree,
ssize_t smbcli_smbwrite(struct smbcli_tree *tree,
int fnum, const void *_buf, off_t offset, size_t size1)
{
- const uint8_t *buf = _buf;
+ const uint8_t *buf = (const uint8_t *)_buf;
union smb_write parms;
ssize_t total = 0;
diff --git a/source4/libcli/clitrans2.c b/source4/libcli/clitrans2.c
index 03deea2e82..5c5ba6585f 100644
--- a/source4/libcli/clitrans2.c
+++ b/source4/libcli/clitrans2.c
@@ -19,6 +19,7 @@
#include "includes.h"
#include "libcli/raw/libcliraw.h"
+#include "libcli/libcli.h"
/****************************************************************************
send a qpathinfo call
diff --git a/source4/libcli/composite/composite.c b/source4/libcli/composite/composite.c
index 3e21c3823c..67d5885497 100644
--- a/source4/libcli/composite/composite.c
+++ b/source4/libcli/composite/composite.c
@@ -53,7 +53,7 @@ _PUBLIC_ NTSTATUS composite_wait(struct composite_context *c)
{
if (c == NULL) return NT_STATUS_NO_MEMORY;
- c->used_wait = True;
+ c->used_wait = true;
while (c->state < COMPOSITE_STATE_DONE) {
if (event_loop_once(c->event_ctx) != 0) {
@@ -69,16 +69,16 @@ _PUBLIC_ NTSTATUS composite_wait(struct composite_context *c)
* Some composite helpers that are handy if you write larger composite
* functions.
*/
-_PUBLIC_ BOOL composite_is_ok(struct composite_context *ctx)
+_PUBLIC_ bool composite_is_ok(struct composite_context *ctx)
{
if (NT_STATUS_IS_OK(ctx->status)) {
- return True;
+ return true;
}
ctx->state = COMPOSITE_STATE_ERROR;
if (ctx->async.fn != NULL) {
ctx->async.fn(ctx);
}
- return False;
+ return false;
}
/*
@@ -113,13 +113,13 @@ _PUBLIC_ void composite_error(struct composite_context *ctx, NTSTATUS status)
SMB_ASSERT(!composite_is_ok(ctx));
}
-_PUBLIC_ BOOL composite_nomem(const void *p, struct composite_context *ctx)
+_PUBLIC_ bool composite_nomem(const void *p, struct composite_context *ctx)
{
if (p != NULL) {
- return False;
+ return false;
}
composite_error(ctx, NT_STATUS_NO_MEMORY);
- return True;
+ return true;
}
_PUBLIC_ void composite_done(struct composite_context *ctx)
diff --git a/source4/libcli/config.mk b/source4/libcli/config.mk
index d49fc90ec4..d7aaac0447 100644
--- a/source4/libcli/config.mk
+++ b/source4/libcli/config.mk
@@ -3,12 +3,10 @@ include ldap/config.mk
include security/config.mk
[SUBSYSTEM::LIBSAMBA-ERRORS]
-PUBLIC_PROTO_HEADER = util/proto.h
-PUBLIC_HEADERS = util/error.h util/nterr.h util/doserr.h util/nt_status.h
+PUBLIC_HEADERS = util/error.h util/ntstatus.h util/doserr.h util/werror.h
OBJ_FILES = util/doserr.o \
- util/errormap.o \
- util/clierror.o \
- util/nterr.o \
+ util/errormap.o \
+ util/nterr.o \
[SUBSYSTEM::ASN1_UTIL]
PUBLIC_PROTO_HEADER = util/asn1_proto.h
@@ -60,6 +58,13 @@ PUBLIC_DEPENDENCIES = LIBNDR NDR_NBT LIBCLI_COMPOSITE LIBEVENTS \
LIBRARY_REALNAME = swig/_libcli_nbt.$(SHLIBEXT)
OBJ_FILES = swig/libcli_nbt_wrap.o
PUBLIC_DEPENDENCIES = LIBCLI_NBT DYNCONFIG LIBSAMBA-CONFIG
+ENABLE = NO
+
+[LIBRARY::swig_libcli_smb]
+LIBRARY_REALNAME = swig/_libcli_smb.$(SHLIBEXT)
+OBJ_FILES = swig/libcli_smb_wrap.o
+PUBLIC_DEPENDENCIES = LIBCLI_SMB DYNCONFIG LIBSAMBA-CONFIG
+ENABLE = NO
[SUBSYSTEM::LIBCLI_DGRAM]
OBJ_FILES = \
@@ -133,6 +138,7 @@ OBJ_FILES = raw/rawfile.o \
raw/clitransport.o \
raw/clisession.o \
raw/clitree.o \
+ raw/clierror.o \
raw/rawrequest.o \
raw/rawreadwrite.o \
raw/rawsearch.o \
diff --git a/source4/libcli/dgram/browse.c b/source4/libcli/dgram/browse.c
index 84a2a7e534..fc1162e644 100644
--- a/source4/libcli/dgram/browse.c
+++ b/source4/libcli/dgram/browse.c
@@ -25,6 +25,7 @@
#include "lib/socket/socket.h"
#include "libcli/resolve/resolve.h"
#include "librpc/gen_ndr/ndr_nbt.h"
+#include "param/param.h"
NTSTATUS dgram_mailslot_browse_send(struct nbt_dgram_socket *dgmsock,
struct nbt_name *dest_name,
@@ -69,7 +70,7 @@ NTSTATUS dgram_mailslot_browse_reply(struct nbt_dgram_socket *dgmsock,
return status;
}
- make_nbt_name_client(&myname, lp_netbios_name());
+ make_nbt_name_client(&myname, lp_netbios_name(global_loadparm));
dest = socket_address_from_strings(tmp_ctx, dgmsock->sock->backend_name,
request->src_addr, request->src_port);
diff --git a/source4/libcli/dgram/mailslot.c b/source4/libcli/dgram/mailslot.c
index 14eb7b931b..4e94e5ee5b 100644
--- a/source4/libcli/dgram/mailslot.c
+++ b/source4/libcli/dgram/mailslot.c
@@ -36,6 +36,7 @@
#include "lib/util/dlinklist.h"
#include "libcli/dgram/libdgram.h"
#include "lib/socket/socket.h"
+#include "param/param.h"
/*
destroy a mailslot handler
@@ -164,7 +165,7 @@ NTSTATUS dgram_mailslot_send(struct nbt_dgram_socket *dgmsock,
if (_dest->port == 0) {
dest = socket_address_from_strings(tmp_ctx, _dest->family,
- _dest->addr, lp_dgram_port());
+ _dest->addr, lp_dgram_port(global_loadparm));
} else {
dest = _dest;
}
diff --git a/source4/libcli/dgram/netlogon.c b/source4/libcli/dgram/netlogon.c
index df47a34a0e..46f6e50e7b 100644
--- a/source4/libcli/dgram/netlogon.c
+++ b/source4/libcli/dgram/netlogon.c
@@ -24,6 +24,7 @@
#include "lib/socket/socket.h"
#include "libcli/resolve/resolve.h"
#include "librpc/gen_ndr/ndr_nbt.h"
+#include "param/param.h"
/*
send a netlogon mailslot request
@@ -76,7 +77,7 @@ NTSTATUS dgram_mailslot_netlogon_reply(struct nbt_dgram_socket *dgmsock,
return status;
}
- make_nbt_name_client(&myname, lp_netbios_name());
+ make_nbt_name_client(&myname, lp_netbios_name(global_loadparm));
dest = socket_address_from_strings(tmp_ctx, dgmsock->sock->backend_name,
request->src_addr, request->src_port);
diff --git a/source4/libcli/dgram/ntlogon.c b/source4/libcli/dgram/ntlogon.c
index 5881dcf702..25f767688a 100644
--- a/source4/libcli/dgram/ntlogon.c
+++ b/source4/libcli/dgram/ntlogon.c
@@ -24,6 +24,7 @@
#include "lib/socket/socket.h"
#include "libcli/resolve/resolve.h"
#include "librpc/gen_ndr/ndr_nbt.h"
+#include "param/param.h"
/*
send a ntlogon mailslot request
@@ -77,7 +78,7 @@ NTSTATUS dgram_mailslot_ntlogon_reply(struct nbt_dgram_socket *dgmsock,
return status;
}
- make_nbt_name_client(&myname, lp_netbios_name());
+ make_nbt_name_client(&myname, lp_netbios_name(global_loadparm));
dest = socket_address_from_strings(tmp_ctx,
dgmsock->sock->backend_name,
diff --git a/source4/libcli/finddcs.c b/source4/libcli/finddcs.c
index a159ab6dfc..e00697fe17 100644
--- a/source4/libcli/finddcs.c
+++ b/source4/libcli/finddcs.c
@@ -27,6 +27,8 @@
#include "libcli/composite/composite.h"
#include "libcli/libcli.h"
#include "libcli/resolve/resolve.h"
+#include "libcli/finddcs.h"
+#include "param/param.h"
struct finddcs_state {
struct composite_context *ctx;
@@ -143,9 +145,9 @@ static void finddcs_name_resolved(struct composite_context *ctx)
state->r.in.domainname = state->domain_name;
state->r.in.ip_address = state->dcs[0].address;
- state->r.in.my_computername = lp_netbios_name();
+ state->r.in.my_computername = lp_netbios_name(global_loadparm);
state->r.in.my_accountname = talloc_asprintf(state, "%s$",
- lp_netbios_name());
+ lp_netbios_name(global_loadparm));
if (composite_nomem(state->r.in.my_accountname, state->ctx)) return;
state->r.in.account_control = ACB_WSTRUST;
state->r.in.domain_sid = state->domain_sid;
diff --git a/source4/libcli/ldap/ldap.c b/source4/libcli/ldap/ldap.c
index 64f6f90d31..11689fbd79 100644
--- a/source4/libcli/ldap/ldap.c
+++ b/source4/libcli/ldap/ldap.c
@@ -27,7 +27,7 @@
#include "libcli/ldap/ldap.h"
-static BOOL ldap_push_filter(struct asn1_data *data, struct ldb_parse_tree *tree)
+static bool ldap_push_filter(struct asn1_data *data, struct ldb_parse_tree *tree)
{
int i;
@@ -37,7 +37,7 @@ static BOOL ldap_push_filter(struct asn1_data *data, struct ldb_parse_tree *tree
asn1_push_tag(data, ASN1_CONTEXT(tree->operation==LDB_OP_AND?0:1));
for (i=0; i<tree->u.list.num_elements; i++) {
if (!ldap_push_filter(data, tree->u.list.elements[i])) {
- return False;
+ return false;
}
}
asn1_pop_tag(data);
@@ -46,7 +46,7 @@ static BOOL ldap_push_filter(struct asn1_data *data, struct ldb_parse_tree *tree
case LDB_OP_NOT:
asn1_push_tag(data, ASN1_CONTEXT(2));
if (!ldap_push_filter(data, tree->u.isnot.child)) {
- return False;
+ return false;
}
asn1_pop_tag(data);
break;
@@ -166,7 +166,7 @@ static BOOL ldap_push_filter(struct asn1_data *data, struct ldb_parse_tree *tree
break;
default:
- return False;
+ return false;
}
return !data->has_error;
}
@@ -187,12 +187,12 @@ static void ldap_encode_response(struct asn1_data *data, struct ldap_Result *res
}
}
-BOOL ldap_encode(struct ldap_message *msg, DATA_BLOB *result, TALLOC_CTX *mem_ctx)
+bool ldap_encode(struct ldap_message *msg, DATA_BLOB *result, TALLOC_CTX *mem_ctx)
{
struct asn1_data *data = asn1_init(mem_ctx);
int i, j;
- if (!data) return False;
+ if (!data) return false;
asn1_push_tag(data, ASN1_SEQUENCE(0));
asn1_write_Integer(data, msg->messageid);
@@ -225,7 +225,7 @@ BOOL ldap_encode(struct ldap_message *msg, DATA_BLOB *result, TALLOC_CTX *mem_ct
asn1_pop_tag(data);
break;
default:
- return False;
+ return false;
}
asn1_pop_tag(data);
@@ -256,7 +256,7 @@ BOOL ldap_encode(struct ldap_message *msg, DATA_BLOB *result, TALLOC_CTX *mem_ct
asn1_write_BOOLEAN(data, r->attributesonly);
if (!ldap_push_filter(data, r->tree)) {
- return False;
+ return false;
}
asn1_push_tag(data, ASN1_SEQUENCE(0));
@@ -467,7 +467,7 @@ BOOL ldap_encode(struct ldap_message *msg, DATA_BLOB *result, TALLOC_CTX *mem_ct
break;
}
default:
- return False;
+ return false;
}
if (msg->controls != NULL) {
@@ -475,7 +475,7 @@ BOOL ldap_encode(struct ldap_message *msg, DATA_BLOB *result, TALLOC_CTX *mem_ct
for (i = 0; msg->controls[i] != NULL; i++) {
if (!ldap_encode_control(mem_ctx, data, msg->controls[i])) {
- return False;
+ return false;
}
}
@@ -486,33 +486,33 @@ BOOL ldap_encode(struct ldap_message *msg, DATA_BLOB *result, TALLOC_CTX *mem_ct
if (data->has_error) {
asn1_free(data);
- return False;
+ return false;
}
*result = data_blob_talloc(mem_ctx, data->data, data->length);
asn1_free(data);
- return True;
+ return true;
}
static const char *blob2string_talloc(TALLOC_CTX *mem_ctx,
DATA_BLOB blob)
{
- char *result = talloc_size(mem_ctx, blob.length+1);
+ char *result = talloc_array(mem_ctx, char, blob.length+1);
memcpy(result, blob.data, blob.length);
result[blob.length] = '\0';
return result;
}
-static BOOL asn1_read_OctetString_talloc(TALLOC_CTX *mem_ctx,
+static bool asn1_read_OctetString_talloc(TALLOC_CTX *mem_ctx,
struct asn1_data *data,
const char **result)
{
DATA_BLOB string;
if (!asn1_read_OctetString(data, mem_ctx, &string))
- return False;
+ return false;
*result = blob2string_talloc(mem_ctx, string);
data_blob_free(&string);
- return True;
+ return true;
}
static void ldap_decode_response(TALLOC_CTX *mem_ctx,
@@ -955,7 +955,7 @@ NTSTATUS ldap_decode(struct asn1_data *data, struct ldap_message *msg)
return NT_STATUS_LDAP(LDAP_PROTOCOL_ERROR);
}
if (pwlen != 0) {
- char *pw = talloc_size(msg, pwlen+1);
+ char *pw = talloc_array(msg, char, pwlen+1);
if (!pw) {
return NT_STATUS_LDAP(LDAP_OPERATIONS_ERROR);
}
@@ -1162,7 +1162,7 @@ NTSTATUS ldap_decode(struct asn1_data *data, struct ldap_message *msg)
if (len == -1) {
return NT_STATUS_LDAP(LDAP_PROTOCOL_ERROR);
}
- dn = talloc_size(msg, len+1);
+ dn = talloc_array(msg, char, len+1);
if (dn == NULL)
break;
asn1_read(data, dn, len);
@@ -1198,7 +1198,7 @@ NTSTATUS ldap_decode(struct asn1_data *data, struct ldap_message *msg)
if (len == -1) {
return NT_STATUS_LDAP(LDAP_PROTOCOL_ERROR);
}
- newsup = talloc_size(msg, len+1);
+ newsup = talloc_array(msg, char, len+1);
if (newsup == NULL) {
return NT_STATUS_LDAP(LDAP_OPERATIONS_ERROR);
}
diff --git a/source4/libcli/ldap/ldap.h b/source4/libcli/ldap/ldap.h
index 022c70e36a..e89322213a 100644
--- a/source4/libcli/ldap/ldap.h
+++ b/source4/libcli/ldap/ldap.h
@@ -22,6 +22,7 @@
#define _SMB_LDAP_H
#include "lib/ldb/include/ldb.h"
+#include "librpc/gen_ndr/misc.h"
enum ldap_request_tag {
LDAP_TAG_BindRequest = 0,
diff --git a/source4/libcli/ldap/ldap_bind.c b/source4/libcli/ldap/ldap_bind.c
index cbe8772414..d285735d4e 100644
--- a/source4/libcli/ldap/ldap_bind.c
+++ b/source4/libcli/ldap/ldap_bind.c
@@ -258,7 +258,7 @@ NTSTATUS ldap_bind_sasl(struct ldap_connection *conn, struct cli_credentials *cr
}
status = ildap_search(conn, "", LDAP_SEARCH_SCOPE_BASE, "", supported_sasl_mech_attrs,
- False, NULL, NULL, &sasl_mechs_msgs);
+ false, NULL, NULL, &sasl_mechs_msgs);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(1, ("Failed to inquire of target's available sasl mechs in rootdse search: %s\n",
nt_errstr(status)));
diff --git a/source4/libcli/ldap/ldap_client.c b/source4/libcli/ldap/ldap_client.c
index 8476a4977b..aea95de161 100644
--- a/source4/libcli/ldap/ldap_client.c
+++ b/source4/libcli/ldap/ldap_client.c
@@ -226,7 +226,7 @@ static void ldap_io_handler(struct event_context *ev, struct fd_event *fde,
parse a ldap URL
*/
static NTSTATUS ldap_parse_basic_url(TALLOC_CTX *mem_ctx, const char *url,
- char **host, uint16_t *port, BOOL *ldaps)
+ char **host, uint16_t *port, bool *ldaps)
{
int tmp_port = 0;
char protocol[11];
@@ -243,10 +243,10 @@ static NTSTATUS ldap_parse_basic_url(TALLOC_CTX *mem_ctx, const char *url,
if (strequal(protocol, "ldap")) {
*port = 389;
- *ldaps = False;
+ *ldaps = false;
} else if (strequal(protocol, "ldaps")) {
*port = 636;
- *ldaps = True;
+ *ldaps = true;
} else {
DEBUG(0, ("unrecognised ldap protocol (%s)!\n", protocol));
return NT_STATUS_PROTOCOL_UNREACHABLE;
diff --git a/source4/libcli/ldap/ldap_controls.c b/source4/libcli/ldap/ldap_controls.c
index 3a5d14c0c9..b7fd1ce178 100644
--- a/source4/libcli/ldap/ldap_controls.c
+++ b/source4/libcli/ldap/ldap_controls.c
@@ -26,56 +26,56 @@
struct control_handler {
const char *oid;
- BOOL (*decode)(void *mem_ctx, DATA_BLOB in, void **out);
- BOOL (*encode)(void *mem_ctx, void *in, DATA_BLOB *out);
+ bool (*decode)(void *mem_ctx, DATA_BLOB in, void **out);
+ bool (*encode)(void *mem_ctx, void *in, DATA_BLOB *out);
};
-static BOOL decode_server_sort_response(void *mem_ctx, DATA_BLOB in, void **out)
+static bool decode_server_sort_response(void *mem_ctx, DATA_BLOB in, void **out)
{
DATA_BLOB attr;
struct asn1_data *data = asn1_init(mem_ctx);
struct ldb_sort_resp_control *lsrc;
- if (!data) return False;
+ if (!data) return false;
if (!asn1_load(data, in)) {
- return False;
+ return false;
}
lsrc = talloc(mem_ctx, struct ldb_sort_resp_control);
if (!lsrc) {
- return False;
+ return false;
}
if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) {
- return False;
+ return false;
}
if (!asn1_read_enumerated(data, &(lsrc->result))) {
- return False;
+ return false;
}
lsrc->attr_desc = NULL;
if (asn1_peek_tag(data, ASN1_OCTET_STRING)) {
if (!asn1_read_OctetString(data, mem_ctx, &attr)) {
- return False;
+ return false;
}
lsrc->attr_desc = talloc_strndup(lsrc, (const char *)attr.data, attr.length);
if (!lsrc->attr_desc) {
- return False;
+ return false;
}
}
if (!asn1_end_tag(data)) {
- return False;
+ return false;
}
*out = lsrc;
- return True;
+ return true;
}
-static BOOL decode_server_sort_request(void *mem_ctx, DATA_BLOB in, void **out)
+static bool decode_server_sort_request(void *mem_ctx, DATA_BLOB in, void **out)
{
DATA_BLOB attr;
DATA_BLOB rule;
@@ -83,14 +83,14 @@ static BOOL decode_server_sort_request(void *mem_ctx, DATA_BLOB in, void **out)
struct ldb_server_sort_control **lssc;
int num;
- if (!data) return False;
+ if (!data) return false;
if (!asn1_load(data, in)) {
- return False;
+ return false;
}
if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) {
- return False;
+ return false;
}
lssc = NULL;
@@ -98,46 +98,46 @@ static BOOL decode_server_sort_request(void *mem_ctx, DATA_BLOB in, void **out)
for (num = 0; asn1_peek_tag(data, ASN1_SEQUENCE(0)); num++) {
lssc = talloc_realloc(mem_ctx, lssc, struct ldb_server_sort_control *, num + 2);
if (!lssc) {
- return False;
+ return false;
}
lssc[num] = talloc_zero(lssc, struct ldb_server_sort_control);
if (!lssc[num]) {
- return False;
+ return false;
}
if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) {
- return False;
+ return false;
}
if (!asn1_read_OctetString(data, mem_ctx, &attr)) {
- return False;
+ return false;
}
lssc[num]->attributeName = talloc_strndup(lssc[num], (const char *)attr.data, attr.length);
if (!lssc [num]->attributeName) {
- return False;
+ return false;
}
if (asn1_peek_tag(data, ASN1_OCTET_STRING)) {
if (!asn1_read_OctetString(data, mem_ctx, &rule)) {
- return False;
+ return false;
}
lssc[num]->orderingRule = talloc_strndup(lssc[num], (const char *)rule.data, rule.length);
if (!lssc[num]->orderingRule) {
- return False;
+ return false;
}
}
if (asn1_peek_tag(data, ASN1_BOOLEAN)) {
- BOOL reverse;
+ bool reverse;
if (!asn1_read_BOOLEAN(data, &reverse)) {
- return False;
+ return false;
}
lssc[num]->reverse = reverse;
}
if (!asn1_end_tag(data)) {
- return False;
+ return false;
}
}
@@ -146,248 +146,248 @@ static BOOL decode_server_sort_request(void *mem_ctx, DATA_BLOB in, void **out)
}
if (!asn1_end_tag(data)) {
- return False;
+ return false;
}
*out = lssc;
- return True;
+ return true;
}
-static BOOL decode_extended_dn_request(void *mem_ctx, DATA_BLOB in, void **out)
+static bool decode_extended_dn_request(void *mem_ctx, DATA_BLOB in, void **out)
{
struct asn1_data *data = asn1_init(mem_ctx);
struct ldb_extended_dn_control *ledc;
- if (!data) return False;
+ if (!data) return false;
if (!asn1_load(data, in)) {
- return False;
+ return false;
}
ledc = talloc(mem_ctx, struct ldb_extended_dn_control);
if (!ledc) {
- return False;
+ return false;
}
if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) {
- return False;
+ return false;
}
if (!asn1_read_Integer(data, &(ledc->type))) {
- return False;
+ return false;
}
if (!asn1_end_tag(data)) {
- return False;
+ return false;
}
*out = ledc;
- return True;
+ return true;
}
-static BOOL decode_sd_flags_request(void *mem_ctx, DATA_BLOB in, void **out)
+static bool decode_sd_flags_request(void *mem_ctx, DATA_BLOB in, void **out)
{
struct asn1_data *data = asn1_init(mem_ctx);
struct ldb_sd_flags_control *lsdfc;
- if (!data) return False;
+ if (!data) return false;
if (!asn1_load(data, in)) {
- return False;
+ return false;
}
lsdfc = talloc(mem_ctx, struct ldb_sd_flags_control);
if (!lsdfc) {
- return False;
+ return false;
}
if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) {
- return False;
+ return false;
}
if (!asn1_read_Integer(data, &(lsdfc->secinfo_flags))) {
- return False;
+ return false;
}
if (!asn1_end_tag(data)) {
- return False;
+ return false;
}
*out = lsdfc;
- return True;
+ return true;
}
-static BOOL decode_search_options_request(void *mem_ctx, DATA_BLOB in, void **out)
+static bool decode_search_options_request(void *mem_ctx, DATA_BLOB in, void **out)
{
struct asn1_data *data = asn1_init(mem_ctx);
struct ldb_search_options_control *lsoc;
- if (!data) return False;
+ if (!data) return false;
if (!asn1_load(data, in)) {
- return False;
+ return false;
}
lsoc = talloc(mem_ctx, struct ldb_search_options_control);
if (!lsoc) {
- return False;
+ return false;
}
if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) {
- return False;
+ return false;
}
if (!asn1_read_Integer(data, &(lsoc->search_options))) {
- return False;
+ return false;
}
if (!asn1_end_tag(data)) {
- return False;
+ return false;
}
*out = lsoc;
- return True;
+ return true;
}
-static BOOL decode_paged_results_request(void *mem_ctx, DATA_BLOB in, void **out)
+static bool decode_paged_results_request(void *mem_ctx, DATA_BLOB in, void **out)
{
DATA_BLOB cookie;
struct asn1_data *data = asn1_init(mem_ctx);
struct ldb_paged_control *lprc;
- if (!data) return False;
+ if (!data) return false;
if (!asn1_load(data, in)) {
- return False;
+ return false;
}
lprc = talloc(mem_ctx, struct ldb_paged_control);
if (!lprc) {
- return False;
+ return false;
}
if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) {
- return False;
+ return false;
}
if (!asn1_read_Integer(data, &(lprc->size))) {
- return False;
+ return false;
}
if (!asn1_read_OctetString(data, mem_ctx, &cookie)) {
- return False;
+ return false;
}
lprc->cookie_len = cookie.length;
if (lprc->cookie_len) {
lprc->cookie = talloc_memdup(lprc, cookie.data, cookie.length);
if (!(lprc->cookie)) {
- return False;
+ return false;
}
} else {
lprc->cookie = NULL;
}
if (!asn1_end_tag(data)) {
- return False;
+ return false;
}
*out = lprc;
- return True;
+ return true;
}
-static BOOL decode_dirsync_request(void *mem_ctx, DATA_BLOB in, void **out)
+static bool decode_dirsync_request(void *mem_ctx, DATA_BLOB in, void **out)
{
DATA_BLOB cookie;
struct asn1_data *data = asn1_init(mem_ctx);
struct ldb_dirsync_control *ldc;
- if (!data) return False;
+ if (!data) return false;
if (!asn1_load(data, in)) {
- return False;
+ return false;
}
ldc = talloc(mem_ctx, struct ldb_dirsync_control);
if (!ldc) {
- return False;
+ return false;
}
if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) {
- return False;
+ return false;
}
if (!asn1_read_Integer(data, &(ldc->flags))) {
- return False;
+ return false;
}
if (!asn1_read_Integer(data, &(ldc->max_attributes))) {
- return False;
+ return false;
}
if (!asn1_read_OctetString(data, mem_ctx, &cookie)) {
- return False;
+ return false;
}
ldc->cookie_len = cookie.length;
if (ldc->cookie_len) {
ldc->cookie = talloc_memdup(ldc, cookie.data, cookie.length);
if (!(ldc->cookie)) {
- return False;
+ return false;
}
} else {
ldc->cookie = NULL;
}
if (!asn1_end_tag(data)) {
- return False;
+ return false;
}
*out = ldc;
- return True;
+ return true;
}
/* seem that this controls has 2 forms one in case it is used with
* a Search Request and another when used ina Search Response
*/
-static BOOL decode_asq_control(void *mem_ctx, DATA_BLOB in, void **out)
+static bool decode_asq_control(void *mem_ctx, DATA_BLOB in, void **out)
{
DATA_BLOB source_attribute;
struct asn1_data *data = asn1_init(mem_ctx);
struct ldb_asq_control *lac;
- if (!data) return False;
+ if (!data) return false;
if (!asn1_load(data, in)) {
- return False;
+ return false;
}
lac = talloc(mem_ctx, struct ldb_asq_control);
if (!lac) {
- return False;
+ return false;
}
if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) {
- return False;
+ return false;
}
if (asn1_peek_tag(data, ASN1_OCTET_STRING)) {
if (!asn1_read_OctetString(data, mem_ctx, &source_attribute)) {
- return False;
+ return false;
}
lac->src_attr_len = source_attribute.length;
if (lac->src_attr_len) {
lac->source_attribute = talloc_strndup(lac, (const char *)source_attribute.data, source_attribute.length);
if (!(lac->source_attribute)) {
- return False;
+ return false;
}
} else {
lac->source_attribute = NULL;
@@ -398,96 +398,96 @@ static BOOL decode_asq_control(void *mem_ctx, DATA_BLOB in, void **out)
} else if (asn1_peek_tag(data, ASN1_ENUMERATED)) {
if (!asn1_read_enumerated(data, &(lac->result))) {
- return False;
+ return false;
}
lac->request = 0;
} else {
- return False;
+ return false;
}
if (!asn1_end_tag(data)) {
- return False;
+ return false;
}
*out = lac;
- return True;
+ return true;
}
-static BOOL decode_domain_scope_request(void *mem_ctx, DATA_BLOB in, void **out)
+static bool decode_domain_scope_request(void *mem_ctx, DATA_BLOB in, void **out)
{
if (in.length != 0) {
- return False;
+ return false;
}
- return True;
+ return true;
}
-static BOOL decode_notification_request(void *mem_ctx, DATA_BLOB in, void **out)
+static bool decode_notification_request(void *mem_ctx, DATA_BLOB in, void **out)
{
if (in.length != 0) {
- return False;
+ return false;
}
- return True;
+ return true;
}
-static BOOL decode_show_deleted_request(void *mem_ctx, DATA_BLOB in, void **out)
+static bool decode_show_deleted_request(void *mem_ctx, DATA_BLOB in, void **out)
{
if (in.length != 0) {
- return False;
+ return false;
}
- return True;
+ return true;
}
-static BOOL decode_permissive_modify_request(void *mem_ctx, DATA_BLOB in, void **out)
+static bool decode_permissive_modify_request(void *mem_ctx, DATA_BLOB in, void **out)
{
if (in.length != 0) {
- return False;
+ return false;
}
- return True;
+ return true;
}
-static BOOL decode_manageDSAIT_request(void *mem_ctx, DATA_BLOB in, void **out)
+static bool decode_manageDSAIT_request(void *mem_ctx, DATA_BLOB in, void **out)
{
if (in.length != 0) {
- return False;
+ return false;
}
- return True;
+ return true;
}
-static BOOL decode_vlv_request(void *mem_ctx, DATA_BLOB in, void **out)
+static bool decode_vlv_request(void *mem_ctx, DATA_BLOB in, void **out)
{
DATA_BLOB assertion_value, context_id;
struct asn1_data *data = asn1_init(mem_ctx);
struct ldb_vlv_req_control *lvrc;
- if (!data) return False;
+ if (!data) return false;
if (!asn1_load(data, in)) {
- return False;
+ return false;
}
lvrc = talloc(mem_ctx, struct ldb_vlv_req_control);
if (!lvrc) {
- return False;
+ return false;
}
if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) {
- return False;
+ return false;
}
if (!asn1_read_Integer(data, &(lvrc->beforeCount))) {
- return False;
+ return false;
}
if (!asn1_read_Integer(data, &(lvrc->afterCount))) {
- return False;
+ return false;
}
if (asn1_peek_tag(data, ASN1_CONTEXT(0))) {
@@ -495,27 +495,27 @@ static BOOL decode_vlv_request(void *mem_ctx, DATA_BLOB in, void **out)
lvrc->type = 0;
if (!asn1_start_tag(data, ASN1_CONTEXT(0))) {
- return False;
+ return false;
}
if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) {
- return False;
+ return false;
}
if (!asn1_read_Integer(data, &(lvrc->match.byOffset.offset))) {
- return False;
+ return false;
}
if (!asn1_read_Integer(data, &(lvrc->match.byOffset.contentCount))) {
- return False;
+ return false;
}
if (!asn1_end_tag(data)) { /*SEQUENCE*/
- return False;
+ return false;
}
if (!asn1_end_tag(data)) { /*CONTEXT*/
- return False;
+ return false;
}
} else {
@@ -523,38 +523,38 @@ static BOOL decode_vlv_request(void *mem_ctx, DATA_BLOB in, void **out)
lvrc->type = 1;
if (!asn1_start_tag(data, ASN1_CONTEXT(1))) {
- return False;
+ return false;
}
if (!asn1_read_OctetString(data, mem_ctx, &assertion_value)) {
- return False;
+ return false;
}
lvrc->match.gtOrEq.value_len = assertion_value.length;
if (lvrc->match.gtOrEq.value_len) {
lvrc->match.gtOrEq.value = talloc_memdup(lvrc, assertion_value.data, assertion_value.length);
if (!(lvrc->match.gtOrEq.value)) {
- return False;
+ return false;
}
} else {
lvrc->match.gtOrEq.value = NULL;
}
if (!asn1_end_tag(data)) { /*CONTEXT*/
- return False;
+ return false;
}
}
if (asn1_peek_tag(data, ASN1_OCTET_STRING)) {
if (!asn1_read_OctetString(data, mem_ctx, &context_id)) {
- return False;
+ return false;
}
lvrc->ctxid_len = context_id.length;
if (lvrc->ctxid_len) {
lvrc->contextId = talloc_memdup(lvrc, context_id.data, context_id.length);
if (!(lvrc->contextId)) {
- return False;
+ return false;
}
} else {
lvrc->contextId = NULL;
@@ -565,54 +565,54 @@ static BOOL decode_vlv_request(void *mem_ctx, DATA_BLOB in, void **out)
}
if (!asn1_end_tag(data)) {
- return False;
+ return false;
}
*out = lvrc;
- return True;
+ return true;
}
-static BOOL decode_vlv_response(void *mem_ctx, DATA_BLOB in, void **out)
+static bool decode_vlv_response(void *mem_ctx, DATA_BLOB in, void **out)
{
DATA_BLOB context_id;
struct asn1_data *data = asn1_init(mem_ctx);
struct ldb_vlv_resp_control *lvrc;
- if (!data) return False;
+ if (!data) return false;
if (!asn1_load(data, in)) {
- return False;
+ return false;
}
lvrc = talloc(mem_ctx, struct ldb_vlv_resp_control);
if (!lvrc) {
- return False;
+ return false;
}
if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) {
- return False;
+ return false;
}
if (!asn1_read_Integer(data, &(lvrc->targetPosition))) {
- return False;
+ return false;
}
if (!asn1_read_Integer(data, &(lvrc->contentCount))) {
- return False;
+ return false;
}
if (!asn1_read_enumerated(data, &(lvrc->vlv_result))) {
- return False;
+ return false;
}
if (asn1_peek_tag(data, ASN1_OCTET_STRING)) {
if (!asn1_read_OctetString(data, mem_ctx, &context_id)) {
- return False;
+ return false;
}
lvrc->contextId = talloc_strndup(lvrc, (const char *)context_id.data, context_id.length);
if (!lvrc->contextId) {
- return False;
+ return false;
}
lvrc->ctxid_len = context_id.length;
} else {
@@ -621,455 +621,455 @@ static BOOL decode_vlv_response(void *mem_ctx, DATA_BLOB in, void **out)
}
if (!asn1_end_tag(data)) {
- return False;
+ return false;
}
*out = lvrc;
- return True;
+ return true;
}
-static BOOL encode_server_sort_response(void *mem_ctx, void *in, DATA_BLOB *out)
+static bool encode_server_sort_response(void *mem_ctx, void *in, DATA_BLOB *out)
{
struct ldb_sort_resp_control *lsrc = talloc_get_type(in, struct ldb_sort_resp_control);
struct asn1_data *data = asn1_init(mem_ctx);
- if (!data) return False;
+ if (!data) return false;
if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) {
- return False;
+ return false;
}
if (!asn1_write_enumerated(data, lsrc->result)) {
- return False;
+ return false;
}
if (lsrc->attr_desc) {
if (!asn1_write_OctetString(data, lsrc->attr_desc, strlen(lsrc->attr_desc))) {
- return False;
+ return false;
}
}
if (!asn1_pop_tag(data)) {
- return False;
+ return false;
}
*out = data_blob_talloc(mem_ctx, data->data, data->length);
if (out->data == NULL) {
- return False;
+ return false;
}
talloc_free(data);
- return True;
+ return true;
}
-static BOOL encode_server_sort_request(void *mem_ctx, void *in, DATA_BLOB *out)
+static bool encode_server_sort_request(void *mem_ctx, void *in, DATA_BLOB *out)
{
struct ldb_server_sort_control **lssc = talloc_get_type(in, struct ldb_server_sort_control *);
struct asn1_data *data = asn1_init(mem_ctx);
int num;
- if (!data) return False;
+ if (!data) return false;
if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) {
- return False;
+ return false;
}
for (num = 0; lssc[num]; num++) {
if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) {
- return False;
+ return false;
}
if (!asn1_write_OctetString(data, lssc[num]->attributeName, strlen(lssc[num]->attributeName))) {
- return False;
+ return false;
}
if (lssc[num]->orderingRule) {
if (!asn1_write_OctetString(data, lssc[num]->orderingRule, strlen(lssc[num]->orderingRule))) {
- return False;
+ return false;
}
}
if (lssc[num]->reverse) {
if (!asn1_write_BOOLEAN(data, lssc[num]->reverse)) {
- return False;
+ return false;
}
}
if (!asn1_pop_tag(data)) {
- return False;
+ return false;
}
}
if (!asn1_pop_tag(data)) {
- return False;
+ return false;
}
*out = data_blob_talloc(mem_ctx, data->data, data->length);
if (out->data == NULL) {
- return False;
+ return false;
}
talloc_free(data);
- return True;
+ return true;
}
-static BOOL encode_extended_dn_request(void *mem_ctx, void *in, DATA_BLOB *out)
+static bool encode_extended_dn_request(void *mem_ctx, void *in, DATA_BLOB *out)
{
struct ldb_extended_dn_control *ledc = talloc_get_type(in, struct ldb_extended_dn_control);
struct asn1_data *data = asn1_init(mem_ctx);
- if (!data) return False;
+ if (!data) return false;
if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) {
- return False;
+ return false;
}
if (!asn1_write_Integer(data, ledc->type)) {
- return False;
+ return false;
}
if (!asn1_pop_tag(data)) {
- return False;
+ return false;
}
*out = data_blob_talloc(mem_ctx, data->data, data->length);
if (out->data == NULL) {
- return False;
+ return false;
}
talloc_free(data);
- return True;
+ return true;
}
-static BOOL encode_sd_flags_request(void *mem_ctx, void *in, DATA_BLOB *out)
+static bool encode_sd_flags_request(void *mem_ctx, void *in, DATA_BLOB *out)
{
struct ldb_sd_flags_control *lsdfc = talloc_get_type(in, struct ldb_sd_flags_control);
struct asn1_data *data = asn1_init(mem_ctx);
- if (!data) return False;
+ if (!data) return false;
if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) {
- return False;
+ return false;
}
if (!asn1_write_Integer(data, lsdfc->secinfo_flags)) {
- return False;
+ return false;
}
if (!asn1_pop_tag(data)) {
- return False;
+ return false;
}
*out = data_blob_talloc(mem_ctx, data->data, data->length);
if (out->data == NULL) {
- return False;
+ return false;
}
talloc_free(data);
- return True;
+ return true;
}
-static BOOL encode_search_options_request(void *mem_ctx, void *in, DATA_BLOB *out)
+static bool encode_search_options_request(void *mem_ctx, void *in, DATA_BLOB *out)
{
struct ldb_search_options_control *lsoc = talloc_get_type(in, struct ldb_search_options_control);
struct asn1_data *data = asn1_init(mem_ctx);
- if (!data) return False;
+ if (!data) return false;
if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) {
- return False;
+ return false;
}
if (!asn1_write_Integer(data, lsoc->search_options)) {
- return False;
+ return false;
}
if (!asn1_pop_tag(data)) {
- return False;
+ return false;
}
*out = data_blob_talloc(mem_ctx, data->data, data->length);
if (out->data == NULL) {
- return False;
+ return false;
}
talloc_free(data);
- return True;
+ return true;
}
-static BOOL encode_paged_results_request(void *mem_ctx, void *in, DATA_BLOB *out)
+static bool encode_paged_results_request(void *mem_ctx, void *in, DATA_BLOB *out)
{
struct ldb_paged_control *lprc = talloc_get_type(in, struct ldb_paged_control);
struct asn1_data *data = asn1_init(mem_ctx);
- if (!data) return False;
+ if (!data) return false;
if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) {
- return False;
+ return false;
}
if (!asn1_write_Integer(data, lprc->size)) {
- return False;
+ return false;
}
if (!asn1_write_OctetString(data, lprc->cookie, lprc->cookie_len)) {
- return False;
+ return false;
}
if (!asn1_pop_tag(data)) {
- return False;
+ return false;
}
*out = data_blob_talloc(mem_ctx, data->data, data->length);
if (out->data == NULL) {
- return False;
+ return false;
}
talloc_free(data);
- return True;
+ return true;
}
/* seem that this controls has 2 forms one in case it is used with
* a Search Request and another when used ina Search Response
*/
-static BOOL encode_asq_control(void *mem_ctx, void *in, DATA_BLOB *out)
+static bool encode_asq_control(void *mem_ctx, void *in, DATA_BLOB *out)
{
struct ldb_asq_control *lac = talloc_get_type(in, struct ldb_asq_control);
struct asn1_data *data = asn1_init(mem_ctx);
- if (!data) return False;
+ if (!data) return false;
if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) {
- return False;
+ return false;
}
if (lac->request) {
if (!asn1_write_OctetString(data, lac->source_attribute, lac->src_attr_len)) {
- return False;
+ return false;
}
} else {
if (!asn1_write_enumerated(data, lac->result)) {
- return False;
+ return false;
}
}
if (!asn1_pop_tag(data)) {
- return False;
+ return false;
}
*out = data_blob_talloc(mem_ctx, data->data, data->length);
if (out->data == NULL) {
- return False;
+ return false;
}
talloc_free(data);
- return True;
+ return true;
}
-static BOOL encode_dirsync_request(void *mem_ctx, void *in, DATA_BLOB *out)
+static bool encode_dirsync_request(void *mem_ctx, void *in, DATA_BLOB *out)
{
struct ldb_dirsync_control *ldc = talloc_get_type(in, struct ldb_dirsync_control);
struct asn1_data *data = asn1_init(mem_ctx);
- if (!data) return False;
+ if (!data) return false;
if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) {
- return False;
+ return false;
}
if (!asn1_write_Integer(data, ldc->flags)) {
- return False;
+ return false;
}
if (!asn1_write_Integer(data, ldc->max_attributes)) {
- return False;
+ return false;
}
if (!asn1_write_OctetString(data, ldc->cookie, ldc->cookie_len)) {
- return False;
+ return false;
}
if (!asn1_pop_tag(data)) {
- return False;
+ return false;
}
*out = data_blob_talloc(mem_ctx, data->data, data->length);
if (out->data == NULL) {
- return False;
+ return false;
}
talloc_free(data);
- return True;
+ return true;
}
-static BOOL encode_domain_scope_request(void *mem_ctx, void *in, DATA_BLOB *out)
+static bool encode_domain_scope_request(void *mem_ctx, void *in, DATA_BLOB *out)
{
if (in) {
- return False;
+ return false;
}
*out = data_blob(NULL, 0);
- return True;
+ return true;
}
-static BOOL encode_notification_request(void *mem_ctx, void *in, DATA_BLOB *out)
+static bool encode_notification_request(void *mem_ctx, void *in, DATA_BLOB *out)
{
if (in) {
- return False;
+ return false;
}
*out = data_blob(NULL, 0);
- return True;
+ return true;
}
-static BOOL encode_show_deleted_request(void *mem_ctx, void *in, DATA_BLOB *out)
+static bool encode_show_deleted_request(void *mem_ctx, void *in, DATA_BLOB *out)
{
if (in) {
- return False;
+ return false;
}
*out = data_blob(NULL, 0);
- return True;
+ return true;
}
-static BOOL encode_permissive_modify_request(void *mem_ctx, void *in, DATA_BLOB *out)
+static bool encode_permissive_modify_request(void *mem_ctx, void *in, DATA_BLOB *out)
{
if (in) {
- return False;
+ return false;
}
*out = data_blob(NULL, 0);
- return True;
+ return true;
}
-static BOOL encode_manageDSAIT_request(void *mem_ctx, void *in, DATA_BLOB *out)
+static bool encode_manageDSAIT_request(void *mem_ctx, void *in, DATA_BLOB *out)
{
if (in) {
- return False;
+ return false;
}
*out = data_blob(NULL, 0);
- return True;
+ return true;
}
-static BOOL encode_vlv_request(void *mem_ctx, void *in, DATA_BLOB *out)
+static bool encode_vlv_request(void *mem_ctx, void *in, DATA_BLOB *out)
{
struct ldb_vlv_req_control *lvrc = talloc_get_type(in, struct ldb_vlv_req_control);
struct asn1_data *data = asn1_init(mem_ctx);
- if (!data) return False;
+ if (!data) return false;
if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) {
- return False;
+ return false;
}
if (!asn1_write_Integer(data, lvrc->beforeCount)) {
- return False;
+ return false;
}
if (!asn1_write_Integer(data, lvrc->afterCount)) {
- return False;
+ return false;
}
if (lvrc->type == 0) {
if (!asn1_push_tag(data, ASN1_CONTEXT(0))) {
- return False;
+ return false;
}
if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) {
- return False;
+ return false;
}
if (!asn1_write_Integer(data, lvrc->match.byOffset.offset)) {
- return False;
+ return false;
}
if (!asn1_write_Integer(data, lvrc->match.byOffset.contentCount)) {
- return False;
+ return false;
}
if (!asn1_pop_tag(data)) { /*SEQUENCE*/
- return False;
+ return false;
}
if (!asn1_pop_tag(data)) { /*CONTEXT*/
- return False;
+ return false;
}
} else {
if (!asn1_push_tag(data, ASN1_CONTEXT(1))) {
- return False;
+ return false;
}
if (!asn1_write_OctetString(data, lvrc->match.gtOrEq.value, lvrc->match.gtOrEq.value_len)) {
- return False;
+ return false;
}
if (!asn1_pop_tag(data)) { /*CONTEXT*/
- return False;
+ return false;
}
}
if (lvrc->ctxid_len) {
if (!asn1_write_OctetString(data, lvrc->contextId, lvrc->ctxid_len)) {
- return False;
+ return false;
}
}
if (!asn1_pop_tag(data)) {
- return False;
+ return false;
}
*out = data_blob_talloc(mem_ctx, data->data, data->length);
if (out->data == NULL) {
- return False;
+ return false;
}
talloc_free(data);
- return True;
+ return true;
}
-static BOOL encode_vlv_response(void *mem_ctx, void *in, DATA_BLOB *out)
+static bool encode_vlv_response(void *mem_ctx, void *in, DATA_BLOB *out)
{
struct ldb_vlv_resp_control *lvrc = talloc_get_type(in, struct ldb_vlv_resp_control);
struct asn1_data *data = asn1_init(mem_ctx);
- if (!data) return False;
+ if (!data) return false;
if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) {
- return False;
+ return false;
}
if (!asn1_write_Integer(data, lvrc->targetPosition)) {
- return False;
+ return false;
}
if (!asn1_write_Integer(data, lvrc->contentCount)) {
- return False;
+ return false;
}
if (!asn1_write_enumerated(data, lvrc->vlv_result)) {
- return False;
+ return false;
}
if (lvrc->ctxid_len) {
if (!asn1_write_OctetString(data, lvrc->contextId, lvrc->ctxid_len)) {
- return False;
+ return false;
}
}
if (!asn1_pop_tag(data)) {
- return False;
+ return false;
}
*out = data_blob_talloc(mem_ctx, data->data, data->length);
if (out->data == NULL) {
- return False;
+ return false;
}
talloc_free(data);
- return True;
+ return true;
}
struct control_handler ldap_known_controls[] = {
@@ -1095,49 +1095,49 @@ struct control_handler ldap_known_controls[] = {
{ NULL, NULL, NULL }
};
-BOOL ldap_decode_control_value(void *mem_ctx, DATA_BLOB value, struct ldb_control *ctrl)
+bool ldap_decode_control_value(void *mem_ctx, DATA_BLOB value, struct ldb_control *ctrl)
{
int i;
for (i = 0; ldap_known_controls[i].oid != NULL; i++) {
if (strcmp(ldap_known_controls[i].oid, ctrl->oid) == 0) {
if (!ldap_known_controls[i].decode || !ldap_known_controls[i].decode(mem_ctx, value, &ctrl->data)) {
- return False;
+ return false;
}
break;
}
}
if (ldap_known_controls[i].oid == NULL) {
- return False;
+ return false;
}
- return True;
+ return true;
}
-BOOL ldap_decode_control_wrapper(void *mem_ctx, struct asn1_data *data, struct ldb_control *ctrl, DATA_BLOB *value)
+bool ldap_decode_control_wrapper(void *mem_ctx, struct asn1_data *data, struct ldb_control *ctrl, DATA_BLOB *value)
{
DATA_BLOB oid;
if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) {
- return False;
+ return false;
}
if (!asn1_read_OctetString(data, mem_ctx, &oid)) {
- return False;
+ return false;
}
ctrl->oid = talloc_strndup(mem_ctx, (char *)oid.data, oid.length);
if (!ctrl->oid) {
- return False;
+ return false;
}
if (asn1_peek_tag(data, ASN1_BOOLEAN)) {
- BOOL critical;
+ bool critical;
if (!asn1_read_BOOLEAN(data, &critical)) {
- return False;
+ return false;
}
ctrl->critical = critical;
} else {
- ctrl->critical = False;
+ ctrl->critical = false;
}
ctrl->data = NULL;
@@ -1148,18 +1148,18 @@ BOOL ldap_decode_control_wrapper(void *mem_ctx, struct asn1_data *data, struct l
}
if (!asn1_read_OctetString(data, mem_ctx, value)) {
- return False;
+ return false;
}
end_tag:
if (!asn1_end_tag(data)) {
- return False;
+ return false;
}
- return True;
+ return true;
}
-BOOL ldap_encode_control(void *mem_ctx, struct asn1_data *data, struct ldb_control *ctrl)
+bool ldap_encode_control(void *mem_ctx, struct asn1_data *data, struct ldb_control *ctrl)
{
DATA_BLOB value;
int i;
@@ -1168,33 +1168,33 @@ BOOL ldap_encode_control(void *mem_ctx, struct asn1_data *data, struct ldb_contr
if (strcmp(ldap_known_controls[i].oid, ctrl->oid) == 0) {
if (!ldap_known_controls[i].encode) {
if (ctrl->critical) {
- return False;
+ return false;
} else {
/* not encoding this control */
- return True;
+ return true;
}
}
if (!ldap_known_controls[i].encode(mem_ctx, ctrl->data, &value)) {
- return False;
+ return false;
}
break;
}
}
if (ldap_known_controls[i].oid == NULL) {
- return False;
+ return false;
}
if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) {
- return False;
+ return false;
}
if (!asn1_write_OctetString(data, ctrl->oid, strlen(ctrl->oid))) {
- return False;
+ return false;
}
if (ctrl->critical) {
if (!asn1_write_BOOLEAN(data, ctrl->critical)) {
- return False;
+ return false;
}
}
@@ -1203,13 +1203,13 @@ BOOL ldap_encode_control(void *mem_ctx, struct asn1_data *data, struct ldb_contr
}
if (!asn1_write_OctetString(data, value.data, value.length)) {
- return False;
+ return false;
}
pop_tag:
if (!asn1_pop_tag(data)) {
- return False;
+ return false;
}
- return True;
+ return true;
}
diff --git a/source4/libcli/ldap/ldap_ildap.c b/source4/libcli/ldap/ldap_ildap.c
index 62019b8cc1..7b592c65ae 100644
--- a/source4/libcli/ldap/ldap_ildap.c
+++ b/source4/libcli/ldap/ldap_ildap.c
@@ -41,7 +41,7 @@ int ildap_count_entries(struct ldap_connection *conn, struct ldap_message **res)
*/
NTSTATUS ildap_search_bytree(struct ldap_connection *conn, const char *basedn,
int scope, struct ldb_parse_tree *tree,
- const char * const *attrs, BOOL attributesonly,
+ const char * const *attrs, bool attributesonly,
struct ldb_control **control_req,
struct ldb_control ***control_res,
struct ldap_message ***results)
@@ -75,7 +75,7 @@ NTSTATUS ildap_search_bytree(struct ldap_connection *conn, const char *basedn,
req = ldap_request_send(conn, msg);
talloc_steal(msg, req);
- for (i=n=0;True;i++) {
+ for (i=n=0;true;i++) {
struct ldap_message *res;
status = ldap_result_n(req, i, &res);
if (!NT_STATUS_IS_OK(status)) break;
@@ -114,7 +114,7 @@ NTSTATUS ildap_search_bytree(struct ldap_connection *conn, const char *basedn,
*/
NTSTATUS ildap_search(struct ldap_connection *conn, const char *basedn,
int scope, const char *expression,
- const char * const *attrs, BOOL attributesonly,
+ const char * const *attrs, bool attributesonly,
struct ldb_control **control_req,
struct ldb_control ***control_res,
struct ldap_message ***results)
diff --git a/source4/libcli/ldap/ldap_msg.c b/source4/libcli/ldap/ldap_msg.c
index c9643dafda..12832b8ec4 100644
--- a/source4/libcli/ldap/ldap_msg.c
+++ b/source4/libcli/ldap/ldap_msg.c
@@ -32,7 +32,7 @@ struct ldap_message *new_ldap_message(TALLOC_CTX *mem_ctx)
}
-BOOL add_value_to_attrib(TALLOC_CTX *mem_ctx, struct ldb_val *value,
+bool add_value_to_attrib(TALLOC_CTX *mem_ctx, struct ldb_val *value,
struct ldb_message_element *attrib)
{
attrib->values = talloc_realloc(mem_ctx,
@@ -40,16 +40,16 @@ BOOL add_value_to_attrib(TALLOC_CTX *mem_ctx, struct ldb_val *value,
DATA_BLOB,
attrib->num_values+1);
if (attrib->values == NULL)
- return False;
+ return false;
attrib->values[attrib->num_values].data = talloc_steal(attrib->values,
value->data);
attrib->values[attrib->num_values].length = value->length;
attrib->num_values += 1;
- return True;
+ return true;
}
-BOOL add_attrib_to_array_talloc(TALLOC_CTX *mem_ctx,
+bool add_attrib_to_array_talloc(TALLOC_CTX *mem_ctx,
const struct ldb_message_element *attrib,
struct ldb_message_element **attribs,
int *num_attribs)
@@ -60,16 +60,16 @@ BOOL add_attrib_to_array_talloc(TALLOC_CTX *mem_ctx,
*num_attribs+1);
if (*attribs == NULL)
- return False;
+ return false;
(*attribs)[*num_attribs] = *attrib;
talloc_steal(*attribs, attrib->values);
talloc_steal(*attribs, attrib->name);
*num_attribs += 1;
- return True;
+ return true;
}
-BOOL add_mod_to_array_talloc(TALLOC_CTX *mem_ctx,
+bool add_mod_to_array_talloc(TALLOC_CTX *mem_ctx,
struct ldap_mod *mod,
struct ldap_mod **mods,
int *num_mods)
@@ -77,10 +77,10 @@ BOOL add_mod_to_array_talloc(TALLOC_CTX *mem_ctx,
*mods = talloc_realloc(mem_ctx, *mods, struct ldap_mod, (*num_mods)+1);
if (*mods == NULL)
- return False;
+ return false;
(*mods)[*num_mods] = *mod;
*num_mods += 1;
- return True;
+ return true;
}
diff --git a/source4/libcli/libcli.h b/source4/libcli/libcli.h
index 1d573cadde..163852d90a 100644
--- a/source4/libcli/libcli.h
+++ b/source4/libcli/libcli.h
@@ -23,6 +23,8 @@
#include "librpc/gen_ndr/nbt.h"
+struct substitute_context;
+
/*
smbcli_state: internal state used in libcli library for single-threaded callers,
i.e. a single session on a single socket.
diff --git a/source4/libcli/nbt/namequery.c b/source4/libcli/nbt/namequery.c
index 32de9723b9..755e06e880 100644
--- a/source4/libcli/nbt/namequery.c
+++ b/source4/libcli/nbt/namequery.c
@@ -22,6 +22,7 @@
#include "includes.h"
#include "libcli/nbt/libnbt.h"
#include "lib/socket/socket.h"
+#include "param/param.h"
/**
send a nbt name query
@@ -53,10 +54,10 @@ _PUBLIC_ struct nbt_name_request *nbt_name_query_send(struct nbt_name_socket *nb
packet->questions[0].question_class = NBT_QCLASS_IP;
dest = socket_address_from_strings(packet, nbtsock->sock->backend_name,
- io->in.dest_addr, lp_nbt_port());
+ io->in.dest_addr, lp_nbt_port(global_loadparm));
if (dest == NULL) goto failed;
req = nbt_name_request_send(nbtsock, dest, packet,
- io->in.timeout, io->in.retries, False);
+ io->in.timeout, io->in.retries, false);
if (req == NULL) goto failed;
talloc_free(packet);
@@ -157,10 +158,10 @@ _PUBLIC_ struct nbt_name_request *nbt_name_status_send(struct nbt_name_socket *n
packet->questions[0].question_class = NBT_QCLASS_IP;
dest = socket_address_from_strings(packet, nbtsock->sock->backend_name,
- io->in.dest_addr, lp_nbt_port());
+ io->in.dest_addr, lp_nbt_port(global_loadparm));
if (dest == NULL) goto failed;
req = nbt_name_request_send(nbtsock, dest, packet,
- io->in.timeout, io->in.retries, False);
+ io->in.timeout, io->in.retries, false);
if (req == NULL) goto failed;
talloc_free(packet);
diff --git a/source4/libcli/nbt/namerefresh.c b/source4/libcli/nbt/namerefresh.c
index a60e54ed6a..d723eed9f5 100644
--- a/source4/libcli/nbt/namerefresh.c
+++ b/source4/libcli/nbt/namerefresh.c
@@ -23,6 +23,7 @@
#include "libcli/nbt/libnbt.h"
#include "libcli/composite/composite.h"
#include "lib/socket/socket.h"
+#include "param/param.h"
/*
send a nbt name refresh request
@@ -66,11 +67,12 @@ struct nbt_name_request *nbt_name_refresh_send(struct nbt_name_socket *nbtsock,
packet->additional[0].rdata.netbios.addresses[0].ipaddr =
talloc_strdup(packet->additional, io->in.address);
- dest = socket_address_from_strings(nbtsock, nbtsock->sock->backend_name,
- io->in.dest_addr, lp_nbt_port());
+ dest = socket_address_from_strings(nbtsock,
+ nbtsock->sock->backend_name,
+ io->in.dest_addr, lp_nbt_port(global_loadparm));
if (dest == NULL) goto failed;
req = nbt_name_request_send(nbtsock, dest, packet,
- io->in.timeout, io->in.retries, False);
+ io->in.timeout, io->in.retries, false);
if (req == NULL) goto failed;
talloc_free(packet);
@@ -240,7 +242,7 @@ struct composite_context *nbt_name_refresh_wins_send(struct nbt_name_socket *nbt
state->io->in.dest_addr = state->wins_servers[0];
state->io->in.address = io->in.addresses[0];
state->io->in.nb_flags = io->in.nb_flags;
- state->io->in.broadcast = False;
+ state->io->in.broadcast = false;
state->io->in.ttl = io->in.ttl;
state->io->in.timeout = 2;
state->io->in.retries = 2;
diff --git a/source4/libcli/nbt/nameregister.c b/source4/libcli/nbt/nameregister.c
index 7b03667fec..fd4a94dd44 100644
--- a/source4/libcli/nbt/nameregister.c
+++ b/source4/libcli/nbt/nameregister.c
@@ -24,6 +24,7 @@
#include "libcli/composite/composite.h"
#include "lib/socket/socket.h"
#include "librpc/gen_ndr/ndr_nbt.h"
+#include "param/param.h"
/*
send a nbt name registration request
@@ -76,10 +77,10 @@ struct nbt_name_request *nbt_name_register_send(struct nbt_name_socket *nbtsock,
if (packet->additional[0].rdata.netbios.addresses[0].ipaddr == NULL) goto failed;
dest = socket_address_from_strings(packet, nbtsock->sock->backend_name,
- io->in.dest_addr, lp_nbt_port());
+ io->in.dest_addr, lp_nbt_port(global_loadparm));
if (dest == NULL) goto failed;
req = nbt_name_request_send(nbtsock, dest, packet,
- io->in.timeout, io->in.retries, False);
+ io->in.timeout, io->in.retries, false);
if (req == NULL) goto failed;
talloc_free(packet);
@@ -165,7 +166,7 @@ static void name_register_bcast_handler(struct nbt_name_request *req)
status = nbt_name_register_recv(state->req, state, state->io);
if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
- if (state->io->in.register_demand == True) {
+ if (state->io->in.register_demand == true) {
/* all done */
c->state = COMPOSITE_STATE_DONE;
c->status = NT_STATUS_OK;
@@ -173,7 +174,7 @@ static void name_register_bcast_handler(struct nbt_name_request *req)
}
/* the registration timed out - good, send the demand */
- state->io->in.register_demand = True;
+ state->io->in.register_demand = true;
state->io->in.retries = 0;
state->req = nbt_name_register_send(state->nbtsock, state->io);
if (state->req == NULL) {
@@ -225,9 +226,9 @@ struct composite_context *nbt_name_register_bcast_send(struct nbt_name_socket *n
state->io->in.dest_addr = io->in.dest_addr;
state->io->in.address = io->in.address;
state->io->in.nb_flags = io->in.nb_flags;
- state->io->in.register_demand = False;
- state->io->in.broadcast = True;
- state->io->in.multi_homed = False;
+ state->io->in.register_demand = false;
+ state->io->in.broadcast = true;
+ state->io->in.multi_homed = false;
state->io->in.ttl = io->in.ttl;
state->io->in.timeout = 1;
state->io->in.retries = 2;
@@ -378,9 +379,9 @@ struct composite_context *nbt_name_register_wins_send(struct nbt_name_socket *nb
state->io->in.dest_addr = state->wins_servers[0];
state->io->in.address = io->in.addresses[0];
state->io->in.nb_flags = io->in.nb_flags;
- state->io->in.broadcast = False;
- state->io->in.register_demand = False;
- state->io->in.multi_homed = (io->in.nb_flags & NBT_NM_GROUP)?False:True;
+ state->io->in.broadcast = false;
+ state->io->in.register_demand = false;
+ state->io->in.multi_homed = (io->in.nb_flags & NBT_NM_GROUP)?false:true;
state->io->in.ttl = io->in.ttl;
state->io->in.timeout = 3;
state->io->in.retries = 2;
diff --git a/source4/libcli/nbt/namerelease.c b/source4/libcli/nbt/namerelease.c
index fd3967d1e6..1b3c9ae17e 100644
--- a/source4/libcli/nbt/namerelease.c
+++ b/source4/libcli/nbt/namerelease.c
@@ -22,6 +22,7 @@
#include "includes.h"
#include "libcli/nbt/libnbt.h"
#include "lib/socket/socket.h"
+#include "param/param.h"
/*
send a nbt name release request
@@ -66,10 +67,10 @@ struct nbt_name_request *nbt_name_release_send(struct nbt_name_socket *nbtsock,
talloc_strdup(packet->additional, io->in.address);
dest = socket_address_from_strings(packet, nbtsock->sock->backend_name,
- io->in.dest_addr, lp_nbt_port());
+ io->in.dest_addr, lp_nbt_port(global_loadparm));
if (dest == NULL) goto failed;
req = nbt_name_request_send(nbtsock, dest, packet,
- io->in.timeout, io->in.retries, False);
+ io->in.timeout, io->in.retries, false);
if (req == NULL) goto failed;
talloc_free(packet);
diff --git a/source4/libcli/nbt/nbtname.c b/source4/libcli/nbt/nbtname.c
index af3f62b987..37cdf64023 100644
--- a/source4/libcli/nbt/nbtname.c
+++ b/source4/libcli/nbt/nbtname.c
@@ -111,7 +111,7 @@ _PUBLIC_ NTSTATUS ndr_pull_nbt_string(struct ndr_pull *ndr, int ndr_flags, const
NT_STATUS_NOT_OK_RETURN(status);
if (component == NULL) break;
if (name) {
- name = talloc_asprintf_append(name, ".%s", component);
+ name = talloc_asprintf_append_buffer(name, ".%s", component);
NT_STATUS_HAVE_NO_MEMORY(name);
} else {
name = (char *)component;
@@ -149,7 +149,7 @@ _PUBLIC_ NTSTATUS ndr_push_nbt_string(struct ndr_push *ndr, int ndr_flags, const
/* see if we have pushed the remaing string allready,
* if so we use a label pointer to this string
*/
- status = ndr_token_retrieve_cmp_fn(&ndr->nbt_string_list, s, &offset, (comparison_fn_t)strcmp, False);
+ status = ndr_token_retrieve_cmp_fn(&ndr->nbt_string_list, s, &offset, (comparison_fn_t)strcmp, false);
if (NT_STATUS_IS_OK(status)) {
uint8_t b[2];
@@ -401,7 +401,7 @@ _PUBLIC_ void nbt_choose_called_name(TALLOC_CTX *mem_ctx,
n->scope = NULL;
n->type = type;
- if (is_ipaddress(name)) {
+ if (is_ipaddress(name) || name == NULL) {
n->name = "*SMBSERVER";
return;
}
diff --git a/source4/libcli/nbt/nbtsocket.c b/source4/libcli/nbt/nbtsocket.c
index 597dc5a354..7d88c83044 100644
--- a/source4/libcli/nbt/nbtsocket.c
+++ b/source4/libcli/nbt/nbtsocket.c
@@ -25,6 +25,7 @@
#include "libcli/nbt/libnbt.h"
#include "lib/socket/socket.h"
#include "librpc/gen_ndr/ndr_nbt.h"
+#include "param/param.h"
#define NBT_MAX_REPLIES 1000
@@ -214,7 +215,8 @@ static void nbt_name_socket_recv(struct nbt_name_socket *nbtsock)
}
/* find the matching request */
- req = idr_find(nbtsock->idr, packet->name_trn_id);
+ req = (struct nbt_name_request *)idr_find(nbtsock->idr,
+ packet->name_trn_id);
if (req == NULL) {
if (nbtsock->unexpected.handler) {
nbtsock->unexpected.handler(nbtsock, packet, src);
@@ -239,10 +241,10 @@ static void nbt_name_socket_recv(struct nbt_name_socket *nbtsock)
/* we know we won't need any more retries - the server
has received our request */
req->num_retries = 0;
- req->received_wack = True;
+ req->received_wack = true;
/* although there can be a timeout in the packet, w2k3 screws it up,
so better to set it ourselves */
- req->timeout = lp_parm_int(-1, "nbt", "wack_timeout", 30);
+ req->timeout = lp_parm_int(global_loadparm, NULL, "nbt", "wack_timeout", 30);
req->te = event_add_timed(req->nbtsock->event_ctx, req,
timeval_current_ofs(req->timeout, 0),
nbt_name_socket_timeout, req);
@@ -353,7 +355,7 @@ struct nbt_name_request *nbt_name_request_send(struct nbt_name_socket *nbtsock,
struct socket_address *dest,
struct nbt_name_packet *request,
int timeout, int retries,
- BOOL allow_multiple_replies)
+ bool allow_multiple_replies)
{
struct nbt_name_request *req;
int id;
@@ -365,7 +367,7 @@ struct nbt_name_request *nbt_name_request_send(struct nbt_name_socket *nbtsock,
req->nbtsock = nbtsock;
req->allow_multiple_replies = allow_multiple_replies;
req->state = NBT_REQUEST_SEND;
- req->is_reply = False;
+ req->is_reply = false;
req->timeout = timeout;
req->num_retries = retries;
req->dest = dest;
@@ -429,7 +431,7 @@ NTSTATUS nbt_name_reply_send(struct nbt_name_socket *nbtsock,
req->dest = dest;
if (talloc_reference(req, dest) == NULL) goto failed;
req->state = NBT_REQUEST_SEND;
- req->is_reply = True;
+ req->is_reply = true;
talloc_set_destructor(req, nbt_name_request_destructor);
diff --git a/source4/libcli/util/clierror.c b/source4/libcli/raw/clierror.c
index 89bba21ed6..c515259ee7 100644
--- a/source4/libcli/util/clierror.c
+++ b/source4/libcli/raw/clierror.c
@@ -66,7 +66,7 @@ NTSTATUS smbcli_nt_error(struct smbcli_tree *tree)
/* Return true if the last packet was an error */
-BOOL smbcli_is_error(struct smbcli_tree *tree)
+bool smbcli_is_error(struct smbcli_tree *tree)
{
return NT_STATUS_IS_ERR(smbcli_nt_error(tree));
}
diff --git a/source4/libcli/raw/clioplock.c b/source4/libcli/raw/clioplock.c
index 12b586aafa..ae4e58ae01 100644
--- a/source4/libcli/raw/clioplock.c
+++ b/source4/libcli/raw/clioplock.c
@@ -23,9 +23,9 @@
/****************************************************************************
send an ack for an oplock break request
****************************************************************************/
-_PUBLIC_ BOOL smbcli_oplock_ack(struct smbcli_tree *tree, uint16_t fnum, uint16_t ack_level)
+_PUBLIC_ bool smbcli_oplock_ack(struct smbcli_tree *tree, uint16_t fnum, uint16_t ack_level)
{
- BOOL ret;
+ bool ret;
struct smbcli_request *req;
req = smbcli_request_setup(tree, SMBlockingX, 8, 0);
@@ -53,7 +53,7 @@ _PUBLIC_ BOOL smbcli_oplock_ack(struct smbcli_tree *tree, uint16_t fnum, uint16_
set the oplock handler for a connection
****************************************************************************/
_PUBLIC_ void smbcli_oplock_handler(struct smbcli_transport *transport,
- BOOL (*handler)(struct smbcli_transport *, uint16_t, uint16_t, uint8_t, void *),
+ bool (*handler)(struct smbcli_transport *, uint16_t, uint16_t, uint8_t, void *),
void *private)
{
transport->oplock.handler = handler;
diff --git a/source4/libcli/raw/clisession.c b/source4/libcli/raw/clisession.c
index c6c575b818..617131c53c 100644
--- a/source4/libcli/raw/clisession.c
+++ b/source4/libcli/raw/clisession.c
@@ -33,7 +33,7 @@
Initialize the session context
****************************************************************************/
struct smbcli_session *smbcli_session_init(struct smbcli_transport *transport,
- TALLOC_CTX *parent_ctx, BOOL primary)
+ TALLOC_CTX *parent_ctx, bool primary)
{
struct smbcli_session *session;
uint16_t flags2;
diff --git a/source4/libcli/raw/clisocket.c b/source4/libcli/raw/clisocket.c
index 0aa6ec5616..a748b40a32 100644
--- a/source4/libcli/raw/clisocket.c
+++ b/source4/libcli/raw/clisocket.c
@@ -26,6 +26,7 @@
#include "libcli/composite/composite.h"
#include "lib/socket/socket.h"
#include "libcli/resolve/resolve.h"
+#include "param/param.h"
struct sock_connect_state {
struct composite_context *ctx;
@@ -72,7 +73,7 @@ struct composite_context *smbcli_sock_connect_send(TALLOC_CTX *mem_ctx,
if (state->host_name == NULL) goto failed;
if (port == 0) {
- const char **ports = lp_smb_ports();
+ const char **ports = lp_smb_ports(global_loadparm);
int i;
for (i=0;ports[i];i++) /* noop */ ;
@@ -119,7 +120,7 @@ static void smbcli_sock_connect_recv_conn(struct composite_context *ctx)
if (!composite_is_ok(state->ctx)) return;
state->ctx->status =
- socket_set_option(sock, lp_socket_options(), NULL);
+ socket_set_option(sock, lp_socket_options(global_loadparm), NULL);
if (!composite_is_ok(state->ctx)) return;
diff --git a/source4/libcli/raw/clitransport.c b/source4/libcli/raw/clitransport.c
index 98f5042d99..0bf805910e 100644
--- a/source4/libcli/raw/clitransport.c
+++ b/source4/libcli/raw/clitransport.c
@@ -26,6 +26,7 @@
#include "lib/events/events.h"
#include "lib/stream/packet.h"
#include "librpc/gen_ndr/ndr_nbt.h"
+#include "param/param.h"
/*
@@ -71,7 +72,8 @@ static NTSTATUS smbcli_transport_finish_recv(void *private, DATA_BLOB blob);
create a transport structure based on an established socket
*/
struct smbcli_transport *smbcli_transport_init(struct smbcli_socket *sock,
- TALLOC_CTX *parent_ctx, BOOL primary)
+ TALLOC_CTX *parent_ctx,
+ bool primary)
{
struct smbcli_transport *transport;
@@ -84,9 +86,10 @@ struct smbcli_transport *smbcli_transport_init(struct smbcli_socket *sock,
transport->socket = talloc_reference(transport, sock);
}
transport->negotiate.protocol = PROTOCOL_NT1;
- transport->options.use_spnego = lp_use_spnego() && lp_nt_status_support();
- transport->options.max_xmit = lp_max_xmit();
- transport->options.max_mux = lp_maxmux();
+ transport->options.use_spnego = lp_use_spnego(global_loadparm) &&
+ lp_nt_status_support(global_loadparm);
+ transport->options.max_xmit = lp_max_xmit(global_loadparm);
+ transport->options.max_mux = lp_maxmux(global_loadparm);
transport->options.request_timeout = SMB_REQUEST_TIMEOUT;
transport->negotiate.max_xmit = transport->options.max_xmit;
@@ -259,7 +262,7 @@ NTSTATUS smbcli_transport_connect_recv(struct smbcli_request *req)
/*
send a session request (if needed)
*/
-BOOL smbcli_transport_connect(struct smbcli_transport *transport,
+bool smbcli_transport_connect(struct smbcli_transport *transport,
struct nbt_name *calling,
struct nbt_name *called)
{
@@ -267,7 +270,7 @@ BOOL smbcli_transport_connect(struct smbcli_transport *transport,
NTSTATUS status;
if (transport->socket->port == 445) {
- return True;
+ return true;
}
req = smbcli_transport_connect_send(transport,
@@ -498,16 +501,16 @@ error:
/*
process some read/write requests that are pending
- return False if the socket is dead
+ return false if the socket is dead
*/
-BOOL smbcli_transport_process(struct smbcli_transport *transport)
+bool smbcli_transport_process(struct smbcli_transport *transport)
{
NTSTATUS status;
size_t npending;
packet_queue_run(transport->packet);
if (transport->socket->sock == NULL) {
- return False;
+ return false;
}
status = socket_pending(transport->socket->sock, &npending);
@@ -515,9 +518,9 @@ BOOL smbcli_transport_process(struct smbcli_transport *transport)
packet_recv(transport->packet);
}
if (transport->socket->sock == NULL) {
- return False;
+ return false;
}
- return True;
+ return true;
}
/*
@@ -635,7 +638,7 @@ NTSTATUS smb_raw_echo_recv(struct smbcli_request *req, TALLOC_CTX *mem_ctx,
p->out.sequence_number = SVAL(req->in.vwv, VWV(0));
p->out.size = req->in.data_size;
talloc_free(p->out.data);
- p->out.data = talloc_size(mem_ctx, p->out.size);
+ p->out.data = talloc_array(mem_ctx, uint8_t, p->out.size);
NT_STATUS_HAVE_NO_MEMORY(p->out.data);
if (!smbcli_raw_pull_data(req, req->in.data, p->out.size, p->out.data)) {
diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c
index a5217d74b2..54f8ac95a4 100644
--- a/source4/libcli/raw/clitree.c
+++ b/source4/libcli/raw/clitree.c
@@ -23,6 +23,7 @@
#include "includes.h"
#include "libcli/raw/libcliraw.h"
#include "libcli/smb_composite/smb_composite.h"
+#include "param/param.h"
#define SETUP_REQUEST_TREE(cmd, wct, buflen) do { \
req = smbcli_request_setup(tree, cmd, wct, buflen); \
@@ -33,7 +34,7 @@
Initialize the tree context
****************************************************************************/
struct smbcli_tree *smbcli_tree_init(struct smbcli_session *session,
- TALLOC_CTX *parent_ctx, BOOL primary)
+ TALLOC_CTX *parent_ctx, bool primary)
{
struct smbcli_tree *tree;
@@ -188,8 +189,8 @@ NTSTATUS smbcli_tree_full_connection(TALLOC_CTX *parent_ctx,
io.in.service = service;
io.in.service_type = service_type;
io.in.credentials = credentials;
- io.in.fallback_to_anonymous = False;
- io.in.workgroup = lp_workgroup();
+ io.in.fallback_to_anonymous = false;
+ io.in.workgroup = lp_workgroup(global_loadparm);
status = smb_composite_connect(&io, parent_ctx, ev);
if (NT_STATUS_IS_OK(status)) {
diff --git a/source4/libcli/raw/interfaces.h b/source4/libcli/raw/interfaces.h
index 23de6c3838..00ab788184 100644
--- a/source4/libcli/raw/interfaces.h
+++ b/source4/libcli/raw/interfaces.h
@@ -23,6 +23,7 @@
#define __LIBCLI_RAW_INTERFACES_H__
#include "smb.h"
+#include "librpc/gen_ndr/misc.h" /* for struct GUID */
/* this structure is just a wrapper for a string, the only reason we
bother with this is that it allows us to check the length provided
diff --git a/source4/libcli/raw/raweas.c b/source4/libcli/raw/raweas.c
index f79de88fa6..8ea8e621c9 100644
--- a/source4/libcli/raw/raweas.c
+++ b/source4/libcli/raw/raweas.c
@@ -19,6 +19,7 @@
#include "includes.h"
#include "smb.h"
+#include "libcli/raw/libcliraw.h"
/*
work out how many bytes on the wire a ea list will consume.
@@ -332,7 +333,7 @@ NTSTATUS ea_pull_name_list(const DATA_BLOB *blob,
/*
put a ea_name list into a data blob
*/
-BOOL ea_push_name_list(TALLOC_CTX *mem_ctx,
+bool ea_push_name_list(TALLOC_CTX *mem_ctx,
DATA_BLOB *data, uint_t num_names, struct ea_name *eas)
{
int i;
@@ -343,7 +344,7 @@ BOOL ea_push_name_list(TALLOC_CTX *mem_ctx,
*data = data_blob_talloc(mem_ctx, NULL, ea_size);
if (data->data == NULL) {
- return False;
+ return false;
}
SIVAL(data->data, 0, ea_size);
@@ -356,5 +357,5 @@ BOOL ea_push_name_list(TALLOC_CTX *mem_ctx,
off += 1+nlen+1;
}
- return True;
+ return true;
}
diff --git a/source4/libcli/raw/rawfile.c b/source4/libcli/raw/rawfile.c
index 60a9bf2656..83303cf470 100644
--- a/source4/libcli/raw/rawfile.c
+++ b/source4/libcli/raw/rawfile.c
@@ -426,7 +426,7 @@ struct smbcli_request *smb_raw_open_send(struct smbcli_tree *tree, union smb_ope
{
int len;
struct smbcli_request *req = NULL;
- BOOL bigoffset = False;
+ bool bigoffset = false;
switch (parms->generic.level) {
case RAW_OPEN_T2OPEN:
@@ -527,7 +527,7 @@ struct smbcli_request *smb_raw_open_send(struct smbcli_tree *tree, union smb_ope
smbcli_req_append_string(req, parms->openxreadx.in.fname, STR_TERMINATE);
if (tree->session->transport->negotiate.capabilities & CAP_LARGE_FILES) {
- bigoffset = True;
+ bigoffset = true;
}
smbcli_chained_request_setup(req, SMBreadX, bigoffset ? 12 : 10, 0);
diff --git a/source4/libcli/raw/rawfileinfo.c b/source4/libcli/raw/rawfileinfo.c
index faae3a52b1..8481995c1a 100644
--- a/source4/libcli/raw/rawfileinfo.c
+++ b/source4/libcli/raw/rawfileinfo.c
@@ -66,7 +66,7 @@ NTSTATUS smbcli_parse_stream_info(DATA_BLOB blob, TALLOC_CTX *mem_ctx,
if (size == -1) {
return NT_STATUS_ILLEGAL_CHARACTER;
}
- io->streams[n].stream_name.s = vstr;
+ io->streams[n].stream_name.s = (const char *)vstr;
io->streams[n].stream_name.private_length = nlen;
io->num_streams++;
len = IVAL(blob.data, ofs);
diff --git a/source4/libcli/raw/rawlpq.c b/source4/libcli/raw/rawlpq.c
index 03f7a82f1c..46e0efaaf5 100644
--- a/source4/libcli/raw/rawlpq.c
+++ b/source4/libcli/raw/rawlpq.c
@@ -19,6 +19,7 @@
#include "includes.h"
#include "smb.h"
+#include "libcli/raw/libcliraw.h"
/****************************************************************************
lpq - async send
diff --git a/source4/libcli/raw/rawnegotiate.c b/source4/libcli/raw/rawnegotiate.c
index c2dc393481..82d6fe5236 100644
--- a/source4/libcli/raw/rawnegotiate.c
+++ b/source4/libcli/raw/rawnegotiate.c
@@ -23,6 +23,7 @@
#include "includes.h"
#include "libcli/raw/libcliraw.h"
#include "system/time.h"
+#include "param/param.h"
static const struct {
enum protocol_types prot;
@@ -57,7 +58,7 @@ struct smbcli_request *smb_raw_negotiate_send(struct smbcli_transport *transport
}
flags2 |= FLAGS2_32_BIT_ERROR_CODES;
- if (lp_unicode()) {
+ if (lp_unicode(global_loadparm)) {
flags2 |= FLAGS2_UNICODE_STRINGS;
}
flags2 |= FLAGS2_EXTENDED_ATTRIBUTES;
@@ -143,8 +144,8 @@ NTSTATUS smb_raw_negotiate_recv(struct smbcli_request *req)
}
if (transport->negotiate.capabilities & CAP_RAW_MODE) {
- transport->negotiate.readbraw_supported = True;
- transport->negotiate.writebraw_supported = True;
+ transport->negotiate.readbraw_supported = true;
+ transport->negotiate.writebraw_supported = true;
}
} else if (transport->negotiate.protocol >= PROTOCOL_LANMAN1) {
SMBCLI_CHECK_WCT(req, 13);
@@ -173,11 +174,11 @@ NTSTATUS smb_raw_negotiate_recv(struct smbcli_request *req)
}
/* a way to force ascii SMB */
- if (!lp_unicode()) {
+ if (!lp_unicode(global_loadparm)) {
transport->negotiate.capabilities &= ~CAP_UNICODE;
}
- if (!lp_nt_status_support()) {
+ if (!lp_nt_status_support(global_loadparm)) {
transport->negotiate.capabilities &= ~CAP_STATUS32;
}
diff --git a/source4/libcli/raw/rawreadwrite.c b/source4/libcli/raw/rawreadwrite.c
index a288b7ec54..b0c49ddab7 100644
--- a/source4/libcli/raw/rawreadwrite.c
+++ b/source4/libcli/raw/rawreadwrite.c
@@ -31,13 +31,13 @@
****************************************************************************/
struct smbcli_request *smb_raw_read_send(struct smbcli_tree *tree, union smb_read *parms)
{
- BOOL bigoffset = False;
+ bool bigoffset = false;
struct smbcli_request *req = NULL;
switch (parms->generic.level) {
case RAW_READ_READBRAW:
if (tree->session->transport->negotiate.capabilities & CAP_LARGE_FILES) {
- bigoffset = True;
+ bigoffset = true;
}
SETUP_REQUEST(SMBreadbraw, bigoffset? 10:8, 0);
SSVAL(req->out.vwv, VWV(0), parms->readbraw.in.file.fnum);
@@ -69,7 +69,7 @@ struct smbcli_request *smb_raw_read_send(struct smbcli_tree *tree, union smb_rea
case RAW_READ_READX:
if (tree->session->transport->negotiate.capabilities & CAP_LARGE_FILES) {
- bigoffset = True;
+ bigoffset = true;
}
SETUP_REQUEST(SMBreadX, bigoffset ? 12 : 10, 0);
SSVAL(req->out.vwv, VWV(0), SMB_CHAIN_NONE);
@@ -206,7 +206,7 @@ NTSTATUS smb_raw_read(struct smbcli_tree *tree, union smb_read *parms)
****************************************************************************/
struct smbcli_request *smb_raw_write_send(struct smbcli_tree *tree, union smb_write *parms)
{
- BOOL bigoffset = False;
+ bool bigoffset = false;
struct smbcli_request *req = NULL;
switch (parms->generic.level) {
@@ -253,7 +253,7 @@ struct smbcli_request *smb_raw_write_send(struct smbcli_tree *tree, union smb_wr
case RAW_WRITE_WRITEX:
if (tree->session->transport->negotiate.capabilities & CAP_LARGE_FILES) {
- bigoffset = True;
+ bigoffset = true;
}
SETUP_REQUEST(SMBwriteX, bigoffset ? 14 : 12, parms->writex.in.count);
SSVAL(req->out.vwv, VWV(0), SMB_CHAIN_NONE);
diff --git a/source4/libcli/raw/rawrequest.c b/source4/libcli/raw/rawrequest.c
index 6bf2bb58cc..6a4f432088 100644
--- a/source4/libcli/raw/rawrequest.c
+++ b/source4/libcli/raw/rawrequest.c
@@ -83,7 +83,7 @@ struct smbcli_request *smbcli_request_setup_nonsmb(struct smbcli_transport *tran
/* over allocate by a small amount */
req->out.allocated = req->out.size + REQ_OVER_ALLOCATION;
- req->out.buffer = talloc_size(req, req->out.allocated);
+ req->out.buffer = talloc_array(req, uint8_t, req->out.allocated);
if (!req->out.buffer) {
return NULL;
}
@@ -309,7 +309,7 @@ NTSTATUS smbcli_chained_advance(struct smbcli_request *req)
/*
send a message
*/
-BOOL smbcli_request_send(struct smbcli_request *req)
+bool smbcli_request_send(struct smbcli_request *req)
{
if (IVAL(req->out.buffer, 0) == 0) {
_smb_setlen(req->out.buffer, req->out.size - NBT_HDR_SIZE);
@@ -319,23 +319,23 @@ BOOL smbcli_request_send(struct smbcli_request *req)
smbcli_transport_send(req);
- return True;
+ return true;
}
/*
receive a response to a packet
*/
-BOOL smbcli_request_receive(struct smbcli_request *req)
+bool smbcli_request_receive(struct smbcli_request *req)
{
/* req can be NULL when a send has failed. This eliminates lots of NULL
checks in each module */
- if (!req) return False;
+ if (!req) return false;
/* keep receiving packets until this one is replied to */
while (req->state <= SMBCLI_REQUEST_RECV) {
if (event_loop_once(req->transport->socket->event.ctx) != 0) {
- return False;
+ return false;
}
}
@@ -347,7 +347,7 @@ BOOL smbcli_request_receive(struct smbcli_request *req)
receive another reply to a request - this is used for requests that
have multi-part replies (such as SMBtrans2)
*/
-BOOL smbcli_request_receive_more(struct smbcli_request *req)
+bool smbcli_request_receive_more(struct smbcli_request *req)
{
req->state = SMBCLI_REQUEST_RECV;
DLIST_ADD(req->transport->pending_recv, req);
@@ -357,10 +357,10 @@ BOOL smbcli_request_receive_more(struct smbcli_request *req)
/*
- handle oplock break requests from the server - return True if the request was
+ handle oplock break requests from the server - return true if the request was
an oplock break
*/
-BOOL smbcli_handle_oplock_break(struct smbcli_transport *transport, uint_t len, const uint8_t *hdr, const uint8_t *vwv)
+bool smbcli_handle_oplock_break(struct smbcli_transport *transport, uint_t len, const uint8_t *hdr, const uint8_t *vwv)
{
/* we must be very fussy about what we consider an oplock break to avoid
matching readbraw replies */
@@ -370,7 +370,7 @@ BOOL smbcli_handle_oplock_break(struct smbcli_transport *transport, uint_t len,
SVAL(hdr, HDR_MID) != 0xFFFF ||
SVAL(vwv,VWV(6)) != 0 ||
SVAL(vwv,VWV(7)) != 0) {
- return False;
+ return false;
}
if (transport->oplock.handler) {
@@ -380,7 +380,7 @@ BOOL smbcli_handle_oplock_break(struct smbcli_transport *transport, uint_t len,
transport->oplock.handler(transport, tid, fnum, level, transport->oplock.private);
}
- return True;
+ return true;
}
/*
@@ -395,7 +395,7 @@ NTSTATUS smbcli_request_simple_recv(struct smbcli_request *req)
/* Return true if the last packet was in error */
-BOOL smbcli_request_is_error(struct smbcli_request *req)
+bool smbcli_request_is_error(struct smbcli_request *req)
{
return NT_STATUS_IS_ERR(req->status);
}
@@ -676,33 +676,33 @@ DATA_BLOB smbcli_req_pull_blob(struct smbcli_request *req, TALLOC_CTX *mem_ctx,
/* check that a lump of data in a request is within the bounds of the data section of
the packet */
-static BOOL smbcli_req_data_oob(struct smbcli_request *req, const uint8_t *ptr, uint32_t count)
+static bool smbcli_req_data_oob(struct smbcli_request *req, const uint8_t *ptr, uint32_t count)
{
/* be careful with wraparound! */
if (ptr < req->in.data ||
ptr >= req->in.data + req->in.data_size ||
count > req->in.data_size ||
ptr + count > req->in.data + req->in.data_size) {
- return True;
+ return true;
}
- return False;
+ return false;
}
/*
pull a lump of data from a request packet
- return False if any part is outside the data portion of the packet
+ return false if any part is outside the data portion of the packet
*/
-BOOL smbcli_raw_pull_data(struct smbcli_request *req, const uint8_t *src, int len, uint8_t *dest)
+bool smbcli_raw_pull_data(struct smbcli_request *req, const uint8_t *src, int len, uint8_t *dest)
{
- if (len == 0) return True;
+ if (len == 0) return true;
if (smbcli_req_data_oob(req, src, len)) {
- return False;
+ return false;
}
memcpy(dest, src, len);
- return True;
+ return true;
}
diff --git a/source4/libcli/raw/rawsetfileinfo.c b/source4/libcli/raw/rawsetfileinfo.c
index 7738e849e8..5fa0c1f2da 100644
--- a/source4/libcli/raw/rawsetfileinfo.c
+++ b/source4/libcli/raw/rawsetfileinfo.c
@@ -27,7 +27,7 @@
/*
Handle setfileinfo/setpathinfo passthu constructions
*/
-BOOL smb_raw_setfileinfo_passthru(TALLOC_CTX *mem_ctx,
+bool smb_raw_setfileinfo_passthru(TALLOC_CTX *mem_ctx,
enum smb_setfileinfo_level level,
union smb_setfileinfo *parms,
DATA_BLOB *blob)
@@ -36,7 +36,7 @@ BOOL smb_raw_setfileinfo_passthru(TALLOC_CTX *mem_ctx,
#define NEED_BLOB(n) do { \
*blob = data_blob_talloc(mem_ctx, NULL, n); \
- if (blob->data == NULL) return False; \
+ if (blob->data == NULL) return false; \
} while (0)
switch (level) {
@@ -48,22 +48,22 @@ BOOL smb_raw_setfileinfo_passthru(TALLOC_CTX *mem_ctx,
smbcli_push_nttime(blob->data, 24, parms->basic_info.in.change_time);
SIVAL(blob->data, 32, parms->basic_info.in.attrib);
SIVAL(blob->data, 36, 0); /* padding */
- return True;
+ return true;
case RAW_SFILEINFO_DISPOSITION_INFORMATION:
NEED_BLOB(4);
SIVAL(blob->data, 0, parms->disposition_info.in.delete_on_close);
- return True;
+ return true;
case RAW_SFILEINFO_ALLOCATION_INFORMATION:
NEED_BLOB(8);
SBVAL(blob->data, 0, parms->allocation_info.in.alloc_size);
- return True;
+ return true;
case RAW_SFILEINFO_END_OF_FILE_INFORMATION:
NEED_BLOB(8);
SBVAL(blob->data, 0, parms->end_of_file_info.in.size);
- return True;
+ return true;
case RAW_SFILEINFO_RENAME_INFORMATION:
NEED_BLOB(12);
@@ -73,17 +73,17 @@ BOOL smb_raw_setfileinfo_passthru(TALLOC_CTX *mem_ctx,
parms->rename_information.in.new_name,
STR_UNICODE|STR_TERMINATE);
SIVAL(blob->data, 8, len - 2);
- return True;
+ return true;
case RAW_SFILEINFO_POSITION_INFORMATION:
NEED_BLOB(8);
SBVAL(blob->data, 0, parms->position_information.in.position);
- return True;
+ return true;
case RAW_SFILEINFO_MODE_INFORMATION:
NEED_BLOB(4);
SIVAL(blob->data, 0, parms->mode_information.in.mode);
- return True;
+ return true;
case RAW_FILEINFO_SEC_DESC: {
NTSTATUS status;
@@ -91,9 +91,9 @@ BOOL smb_raw_setfileinfo_passthru(TALLOC_CTX *mem_ctx,
status = ndr_push_struct_blob(blob, mem_ctx,
parms->set_secdesc.in.sd,
(ndr_push_flags_fn_t)ndr_push_security_descriptor);
- if (!NT_STATUS_IS_OK(status)) return False;
+ if (!NT_STATUS_IS_OK(status)) return false;
- return True;
+ return true;
}
/* Unhandled levels */
@@ -107,16 +107,16 @@ BOOL smb_raw_setfileinfo_passthru(TALLOC_CTX *mem_ctx,
default:
DEBUG(0,("Unhandled setfileinfo passthru level %d\n", level));
- return False;
+ return false;
}
- return False;
+ return false;
}
/*
Handle setfileinfo/setpathinfo trans2 backend.
*/
-static BOOL smb_raw_setinfo_backend(struct smbcli_tree *tree,
+static bool smb_raw_setinfo_backend(struct smbcli_tree *tree,
TALLOC_CTX *mem_ctx,
union smb_setfileinfo *parms,
DATA_BLOB *blob)
@@ -127,7 +127,7 @@ static BOOL smb_raw_setinfo_backend(struct smbcli_tree *tree,
case RAW_SFILEINFO_SETATTRE:
case RAW_SFILEINFO_SEC_DESC:
/* not handled here */
- return False;
+ return false;
case RAW_SFILEINFO_STANDARD:
NEED_BLOB(12);
@@ -137,12 +137,12 @@ static BOOL smb_raw_setinfo_backend(struct smbcli_tree *tree,
blob->data, 4, parms->standard.in.access_time);
raw_push_dos_date2(tree->session->transport,
blob->data, 8, parms->standard.in.write_time);
- return True;
+ return true;
case RAW_SFILEINFO_EA_SET:
NEED_BLOB(ea_list_size(parms->ea_set.in.num_eas, parms->ea_set.in.eas));
ea_put_list(blob->data, parms->ea_set.in.num_eas, parms->ea_set.in.eas);
- return True;
+ return true;
case RAW_SFILEINFO_BASIC_INFO:
case RAW_SFILEINFO_BASIC_INFORMATION:
@@ -164,7 +164,7 @@ static BOOL smb_raw_setinfo_backend(struct smbcli_tree *tree,
SBVAL(blob->data, 76, parms->unix_basic.in.unique_id);
SBVAL(blob->data, 84, parms->unix_basic.in.permissions);
SBVAL(blob->data, 92, parms->unix_basic.in.nlink);
- return True;
+ return true;
case RAW_SFILEINFO_UNIX_INFO2:
NEED_BLOB(116);
@@ -184,7 +184,7 @@ static BOOL smb_raw_setinfo_backend(struct smbcli_tree *tree,
smbcli_push_nttime(blob->data, 100, parms->unix_info2.in.create_time);
SIVAL(blob->data, 108, parms->unix_info2.in.file_flags);
SIVAL(blob->data, 112, parms->unix_info2.in.flags_mask);
- return True;
+ return true;
case RAW_SFILEINFO_DISPOSITION_INFO:
case RAW_SFILEINFO_DISPOSITION_INFORMATION:
@@ -230,7 +230,7 @@ static BOOL smb_raw_setinfo_backend(struct smbcli_tree *tree,
break;
}
- return False;
+ return false;
}
/****************************************************************************
diff --git a/source4/libcli/raw/rawshadow.c b/source4/libcli/raw/rawshadow.c
index 8fc81dab4c..4c58c91383 100644
--- a/source4/libcli/raw/rawshadow.c
+++ b/source4/libcli/raw/rawshadow.c
@@ -39,7 +39,7 @@ _PUBLIC_ NTSTATUS smb_raw_shadow_data(struct smbcli_tree *tree,
nt.ntioctl.level = RAW_IOCTL_NTIOCTL;
nt.ntioctl.in.function = FSCTL_GET_SHADOW_COPY_DATA;
nt.ntioctl.in.file.fnum = info->in.file.fnum;
- nt.ntioctl.in.fsctl = True;
+ nt.ntioctl.in.fsctl = true;
nt.ntioctl.in.filter = 0;
nt.ntioctl.in.max_data = info->in.max_data;
nt.ntioctl.in.blob = data_blob(NULL, 0);
diff --git a/source4/libcli/raw/rawtrans.c b/source4/libcli/raw/rawtrans.c
index fe26a71310..53670d22a3 100644
--- a/source4/libcli/raw/rawtrans.c
+++ b/source4/libcli/raw/rawtrans.c
@@ -27,13 +27,13 @@
/*
check out of bounds for incoming data
*/
-static BOOL raw_trans_oob(struct smbcli_request *req,
+static bool raw_trans_oob(struct smbcli_request *req,
uint_t offset, uint_t count)
{
uint8_t *ptr;
if (count == 0) {
- return False;
+ return false;
}
ptr = req->in.hdr + offset;
@@ -43,9 +43,9 @@ static BOOL raw_trans_oob(struct smbcli_request *req,
ptr >= req->in.data + req->in.data_size ||
count > req->in.data_size ||
ptr + count > req->in.data + req->in.data_size) {
- return True;
+ return true;
}
- return False;
+ return false;
}
/****************************************************************************
@@ -86,7 +86,7 @@ NTSTATUS smb_raw_trans2_recv(struct smbcli_request *req,
/* allocate it */
if (total_data != 0) {
- tdata = talloc_size(mem_ctx, total_data);
+ tdata = talloc_array(mem_ctx, uint8_t, total_data);
if (!tdata) {
DEBUG(0,("smb_raw_receive_trans: failed to enlarge data buffer to %d bytes\n", total_data));
req->status = NT_STATUS_NO_MEMORY;
@@ -96,7 +96,7 @@ NTSTATUS smb_raw_trans2_recv(struct smbcli_request *req,
}
if (total_param != 0) {
- tparam = talloc_size(mem_ctx, total_param);
+ tparam = talloc_array(mem_ctx, uint8_t, total_param);
if (!tparam) {
DEBUG(0,("smb_raw_receive_trans: failed to enlarge param buffer to %d bytes\n", total_param));
req->status = NT_STATUS_NO_MEMORY;
diff --git a/source4/libcli/raw/smb_signing.c b/source4/libcli/raw/smb_signing.c
index 99044d23ae..e19e81af7e 100644
--- a/source4/libcli/raw/smb_signing.c
+++ b/source4/libcli/raw/smb_signing.c
@@ -23,45 +23,46 @@
#include "smb.h"
#include "libcli/raw/libcliraw.h"
#include "lib/crypto/crypto.h"
+#include "param/param.h"
/***********************************************************
SMB signing - Common code before we set a new signing implementation
************************************************************/
-BOOL set_smb_signing_common(struct smb_signing_context *sign_info)
+bool set_smb_signing_common(struct smb_signing_context *sign_info)
{
if (sign_info->doing_signing) {
DEBUG(5, ("SMB Signing already in progress, so we don't start it again\n"));
- return False;
+ return false;
}
if (!sign_info->allow_smb_signing) {
DEBUG(5, ("SMB Signing has been locally disabled\n"));
- return False;
+ return false;
}
- return True;
+ return true;
}
/***********************************************************
SMB signing - Common code before we set a new signing implementation
************************************************************/
-static BOOL smbcli_set_smb_signing_common(struct smbcli_transport *transport)
+static bool smbcli_set_smb_signing_common(struct smbcli_transport *transport)
{
if (!set_smb_signing_common(&transport->negotiate.sign_info)) {
- return False;
+ return false;
}
if (!(transport->negotiate.sec_mode &
(NEGOTIATE_SECURITY_SIGNATURES_REQUIRED|NEGOTIATE_SECURITY_SIGNATURES_ENABLED))) {
DEBUG(5, ("SMB Signing is not negotiated by the peer\n"));
- return False;
+ return false;
}
/* These calls are INCOMPATIBLE with SMB signing */
- transport->negotiate.readbraw_supported = False;
- transport->negotiate.writebraw_supported = False;
+ transport->negotiate.readbraw_supported = false;
+ transport->negotiate.writebraw_supported = false;
- return True;
+ return true;
}
void mark_packet_signed(struct request_buffer *out)
@@ -72,17 +73,17 @@ void mark_packet_signed(struct request_buffer *out)
SSVAL(out->hdr, HDR_FLG2, flags2);
}
-BOOL signing_good(struct smb_signing_context *sign_info,
- unsigned int seq, BOOL good)
+bool signing_good(struct smb_signing_context *sign_info,
+ unsigned int seq, bool good)
{
if (good) {
if (!sign_info->doing_signing) {
DEBUG(5, ("Seen valid packet, so turning signing on\n"));
- sign_info->doing_signing = True;
+ sign_info->doing_signing = true;
}
if (!sign_info->seen_valid) {
DEBUG(5, ("Seen valid packet, so marking signing as 'seen valid'\n"));
- sign_info->seen_valid = True;
+ sign_info->seen_valid = true;
}
} else {
if (!sign_info->seen_valid) {
@@ -90,14 +91,14 @@ BOOL signing_good(struct smb_signing_context *sign_info,
DEBUG(5, ("signing_good: signing negotiated but not required and peer\n"
"isn't sending correct signatures. Turning off.\n"));
smbcli_set_signing_off(sign_info);
- return True;
+ return true;
} else {
/* bad packet after signing started - fail and disconnect. */
DEBUG(0, ("signing_good: BAD SIG: seq %u\n", seq));
- return False;
+ return false;
}
}
- return True;
+ return true;
}
void sign_outgoing_message(struct request_buffer *out, DATA_BLOB *mac_key, unsigned int seq_num)
@@ -132,9 +133,9 @@ void sign_outgoing_message(struct request_buffer *out, DATA_BLOB *mac_key, unsig
Uncomment this to test if the remote server actually verifies signitures...*/
}
-BOOL check_signed_incoming_message(struct request_buffer *in, DATA_BLOB *mac_key, uint_t seq_num)
+bool check_signed_incoming_message(struct request_buffer *in, DATA_BLOB *mac_key, uint_t seq_num)
{
- BOOL good;
+ bool good;
uint8_t calc_md5_mac[16];
uint8_t *server_sent_mac;
uint8_t sequence_buf[8];
@@ -145,12 +146,12 @@ BOOL check_signed_incoming_message(struct request_buffer *in, DATA_BLOB *mac_key
/* room enough for the signature? */
if (in->size < NBT_HDR_SIZE + HDR_SS_FIELD + 8) {
- return False;
+ return false;
}
if (!mac_key->length) {
/* NO key yet */
- return False;
+ return false;
}
/* its quite bogus to be guessing sequence numbers, but very useful
@@ -257,24 +258,24 @@ void smbcli_request_calculate_sign_mac(struct smbcli_request *req)
@note Used as an initialisation only - it will not correctly
shut down a real signing mechanism
*/
-BOOL smbcli_set_signing_off(struct smb_signing_context *sign_info)
+bool smbcli_set_signing_off(struct smb_signing_context *sign_info)
{
DEBUG(5, ("Shutdown SMB signing\n"));
- sign_info->doing_signing = False;
+ sign_info->doing_signing = false;
sign_info->next_seq_num = 0;
data_blob_free(&sign_info->mac_key);
sign_info->signing_state = SMB_SIGNING_ENGINE_OFF;
- return True;
+ return true;
}
/**
SMB signing - TEMP implementation - setup the MAC key.
*/
-BOOL smbcli_temp_set_signing(struct smbcli_transport *transport)
+bool smbcli_temp_set_signing(struct smbcli_transport *transport)
{
if (!smbcli_set_smb_signing_common(transport)) {
- return False;
+ return false;
}
DEBUG(5, ("BSRSPYL SMB signing enabled\n"));
smbcli_set_signing_off(&transport->negotiate.sign_info);
@@ -282,7 +283,7 @@ BOOL smbcli_temp_set_signing(struct smbcli_transport *transport)
transport->negotiate.sign_info.mac_key = data_blob(NULL, 0);
transport->negotiate.sign_info.signing_state = SMB_SIGNING_ENGINE_BSRSPYL;
- return True;
+ return true;
}
/***********************************************************
@@ -290,22 +291,22 @@ BOOL smbcli_temp_set_signing(struct smbcli_transport *transport)
************************************************************/
/**
* Check a packet supplied by the server.
- * @return False if we had an established signing connection
- * which had a back checksum, True otherwise
+ * @return false if we had an established signing connection
+ * which had a back checksum, true otherwise
*/
-BOOL smbcli_request_check_sign_mac(struct smbcli_request *req)
+bool smbcli_request_check_sign_mac(struct smbcli_request *req)
{
- BOOL good;
+ bool good;
switch (req->transport->negotiate.sign_info.signing_state)
{
case SMB_SIGNING_ENGINE_OFF:
- return True;
+ return true;
case SMB_SIGNING_ENGINE_BSRSPYL:
case SMB_SIGNING_ENGINE_ON:
{
if (req->in.size < (HDR_SS_FIELD + 8)) {
- return False;
+ return false;
} else {
good = check_signed_incoming_message(&req->in,
&req->transport->negotiate.sign_info.mac_key,
@@ -316,14 +317,14 @@ BOOL smbcli_request_check_sign_mac(struct smbcli_request *req)
}
}
}
- return False;
+ return false;
}
/***********************************************************
SMB signing - Simple implementation - setup the MAC key.
************************************************************/
-BOOL smbcli_simple_set_signing(TALLOC_CTX *mem_ctx,
+bool smbcli_simple_set_signing(TALLOC_CTX *mem_ctx,
struct smb_signing_context *sign_info,
const DATA_BLOB *user_session_key,
const DATA_BLOB *response)
@@ -353,19 +354,19 @@ BOOL smbcli_simple_set_signing(TALLOC_CTX *mem_ctx,
sign_info->signing_state = SMB_SIGNING_ENGINE_ON;
- return True;
+ return true;
}
/***********************************************************
SMB signing - Simple implementation - setup the MAC key.
************************************************************/
-BOOL smbcli_transport_simple_set_signing(struct smbcli_transport *transport,
+bool smbcli_transport_simple_set_signing(struct smbcli_transport *transport,
const DATA_BLOB user_session_key,
const DATA_BLOB response)
{
if (!smbcli_set_smb_signing_common(transport)) {
- return False;
+ return false;
}
return smbcli_simple_set_signing(transport,
@@ -375,25 +376,25 @@ BOOL smbcli_transport_simple_set_signing(struct smbcli_transport *transport,
}
-BOOL smbcli_init_signing(struct smbcli_transport *transport)
+bool smbcli_init_signing(struct smbcli_transport *transport)
{
transport->negotiate.sign_info.mac_key = data_blob(NULL, 0);
if (!smbcli_set_signing_off(&transport->negotiate.sign_info)) {
- return False;
+ return false;
}
- switch (lp_client_signing()) {
+ switch (lp_client_signing(global_loadparm)) {
case SMB_SIGNING_OFF:
- transport->negotiate.sign_info.allow_smb_signing = False;
+ transport->negotiate.sign_info.allow_smb_signing = false;
break;
case SMB_SIGNING_SUPPORTED:
case SMB_SIGNING_AUTO:
- transport->negotiate.sign_info.allow_smb_signing = True;
+ transport->negotiate.sign_info.allow_smb_signing = true;
break;
case SMB_SIGNING_REQUIRED:
- transport->negotiate.sign_info.allow_smb_signing = True;
- transport->negotiate.sign_info.mandatory_signing = True;
+ transport->negotiate.sign_info.allow_smb_signing = true;
+ transport->negotiate.sign_info.mandatory_signing = true;
break;
}
- return True;
+ return true;
}
diff --git a/source4/libcli/resolve/bcast.c b/source4/libcli/resolve/bcast.c
index f356dafdaa..3193d70789 100644
--- a/source4/libcli/resolve/bcast.c
+++ b/source4/libcli/resolve/bcast.c
@@ -51,7 +51,7 @@ struct composite_context *resolve_name_bcast_send(TALLOC_CTX *mem_ctx,
}
address_list[count] = NULL;
- c = resolve_name_nbtlist_send(mem_ctx, event_ctx, name, address_list, True, False);
+ c = resolve_name_nbtlist_send(mem_ctx, event_ctx, name, address_list, true, false);
talloc_free(address_list);
return c;
diff --git a/source4/libcli/resolve/nbtlist.c b/source4/libcli/resolve/nbtlist.c
index ad331c872d..baf3874aa4 100644
--- a/source4/libcli/resolve/nbtlist.c
+++ b/source4/libcli/resolve/nbtlist.c
@@ -29,6 +29,7 @@
#include "lib/socket/netif.h"
#include "librpc/gen_ndr/ndr_nbt.h"
#include "libcli/nbt/libnbt.h"
+#include "param/param.h"
struct nbtlist_state {
struct nbt_name name;
@@ -98,8 +99,8 @@ struct composite_context *resolve_name_nbtlist_send(TALLOC_CTX *mem_ctx,
struct event_context *event_ctx,
struct nbt_name *name,
const char **address_list,
- BOOL broadcast,
- BOOL wins_lookup)
+ bool broadcast,
+ bool wins_lookup)
{
struct composite_context *c;
struct nbtlist_state *state;
@@ -154,7 +155,7 @@ struct composite_context *resolve_name_nbtlist_send(TALLOC_CTX *mem_ctx,
state->io_queries[i].in.broadcast = broadcast;
state->io_queries[i].in.wins_lookup = wins_lookup;
- state->io_queries[i].in.timeout = lp_parm_int(-1, "nbt", "timeout", 1);
+ state->io_queries[i].in.timeout = lp_parm_int(global_loadparm, NULL, "nbt", "timeout", 1);
state->io_queries[i].in.retries = 2;
state->queries[i] = nbt_name_query_send(state->nbtsock, &state->io_queries[i]);
@@ -192,7 +193,7 @@ NTSTATUS resolve_name_nbtlist_recv(struct composite_context *c,
NTSTATUS resolve_name_nbtlist(struct nbt_name *name,
TALLOC_CTX *mem_ctx,
const char **address_list,
- BOOL broadcast, BOOL wins_lookup,
+ bool broadcast, bool wins_lookup,
const char **reply_addr)
{
struct composite_context *c = resolve_name_nbtlist_send(mem_ctx, NULL, name, address_list,
diff --git a/source4/libcli/resolve/resolve.c b/source4/libcli/resolve/resolve.c
index 4df4de020c..02e1fbdc04 100644
--- a/source4/libcli/resolve/resolve.c
+++ b/source4/libcli/resolve/resolve.c
@@ -24,6 +24,7 @@
#include "libcli/composite/composite.h"
#include "libcli/resolve/resolve.h"
#include "librpc/gen_ndr/ndr_nbt.h"
+#include "param/param.h"
struct resolve_state {
struct nbt_name name;
@@ -67,7 +68,7 @@ static const struct resolve_method *find_method(const char *name)
*/
static void resolve_handler(struct composite_context *creq)
{
- struct composite_context *c = creq->async.private_data;
+ struct composite_context *c = (struct composite_context *)creq->async.private_data;
struct resolve_state *state = talloc_get_type(c->private_data, struct resolve_state);
const struct resolve_method *method = find_method(state->methods[0]);
@@ -188,7 +189,8 @@ NTSTATUS resolve_name_recv(struct composite_context *c,
NTSTATUS resolve_name(struct nbt_name *name, TALLOC_CTX *mem_ctx, const char **reply_addr,
struct event_context *ev)
{
- struct composite_context *c = resolve_name_send(name, ev, lp_name_resolve_order());
+ struct composite_context *c = resolve_name_send(name, ev,
+ lp_name_resolve_order(global_loadparm));
return resolve_name_recv(c, mem_ctx, reply_addr);
}
diff --git a/source4/libcli/resolve/wins.c b/source4/libcli/resolve/wins.c
index 7af12075a1..2cbcd5f483 100644
--- a/source4/libcli/resolve/wins.c
+++ b/source4/libcli/resolve/wins.c
@@ -22,17 +22,19 @@
#include "includes.h"
#include "libcli/nbt/libnbt.h"
#include "libcli/resolve/resolve.h"
+#include "param/param.h"
/*
wins name resolution method - async send
*/
-struct composite_context *resolve_name_wins_send(TALLOC_CTX *mem_ctx,
- struct event_context *event_ctx,
- struct nbt_name *name)
+struct composite_context *resolve_name_wins_send(
+ TALLOC_CTX *mem_ctx,
+ struct event_context *event_ctx,
+ struct nbt_name *name)
{
- const char **address_list = lp_wins_server_list();
+ const char **address_list = lp_wins_server_list(global_loadparm);
if (address_list == NULL) return NULL;
- return resolve_name_nbtlist_send(mem_ctx, event_ctx, name, address_list, False, True);
+ return resolve_name_nbtlist_send(mem_ctx, event_ctx, name, address_list, false, true);
}
/*
diff --git a/source4/libcli/security/dom_sid.c b/source4/libcli/security/dom_sid.c
index 64e418677a..f5457e7e0e 100644
--- a/source4/libcli/security/dom_sid.c
+++ b/source4/libcli/security/dom_sid.c
@@ -22,6 +22,7 @@
#include "includes.h"
#include "librpc/gen_ndr/security.h"
+#include "libcli/security/security.h"
/*****************************************************************
Compare the auth portion of two sids.
@@ -78,7 +79,7 @@ static int dom_sid_compare(const struct dom_sid *sid1, const struct dom_sid *sid
Compare two sids.
*****************************************************************/
-BOOL dom_sid_equal(const struct dom_sid *sid1, const struct dom_sid *sid2)
+bool dom_sid_equal(const struct dom_sid *sid1, const struct dom_sid *sid2)
{
return dom_sid_compare(sid1, sid2) == 0;
}
@@ -240,24 +241,24 @@ NTSTATUS dom_sid_split_rid(TALLOC_CTX *mem_ctx, const struct dom_sid *sid,
}
/*
- return True if the 2nd sid is in the domain given by the first sid
+ return true if the 2nd sid is in the domain given by the first sid
*/
-BOOL dom_sid_in_domain(const struct dom_sid *domain_sid,
+bool dom_sid_in_domain(const struct dom_sid *domain_sid,
const struct dom_sid *sid)
{
int i;
if (!domain_sid || !sid) {
- return False;
+ return false;
}
if (domain_sid->num_auths > sid->num_auths) {
- return False;
+ return false;
}
for (i = domain_sid->num_auths-1; i >= 0; --i) {
if (domain_sid->sub_auths[i] != sid->sub_auths[i]) {
- return False;
+ return false;
}
}
@@ -278,7 +279,7 @@ char *dom_sid_string(TALLOC_CTX *mem_ctx, const struct dom_sid *sid)
}
maxlen = sid->num_auths * 11 + 25;
- ret = talloc_size(mem_ctx, maxlen);
+ ret = talloc_array(mem_ctx, char, maxlen);
if (!ret) return talloc_strdup(mem_ctx, "(SID ERR)");
ia = (sid->id_auth[5]) +
diff --git a/source4/libcli/security/privilege.c b/source4/libcli/security/privilege.c
index 635f470bf6..2cbef13538 100644
--- a/source4/libcli/security/privilege.c
+++ b/source4/libcli/security/privilege.c
@@ -21,6 +21,7 @@
#include "includes.h"
#include "librpc/gen_ndr/security.h"
+#include "libcli/security/security.h"
static const struct {
@@ -191,21 +192,21 @@ static uint64_t sec_privilege_mask(enum sec_privilege privilege)
/*
- return True if a security_token has a particular privilege bit set
+ return true if a security_token has a particular privilege bit set
*/
-BOOL security_token_has_privilege(const struct security_token *token, enum sec_privilege privilege)
+bool security_token_has_privilege(const struct security_token *token, enum sec_privilege privilege)
{
uint64_t mask;
if (privilege < 1 || privilege > 64) {
- return False;
+ return false;
}
mask = sec_privilege_mask(privilege);
if (token->privilege_mask & mask) {
- return True;
+ return true;
}
- return False;
+ return false;
}
/*
diff --git a/source4/libcli/security/sddl.c b/source4/libcli/security/sddl.c
index 4342a7b87a..09522f182a 100644
--- a/source4/libcli/security/sddl.c
+++ b/source4/libcli/security/sddl.c
@@ -32,7 +32,7 @@ struct flag_map {
/*
map a series of letter codes into a uint32_t
*/
-static BOOL sddl_map_flags(const struct flag_map *map, const char *str,
+static bool sddl_map_flags(const struct flag_map *map, const char *str,
uint32_t *flags, size_t *len)
{
const char *str0 = str;
@@ -51,10 +51,10 @@ static BOOL sddl_map_flags(const struct flag_map *map, const char *str,
}
if (map[i].name == NULL) {
DEBUG(1, ("Unknown flag - %s in %s\n", str, str0));
- return False;
+ return false;
}
}
- return True;
+ return true;
}
/*
@@ -176,10 +176,10 @@ static const struct flag_map ace_access_mask[] = {
/*
decode an ACE
- return True on success, False on failure
+ return true on success, false on failure
note that this routine modifies the string
*/
-static BOOL sddl_decode_ace(TALLOC_CTX *mem_ctx, struct security_ace *ace, char *str,
+static bool sddl_decode_ace(TALLOC_CTX *mem_ctx, struct security_ace *ace, char *str,
const struct dom_sid *domain_sid)
{
const char *tok[6];
@@ -194,7 +194,7 @@ static BOOL sddl_decode_ace(TALLOC_CTX *mem_ctx, struct security_ace *ace, char
tok[0] = str;
for (i=0;i<5;i++) {
char *ptr = strchr(str, ';');
- if (ptr == NULL) return False;
+ if (ptr == NULL) return false;
*ptr = 0;
str = ptr+1;
tok[i+1] = str;
@@ -202,13 +202,13 @@ static BOOL sddl_decode_ace(TALLOC_CTX *mem_ctx, struct security_ace *ace, char
/* parse ace type */
if (!sddl_map_flags(ace_types, tok[0], &v, NULL)) {
- return False;
+ return false;
}
ace->type = v;
/* ace flags */
if (!sddl_map_flags(ace_flags, tok[1], &v, NULL)) {
- return False;
+ return false;
}
ace->flags = v;
@@ -217,7 +217,7 @@ static BOOL sddl_decode_ace(TALLOC_CTX *mem_ctx, struct security_ace *ace, char
ace->access_mask = strtol(tok[2], NULL, 16);
} else {
if (!sddl_map_flags(ace_access_mask, tok[2], &v, NULL)) {
- return False;
+ return false;
}
ace->access_mask = v;
}
@@ -227,7 +227,7 @@ static BOOL sddl_decode_ace(TALLOC_CTX *mem_ctx, struct security_ace *ace, char
NTSTATUS status = GUID_from_string(tok[3],
&ace->object.object.type.type);
if (!NT_STATUS_IS_OK(status)) {
- return False;
+ return false;
}
ace->object.object.flags |= SEC_ACE_OBJECT_TYPE_PRESENT;
}
@@ -237,7 +237,7 @@ static BOOL sddl_decode_ace(TALLOC_CTX *mem_ctx, struct security_ace *ace, char
NTSTATUS status = GUID_from_string(tok[4],
&ace->object.object.inherited_type.inherited_type);
if (!NT_STATUS_IS_OK(status)) {
- return False;
+ return false;
}
ace->object.object.flags |= SEC_ACE_INHERITED_OBJECT_TYPE_PRESENT;
}
@@ -246,13 +246,13 @@ static BOOL sddl_decode_ace(TALLOC_CTX *mem_ctx, struct security_ace *ace, char
s = tok[5];
sid = sddl_decode_sid(mem_ctx, &s, domain_sid);
if (sid == NULL) {
- return False;
+ return false;
}
ace->trustee = *sid;
talloc_steal(mem_ctx, sid->sub_auths);
talloc_free(sid);
- return True;
+ return true;
}
static const struct flag_map acl_flags[] = {
@@ -388,7 +388,7 @@ failed:
turn a set of flags into a string
*/
static char *sddl_flags_to_string(TALLOC_CTX *mem_ctx, const struct flag_map *map,
- uint32_t flags, BOOL check_all)
+ uint32_t flags, bool check_all)
{
int i;
char *s;
@@ -405,7 +405,7 @@ static char *sddl_flags_to_string(TALLOC_CTX *mem_ctx, const struct flag_map *ma
/* now by bits */
for (i=0;map[i].name;i++) {
if ((flags & map[i].flag) != 0) {
- s = talloc_asprintf_append(s, "%s", map[i].name);
+ s = talloc_asprintf_append_buffer(s, "%s", map[i].name);
if (s == NULL) goto failed;
flags &= ~map[i].flag;
}
@@ -477,13 +477,13 @@ static char *sddl_encode_ace(TALLOC_CTX *mem_ctx, const struct security_ace *ace
return NULL;
}
- s_type = sddl_flags_to_string(tmp_ctx, ace_types, ace->type, True);
+ s_type = sddl_flags_to_string(tmp_ctx, ace_types, ace->type, true);
if (s_type == NULL) goto failed;
- s_flags = sddl_flags_to_string(tmp_ctx, ace_flags, ace->flags, True);
+ s_flags = sddl_flags_to_string(tmp_ctx, ace_flags, ace->flags, true);
if (s_flags == NULL) goto failed;
- s_mask = sddl_flags_to_string(tmp_ctx, ace_access_mask, ace->access_mask, True);
+ s_mask = sddl_flags_to_string(tmp_ctx, ace_access_mask, ace->access_mask, true);
if (s_mask == NULL) {
s_mask = talloc_asprintf(tmp_ctx, "0x%08x", ace->access_mask);
if (s_mask == NULL) goto failed;
@@ -525,14 +525,14 @@ static char *sddl_encode_acl(TALLOC_CTX *mem_ctx, const struct security_acl *acl
int i;
/* add any ACL flags */
- sddl = sddl_flags_to_string(mem_ctx, acl_flags, flags, False);
+ sddl = sddl_flags_to_string(mem_ctx, acl_flags, flags, false);
if (sddl == NULL) goto failed;
/* now the ACEs, encoded in braces */
for (i=0;i<acl->num_aces;i++) {
char *ace = sddl_encode_ace(sddl, &acl->aces[i], domain_sid);
if (ace == NULL) goto failed;
- sddl = talloc_asprintf_append(sddl, "(%s)", ace);
+ sddl = talloc_asprintf_append_buffer(sddl, "(%s)", ace);
if (sddl == NULL) goto failed;
talloc_free(ace);
}
@@ -563,28 +563,28 @@ char *sddl_encode(TALLOC_CTX *mem_ctx, const struct security_descriptor *sd,
if (sd->owner_sid != NULL) {
char *sid = sddl_encode_sid(tmp_ctx, sd->owner_sid, domain_sid);
if (sid == NULL) goto failed;
- sddl = talloc_asprintf_append(sddl, "O:%s", sid);
+ sddl = talloc_asprintf_append_buffer(sddl, "O:%s", sid);
if (sddl == NULL) goto failed;
}
if (sd->group_sid != NULL) {
char *sid = sddl_encode_sid(tmp_ctx, sd->group_sid, domain_sid);
if (sid == NULL) goto failed;
- sddl = talloc_asprintf_append(sddl, "G:%s", sid);
+ sddl = talloc_asprintf_append_buffer(sddl, "G:%s", sid);
if (sddl == NULL) goto failed;
}
if ((sd->type & SEC_DESC_DACL_PRESENT) && sd->dacl != NULL) {
char *acl = sddl_encode_acl(tmp_ctx, sd->dacl, sd->type, domain_sid);
if (acl == NULL) goto failed;
- sddl = talloc_asprintf_append(sddl, "D:%s", acl);
+ sddl = talloc_asprintf_append_buffer(sddl, "D:%s", acl);
if (sddl == NULL) goto failed;
}
if ((sd->type & SEC_DESC_SACL_PRESENT) && sd->sacl != NULL) {
char *acl = sddl_encode_acl(tmp_ctx, sd->sacl, sd->type>>1, domain_sid);
if (acl == NULL) goto failed;
- sddl = talloc_asprintf_append(sddl, "S:%s", acl);
+ sddl = talloc_asprintf_append_buffer(sddl, "S:%s", acl);
if (sddl == NULL) goto failed;
}
diff --git a/source4/libcli/security/security_descriptor.c b/source4/libcli/security/security_descriptor.c
index 06c3c2eca7..7ed619d0c4 100644
--- a/source4/libcli/security/security_descriptor.c
+++ b/source4/libcli/security/security_descriptor.c
@@ -60,7 +60,7 @@ static struct security_acl *security_acl_dup(TALLOC_CTX *mem_ctx,
return NULL;
}
- nacl->aces = talloc_memdup (nacl, oacl->aces, sizeof(struct security_ace) * oacl->num_aces);
+ nacl->aces = (struct security_ace *)talloc_memdup (nacl, oacl->aces, sizeof(struct security_ace) * oacl->num_aces);
if ((nacl->aces == NULL) && (oacl->num_aces > 0)) {
goto failed;
}
@@ -69,7 +69,7 @@ static struct security_acl *security_acl_dup(TALLOC_CTX *mem_ctx,
for (i = 0; i < oacl->num_aces; i++) {
nacl->aces[i].trustee.sub_auths =
- talloc_memdup(nacl->aces, nacl->aces[i].trustee.sub_auths,
+ (uint32_t *)talloc_memdup(nacl->aces, nacl->aces[i].trustee.sub_auths,
sizeof(uint32_t) * nacl->aces[i].trustee.num_auths);
if ((nacl->aces[i].trustee.sub_auths == NULL) && (nacl->aces[i].trustee.num_auths > 0)) {
@@ -163,7 +163,7 @@ NTSTATUS security_descriptor_dacl_add(struct security_descriptor *sd,
sd->dacl->aces[sd->dacl->num_aces] = *ace;
sd->dacl->aces[sd->dacl->num_aces].trustee.sub_auths =
- talloc_memdup(sd->dacl->aces,
+ (uint32_t *)talloc_memdup(sd->dacl->aces,
sd->dacl->aces[sd->dacl->num_aces].trustee.sub_auths,
sizeof(uint32_t) *
sd->dacl->aces[sd->dacl->num_aces].trustee.num_auths);
@@ -242,77 +242,77 @@ NTSTATUS security_descriptor_dacl_del(struct security_descriptor *sd,
/*
compare two security ace structures
*/
-BOOL security_ace_equal(const struct security_ace *ace1,
+bool security_ace_equal(const struct security_ace *ace1,
const struct security_ace *ace2)
{
- if (ace1 == ace2) return True;
- if (!ace1 || !ace2) return False;
- if (ace1->type != ace2->type) return False;
- if (ace1->flags != ace2->flags) return False;
- if (ace1->access_mask != ace2->access_mask) return False;
- if (!dom_sid_equal(&ace1->trustee, &ace2->trustee)) return False;
-
- return True;
+ if (ace1 == ace2) return true;
+ if (!ace1 || !ace2) return false;
+ if (ace1->type != ace2->type) return false;
+ if (ace1->flags != ace2->flags) return false;
+ if (ace1->access_mask != ace2->access_mask) return false;
+ if (!dom_sid_equal(&ace1->trustee, &ace2->trustee)) return false;
+
+ return true;
}
/*
compare two security acl structures
*/
-BOOL security_acl_equal(const struct security_acl *acl1,
+bool security_acl_equal(const struct security_acl *acl1,
const struct security_acl *acl2)
{
int i;
- if (acl1 == acl2) return True;
- if (!acl1 || !acl2) return False;
- if (acl1->revision != acl2->revision) return False;
- if (acl1->num_aces != acl2->num_aces) return False;
+ if (acl1 == acl2) return true;
+ if (!acl1 || !acl2) return false;
+ if (acl1->revision != acl2->revision) return false;
+ if (acl1->num_aces != acl2->num_aces) return false;
for (i=0;i<acl1->num_aces;i++) {
- if (!security_ace_equal(&acl1->aces[i], &acl2->aces[i])) return False;
+ if (!security_ace_equal(&acl1->aces[i], &acl2->aces[i])) return false;
}
- return True;
+ return true;
}
/*
compare two security descriptors.
*/
-BOOL security_descriptor_equal(const struct security_descriptor *sd1,
+bool security_descriptor_equal(const struct security_descriptor *sd1,
const struct security_descriptor *sd2)
{
- if (sd1 == sd2) return True;
- if (!sd1 || !sd2) return False;
- if (sd1->revision != sd2->revision) return False;
- if (sd1->type != sd2->type) return False;
+ if (sd1 == sd2) return true;
+ if (!sd1 || !sd2) return false;
+ if (sd1->revision != sd2->revision) return false;
+ if (sd1->type != sd2->type) return false;
- if (!dom_sid_equal(sd1->owner_sid, sd2->owner_sid)) return False;
- if (!dom_sid_equal(sd1->group_sid, sd2->group_sid)) return False;
- if (!security_acl_equal(sd1->sacl, sd2->sacl)) return False;
- if (!security_acl_equal(sd1->dacl, sd2->dacl)) return False;
+ if (!dom_sid_equal(sd1->owner_sid, sd2->owner_sid)) return false;
+ if (!dom_sid_equal(sd1->group_sid, sd2->group_sid)) return false;
+ if (!security_acl_equal(sd1->sacl, sd2->sacl)) return false;
+ if (!security_acl_equal(sd1->dacl, sd2->dacl)) return false;
- return True;
+ return true;
}
/*
compare two security descriptors, but allow certain (missing) parts
to be masked out of the comparison
*/
-BOOL security_descriptor_mask_equal(const struct security_descriptor *sd1,
+bool security_descriptor_mask_equal(const struct security_descriptor *sd1,
const struct security_descriptor *sd2,
uint32_t mask)
{
- if (sd1 == sd2) return True;
- if (!sd1 || !sd2) return False;
- if (sd1->revision != sd2->revision) return False;
- if ((sd1->type & mask) != (sd2->type & mask)) return False;
+ if (sd1 == sd2) return true;
+ if (!sd1 || !sd2) return false;
+ if (sd1->revision != sd2->revision) return false;
+ if ((sd1->type & mask) != (sd2->type & mask)) return false;
- if (!dom_sid_equal(sd1->owner_sid, sd2->owner_sid)) return False;
- if (!dom_sid_equal(sd1->group_sid, sd2->group_sid)) return False;
- if ((mask & SEC_DESC_DACL_PRESENT) && !security_acl_equal(sd1->dacl, sd2->dacl)) return False;
- if ((mask & SEC_DESC_SACL_PRESENT) && !security_acl_equal(sd1->sacl, sd2->sacl)) return False;
+ if (!dom_sid_equal(sd1->owner_sid, sd2->owner_sid)) return false;
+ if (!dom_sid_equal(sd1->group_sid, sd2->group_sid)) return false;
+ if ((mask & SEC_DESC_DACL_PRESENT) && !security_acl_equal(sd1->dacl, sd2->dacl)) return false;
+ if ((mask & SEC_DESC_SACL_PRESENT) && !security_acl_equal(sd1->sacl, sd2->sacl)) return false;
- return True;
+ return true;
}
diff --git a/source4/libcli/security/security_token.c b/source4/libcli/security/security_token.c
index 684c3de7e6..e126340c46 100644
--- a/source4/libcli/security/security_token.c
+++ b/source4/libcli/security/security_token.c
@@ -79,19 +79,19 @@ void security_token_debug(int dbg_lev, const struct security_token *token)
/* These really should be cheaper... */
-BOOL security_token_is_sid(const struct security_token *token, const struct dom_sid *sid)
+bool security_token_is_sid(const struct security_token *token, const struct dom_sid *sid)
{
if (dom_sid_equal(token->user_sid, sid)) {
- return True;
+ return true;
}
- return False;
+ return false;
}
-BOOL security_token_is_sid_string(const struct security_token *token, const char *sid_string)
+bool security_token_is_sid_string(const struct security_token *token, const char *sid_string)
{
- BOOL ret;
+ bool ret;
struct dom_sid *sid = dom_sid_parse_talloc(NULL, sid_string);
- if (!sid) return False;
+ if (!sid) return false;
ret = security_token_is_sid(token, sid);
@@ -99,32 +99,32 @@ BOOL security_token_is_sid_string(const struct security_token *token, const char
return ret;
}
-BOOL security_token_is_system(const struct security_token *token)
+bool security_token_is_system(const struct security_token *token)
{
return security_token_is_sid_string(token, SID_NT_SYSTEM);
}
-BOOL security_token_is_anonymous(const struct security_token *token)
+bool security_token_is_anonymous(const struct security_token *token)
{
return security_token_is_sid_string(token, SID_NT_ANONYMOUS);
}
-BOOL security_token_has_sid(const struct security_token *token, const struct dom_sid *sid)
+bool security_token_has_sid(const struct security_token *token, const struct dom_sid *sid)
{
int i;
for (i = 0; i < token->num_sids; i++) {
if (dom_sid_equal(token->sids[i], sid)) {
- return True;
+ return true;
}
}
- return False;
+ return false;
}
-BOOL security_token_has_sid_string(const struct security_token *token, const char *sid_string)
+bool security_token_has_sid_string(const struct security_token *token, const char *sid_string)
{
- BOOL ret;
+ bool ret;
struct dom_sid *sid = dom_sid_parse_talloc(NULL, sid_string);
- if (!sid) return False;
+ if (!sid) return false;
ret = security_token_has_sid(token, sid);
@@ -132,12 +132,12 @@ BOOL security_token_has_sid_string(const struct security_token *token, const cha
return ret;
}
-BOOL security_token_has_builtin_administrators(const struct security_token *token)
+bool security_token_has_builtin_administrators(const struct security_token *token)
{
return security_token_has_sid_string(token, SID_BUILTIN_ADMINISTRATORS);
}
-BOOL security_token_has_nt_authenticated_users(const struct security_token *token)
+bool security_token_has_nt_authenticated_users(const struct security_token *token)
{
return security_token_has_sid_string(token, SID_NT_AUTHENTICATED_USERS);
}
diff --git a/source4/libcli/smb2/cancel.c b/source4/libcli/smb2/cancel.c
index f0a0b01817..096919f177 100644
--- a/source4/libcli/smb2/cancel.c
+++ b/source4/libcli/smb2/cancel.c
@@ -46,7 +46,7 @@ NTSTATUS smb2_cancel(struct smb2_request *r)
/* we don't want a seqmun for a SMB2 Cancel */
old_seqnum = r->transport->seqnum;
- c = smb2_request_init(r->transport, SMB2_OP_CANCEL, 0x04, False, 0);
+ c = smb2_request_init(r->transport, SMB2_OP_CANCEL, 0x04, false, 0);
r->transport->seqnum = old_seqnum;
NT_STATUS_HAVE_NO_MEMORY(c);
c->seqnum = 0;
diff --git a/source4/libcli/smb2/close.c b/source4/libcli/smb2/close.c
index e83f81b630..04c0c85499 100644
--- a/source4/libcli/smb2/close.c
+++ b/source4/libcli/smb2/close.c
@@ -31,7 +31,7 @@ struct smb2_request *smb2_close_send(struct smb2_tree *tree, struct smb2_close *
{
struct smb2_request *req;
- req = smb2_request_init_tree(tree, SMB2_OP_CLOSE, 0x18, False, 0);
+ req = smb2_request_init_tree(tree, SMB2_OP_CLOSE, 0x18, false, 0);
if (req == NULL) return NULL;
SSVAL(req->out.body, 0x02, io->in.flags);
@@ -54,7 +54,7 @@ NTSTATUS smb2_close_recv(struct smb2_request *req, struct smb2_close *io)
return smb2_request_destroy(req);
}
- SMB2_CHECK_PACKET_RECV(req, 0x3C, False);
+ SMB2_CHECK_PACKET_RECV(req, 0x3C, false);
io->out.flags = SVAL(req->in.body, 0x02);
io->out._pad = IVAL(req->in.body, 0x04);
diff --git a/source4/libcli/smb2/connect.c b/source4/libcli/smb2/connect.c
index a365f25d49..6f05d56cd4 100644
--- a/source4/libcli/smb2/connect.c
+++ b/source4/libcli/smb2/connect.c
@@ -25,6 +25,7 @@
#include "libcli/smb2/smb2_calls.h"
#include "libcli/composite/composite.h"
#include "libcli/resolve/resolve.h"
+#include "param/param.h"
struct smb2_connect_state {
struct cli_credentials *credentials;
@@ -68,7 +69,7 @@ static void continue_session(struct composite_context *creq)
c->status = smb2_session_setup_spnego_recv(creq);
if (!composite_is_ok(c)) return;
- state->tree = smb2_tree_init(state->session, state, True);
+ state->tree = smb2_tree_init(state->session, state, true);
if (composite_nomem(state->tree, c)) return;
state->tcon.in.unknown1 = 0x09;
@@ -98,7 +99,7 @@ static void continue_negprot(struct smb2_request *req)
c->status = smb2_negprot_recv(req, c, &state->negprot);
if (!composite_is_ok(c)) return;
- state->session = smb2_session_init(transport, state, True);
+ state->session = smb2_session_init(transport, state, true);
if (composite_nomem(state->session, c)) return;
creq = smb2_session_setup_spnego_send(state->session, state->credentials);
@@ -186,7 +187,8 @@ struct composite_context *smb2_connect_send(TALLOC_CTX *mem_ctx,
ZERO_STRUCT(name);
name.name = host;
- creq = resolve_name_send(&name, c->event_ctx, lp_name_resolve_order());
+ creq = resolve_name_send(&name, c->event_ctx,
+ lp_name_resolve_order(global_loadparm));
composite_continue(c, creq, continue_resolve, c);
return c;
}
diff --git a/source4/libcli/smb2/create.c b/source4/libcli/smb2/create.c
index c8ac271f44..ba11c22e87 100644
--- a/source4/libcli/smb2/create.c
+++ b/source4/libcli/smb2/create.c
@@ -32,7 +32,7 @@
*/
NTSTATUS smb2_create_blob_add(TALLOC_CTX *mem_ctx, DATA_BLOB *blob,
uint32_t tag,
- DATA_BLOB add, BOOL last)
+ DATA_BLOB add, bool last)
{
uint32_t ofs = blob->length;
uint8_t pad = smb2_padding_size(add.length, 8);
@@ -65,7 +65,7 @@ struct smb2_request *smb2_create_send(struct smb2_tree *tree, struct smb2_create
NTSTATUS status;
DATA_BLOB blob = data_blob(NULL, 0);
- req = smb2_request_init_tree(tree, SMB2_OP_CREATE, 0x38, True, 0);
+ req = smb2_request_init_tree(tree, SMB2_OP_CREATE, 0x38, true, 0);
if (req == NULL) return NULL;
SSVAL(req->out.body, 0x02, io->in.oplock_flags);
@@ -90,7 +90,7 @@ struct smb2_request *smb2_create_send(struct smb2_tree *tree, struct smb2_create
DATA_BLOB b = data_blob_talloc(req, NULL,
ea_list_size_chained(io->in.eas.num_eas, io->in.eas.eas));
ea_put_list_chained(b.data, io->in.eas.num_eas, io->in.eas.eas);
- status = smb2_create_blob_add(req, &blob, CREATE_TAG_EXTA, b, False);
+ status = smb2_create_blob_add(req, &blob, CREATE_TAG_EXTA, b, false);
if (!NT_STATUS_IS_OK(status)) {
talloc_free(req);
return NULL;
@@ -100,7 +100,7 @@ struct smb2_request *smb2_create_send(struct smb2_tree *tree, struct smb2_create
/* an empty MxAc tag seems to be used to ask the server to
return the maximum access mask allowed on the file */
- status = smb2_create_blob_add(req, &blob, CREATE_TAG_MXAC, data_blob(NULL, 0), True);
+ status = smb2_create_blob_add(req, &blob, CREATE_TAG_MXAC, data_blob(NULL, 0), true);
if (!NT_STATUS_IS_OK(status)) {
talloc_free(req);
@@ -130,7 +130,7 @@ NTSTATUS smb2_create_recv(struct smb2_request *req, TALLOC_CTX *mem_ctx, struct
return smb2_request_destroy(req);
}
- SMB2_CHECK_PACKET_RECV(req, 0x58, True);
+ SMB2_CHECK_PACKET_RECV(req, 0x58, true);
io->out.oplock_flags = SVAL(req->in.body, 0x02);
io->out.create_action = IVAL(req->in.body, 0x04);
diff --git a/source4/libcli/smb2/find.c b/source4/libcli/smb2/find.c
index e8643f1868..6d0a9c8072 100644
--- a/source4/libcli/smb2/find.c
+++ b/source4/libcli/smb2/find.c
@@ -32,7 +32,7 @@ struct smb2_request *smb2_find_send(struct smb2_tree *tree, struct smb2_find *io
struct smb2_request *req;
NTSTATUS status;
- req = smb2_request_init_tree(tree, SMB2_OP_FIND, 0x20, True, 0);
+ req = smb2_request_init_tree(tree, SMB2_OP_FIND, 0x20, true, 0);
if (req == NULL) return NULL;
SCVAL(req->out.body, 0x02, io->in.level);
@@ -67,7 +67,7 @@ NTSTATUS smb2_find_recv(struct smb2_request *req, TALLOC_CTX *mem_ctx,
return smb2_request_destroy(req);
}
- SMB2_CHECK_PACKET_RECV(req, 0x08, True);
+ SMB2_CHECK_PACKET_RECV(req, 0x08, true);
status = smb2_pull_o16s32_blob(&req->in, mem_ctx,
req->in.body+0x02, &io->out.blob);
diff --git a/source4/libcli/smb2/flush.c b/source4/libcli/smb2/flush.c
index 2f1b7bd749..116068ed6e 100644
--- a/source4/libcli/smb2/flush.c
+++ b/source4/libcli/smb2/flush.c
@@ -30,7 +30,7 @@ struct smb2_request *smb2_flush_send(struct smb2_tree *tree, struct smb2_flush *
{
struct smb2_request *req;
- req = smb2_request_init_tree(tree, SMB2_OP_FLUSH, 0x18, False, 0);
+ req = smb2_request_init_tree(tree, SMB2_OP_FLUSH, 0x18, false, 0);
if (req == NULL) return NULL;
SSVAL(req->out.body, 0x02, 0); /* pad? */
@@ -53,7 +53,7 @@ NTSTATUS smb2_flush_recv(struct smb2_request *req, struct smb2_flush *io)
return smb2_request_destroy(req);
}
- SMB2_CHECK_PACKET_RECV(req, 0x04, False);
+ SMB2_CHECK_PACKET_RECV(req, 0x04, false);
return smb2_request_destroy(req);
}
diff --git a/source4/libcli/smb2/getinfo.c b/source4/libcli/smb2/getinfo.c
index a9a681ea53..0665dd441c 100644
--- a/source4/libcli/smb2/getinfo.c
+++ b/source4/libcli/smb2/getinfo.c
@@ -31,7 +31,7 @@ struct smb2_request *smb2_getinfo_send(struct smb2_tree *tree, struct smb2_getin
{
struct smb2_request *req;
- req = smb2_request_init_tree(tree, SMB2_OP_GETINFO, 0x28, False, 0);
+ req = smb2_request_init_tree(tree, SMB2_OP_GETINFO, 0x28, false, 0);
if (req == NULL) return NULL;
/* this seems to be a bug, they use 0x29 but only send 0x28 bytes */
@@ -64,7 +64,7 @@ NTSTATUS smb2_getinfo_recv(struct smb2_request *req, TALLOC_CTX *mem_ctx,
return smb2_request_destroy(req);
}
- SMB2_CHECK_PACKET_RECV(req, 0x08, True);
+ SMB2_CHECK_PACKET_RECV(req, 0x08, true);
status = smb2_pull_o16s16_blob(&req->in, mem_ctx, req->in.body+0x02, &io->out.blob);
if (!NT_STATUS_IS_OK(status)) {
diff --git a/source4/libcli/smb2/ioctl.c b/source4/libcli/smb2/ioctl.c
index c13ec7943c..d81bca517f 100644
--- a/source4/libcli/smb2/ioctl.c
+++ b/source4/libcli/smb2/ioctl.c
@@ -31,7 +31,7 @@ struct smb2_request *smb2_ioctl_send(struct smb2_tree *tree, struct smb2_ioctl *
NTSTATUS status;
struct smb2_request *req;
- req = smb2_request_init_tree(tree, SMB2_OP_IOCTL, 0x38, True,
+ req = smb2_request_init_tree(tree, SMB2_OP_IOCTL, 0x38, true,
io->in.in.length+io->in.out.length);
if (req == NULL) return NULL;
@@ -75,7 +75,7 @@ NTSTATUS smb2_ioctl_recv(struct smb2_request *req,
return smb2_request_destroy(req);
}
- SMB2_CHECK_PACKET_RECV(req, 0x30, True);
+ SMB2_CHECK_PACKET_RECV(req, 0x30, true);
io->out._pad = SVAL(req->in.body, 0x02);
io->out.function = IVAL(req->in.body, 0x04);
diff --git a/source4/libcli/smb2/keepalive.c b/source4/libcli/smb2/keepalive.c
index e2b7c83b8a..402b063e81 100644
--- a/source4/libcli/smb2/keepalive.c
+++ b/source4/libcli/smb2/keepalive.c
@@ -30,7 +30,7 @@ struct smb2_request *smb2_keepalive_send(struct smb2_transport *transport)
{
struct smb2_request *req;
- req = smb2_request_init(transport, SMB2_OP_KEEPALIVE, 0x04, False, 0);
+ req = smb2_request_init(transport, SMB2_OP_KEEPALIVE, 0x04, false, 0);
if (req == NULL) return NULL;
SSVAL(req->out.body, 0x02, 0);
@@ -51,7 +51,7 @@ NTSTATUS smb2_keepalive_recv(struct smb2_request *req)
return smb2_request_destroy(req);
}
- SMB2_CHECK_PACKET_RECV(req, 0x04, False);
+ SMB2_CHECK_PACKET_RECV(req, 0x04, false);
return smb2_request_destroy(req);
}
diff --git a/source4/libcli/smb2/lock.c b/source4/libcli/smb2/lock.c
index 470648a34c..d71a337d56 100644
--- a/source4/libcli/smb2/lock.c
+++ b/source4/libcli/smb2/lock.c
@@ -30,7 +30,7 @@ struct smb2_request *smb2_lock_send(struct smb2_tree *tree, struct smb2_lock *io
{
struct smb2_request *req;
- req = smb2_request_init_tree(tree, SMB2_OP_LOCK, 0x30, False, 0);
+ req = smb2_request_init_tree(tree, SMB2_OP_LOCK, 0x30, false, 0);
if (req == NULL) return NULL;
SSVAL(req->out.body, 0x02, io->in.unknown1);
@@ -57,7 +57,7 @@ NTSTATUS smb2_lock_recv(struct smb2_request *req, struct smb2_lock *io)
return smb2_request_destroy(req);
}
- SMB2_CHECK_PACKET_RECV(req, 0x04, False);
+ SMB2_CHECK_PACKET_RECV(req, 0x04, false);
io->out.unknown1 = SVAL(req->in.body, 0x02);
diff --git a/source4/libcli/smb2/logoff.c b/source4/libcli/smb2/logoff.c
index 00d5e19e82..321a4db1a6 100644
--- a/source4/libcli/smb2/logoff.c
+++ b/source4/libcli/smb2/logoff.c
@@ -30,7 +30,7 @@ struct smb2_request *smb2_logoff_send(struct smb2_session *session)
{
struct smb2_request *req;
- req = smb2_request_init(session->transport, SMB2_OP_LOGOFF, 0x04, False, 0);
+ req = smb2_request_init(session->transport, SMB2_OP_LOGOFF, 0x04, false, 0);
if (req == NULL) return NULL;
SBVAL(req->out.hdr, SMB2_HDR_UID, session->uid);
@@ -53,7 +53,7 @@ NTSTATUS smb2_logoff_recv(struct smb2_request *req)
return smb2_request_destroy(req);
}
- SMB2_CHECK_PACKET_RECV(req, 0x04, False);
+ SMB2_CHECK_PACKET_RECV(req, 0x04, false);
return smb2_request_destroy(req);
}
diff --git a/source4/libcli/smb2/negprot.c b/source4/libcli/smb2/negprot.c
index 07d06ca2ff..38fe0e7e53 100644
--- a/source4/libcli/smb2/negprot.c
+++ b/source4/libcli/smb2/negprot.c
@@ -32,7 +32,7 @@ struct smb2_request *smb2_negprot_send(struct smb2_transport *transport,
{
struct smb2_request *req;
- req = smb2_request_init(transport, SMB2_OP_NEGPROT, 0x26, False, 0);
+ req = smb2_request_init(transport, SMB2_OP_NEGPROT, 0x26, false, 0);
if (req == NULL) return NULL;
/* this seems to be a bug, they use 0x24 but the length is 0x26 */
@@ -60,7 +60,7 @@ NTSTATUS smb2_negprot_recv(struct smb2_request *req, TALLOC_CTX *mem_ctx,
return smb2_request_destroy(req);
}
- SMB2_CHECK_PACKET_RECV(req, 0x40, True);
+ SMB2_CHECK_PACKET_RECV(req, 0x40, true);
io->out._pad = SVAL(req->in.body, 0x02);
io->out.unknown2 = IVAL(req->in.body, 0x04);
diff --git a/source4/libcli/smb2/notify.c b/source4/libcli/smb2/notify.c
index 58e2876745..a3bea41eb0 100644
--- a/source4/libcli/smb2/notify.c
+++ b/source4/libcli/smb2/notify.c
@@ -32,7 +32,7 @@ struct smb2_request *smb2_notify_send(struct smb2_tree *tree, struct smb2_notify
struct smb2_request *req;
uint32_t old_timeout;
- req = smb2_request_init_tree(tree, SMB2_OP_NOTIFY, 0x20, False, 0);
+ req = smb2_request_init_tree(tree, SMB2_OP_NOTIFY, 0x20, false, 0);
if (req == NULL) return NULL;
SSVAL(req->out.hdr, SMB2_HDR_UNKNOWN1, 0x0030);
@@ -67,7 +67,7 @@ NTSTATUS smb2_notify_recv(struct smb2_request *req, TALLOC_CTX *mem_ctx,
return smb2_request_destroy(req);
}
- SMB2_CHECK_PACKET_RECV(req, 0x08, True);
+ SMB2_CHECK_PACKET_RECV(req, 0x08, true);
status = smb2_pull_o16s32_blob(&req->in, mem_ctx, req->in.body+0x02, &blob);
if (!NT_STATUS_IS_OK(status)) {
diff --git a/source4/libcli/smb2/read.c b/source4/libcli/smb2/read.c
index f78a1a8b0e..b61f918481 100644
--- a/source4/libcli/smb2/read.c
+++ b/source4/libcli/smb2/read.c
@@ -30,7 +30,7 @@ struct smb2_request *smb2_read_send(struct smb2_tree *tree, struct smb2_read *io
{
struct smb2_request *req;
- req = smb2_request_init_tree(tree, SMB2_OP_READ, 0x30, True, 0);
+ req = smb2_request_init_tree(tree, SMB2_OP_READ, 0x30, true, 0);
if (req == NULL) return NULL;
SSVAL(req->out.body, 0x02, 0); /* pad */
@@ -59,7 +59,7 @@ NTSTATUS smb2_read_recv(struct smb2_request *req,
return smb2_request_destroy(req);
}
- SMB2_CHECK_PACKET_RECV(req, 0x10, True);
+ SMB2_CHECK_PACKET_RECV(req, 0x10, true);
status = smb2_pull_o16s32_blob(&req->in, mem_ctx, req->in.body+0x02, &io->out.data);
if (!NT_STATUS_IS_OK(status)) {
diff --git a/source4/libcli/smb2/request.c b/source4/libcli/smb2/request.c
index d857fc8c5b..576e2b6fcf 100644
--- a/source4/libcli/smb2/request.c
+++ b/source4/libcli/smb2/request.c
@@ -25,12 +25,13 @@
#include "libcli/smb2/smb2.h"
#include "lib/util/dlinklist.h"
#include "lib/events/events.h"
+#include "libcli/smb2/smb2_calls.h"
/*
initialise a smb2 request
*/
struct smb2_request *smb2_request_init(struct smb2_transport *transport, uint16_t opcode,
- uint16_t body_fixed_size, BOOL body_dynamic_present,
+ uint16_t body_fixed_size, bool body_dynamic_present,
uint32_t body_dynamic_size)
{
struct smb2_request *req;
@@ -67,7 +68,7 @@ struct smb2_request *smb2_request_init(struct smb2_transport *transport, uint16_
req->out.size = SMB2_HDR_BODY+NBT_HDR_SIZE+body_fixed_size;
req->out.allocated = req->out.size + body_dynamic_size;
- req->out.buffer = talloc_size(req, req->out.allocated);
+ req->out.buffer = talloc_array(req, uint8_t, req->out.allocated);
if (req->out.buffer == NULL) {
talloc_free(req);
return NULL;
@@ -112,7 +113,7 @@ struct smb2_request *smb2_request_init(struct smb2_transport *transport, uint16_
initialise a smb2 request for tree operations
*/
struct smb2_request *smb2_request_init_tree(struct smb2_tree *tree, uint16_t opcode,
- uint16_t body_fixed_size, BOOL body_dynamic_present,
+ uint16_t body_fixed_size, bool body_dynamic_present,
uint32_t body_dynamic_size)
{
struct smb2_request *req = smb2_request_init(tree->session->transport, opcode,
@@ -156,16 +157,16 @@ NTSTATUS smb2_request_destroy(struct smb2_request *req)
/*
receive a response to a packet
*/
-BOOL smb2_request_receive(struct smb2_request *req)
+bool smb2_request_receive(struct smb2_request *req)
{
/* req can be NULL when a send has failed. This eliminates lots of NULL
checks in each module */
- if (!req) return False;
+ if (!req) return false;
/* keep receiving packets until this one is replied to */
while (req->state <= SMB2_REQUEST_RECV) {
if (event_loop_once(req->transport->socket->event.ctx) != 0) {
- return False;
+ return false;
}
}
@@ -173,13 +174,13 @@ BOOL smb2_request_receive(struct smb2_request *req)
}
/* Return true if the last packet was in error */
-BOOL smb2_request_is_error(struct smb2_request *req)
+bool smb2_request_is_error(struct smb2_request *req)
{
return NT_STATUS_IS_ERR(req->status);
}
/* Return true if the last packet was OK */
-BOOL smb2_request_is_ok(struct smb2_request *req)
+bool smb2_request_is_ok(struct smb2_request *req)
{
return NT_STATUS_IS_OK(req->status);
}
@@ -187,16 +188,16 @@ BOOL smb2_request_is_ok(struct smb2_request *req)
/*
check if a range in the reply body is out of bounds
*/
-BOOL smb2_oob(struct smb2_request_buffer *buf, const uint8_t *ptr, size_t size)
+bool smb2_oob(struct smb2_request_buffer *buf, const uint8_t *ptr, size_t size)
{
/* be careful with wraparound! */
if (ptr < buf->body ||
ptr >= buf->body + buf->body_size ||
size > buf->body_size ||
ptr + size > buf->body + buf->body_size) {
- return True;
+ return true;
}
- return False;
+ return false;
}
size_t smb2_padding_size(uint32_t offset, size_t n)
@@ -229,7 +230,7 @@ static NTSTATUS smb2_grow_buffer(struct smb2_request_buffer *buf, size_t increas
dynamic_ofs = buf->dynamic - buf->buffer;
- buffer_ptr = talloc_realloc_size(buf, buf->buffer, newsize);
+ buffer_ptr = talloc_realloc(buf, buf->buffer, uint8_t, newsize);
NT_STATUS_HAVE_NO_MEMORY(buffer_ptr);
buf->buffer = buffer_ptr;
@@ -581,7 +582,7 @@ NTSTATUS smb2_pull_o16s16_string(struct smb2_request_buffer *buf, TALLOC_CTX *me
size = convert_string_talloc(mem_ctx, CH_UTF16, CH_UNIX,
blob.data, blob.length, &vstr);
data_blob_free(&blob);
- (*str) = vstr;
+ (*str) = (char *)vstr;
if (size == -1) {
return NT_STATUS_ILLEGAL_CHARACTER;
}
diff --git a/source4/libcli/smb2/session.c b/source4/libcli/smb2/session.c
index 3f9b3ed55c..462f60d2c2 100644
--- a/source4/libcli/smb2/session.c
+++ b/source4/libcli/smb2/session.c
@@ -30,7 +30,7 @@
initialise a smb2_session structure
*/
struct smb2_session *smb2_session_init(struct smb2_transport *transport,
- TALLOC_CTX *parent_ctx, BOOL primary)
+ TALLOC_CTX *parent_ctx, bool primary)
{
struct smb2_session *session;
NTSTATUS status;
@@ -68,7 +68,7 @@ struct smb2_request *smb2_session_setup_send(struct smb2_session *session,
NTSTATUS status;
req = smb2_request_init(session->transport, SMB2_OP_SESSSETUP,
- 0x18, True, io->in.secblob.length);
+ 0x18, true, io->in.secblob.length);
if (req == NULL) return NULL;
SBVAL(req->out.hdr, SMB2_HDR_UID, session->uid);
@@ -105,7 +105,7 @@ NTSTATUS smb2_session_setup_recv(struct smb2_request *req, TALLOC_CTX *mem_ctx,
return smb2_request_destroy(req);
}
- SMB2_CHECK_PACKET_RECV(req, 0x08, True);
+ SMB2_CHECK_PACKET_RECV(req, 0x08, true);
io->out._pad = SVAL(req->in.body, 0x02);
io->out.uid = BVAL(req->in.hdr, SMB2_HDR_UID);
diff --git a/source4/libcli/smb2/setinfo.c b/source4/libcli/smb2/setinfo.c
index 67d433a48a..d942568a2d 100644
--- a/source4/libcli/smb2/setinfo.c
+++ b/source4/libcli/smb2/setinfo.c
@@ -32,7 +32,7 @@ struct smb2_request *smb2_setinfo_send(struct smb2_tree *tree, struct smb2_setin
NTSTATUS status;
struct smb2_request *req;
- req = smb2_request_init_tree(tree, SMB2_OP_SETINFO, 0x20, True, io->in.blob.length);
+ req = smb2_request_init_tree(tree, SMB2_OP_SETINFO, 0x20, true, io->in.blob.length);
if (req == NULL) return NULL;
SSVAL(req->out.body, 0x02, io->in.level);
@@ -62,7 +62,7 @@ NTSTATUS smb2_setinfo_recv(struct smb2_request *req)
return smb2_request_destroy(req);
}
- SMB2_CHECK_PACKET_RECV(req, 0x02, False);
+ SMB2_CHECK_PACKET_RECV(req, 0x02, false);
return smb2_request_destroy(req);
}
diff --git a/source4/libcli/smb2/tcon.c b/source4/libcli/smb2/tcon.c
index 4f341d1206..ad1ba4c92d 100644
--- a/source4/libcli/smb2/tcon.c
+++ b/source4/libcli/smb2/tcon.c
@@ -27,7 +27,7 @@
initialise a smb2_session structure
*/
struct smb2_tree *smb2_tree_init(struct smb2_session *session,
- TALLOC_CTX *parent_ctx, BOOL primary)
+ TALLOC_CTX *parent_ctx, bool primary)
{
struct smb2_tree *tree;
@@ -53,7 +53,7 @@ struct smb2_request *smb2_tree_connect_send(struct smb2_tree *tree,
NTSTATUS status;
req = smb2_request_init(tree->session->transport, SMB2_OP_TCON,
- 0x08, True, 0);
+ 0x08, true, 0);
if (req == NULL) return NULL;
SBVAL(req->out.hdr, SMB2_HDR_UID, tree->session->uid);
@@ -81,7 +81,7 @@ NTSTATUS smb2_tree_connect_recv(struct smb2_request *req, struct smb2_tree_conne
return smb2_request_destroy(req);
}
- SMB2_CHECK_PACKET_RECV(req, 0x10, False);
+ SMB2_CHECK_PACKET_RECV(req, 0x10, false);
io->out.tid = IVAL(req->in.hdr, SMB2_HDR_TID);
diff --git a/source4/libcli/smb2/tdis.c b/source4/libcli/smb2/tdis.c
index 6ad3120740..5adad9dc6e 100644
--- a/source4/libcli/smb2/tdis.c
+++ b/source4/libcli/smb2/tdis.c
@@ -30,7 +30,7 @@ struct smb2_request *smb2_tdis_send(struct smb2_tree *tree)
{
struct smb2_request *req;
- req = smb2_request_init_tree(tree, SMB2_OP_TDIS, 0x04, False, 0);
+ req = smb2_request_init_tree(tree, SMB2_OP_TDIS, 0x04, false, 0);
if (req == NULL) return NULL;
SSVAL(req->out.body, 0x02, 0);
@@ -51,7 +51,7 @@ NTSTATUS smb2_tdis_recv(struct smb2_request *req)
return smb2_request_destroy(req);
}
- SMB2_CHECK_PACKET_RECV(req, 0x04, False);
+ SMB2_CHECK_PACKET_RECV(req, 0x04, false);
return smb2_request_destroy(req);
}
diff --git a/source4/libcli/smb2/transport.c b/source4/libcli/smb2/transport.c
index de08201c8b..83e9436a58 100644
--- a/source4/libcli/smb2/transport.c
+++ b/source4/libcli/smb2/transport.c
@@ -193,7 +193,7 @@ static NTSTATUS smb2_transport_finish_recv(void *private, DATA_BLOB blob)
if (NT_STATUS_EQUAL(req->status, STATUS_PENDING)) {
if (flags & 0x00000002) {
- req->cancel.can_cancel = True;
+ req->cancel.can_cancel = true;
req->cancel.pending_id = IVAL(hdr, SMB2_HDR_PID);
for (i=0; i< req->cancel.do_cancel; i++) {
smb2_cancel(req);
diff --git a/source4/libcli/smb2/write.c b/source4/libcli/smb2/write.c
index 3d501dc915..bc283370d7 100644
--- a/source4/libcli/smb2/write.c
+++ b/source4/libcli/smb2/write.c
@@ -31,7 +31,7 @@ struct smb2_request *smb2_write_send(struct smb2_tree *tree, struct smb2_write *
NTSTATUS status;
struct smb2_request *req;
- req = smb2_request_init_tree(tree, SMB2_OP_WRITE, 0x30, True, io->in.data.length);
+ req = smb2_request_init_tree(tree, SMB2_OP_WRITE, 0x30, true, io->in.data.length);
if (req == NULL) return NULL;
status = smb2_push_o16s32_blob(&req->out, 0x02, io->in.data);
@@ -62,7 +62,7 @@ NTSTATUS smb2_write_recv(struct smb2_request *req, struct smb2_write *io)
return smb2_request_destroy(req);
}
- SMB2_CHECK_PACKET_RECV(req, 0x10, True);
+ SMB2_CHECK_PACKET_RECV(req, 0x10, true);
io->out._pad = SVAL(req->in.body, 0x02);
io->out.nwritten = IVAL(req->in.body, 0x04);
diff --git a/source4/libcli/smb_composite/appendacl.c b/source4/libcli/smb_composite/appendacl.c
index f82714de5b..0fda8c4d65 100644
--- a/source4/libcli/smb_composite/appendacl.c
+++ b/source4/libcli/smb_composite/appendacl.c
@@ -187,7 +187,7 @@ static NTSTATUS appendacl_close(struct composite_context *c,
*/
static void appendacl_handler(struct smbcli_request *req)
{
- struct composite_context *c = req->async.private;
+ struct composite_context *c = (struct composite_context *)req->async.private;
struct appendacl_state *state = talloc_get_type(c->private_data, struct appendacl_state);
/* when this handler is called, the stage indicates what
diff --git a/source4/libcli/smb_composite/connect.c b/source4/libcli/smb_composite/connect.c
index 026fe0b029..9f18c0d924 100644
--- a/source4/libcli/smb_composite/connect.c
+++ b/source4/libcli/smb_composite/connect.c
@@ -28,6 +28,7 @@
#include "libcli/resolve/resolve.h"
#include "auth/credentials/credentials.h"
#include "librpc/gen_ndr/ndr_nbt.h"
+#include "param/param.h"
/* the stages of this call */
enum connect_stage {CONNECT_RESOLVE,
@@ -62,7 +63,8 @@ static NTSTATUS connect_send_negprot(struct composite_context *c,
{
struct connect_state *state = talloc_get_type(c->private_data, struct connect_state);
- state->req = smb_raw_negotiate_send(state->transport, lp_cli_maxprotocol());
+ state->req = smb_raw_negotiate_send(state->transport,
+ lp_cli_maxprotocol(global_loadparm));
NT_STATUS_HAVE_NO_MEMORY(state->req);
state->req->async.fn = request_handler;
@@ -114,12 +116,12 @@ static NTSTATUS connect_session_setup_anon(struct composite_context *c,
status = smb_composite_sesssetup_recv(state->creq);
NT_STATUS_NOT_OK_RETURN(status);
- io->out.anonymous_fallback_done = True;
+ io->out.anonymous_fallback_done = true;
state->session->vuid = state->io_setup->out.vuid;
/* setup for a tconx */
- io->out.tree = smbcli_tree_init(state->session, state, True);
+ io->out.tree = smbcli_tree_init(state->session, state, true);
NT_STATUS_HAVE_NO_MEMORY(io->out.tree);
state->io_tcon = talloc(c, union smb_tcon);
@@ -171,7 +173,8 @@ static NTSTATUS connect_session_setup(struct composite_context *c,
state->io_setup->in.credentials = cli_credentials_init(state);
NT_STATUS_HAVE_NO_MEMORY(state->io_setup->in.credentials);
- cli_credentials_set_conf(state->io_setup->in.credentials);
+ cli_credentials_set_conf(state->io_setup->in.credentials,
+ global_loadparm);
cli_credentials_set_anonymous(state->io_setup->in.credentials);
/* If the preceding attempt was with extended security, we
@@ -200,7 +203,7 @@ static NTSTATUS connect_session_setup(struct composite_context *c,
state->session->vuid = state->io_setup->out.vuid;
/* setup for a tconx */
- io->out.tree = smbcli_tree_init(state->session, state, True);
+ io->out.tree = smbcli_tree_init(state->session, state, true);
NT_STATUS_HAVE_NO_MEMORY(io->out.tree);
state->io_tcon = talloc(c, union smb_tcon);
@@ -248,7 +251,7 @@ static NTSTATUS connect_negprot(struct composite_context *c,
NT_STATUS_NOT_OK_RETURN(status);
/* next step is a session setup */
- state->session = smbcli_session_init(state->transport, state, True);
+ state->session = smbcli_session_init(state->transport, state, true);
NT_STATUS_HAVE_NO_MEMORY(state->session);
state->io_setup = talloc(c, struct smb_composite_sesssetup);
@@ -304,7 +307,7 @@ static NTSTATUS connect_socket(struct composite_context *c,
NT_STATUS_NOT_OK_RETURN(status);
/* the socket is up - we can initialise the smbcli transport layer */
- state->transport = smbcli_transport_init(state->sock, state, True);
+ state->transport = smbcli_transport_init(state->sock, state, true);
NT_STATUS_HAVE_NO_MEMORY(state->transport);
if (is_ipaddress(state->sock->hostname) &&
@@ -458,7 +461,8 @@ struct composite_context *smb_composite_connect_send(struct smb_composite_connec
state->stage = CONNECT_RESOLVE;
make_nbt_name_server(&name, io->in.dest_host);
- state->creq = resolve_name_send(&name, c->event_ctx, lp_name_resolve_order());
+ state->creq = resolve_name_send(&name, c->event_ctx,
+ lp_name_resolve_order(global_loadparm));
if (state->creq == NULL) goto failed;
state->creq->async.private_data = c;
diff --git a/source4/libcli/smb_composite/fetchfile.c b/source4/libcli/smb_composite/fetchfile.c
index 63a10a667d..2dbaff5a66 100644
--- a/source4/libcli/smb_composite/fetchfile.c
+++ b/source4/libcli/smb_composite/fetchfile.c
@@ -142,7 +142,7 @@ struct composite_context *smb_composite_fetchfile_send(struct smb_composite_fetc
state->connect->in.service = io->in.service;
state->connect->in.service_type = io->in.service_type;
state->connect->in.credentials = io->in.credentials;
- state->connect->in.fallback_to_anonymous = False;
+ state->connect->in.fallback_to_anonymous = false;
state->connect->in.workgroup = io->in.workgroup;
state->creq = smb_composite_connect_send(state->connect, state, event_ctx);
diff --git a/source4/libcli/smb_composite/fsinfo.c b/source4/libcli/smb_composite/fsinfo.c
index e81e3a2085..faf3723539 100644
--- a/source4/libcli/smb_composite/fsinfo.c
+++ b/source4/libcli/smb_composite/fsinfo.c
@@ -148,7 +148,7 @@ struct composite_context *smb_composite_fsinfo_send(struct smbcli_tree *tree,
state->connect->in.service = io->in.service;
state->connect->in.service_type = io->in.service_type;
state->connect->in.credentials = io->in.credentials;
- state->connect->in.fallback_to_anonymous = False;
+ state->connect->in.fallback_to_anonymous = false;
state->connect->in.workgroup = io->in.workgroup;
c->state = COMPOSITE_STATE_IN_PROGRESS;
diff --git a/source4/libcli/smb_composite/loadfile.c b/source4/libcli/smb_composite/loadfile.c
index 9b65d04ef3..952f24b811 100644
--- a/source4/libcli/smb_composite/loadfile.c
+++ b/source4/libcli/smb_composite/loadfile.c
@@ -105,7 +105,7 @@ static NTSTATUS loadfile_open(struct composite_context *c,
state->io_read->readx.in.mincnt = MIN(32768, io->out.size);
state->io_read->readx.in.maxcnt = state->io_read->readx.in.mincnt;
state->io_read->readx.in.remaining = 0;
- state->io_read->readx.in.read_for_execute = False;
+ state->io_read->readx.in.read_for_execute = false;
state->io_read->readx.out.data = io->out.data;
state->req = smb_raw_read_send(tree, state->io_read);
@@ -180,7 +180,7 @@ static NTSTATUS loadfile_close(struct composite_context *c,
*/
static void loadfile_handler(struct smbcli_request *req)
{
- struct composite_context *c = req->async.private;
+ struct composite_context *c = (struct composite_context *)req->async.private;
struct loadfile_state *state = talloc_get_type(c->private_data, struct loadfile_state);
/* when this handler is called, the stage indicates what
diff --git a/source4/libcli/smb_composite/savefile.c b/source4/libcli/smb_composite/savefile.c
index 32fcdbcd87..b94be9e9b1 100644
--- a/source4/libcli/smb_composite/savefile.c
+++ b/source4/libcli/smb_composite/savefile.c
@@ -180,7 +180,7 @@ static NTSTATUS savefile_close(struct composite_context *c,
*/
static void savefile_handler(struct smbcli_request *req)
{
- struct composite_context *c = req->async.private;
+ struct composite_context *c = (struct composite_context *)req->async.private;
struct savefile_state *state = talloc_get_type(c->private_data, struct savefile_state);
/* when this handler is called, the stage indicates what
diff --git a/source4/libcli/smb_composite/sesssetup.c b/source4/libcli/smb_composite/sesssetup.c
index 25cf8b3f12..622367e746 100644
--- a/source4/libcli/smb_composite/sesssetup.c
+++ b/source4/libcli/smb_composite/sesssetup.c
@@ -29,6 +29,7 @@
#include "auth/gensec/gensec.h"
#include "auth/credentials/credentials.h"
#include "version.h"
+#include "param/param.h"
struct sesssetup_state {
union smb_sesssetup setup;
@@ -76,7 +77,7 @@ static void set_user_session_key(struct smbcli_session *session,
*/
static void request_handler(struct smbcli_request *req)
{
- struct composite_context *c = req->async.private;
+ struct composite_context *c = (struct composite_context *)req->async.private;
struct sesssetup_state *state = talloc_get_type(c->private_data, struct sesssetup_state);
struct smbcli_session *session = req->session;
DATA_BLOB session_key = data_blob(NULL, 0);
@@ -222,14 +223,14 @@ static NTSTATUS session_setup_nt1(struct composite_context *c,
NTSTATUS nt_status;
struct sesssetup_state *state = talloc_get_type(c->private_data, struct sesssetup_state);
const char *password = cli_credentials_get_password(io->in.credentials);
- DATA_BLOB names_blob = NTLMv2_generate_names_blob(state, session->transport->socket->hostname, lp_workgroup());
+ DATA_BLOB names_blob = NTLMv2_generate_names_blob(state, session->transport->socket->hostname, lp_workgroup(global_loadparm));
DATA_BLOB session_key;
int flags = CLI_CRED_NTLM_AUTH;
- if (lp_client_lanman_auth()) {
+ if (lp_client_lanman_auth(global_loadparm)) {
flags |= CLI_CRED_LANMAN_AUTH;
}
- if (lp_client_ntlmv2_auth()) {
+ if (lp_client_ntlmv2_auth(global_loadparm)) {
flags |= CLI_CRED_NTLMv2_AUTH;
}
@@ -262,7 +263,7 @@ static NTSTATUS session_setup_nt1(struct composite_context *c,
set_user_session_key(session, &session_key);
data_blob_free(&session_key);
- } else if (lp_client_plaintext_auth()) {
+ } else if (lp_client_plaintext_auth(global_loadparm)) {
state->setup.nt1.in.password1 = data_blob_talloc(state, password, strlen(password));
state->setup.nt1.in.password2 = data_blob(NULL, 0);
} else {
@@ -289,14 +290,14 @@ static NTSTATUS session_setup_old(struct composite_context *c,
NTSTATUS nt_status;
struct sesssetup_state *state = talloc_get_type(c->private_data, struct sesssetup_state);
const char *password = cli_credentials_get_password(io->in.credentials);
- DATA_BLOB names_blob = NTLMv2_generate_names_blob(state, session->transport->socket->hostname, lp_workgroup());
+ DATA_BLOB names_blob = NTLMv2_generate_names_blob(state, session->transport->socket->hostname, lp_workgroup(global_loadparm));
DATA_BLOB session_key;
int flags = 0;
- if (lp_client_lanman_auth()) {
+ if (lp_client_lanman_auth(global_loadparm)) {
flags |= CLI_CRED_LANMAN_AUTH;
}
- if (lp_client_ntlmv2_auth()) {
+ if (lp_client_ntlmv2_auth(global_loadparm)) {
flags |= CLI_CRED_NTLMv2_AUTH;
}
@@ -323,7 +324,7 @@ static NTSTATUS session_setup_old(struct composite_context *c,
set_user_session_key(session, &session_key);
data_blob_free(&session_key);
- } else if (lp_client_plaintext_auth()) {
+ } else if (lp_client_plaintext_auth(global_loadparm)) {
state->setup.old.in.password = data_blob_talloc(state, password, strlen(password));
} else {
/* could match windows client and return 'cannot logon from this workstation', but it just confuses everybody */
@@ -417,7 +418,7 @@ static NTSTATUS session_setup_spnego(struct composite_context *c,
}
}
- if (chosen_oid == GENSEC_OID_SPNEGO) {
+ if ((const void *)chosen_oid == (const void *)GENSEC_OID_SPNEGO) {
status = gensec_update(session->gensec, state,
session->transport->negotiate.secblob,
&state->setup.spnego.in.secblob);
diff --git a/source4/libcli/swig/libcli_nbt.i b/source4/libcli/swig/libcli_nbt.i
index b887e7df97..ec7632ccf4 100644
--- a/source4/libcli/swig/libcli_nbt.i
+++ b/source4/libcli/swig/libcli_nbt.i
@@ -31,6 +31,7 @@
#include "lib/talloc/talloc.h"
#include "lib/events/events.h"
#include "libcli/nbt/libnbt.h"
+#include "param/param.h"
/* Undo strcpy safety macro as it's used by swig )-: */
@@ -38,7 +39,7 @@
%}
-%apply bool { BOOL };
+%apply bool { bool };
%apply int { uint8_t };
%apply int { int8_t };
%apply unsigned int { uint16_t };
@@ -111,8 +112,8 @@ struct nbt_name_query {
struct {
struct nbt_name name;
const char *dest_addr;
- BOOL broadcast;
- BOOL wins_lookup;
+ bool broadcast;
+ bool wins_lookup;
int timeout; /* in seconds */
int retries;
} in;
@@ -127,9 +128,17 @@ struct nbt_name_query {
%include "carrays.i"
%array_functions(char *, char_ptr_array);
-%rename(do_nbt_name_query) nbt_name_query;
+NTSTATUS do_nbt_name_query(struct nbt_name_socket *nbtsock,
+ TALLOC_CTX *mem_ctx, struct nbt_name_query *io);
-NTSTATUS nbt_name_query(struct nbt_name_socket *nbtsock,
- TALLOC_CTX *mem_ctx, struct nbt_name_query *io);
+%{
+NTSTATUS do_nbt_name_query(struct nbt_name_socket *nbtsock,
+ TALLOC_CTX *mem_ctx, struct nbt_name_query *io)
+{
+ return nbt_name_query(nbtsock, mem_ctx, io);
+}
+%}
-void lp_load(void);
+%init %{
+ lp_load();
+%}
diff --git a/source4/libcli/swig/libcli_smb.i b/source4/libcli/swig/libcli_smb.i
new file mode 100644
index 0000000000..8eb055c2f0
--- /dev/null
+++ b/source4/libcli/swig/libcli_smb.i
@@ -0,0 +1,18 @@
+%module libcli_smb
+
+%{
+#include "includes.h"
+#include "lib/talloc/talloc.h"
+#include "lib/events/events.h"
+#include "libcli/raw/libcliraw.h"
+%}
+
+TALLOC_CTX *talloc_init(char *name);
+int talloc_free(TALLOC_CTX *ptr);
+struct event_context *event_context_init(TALLOC_CTX *mem_ctx);
+
+struct smbcli_socket *smbcli_sock_connect_byname(const char *host, int port,
+ TALLOC_CTX *mem_ctx,
+ struct event_context *event_ctx);
+
+void smbcli_sock_dead(struct smbcli_socket *sock);
diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c
index e7a2e163aa..58cb5f07be 100644
--- a/source4/libcli/util/asn1.c
+++ b/source4/libcli/util/asn1.c
@@ -37,41 +37,41 @@ void asn1_free(struct asn1_data *data)
}
/* write to the ASN1 buffer, advancing the buffer pointer */
-BOOL asn1_write(struct asn1_data *data, const void *p, int len)
+bool asn1_write(struct asn1_data *data, const void *p, int len)
{
- if (data->has_error) return False;
+ if (data->has_error) return false;
if (data->length < data->ofs+len) {
uint8_t *newp;
newp = talloc_realloc(data, data->data, uint8_t, data->ofs+len);
if (!newp) {
asn1_free(data);
- data->has_error = True;
- return False;
+ data->has_error = true;
+ return false;
}
data->data = newp;
data->length = data->ofs+len;
}
memcpy(data->data + data->ofs, p, len);
data->ofs += len;
- return True;
+ return true;
}
/* useful fn for writing a uint8_t */
-BOOL asn1_write_uint8(struct asn1_data *data, uint8_t v)
+bool asn1_write_uint8(struct asn1_data *data, uint8_t v)
{
return asn1_write(data, &v, 1);
}
/* push a tag onto the asn1 data buffer. Used for nested structures */
-BOOL asn1_push_tag(struct asn1_data *data, uint8_t tag)
+bool asn1_push_tag(struct asn1_data *data, uint8_t tag)
{
struct nesting *nesting;
asn1_write_uint8(data, tag);
nesting = talloc(data, struct nesting);
if (!nesting) {
- data->has_error = True;
- return False;
+ data->has_error = true;
+ return false;
}
nesting->start = data->ofs;
@@ -81,7 +81,7 @@ BOOL asn1_push_tag(struct asn1_data *data, uint8_t tag)
}
/* pop a tag */
-BOOL asn1_pop_tag(struct asn1_data *data)
+bool asn1_pop_tag(struct asn1_data *data)
{
struct nesting *nesting;
size_t len;
@@ -89,8 +89,8 @@ BOOL asn1_pop_tag(struct asn1_data *data)
nesting = data->nesting;
if (!nesting) {
- data->has_error = True;
- return False;
+ data->has_error = true;
+ return false;
}
len = data->ofs - (nesting->start+1);
/* yes, this is ugly. We don't know in advance how many bytes the length
@@ -98,10 +98,10 @@ BOOL asn1_pop_tag(struct asn1_data *data)
need to correct our mistake */
if (len > 0xFFFFFF) {
data->data[nesting->start] = 0x84;
- if (!asn1_write_uint8(data, 0)) return False;
- if (!asn1_write_uint8(data, 0)) return False;
- if (!asn1_write_uint8(data, 0)) return False;
- if (!asn1_write_uint8(data, 0)) return False;
+ if (!asn1_write_uint8(data, 0)) return false;
+ if (!asn1_write_uint8(data, 0)) return false;
+ if (!asn1_write_uint8(data, 0)) return false;
+ if (!asn1_write_uint8(data, 0)) return false;
memmove(data->data+nesting->start+5, data->data+nesting->start+1, len);
data->data[nesting->start+1] = (len>>24) & 0xFF;
data->data[nesting->start+2] = (len>>16) & 0xFF;
@@ -109,23 +109,23 @@ BOOL asn1_pop_tag(struct asn1_data *data)
data->data[nesting->start+4] = len&0xff;
} else if (len > 0xFFFF) {
data->data[nesting->start] = 0x83;
- if (!asn1_write_uint8(data, 0)) return False;
- if (!asn1_write_uint8(data, 0)) return False;
- if (!asn1_write_uint8(data, 0)) return False;
+ if (!asn1_write_uint8(data, 0)) return false;
+ if (!asn1_write_uint8(data, 0)) return false;
+ if (!asn1_write_uint8(data, 0)) return false;
memmove(data->data+nesting->start+4, data->data+nesting->start+1, len);
data->data[nesting->start+1] = (len>>16) & 0xFF;
data->data[nesting->start+2] = (len>>8) & 0xFF;
data->data[nesting->start+3] = len&0xff;
} else if (len > 255) {
data->data[nesting->start] = 0x82;
- if (!asn1_write_uint8(data, 0)) return False;
- if (!asn1_write_uint8(data, 0)) return False;
+ if (!asn1_write_uint8(data, 0)) return false;
+ if (!asn1_write_uint8(data, 0)) return false;
memmove(data->data+nesting->start+3, data->data+nesting->start+1, len);
data->data[nesting->start+1] = len>>8;
data->data[nesting->start+2] = len&0xff;
} else if (len > 127) {
data->data[nesting->start] = 0x81;
- if (!asn1_write_uint8(data, 0)) return False;
+ if (!asn1_write_uint8(data, 0)) return false;
memmove(data->data+nesting->start+2, data->data+nesting->start+1, len);
data->data[nesting->start+1] = len;
} else {
@@ -134,20 +134,20 @@ BOOL asn1_pop_tag(struct asn1_data *data)
data->nesting = nesting->next;
talloc_free(nesting);
- return True;
+ return true;
}
/* "i" is the one's complement representation, as is the normal result of an
* implicit signed->unsigned conversion */
-static BOOL push_int_bigendian(struct asn1_data *data, unsigned int i, BOOL negative)
+static bool push_int_bigendian(struct asn1_data *data, unsigned int i, bool negative)
{
uint8_t lowest = i & 0xFF;
i = i >> 8;
if (i != 0)
if (!push_int_bigendian(data, i, negative))
- return False;
+ return false;
if (data->nesting->start+1 == data->ofs) {
@@ -157,14 +157,14 @@ static BOOL push_int_bigendian(struct asn1_data *data, unsigned int i, BOOL nega
if (negative) {
/* Don't write leading 0xff's */
if (lowest == 0xFF)
- return True;
+ return true;
if ((lowest & 0x80) == 0) {
/* The only exception for a leading 0xff is if
* the highest bit is 0, which would indicate
* a positive value */
if (!asn1_write_uint8(data, 0xff))
- return False;
+ return false;
}
} else {
if (lowest & 0x80) {
@@ -172,7 +172,7 @@ static BOOL push_int_bigendian(struct asn1_data *data, unsigned int i, BOOL nega
* this would indicate a negative number. Push
* a 0 to indicate a positive one */
if (!asn1_write_uint8(data, 0))
- return False;
+ return false;
}
}
}
@@ -183,7 +183,7 @@ static BOOL push_int_bigendian(struct asn1_data *data, unsigned int i, BOOL nega
/* write an Integer without the tag framing. Needed for example for the LDAP
* Abandon Operation */
-BOOL asn1_write_implicit_Integer(struct asn1_data *data, int i)
+bool asn1_write_implicit_Integer(struct asn1_data *data, int i)
{
if (i == -1) {
/* -1 is special as it consists of all-0xff bytes. In
@@ -198,14 +198,14 @@ BOOL asn1_write_implicit_Integer(struct asn1_data *data, int i)
/* write an integer */
-BOOL asn1_write_Integer(struct asn1_data *data, int i)
+bool asn1_write_Integer(struct asn1_data *data, int i)
{
- if (!asn1_push_tag(data, ASN1_INTEGER)) return False;
- if (!asn1_write_implicit_Integer(data, i)) return False;
+ if (!asn1_push_tag(data, ASN1_INTEGER)) return false;
+ if (!asn1_write_implicit_Integer(data, i)) return false;
return asn1_pop_tag(data);
}
-BOOL ber_write_OID_String(DATA_BLOB *blob, const char *OID)
+bool ber_write_OID_String(DATA_BLOB *blob, const char *OID)
{
uint_t v, v2;
const char *p = (const char *)OID;
@@ -213,16 +213,16 @@ BOOL ber_write_OID_String(DATA_BLOB *blob, const char *OID)
int i;
v = strtoul(p, &newp, 10);
- if (newp[0] != '.') return False;
+ if (newp[0] != '.') return false;
p = newp + 1;
v2 = strtoul(p, &newp, 10);
- if (newp[0] != '.') return False;
+ if (newp[0] != '.') return false;
p = newp + 1;
/*the ber representation can't use more space then the string one */
*blob = data_blob(NULL, strlen(OID));
- if (!blob->data) return False;
+ if (!blob->data) return false;
blob->data[0] = 40*v + v2;
@@ -235,7 +235,7 @@ BOOL ber_write_OID_String(DATA_BLOB *blob, const char *OID)
p = newp;
} else {
data_blob_free(blob);
- return False;
+ return false;
}
if (v >= (1<<28)) blob->data[i++] = (0x80 | ((v>>28)&0x7f));
if (v >= (1<<21)) blob->data[i++] = (0x80 | ((v>>21)&0x7f));
@@ -246,31 +246,31 @@ BOOL ber_write_OID_String(DATA_BLOB *blob, const char *OID)
blob->length = i;
- return True;
+ return true;
}
/* write an object ID to a ASN1 buffer */
-BOOL asn1_write_OID(struct asn1_data *data, const char *OID)
+bool asn1_write_OID(struct asn1_data *data, const char *OID)
{
DATA_BLOB blob;
- if (!asn1_push_tag(data, ASN1_OID)) return False;
+ if (!asn1_push_tag(data, ASN1_OID)) return false;
if (!ber_write_OID_String(&blob, OID)) {
- data->has_error = True;
- return False;
+ data->has_error = true;
+ return false;
}
if (!asn1_write(data, blob.data, blob.length)) {
- data->has_error = True;
- return False;
+ data->has_error = true;
+ return false;
}
data_blob_free(&blob);
return asn1_pop_tag(data);
}
/* write an octet string */
-BOOL asn1_write_OctetString(struct asn1_data *data, const void *p, size_t length)
+bool asn1_write_OctetString(struct asn1_data *data, const void *p, size_t length)
{
asn1_push_tag(data, ASN1_OCTET_STRING);
asn1_write(data, p, length);
@@ -279,14 +279,14 @@ BOOL asn1_write_OctetString(struct asn1_data *data, const void *p, size_t length
}
/* write a LDAP string */
-BOOL asn1_write_LDAPString(struct asn1_data *data, const char *s)
+bool asn1_write_LDAPString(struct asn1_data *data, const char *s)
{
asn1_write(data, s, strlen(s));
return !data->has_error;
}
/* write a general string */
-BOOL asn1_write_GeneralString(struct asn1_data *data, const char *s)
+bool asn1_write_GeneralString(struct asn1_data *data, const char *s)
{
asn1_push_tag(data, ASN1_GENERAL_STRING);
asn1_write_LDAPString(data, s);
@@ -294,7 +294,7 @@ BOOL asn1_write_GeneralString(struct asn1_data *data, const char *s)
return !data->has_error;
}
-BOOL asn1_write_ContextSimple(struct asn1_data *data, uint8_t num, DATA_BLOB *blob)
+bool asn1_write_ContextSimple(struct asn1_data *data, uint8_t num, DATA_BLOB *blob)
{
asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(num));
asn1_write(data, blob->data, blob->length);
@@ -303,7 +303,7 @@ BOOL asn1_write_ContextSimple(struct asn1_data *data, uint8_t num, DATA_BLOB *bl
}
/* write a BOOLEAN */
-BOOL asn1_write_BOOLEAN(struct asn1_data *data, BOOL v)
+bool asn1_write_BOOLEAN(struct asn1_data *data, bool v)
{
asn1_push_tag(data, ASN1_BOOLEAN);
asn1_write_uint8(data, v ? 0xFF : 0);
@@ -311,137 +311,140 @@ BOOL asn1_write_BOOLEAN(struct asn1_data *data, BOOL v)
return !data->has_error;
}
-BOOL asn1_read_BOOLEAN(struct asn1_data *data, BOOL *v)
+bool asn1_read_BOOLEAN(struct asn1_data *data, bool *v)
{
uint8_t tmp = 0;
asn1_start_tag(data, ASN1_BOOLEAN);
asn1_read_uint8(data, &tmp);
if (tmp == 0xFF) {
- *v = True;
+ *v = true;
} else {
- *v = False;
+ *v = false;
}
asn1_end_tag(data);
return !data->has_error;
}
/* check a BOOLEAN */
-BOOL asn1_check_BOOLEAN(struct asn1_data *data, BOOL v)
+bool asn1_check_BOOLEAN(struct asn1_data *data, bool v)
{
uint8_t b = 0;
asn1_read_uint8(data, &b);
if (b != ASN1_BOOLEAN) {
- data->has_error = True;
- return False;
+ data->has_error = true;
+ return false;
}
asn1_read_uint8(data, &b);
if (b != v) {
- data->has_error = True;
- return False;
+ data->has_error = true;
+ return false;
}
return !data->has_error;
}
/* load a struct asn1_data structure with a lump of data, ready to be parsed */
-BOOL asn1_load(struct asn1_data *data, DATA_BLOB blob)
+bool asn1_load(struct asn1_data *data, DATA_BLOB blob)
{
ZERO_STRUCTP(data);
data->data = talloc_memdup(data, blob.data, blob.length);
if (!data->data) {
- data->has_error = True;
- return False;
+ data->has_error = true;
+ return false;
}
data->length = blob.length;
- return True;
+ return true;
}
/* Peek into an ASN1 buffer, not advancing the pointer */
-BOOL asn1_peek(struct asn1_data *data, void *p, int len)
+bool asn1_peek(struct asn1_data *data, void *p, int len)
{
+ if (data->has_error)
+ return false;
+
if (len < 0 || data->ofs + len < data->ofs || data->ofs + len < len)
- return False;
+ return false;
if (data->ofs + len > data->length) {
/* we need to mark the buffer as consumed, so the caller knows
this was an out of data error, and not a decode error */
data->ofs = data->length;
- return False;
+ return false;
}
memcpy(p, data->data + data->ofs, len);
- return True;
+ return true;
}
/* read from a ASN1 buffer, advancing the buffer pointer */
-BOOL asn1_read(struct asn1_data *data, void *p, int len)
+bool asn1_read(struct asn1_data *data, void *p, int len)
{
if (!asn1_peek(data, p, len)) {
- data->has_error = True;
- return False;
+ data->has_error = true;
+ return false;
}
data->ofs += len;
- return True;
+ return true;
}
/* read a uint8_t from a ASN1 buffer */
-BOOL asn1_read_uint8(struct asn1_data *data, uint8_t *v)
+bool asn1_read_uint8(struct asn1_data *data, uint8_t *v)
{
return asn1_read(data, v, 1);
}
-BOOL asn1_peek_uint8(struct asn1_data *data, uint8_t *v)
+bool asn1_peek_uint8(struct asn1_data *data, uint8_t *v)
{
return asn1_peek(data, v, 1);
}
-BOOL asn1_peek_tag(struct asn1_data *data, uint8_t tag)
+bool asn1_peek_tag(struct asn1_data *data, uint8_t tag)
{
uint8_t b;
if (asn1_tag_remaining(data) <= 0) {
- return False;
+ return false;
}
- if (!asn1_peek(data, &b, sizeof(b)))
- return False;
+ if (!asn1_peek_uint8(data, &b))
+ return false;
return (b == tag);
}
/* start reading a nested asn1 structure */
-BOOL asn1_start_tag(struct asn1_data *data, uint8_t tag)
+bool asn1_start_tag(struct asn1_data *data, uint8_t tag)
{
uint8_t b;
struct nesting *nesting;
if (!asn1_read_uint8(data, &b))
- return False;
+ return false;
if (b != tag) {
- data->has_error = True;
- return False;
+ data->has_error = true;
+ return false;
}
nesting = talloc(data, struct nesting);
if (!nesting) {
- data->has_error = True;
- return False;
+ data->has_error = true;
+ return false;
}
if (!asn1_read_uint8(data, &b)) {
- return False;
+ return false;
}
if (b & 0x80) {
int n = b & 0x7f;
if (!asn1_read_uint8(data, &b))
- return False;
+ return false;
nesting->taglen = b;
while (n > 1) {
if (!asn1_read_uint8(data, &b))
- return False;
+ return false;
nesting->taglen = (nesting->taglen << 8) | b;
n--;
}
@@ -452,32 +455,32 @@ BOOL asn1_start_tag(struct asn1_data *data, uint8_t tag)
nesting->next = data->nesting;
data->nesting = nesting;
if (asn1_tag_remaining(data) == -1) {
- return False;
+ return false;
}
return !data->has_error;
}
/* stop reading a tag */
-BOOL asn1_end_tag(struct asn1_data *data)
+bool asn1_end_tag(struct asn1_data *data)
{
struct nesting *nesting;
/* make sure we read it all */
if (asn1_tag_remaining(data) != 0) {
- data->has_error = True;
- return False;
+ data->has_error = true;
+ return false;
}
nesting = data->nesting;
if (!nesting) {
- data->has_error = True;
- return False;
+ data->has_error = true;
+ return false;
}
data->nesting = nesting->next;
talloc_free(nesting);
- return True;
+ return true;
}
/* work out how many bytes are left in this nested tag */
@@ -489,38 +492,38 @@ int asn1_tag_remaining(struct asn1_data *data)
}
if (!data->nesting) {
- data->has_error = True;
+ data->has_error = true;
return -1;
}
remaining = data->nesting->taglen - (data->ofs - data->nesting->start);
if (remaining > (data->length - data->ofs)) {
- data->has_error = True;
+ data->has_error = true;
return -1;
}
return remaining;
}
/* read an object ID from a data blob */
-BOOL ber_read_OID_String(TALLOC_CTX *mem_ctx, DATA_BLOB blob, const char **OID)
+bool ber_read_OID_String(TALLOC_CTX *mem_ctx, DATA_BLOB blob, const char **OID)
{
int i;
uint8_t *b;
uint_t v;
char *tmp_oid = NULL;
- if (blob.length < 2) return False;
+ if (blob.length < 2) return false;
b = blob.data;
tmp_oid = talloc_asprintf(mem_ctx, "%u", b[0]/40);
if (!tmp_oid) goto nomem;
- tmp_oid = talloc_asprintf_append(tmp_oid, ".%u", b[0]%40);
+ tmp_oid = talloc_asprintf_append_buffer(tmp_oid, ".%u", b[0]%40);
if (!tmp_oid) goto nomem;
for(i = 1, v = 0; i < blob.length; i++) {
v = (v<<7) | (b[i]&0x7f);
if ( ! (b[i] & 0x80)) {
- tmp_oid = talloc_asprintf_append(tmp_oid, ".%u", v);
+ tmp_oid = talloc_asprintf_append_buffer(tmp_oid, ".%u", v);
v = 0;
}
if (!tmp_oid) goto nomem;
@@ -528,82 +531,82 @@ BOOL ber_read_OID_String(TALLOC_CTX *mem_ctx, DATA_BLOB blob, const char **OID)
if (v != 0) {
talloc_free(tmp_oid);
- return False;
+ return false;
}
*OID = tmp_oid;
- return True;
+ return true;
nomem:
- return False;
+ return false;
}
/* read an object ID from a ASN1 buffer */
-BOOL asn1_read_OID(struct asn1_data *data, TALLOC_CTX *mem_ctx, const char **OID)
+bool asn1_read_OID(struct asn1_data *data, TALLOC_CTX *mem_ctx, const char **OID)
{
DATA_BLOB blob;
int len;
- if (!asn1_start_tag(data, ASN1_OID)) return False;
+ if (!asn1_start_tag(data, ASN1_OID)) return false;
len = asn1_tag_remaining(data);
if (len < 0) {
- data->has_error = True;
- return False;
+ data->has_error = true;
+ return false;
}
blob = data_blob(NULL, len);
if (!blob.data) {
- data->has_error = True;
- return False;
+ data->has_error = true;
+ return false;
}
asn1_read(data, blob.data, len);
asn1_end_tag(data);
if (data->has_error) {
data_blob_free(&blob);
- return False;
+ return false;
}
if (!ber_read_OID_String(mem_ctx, blob, OID)) {
- data->has_error = True;
+ data->has_error = true;
data_blob_free(&blob);
- return False;
+ return false;
}
data_blob_free(&blob);
- return True;
+ return true;
}
/* check that the next object ID is correct */
-BOOL asn1_check_OID(struct asn1_data *data, const char *OID)
+bool asn1_check_OID(struct asn1_data *data, const char *OID)
{
const char *id;
- if (!asn1_read_OID(data, data, &id)) return False;
+ if (!asn1_read_OID(data, data, &id)) return false;
if (strcmp(id, OID) != 0) {
talloc_free(discard_const(id));
- data->has_error = True;
- return False;
+ data->has_error = true;
+ return false;
}
talloc_free(discard_const(id));
- return True;
+ return true;
}
/* read a LDAPString from a ASN1 buffer */
-BOOL asn1_read_LDAPString(struct asn1_data *data, TALLOC_CTX *mem_ctx, char **s)
+bool asn1_read_LDAPString(struct asn1_data *data, TALLOC_CTX *mem_ctx, char **s)
{
int len;
len = asn1_tag_remaining(data);
if (len < 0) {
- data->has_error = True;
- return False;
+ data->has_error = true;
+ return false;
}
- *s = talloc_size(mem_ctx, len+1);
+ *s = talloc_array(mem_ctx, char, len+1);
if (! *s) {
- data->has_error = True;
- return False;
+ data->has_error = true;
+ return false;
}
asn1_read(data, *s, len);
(*s)[len] = 0;
@@ -612,29 +615,29 @@ BOOL asn1_read_LDAPString(struct asn1_data *data, TALLOC_CTX *mem_ctx, char **s)
/* read a GeneralString from a ASN1 buffer */
-BOOL asn1_read_GeneralString(struct asn1_data *data, TALLOC_CTX *mem_ctx, char **s)
+bool asn1_read_GeneralString(struct asn1_data *data, TALLOC_CTX *mem_ctx, char **s)
{
- if (!asn1_start_tag(data, ASN1_GENERAL_STRING)) return False;
- if (!asn1_read_LDAPString(data, mem_ctx, s)) return False;
+ if (!asn1_start_tag(data, ASN1_GENERAL_STRING)) return false;
+ if (!asn1_read_LDAPString(data, mem_ctx, s)) return false;
return asn1_end_tag(data);
}
/* read a octet string blob */
-BOOL asn1_read_OctetString(struct asn1_data *data, TALLOC_CTX *mem_ctx, DATA_BLOB *blob)
+bool asn1_read_OctetString(struct asn1_data *data, TALLOC_CTX *mem_ctx, DATA_BLOB *blob)
{
int len;
ZERO_STRUCTP(blob);
- if (!asn1_start_tag(data, ASN1_OCTET_STRING)) return False;
+ if (!asn1_start_tag(data, ASN1_OCTET_STRING)) return false;
len = asn1_tag_remaining(data);
if (len < 0) {
- data->has_error = True;
- return False;
+ data->has_error = true;
+ return false;
}
*blob = data_blob_talloc(mem_ctx, NULL, len+1);
if (!blob->data) {
- data->has_error = True;
- return False;
+ data->has_error = true;
+ return false;
}
asn1_read(data, blob->data, len);
asn1_end_tag(data);
@@ -644,25 +647,25 @@ BOOL asn1_read_OctetString(struct asn1_data *data, TALLOC_CTX *mem_ctx, DATA_BLO
if (data->has_error) {
data_blob_free(blob);
*blob = data_blob(NULL, 0);
- return False;
+ return false;
}
- return True;
+ return true;
}
-BOOL asn1_read_ContextSimple(struct asn1_data *data, uint8_t num, DATA_BLOB *blob)
+bool asn1_read_ContextSimple(struct asn1_data *data, uint8_t num, DATA_BLOB *blob)
{
int len;
ZERO_STRUCTP(blob);
- if (!asn1_start_tag(data, ASN1_CONTEXT_SIMPLE(num))) return False;
+ if (!asn1_start_tag(data, ASN1_CONTEXT_SIMPLE(num))) return false;
len = asn1_tag_remaining(data);
if (len < 0) {
- data->has_error = True;
- return False;
+ data->has_error = true;
+ return false;
}
*blob = data_blob(NULL, len);
if ((len != 0) && (!blob->data)) {
- data->has_error = True;
- return False;
+ data->has_error = true;
+ return false;
}
asn1_read(data, blob->data, len);
asn1_end_tag(data);
@@ -670,13 +673,13 @@ BOOL asn1_read_ContextSimple(struct asn1_data *data, uint8_t num, DATA_BLOB *blo
}
/* read an interger without tag*/
-BOOL asn1_read_implicit_Integer(struct asn1_data *data, int *i)
+bool asn1_read_implicit_Integer(struct asn1_data *data, int *i)
{
uint8_t b;
*i = 0;
while (!data->has_error && asn1_tag_remaining(data)>0) {
- if (!asn1_read_uint8(data, &b)) return False;
+ if (!asn1_read_uint8(data, &b)) return false;
*i = (*i << 8) + b;
}
return !data->has_error;
@@ -684,21 +687,21 @@ BOOL asn1_read_implicit_Integer(struct asn1_data *data, int *i)
}
/* read an interger */
-BOOL asn1_read_Integer(struct asn1_data *data, int *i)
+bool asn1_read_Integer(struct asn1_data *data, int *i)
{
*i = 0;
- if (!asn1_start_tag(data, ASN1_INTEGER)) return False;
- if (!asn1_read_implicit_Integer(data, i)) return False;
+ if (!asn1_start_tag(data, ASN1_INTEGER)) return false;
+ if (!asn1_read_implicit_Integer(data, i)) return false;
return asn1_end_tag(data);
}
/* read an interger */
-BOOL asn1_read_enumerated(struct asn1_data *data, int *v)
+bool asn1_read_enumerated(struct asn1_data *data, int *v)
{
*v = 0;
- if (!asn1_start_tag(data, ASN1_ENUMERATED)) return False;
+ if (!asn1_start_tag(data, ASN1_ENUMERATED)) return false;
while (!data->has_error && asn1_tag_remaining(data)>0) {
uint8_t b;
asn1_read_uint8(data, &b);
@@ -708,23 +711,23 @@ BOOL asn1_read_enumerated(struct asn1_data *data, int *v)
}
/* check a enumarted value is correct */
-BOOL asn1_check_enumerated(struct asn1_data *data, int v)
+bool asn1_check_enumerated(struct asn1_data *data, int v)
{
uint8_t b;
- if (!asn1_start_tag(data, ASN1_ENUMERATED)) return False;
+ if (!asn1_start_tag(data, ASN1_ENUMERATED)) return false;
asn1_read_uint8(data, &b);
asn1_end_tag(data);
if (v != b)
- data->has_error = False;
+ data->has_error = false;
return !data->has_error;
}
/* write an enumarted value to the stream */
-BOOL asn1_write_enumerated(struct asn1_data *data, uint8_t v)
+bool asn1_write_enumerated(struct asn1_data *data, uint8_t v)
{
- if (!asn1_push_tag(data, ASN1_ENUMERATED)) return False;
+ if (!asn1_push_tag(data, ASN1_ENUMERATED)) return false;
asn1_write_uint8(data, v);
asn1_pop_tag(data);
return !data->has_error;
diff --git a/source4/libcli/util/clilsa.c b/source4/libcli/util/clilsa.c
index 6fd84bbe74..7c32294648 100644
--- a/source4/libcli/util/clilsa.c
+++ b/source4/libcli/util/clilsa.c
@@ -31,6 +31,7 @@
#include "libcli/security/security.h"
#include "librpc/gen_ndr/ndr_lsa.h"
#include "librpc/gen_ndr/ndr_lsa_c.h"
+#include "libcli/util/clilsa.h"
struct smblsa_state {
struct dcerpc_pipe *pipe;
@@ -60,7 +61,7 @@ static NTSTATUS smblsa_connect(struct smbcli_state *cli)
return NT_STATUS_NO_MEMORY;
}
- lsa->ipc_tree = smbcli_tree_init(cli->session, lsa, False);
+ lsa->ipc_tree = smbcli_tree_init(cli->session, lsa, false);
if (lsa->ipc_tree == NULL) {
return NT_STATUS_NO_MEMORY;
}
diff --git a/source4/libcli/util/doserr.c b/source4/libcli/util/doserr.c
index d62a31c1fa..49818e573a 100644
--- a/source4/libcli/util/doserr.c
+++ b/source4/libcli/util/doserr.c
@@ -20,7 +20,6 @@
/* DOS error codes. please read doserr.h */
#include "includes.h"
-#include "pstring.h"
struct werror_code_struct {
const char *dos_errstr;
@@ -133,7 +132,7 @@ static const struct werror_code_struct dos_errs[] =
*****************************************************************************/
const char *win_errstr(WERROR werror)
{
- static pstring msg;
+ static char msg[40];
int idx = 0;
while (dos_errs[idx].dos_errstr != NULL) {
diff --git a/source4/libcli/util/doserr.h b/source4/libcli/util/doserr.h
index 0478eff947..bec268a565 100644
--- a/source4/libcli/util/doserr.h
+++ b/source4/libcli/util/doserr.h
@@ -161,133 +161,8 @@
#define ERRsharebufexc 36 /* share buffer exceeded */
#define ERRdiskfull 39
-
-/* these are win32 error codes. There are only a few places where
- these matter for Samba, primarily in the NT printing code */
-#define WERR_OK W_ERROR(0)
-#define WERR_BADFUNC W_ERROR(1)
-#define WERR_BADFILE W_ERROR(2)
-#define WERR_ACCESS_DENIED W_ERROR(5)
-#define WERR_BADFID W_ERROR(6)
-#define WERR_NOMEM W_ERROR(8)
-#define WERR_GENERAL_FAILURE W_ERROR(31)
-#define WERR_NOT_SUPPORTED W_ERROR(50)
-#define WERR_BAD_NETPATH W_ERROR(53)
-#define WERR_BAD_NET_RESP W_ERROR(58)
-#define WERR_UNEXP_NET_ERR W_ERROR(59)
-#define WERR_PRINTQ_FULL W_ERROR(61)
-#define WERR_NO_SPOOL_SPACE W_ERROR(62)
-#define WERR_NO_SUCH_SHARE W_ERROR(67)
-#define WERR_FILE_EXISTS W_ERROR(80)
-#define WERR_BAD_PASSWORD W_ERROR(86)
-#define WERR_INVALID_PARAM W_ERROR(87)
-#define WERR_INSUFFICIENT_BUFFER W_ERROR(122)
-#define WERR_INVALID_NAME W_ERROR(123)
-#define WERR_UNKNOWN_LEVEL W_ERROR(124)
-#define WERR_OBJECT_PATH_INVALID W_ERROR(161)
-#define WERR_ALREADY_EXISTS W_ERROR(183)
-#define WERR_NO_MORE_ITEMS W_ERROR(259)
-#define WERR_MORE_DATA W_ERROR(234)
-#define WERR_CAN_NOT_COMPLETE W_ERROR(1003)
-#define WERR_NOT_FOUND W_ERROR(1168)
-#define WERR_INVALID_COMPUTERNAME W_ERROR(1210)
-#define WERR_INVALID_DOMAINNAME W_ERROR(1212)
-#define WERR_UNKNOWN_REVISION W_ERROR(1305)
-#define WERR_REVISION_MISMATCH W_ERROR(1306)
-#define WERR_INVALID_OWNER W_ERROR(1307)
-#define WERR_NO_LOGON_SERVERS W_ERROR(1311)
-#define WERR_NO_SUCH_PRIVILEGE W_ERROR(1313)
-#define WERR_PRIVILEGE_NOT_HELD W_ERROR(1314)
-#define WERR_NO_SUCH_USER W_ERROR(1317)
-#define WERR_LOGON_FAILURE W_ERROR(1326)
-#define WERR_INVALID_SECURITY_DESCRIPTOR W_ERROR(1338)
-#define WERR_INVALID_DOMAIN_ROLE W_ERROR(1354)
-#define WERR_NO_SUCH_DOMAIN W_ERROR(1355)
-#define WERR_NO_SYSTEM_RESOURCES W_ERROR(1450)
-#define WERR_SERVER_UNAVAILABLE W_ERROR(1722)
-#define WERR_INVALID_FORM_NAME W_ERROR(1902)
-#define WERR_INVALID_FORM_SIZE W_ERROR(1903)
-#define WERR_ALREADY_SHARED W_ERROR(2118)
-#define WERR_BUF_TOO_SMALL W_ERROR(2123)
-#define WERR_JOB_NOT_FOUND W_ERROR(2151)
-#define WERR_DEST_NOT_FOUND W_ERROR(2152)
-#define WERR_SESSION_NOT_FOUND W_ERROR(2312)
-#define WERR_FID_NOT_FOUND W_ERROR(2314)
-#define WERR_NOT_LOCAL_DOMAIN W_ERROR(2320)
-#define WERR_DOMAIN_CONTROLLER_NOT_FOUND W_ERROR(2453)
-#define WERR_DEVICE_NOT_AVAILABLE W_ERROR(4319)
-#define WERR_STATUS_MORE_ENTRIES W_ERROR(0x0105)
-
-#define WERR_PRINTER_DRIVER_ALREADY_INSTALLED W_ERROR(ERRdriveralreadyinstalled)
-#define WERR_UNKNOWN_PORT W_ERROR(ERRunknownprinterport)
-#define WERR_UNKNOWN_PRINTER_DRIVER W_ERROR(ERRunknownprinterdriver)
-#define WERR_UNKNOWN_PRINTPROCESSOR W_ERROR(ERRunknownprintprocessor)
-#define WERR_INVALID_SEPARATOR_FILE W_ERROR(ERRinvalidseparatorfile)
-#define WERR_INVALID_PRIORITY W_ERROR(ERRinvalidjobpriority)
-#define WERR_INVALID_PRINTER_NAME W_ERROR(ERRinvalidprintername)
-#define WERR_PRINTER_ALREADY_EXISTS W_ERROR(ERRprinteralreadyexists)
-#define WERR_INVALID_PRINTER_COMMAND W_ERROR(ERRinvalidprintercommand)
-#define WERR_INVALID_DATATYPE W_ERROR(ERRinvaliddatatype)
-#define WERR_INVALID_ENVIRONMENT W_ERROR(ERRinvalidenvironment)
-
-#define WERR_UNKNOWN_PRINT_MONITOR W_ERROR(ERRunknownprintmonitor)
-#define WERR_PRINTER_DRIVER_IN_USE W_ERROR(ERRprinterdriverinuse)
-#define WERR_SPOOL_FILE_NOT_FOUND W_ERROR(ERRspoolfilenotfound)
-#define WERR_SPL_NO_STARTDOC W_ERROR(ERRnostartdoc)
-#define WERR_SPL_NO_ADDJOB W_ERROR(ERRnoaddjob)
-#define WERR_PRINT_PROCESSOR_ALREADY_INSTALLED W_ERROR(ERRprintprocessoralreadyinstalled)
-#define WERR_PRINT_MONITOR_ALREADY_INSTALLED W_ERROR(ERRprintmonitoralreadyinstalled)
-#define WERR_INVALID_PRINT_MONITOR W_ERROR(ERRinvalidprintmonitor)
-#define WERR_PRINT_MONITOR_IN_USE W_ERROR(ERRprintmonitorinuse)
-#define WERR_PRINTER_HAS_JOBS_QUEUED W_ERROR(ERRprinterhasjobsqueued)
-
-#define WERR_CLASS_NOT_REGISTERED W_ERROR(0x40154)
-#define WERR_NO_SHUTDOWN_IN_PROGRESS W_ERROR(0x45c)
-#define WERR_SHUTDOWN_ALREADY_IN_PROGRESS W_ERROR(0x45b)
-
-
#ifndef NERR_BASE
#define NERR_BASE (2100)
#endif
-#define WERR_NET_NAME_NOT_FOUND W_ERROR(NERR_BASE+210)
-#define WERR_DEVICE_NOT_SHARED W_ERROR(NERR_BASE+211)
-
-/* DFS errors */
-#define WERR_DFS_NO_SUCH_VOL W_ERROR(NERR_BASE+562)
-#define WERR_DFS_NO_SUCH_SHARE W_ERROR(NERR_BASE+565)
-#define WERR_DFS_NO_SUCH_SERVER W_ERROR(NERR_BASE+573)
-#define WERR_DFS_INTERNAL_ERROR W_ERROR(NERR_BASE+590)
-#define WERR_DFS_CANT_CREATE_JUNCT W_ERROR(NERR_BASE+569)
-
-/* DS errors */
-#define WERR_DS_SERVICE_BUSY W_ERROR(0x0000200e)
-#define WERR_DS_SERVICE_UNAVAILABLE W_ERROR(0x0000200f)
-#define WERR_DS_NO_SUCH_OBJECT W_ERROR(0x00002030)
-#define WERR_DS_OBJ_NOT_FOUND W_ERROR(0x0000208d)
-#define WERR_DS_SCHEMA_NOT_LOADED W_ERROR(0x20de)
-#define WERR_DS_SCHEMA_ALLOC_FAILED W_ERROR(0x20df)
-#define WERR_DS_ATT_SCHEMA_REQ_SYNTAX W_ERROR(0x000020e0)
-#define WERR_DS_DRA_SCHEMA_MISMATCH W_ERROR(0x000020e2)
-#define WERR_DS_DRA_INVALID_PARAMETER W_ERROR(0x000020f5)
-#define WERR_DS_DRA_BAD_DN W_ERROR(0x000020f7)
-#define WERR_DS_DRA_BAD_NC W_ERROR(0x000020f8)
-#define WERR_DS_DRA_INTERNAL_ERROR W_ERROR(0x000020fa)
-#define WERR_DS_DRA_OUT_OF_MEM W_ERROR(0x000020fe)
-#define WERR_DS_SINGLE_VALUE_CONSTRAINT W_ERROR(0x00002081)
-#define WERR_DS_DRA_DB_ERROR W_ERROR(0x00002103)
-#define WERR_DS_DRA_NO_REPLICA W_ERROR(0x00002104)
-#define WERR_DS_DRA_ACCESS_DENIED W_ERROR(0x00002105)
-#define WERR_DS_DNS_LOOKUP_FAILURE W_ERROR(0x0000214c)
-#define WERR_DS_WRONG_LINKED_ATTRIBUTE_SYNTAX W_ERROR(0x00002150)
-#define WERR_DS_NO_MSDS_INTID W_ERROR(0x00002194)
-#define WERR_DS_DUP_MSDS_INTID W_ERROR(0x00002195)
-
-/* SEC errors */
-#define WERR_SEC_E_ENCRYPT_FAILURE W_ERROR(0x80090329)
-#define WERR_SEC_E_DECRYPT_FAILURE W_ERROR(0x80090330)
-#define WERR_SEC_E_ALGORITHM_MISMATCH W_ERROR(0x80090331)
-
-#define WERR_FOOBAR WERR_GENERAL_FAILURE
-
#endif /* _DOSERR_H */
diff --git a/source4/libcli/util/error.h b/source4/libcli/util/error.h
index 8a641c8eb9..dd2de3da75 100644
--- a/source4/libcli/util/error.h
+++ b/source4/libcli/util/error.h
@@ -19,8 +19,33 @@
#ifndef _SAMBA_ERROR_H_
#define _SAMBA_ERROR_H_
-#include "libcli/util/nterr.h"
+#include "libcli/util/werror.h"
#include "libcli/util/doserr.h"
-#include "libcli/util/proto.h"
+#include "libcli/util/ntstatus.h"
+
+/** NT error on DOS connection! (NT_STATUS_OK) */
+bool ntstatus_dos_equal(NTSTATUS status1, NTSTATUS status2);
+
+/*****************************************************************************
+convert a NT status code to a dos class/code
+ *****************************************************************************/
+void ntstatus_to_dos(NTSTATUS ntstatus, uint8_t *eclass, uint32_t *ecode);
+
+/*****************************************************************************
+convert a WERROR to a NT status32 code
+ *****************************************************************************/
+NTSTATUS werror_to_ntstatus(WERROR error);
+
+/*****************************************************************************
+convert a NTSTATUS to a WERROR
+ *****************************************************************************/
+WERROR ntstatus_to_werror(NTSTATUS error);
+
+/*********************************************************************
+ Map an NT error code from a Unix error code.
+*********************************************************************/
+NTSTATUS map_nt_error_from_unix(int unix_error);
+
+
#endif /* _SAMBA_ERROR_H */
diff --git a/source4/libcli/util/errormap.c b/source4/libcli/util/errormap.c
index 711f02a626..8d088e1e4b 100644
--- a/source4/libcli/util/errormap.c
+++ b/source4/libcli/util/errormap.c
@@ -20,6 +20,7 @@
*/
#include "includes.h"
+#include "param/param.h"
/* This map was extracted by the ERRMAPEXTRACT smbtorture command.
The setup was a Samba HEAD (2002-01-03) PDC and an Win2k member
@@ -1161,13 +1162,13 @@ static const struct {
/*
check if a DOS encoded NTSTATUS code maps to the given NTSTATUS code
*/
-BOOL ntstatus_dos_equal(NTSTATUS status1, NTSTATUS status2)
+bool ntstatus_dos_equal(NTSTATUS status1, NTSTATUS status2)
{
/* when we negotiate nt status support, we don't want to consider
the mapping of dos codes, as we want to catch the cases where
a forced dos code is needed
*/
- if (lp_nt_status_support()) {
+ if (lp_nt_status_support(global_loadparm)) {
return NT_STATUS_V(status1) == NT_STATUS_V(status2);
}
diff --git a/source4/libcli/util/nt_status.h b/source4/libcli/util/nt_status.h
deleted file mode 100644
index 8d81aab175..0000000000
--- a/source4/libcli/util/nt_status.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- SMB parameters and setup, plus a whole lot more.
-
- Copyright (C) Andrew Tridgell 2001
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef _NT_STATUS_H
-#define _NT_STATUS_H
-
-#include <stdint.h>
-
-/* the following rather strange looking definitions of NTSTATUS and WERROR
- and there in order to catch common coding errors where different error types
- are mixed up. This is especially important as we slowly convert Samba
- from using BOOL for internal functions
-*/
-
-#if defined(HAVE_IMMEDIATE_STRUCTURES)
-typedef struct {uint32_t v;} NTSTATUS;
-#define NT_STATUS(x) ((NTSTATUS) { x })
-#define NT_STATUS_V(x) ((x).v)
-#else
-typedef uint32_t NTSTATUS;
-#define NT_STATUS(x) (x)
-#define NT_STATUS_V(x) (x)
-#endif
-
-#if defined(HAVE_IMMEDIATE_STRUCTURES)
-typedef struct {uint32_t v;} WERROR;
-#define W_ERROR(x) ((WERROR) { x })
-#define W_ERROR_V(x) ((x).v)
-#else
-typedef uint32_t WERROR;
-#define W_ERROR(x) (x)
-#define W_ERROR_V(x) (x)
-#endif
-
-#define NT_STATUS_IS_OK(x) (NT_STATUS_V(x) == 0)
-#define NT_STATUS_IS_ERR(x) ((NT_STATUS_V(x) & 0xc0000000) == 0xc0000000)
-/* checking for DOS error mapping here is ugly, but unfortunately the
- alternative is a very intrusive rewrite of the torture code */
-#define NT_STATUS_EQUAL(x,y) (NT_STATUS_IS_DOS(x)||NT_STATUS_IS_DOS(y)?ntstatus_dos_equal(x,y):NT_STATUS_V(x) == NT_STATUS_V(y))
-
-#define NT_STATUS_HAVE_NO_MEMORY(x) do { \
- if (!(x)) {\
- return NT_STATUS_NO_MEMORY;\
- }\
-} while (0)
-
-#define NT_STATUS_IS_OK_RETURN(x) do { \
- if (NT_STATUS_IS_OK(x)) {\
- return x;\
- }\
-} while (0)
-
-#define NT_STATUS_NOT_OK_RETURN(x) do { \
- if (!NT_STATUS_IS_OK(x)) {\
- return x;\
- }\
-} while (0)
-
-#define NT_STATUS_IS_ERR_RETURN(x) do { \
- if (NT_STATUS_IS_ERR(x)) {\
- return x;\
- }\
-} while (0)
-
-#define NT_STATUS_NOT_ERR_RETURN(x) do { \
- if (!NT_STATUS_IS_ERR(x)) {\
- return x;\
- }\
-} while (0)
-
-#define W_ERROR_IS_OK(x) (W_ERROR_V(x) == 0)
-#define W_ERROR_EQUAL(x,y) (W_ERROR_V(x) == W_ERROR_V(y))
-
-#define W_ERROR_HAVE_NO_MEMORY(x) do { \
- if (!(x)) {\
- return WERR_NOMEM;\
- }\
-} while (0)
-
-#define W_ERROR_IS_OK_RETURN(x) do { \
- if (W_ERROR_IS_OK(x)) {\
- return x;\
- }\
-} while (0)
-
-#define W_ERROR_NOT_OK_RETURN(x) do { \
- if (!W_ERROR_IS_OK(x)) {\
- return x;\
- }\
-} while (0)
-
-/* this defines special NTSTATUS codes to represent DOS errors. I
- have chosen this macro to produce status codes in the invalid
- NTSTATUS range */
-#define NT_STATUS_DOS(class, code) NT_STATUS(0xF1000000 | ((class)<<16) | code)
-#define NT_STATUS_IS_DOS(status) ((NT_STATUS_V(status) & 0xFF000000) == 0xF1000000)
-#define NT_STATUS_DOS_CLASS(status) ((NT_STATUS_V(status) >> 16) & 0xFF)
-#define NT_STATUS_DOS_CODE(status) (NT_STATUS_V(status) & 0xFFFF)
-
-/* define ldap error codes as NTSTATUS codes */
-#define NT_STATUS_LDAP(code) NT_STATUS(0xF2000000 | code)
-#define NT_STATUS_IS_LDAP(status) ((NT_STATUS_V(status) & 0xFF000000) == 0xF2000000)
-#define NT_STATUS_LDAP_CODE(status) (NT_STATUS_V(status) & ~0xFF000000)
-
-#endif
diff --git a/source4/libcli/util/nterr.c b/source4/libcli/util/nterr.c
index 3aea0b51bc..b1f345016d 100644
--- a/source4/libcli/util/nterr.c
+++ b/source4/libcli/util/nterr.c
@@ -20,7 +20,6 @@
/* NT error codes. please read nterr.h */
#include "includes.h"
-#include "pstring.h"
#include "libcli/ldap/ldap.h"
typedef struct
@@ -862,7 +861,7 @@ const char *get_friendly_nt_error_msg(NTSTATUS nt_code)
*****************************************************************************/
const char *get_nt_error_c_code(NTSTATUS nt_code)
{
- static pstring out;
+ static char out[40];
int idx = 0;
while (nt_errs[idx].nt_errstr != NULL) {
diff --git a/source4/libcli/util/nterr.h b/source4/libcli/util/ntstatus.h
index 1ee867a0aa..026b5162db 100644
--- a/source4/libcli/util/nterr.h
+++ b/source4/libcli/util/ntstatus.h
@@ -20,8 +20,24 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef _NTERR_H
-#define _NTERR_H
+#ifndef _NTSTATUS_H
+#define _NTSTATUS_H
+
+/* the following rather strange looking definitions of NTSTATUS
+ are there in order to catch common coding errors where different error types
+ are mixed up. This is especially important as we slowly convert Samba
+ from using bool for internal functions
+*/
+
+#if defined(HAVE_IMMEDIATE_STRUCTURES)
+typedef struct {uint32_t v;} NTSTATUS;
+#define NT_STATUS(x) ((NTSTATUS) { x })
+#define NT_STATUS_V(x) ((x).v)
+#else
+typedef uint32_t NTSTATUS;
+#define NT_STATUS(x) (x)
+#define NT_STATUS_V(x) (x)
+#endif
/* Win32 Status codes. */
@@ -585,4 +601,75 @@
* this means we need a torture test */
#define NT_STATUS_FOOBAR NT_STATUS_UNSUCCESSFUL
-#endif /* _NTERR_H */
+/*****************************************************************************
+ returns an NT error message. not amazingly helpful, but better than a number.
+ *****************************************************************************/
+const char *nt_errstr(NTSTATUS nt_code);
+
+/************************************************************************
+ Print friendler version fo NT error code
+ ***********************************************************************/
+const char *get_friendly_nt_error_msg(NTSTATUS nt_code);
+
+/*****************************************************************************
+ returns an NT_STATUS constant as a string for inclusion in autogen C code
+ *****************************************************************************/
+const char *get_nt_error_c_code(NTSTATUS nt_code);
+
+/*****************************************************************************
+ returns the NT_STATUS constant matching the string supplied (as an NTSTATUS)
+ *****************************************************************************/
+NTSTATUS nt_status_string_to_code(const char *nt_status_str);
+
+#define NT_STATUS_IS_OK(x) (NT_STATUS_V(x) == 0)
+#define NT_STATUS_IS_ERR(x) ((NT_STATUS_V(x) & 0xc0000000) == 0xc0000000)
+/* checking for DOS error mapping here is ugly, but unfortunately the
+ alternative is a very intrusive rewrite of the torture code */
+#define NT_STATUS_EQUAL(x,y) (NT_STATUS_IS_DOS(x)||NT_STATUS_IS_DOS(y)?ntstatus_dos_equal(x,y):NT_STATUS_V(x) == NT_STATUS_V(y))
+
+#define NT_STATUS_HAVE_NO_MEMORY(x) do { \
+ if (!(x)) {\
+ return NT_STATUS_NO_MEMORY;\
+ }\
+} while (0)
+
+#define NT_STATUS_IS_OK_RETURN(x) do { \
+ if (NT_STATUS_IS_OK(x)) {\
+ return x;\
+ }\
+} while (0)
+
+#define NT_STATUS_NOT_OK_RETURN(x) do { \
+ if (!NT_STATUS_IS_OK(x)) {\
+ return x;\
+ }\
+} while (0)
+
+#define NT_STATUS_IS_ERR_RETURN(x) do { \
+ if (NT_STATUS_IS_ERR(x)) {\
+ return x;\
+ }\
+} while (0)
+
+#define NT_STATUS_NOT_ERR_RETURN(x) do { \
+ if (!NT_STATUS_IS_ERR(x)) {\
+ return x;\
+ }\
+} while (0)
+
+/* this defines special NTSTATUS codes to represent DOS errors. I
+ have chosen this macro to produce status codes in the invalid
+ NTSTATUS range */
+#define NT_STATUS_DOS(class, code) NT_STATUS(0xF1000000 | ((class)<<16) | code)
+#define NT_STATUS_IS_DOS(status) ((NT_STATUS_V(status) & 0xFF000000) == 0xF1000000)
+#define NT_STATUS_DOS_CLASS(status) ((NT_STATUS_V(status) >> 16) & 0xFF)
+#define NT_STATUS_DOS_CODE(status) (NT_STATUS_V(status) & 0xFFFF)
+
+/* define ldap error codes as NTSTATUS codes */
+#define NT_STATUS_LDAP(code) NT_STATUS(0xF2000000 | code)
+#define NT_STATUS_IS_LDAP(status) ((NT_STATUS_V(status) & 0xFF000000) == 0xF2000000)
+#define NT_STATUS_LDAP_CODE(status) (NT_STATUS_V(status) & ~0xFF000000)
+
+
+
+#endif /* _NTSTATUS_H */
diff --git a/source4/libcli/util/werror.h b/source4/libcli/util/werror.h
new file mode 100644
index 0000000000..55a4faa6a5
--- /dev/null
+++ b/source4/libcli/util/werror.h
@@ -0,0 +1,193 @@
+/*
+ Unix SMB/CIFS implementation.
+ SMB parameters and setup, plus a whole lot more.
+
+ Copyright (C) Andrew Tridgell 2001
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _WERROR_H_
+#define _WERROR_H_
+
+#include <stdint.h>
+
+/* the following rather strange looking definitions of NTSTATUS and WERROR
+ and there in order to catch common coding errors where different error types
+ are mixed up. This is especially important as we slowly convert Samba
+ from using bool for internal functions
+*/
+
+#if defined(HAVE_IMMEDIATE_STRUCTURES)
+typedef struct {uint32_t v;} WERROR;
+#define W_ERROR(x) ((WERROR) { x })
+#define W_ERROR_V(x) ((x).v)
+#else
+typedef uint32_t WERROR;
+#define W_ERROR(x) (x)
+#define W_ERROR_V(x) (x)
+#endif
+
+#define W_ERROR_IS_OK(x) (W_ERROR_V(x) == 0)
+#define W_ERROR_EQUAL(x,y) (W_ERROR_V(x) == W_ERROR_V(y))
+
+#define W_ERROR_HAVE_NO_MEMORY(x) do { \
+ if (!(x)) {\
+ return WERR_NOMEM;\
+ }\
+} while (0)
+
+#define W_ERROR_IS_OK_RETURN(x) do { \
+ if (W_ERROR_IS_OK(x)) {\
+ return x;\
+ }\
+} while (0)
+
+#define W_ERROR_NOT_OK_RETURN(x) do { \
+ if (!W_ERROR_IS_OK(x)) {\
+ return x;\
+ }\
+} while (0)
+
+/* these are win32 error codes. There are only a few places where
+ these matter for Samba, primarily in the NT printing code */
+#define WERR_OK W_ERROR(0)
+#define WERR_BADFUNC W_ERROR(1)
+#define WERR_BADFILE W_ERROR(2)
+#define WERR_ACCESS_DENIED W_ERROR(5)
+#define WERR_BADFID W_ERROR(6)
+#define WERR_NOMEM W_ERROR(8)
+#define WERR_GENERAL_FAILURE W_ERROR(31)
+#define WERR_NOT_SUPPORTED W_ERROR(50)
+#define WERR_BAD_NETPATH W_ERROR(53)
+#define WERR_BAD_NET_RESP W_ERROR(58)
+#define WERR_UNEXP_NET_ERR W_ERROR(59)
+#define WERR_PRINTQ_FULL W_ERROR(61)
+#define WERR_NO_SPOOL_SPACE W_ERROR(62)
+#define WERR_NO_SUCH_SHARE W_ERROR(67)
+#define WERR_FILE_EXISTS W_ERROR(80)
+#define WERR_BAD_PASSWORD W_ERROR(86)
+#define WERR_INVALID_PARAM W_ERROR(87)
+#define WERR_INSUFFICIENT_BUFFER W_ERROR(122)
+#define WERR_INVALID_NAME W_ERROR(123)
+#define WERR_UNKNOWN_LEVEL W_ERROR(124)
+#define WERR_OBJECT_PATH_INVALID W_ERROR(161)
+#define WERR_ALREADY_EXISTS W_ERROR(183)
+#define WERR_NO_MORE_ITEMS W_ERROR(259)
+#define WERR_MORE_DATA W_ERROR(234)
+#define WERR_CAN_NOT_COMPLETE W_ERROR(1003)
+#define WERR_NOT_FOUND W_ERROR(1168)
+#define WERR_INVALID_COMPUTERNAME W_ERROR(1210)
+#define WERR_INVALID_DOMAINNAME W_ERROR(1212)
+#define WERR_UNKNOWN_REVISION W_ERROR(1305)
+#define WERR_REVISION_MISMATCH W_ERROR(1306)
+#define WERR_INVALID_OWNER W_ERROR(1307)
+#define WERR_NO_LOGON_SERVERS W_ERROR(1311)
+#define WERR_NO_SUCH_PRIVILEGE W_ERROR(1313)
+#define WERR_PRIVILEGE_NOT_HELD W_ERROR(1314)
+#define WERR_NO_SUCH_USER W_ERROR(1317)
+#define WERR_LOGON_FAILURE W_ERROR(1326)
+#define WERR_INVALID_SECURITY_DESCRIPTOR W_ERROR(1338)
+#define WERR_INVALID_DOMAIN_ROLE W_ERROR(1354)
+#define WERR_NO_SUCH_DOMAIN W_ERROR(1355)
+#define WERR_NO_SYSTEM_RESOURCES W_ERROR(1450)
+#define WERR_SERVER_UNAVAILABLE W_ERROR(1722)
+#define WERR_INVALID_FORM_NAME W_ERROR(1902)
+#define WERR_INVALID_FORM_SIZE W_ERROR(1903)
+#define WERR_ALREADY_SHARED W_ERROR(2118)
+#define WERR_BUF_TOO_SMALL W_ERROR(2123)
+#define WERR_JOB_NOT_FOUND W_ERROR(2151)
+#define WERR_DEST_NOT_FOUND W_ERROR(2152)
+#define WERR_SESSION_NOT_FOUND W_ERROR(2312)
+#define WERR_FID_NOT_FOUND W_ERROR(2314)
+#define WERR_NOT_LOCAL_DOMAIN W_ERROR(2320)
+#define WERR_DOMAIN_CONTROLLER_NOT_FOUND W_ERROR(2453)
+#define WERR_DEVICE_NOT_AVAILABLE W_ERROR(4319)
+#define WERR_STATUS_MORE_ENTRIES W_ERROR(0x0105)
+
+#define WERR_PRINTER_DRIVER_ALREADY_INSTALLED W_ERROR(ERRdriveralreadyinstalled)
+#define WERR_UNKNOWN_PORT W_ERROR(ERRunknownprinterport)
+#define WERR_UNKNOWN_PRINTER_DRIVER W_ERROR(ERRunknownprinterdriver)
+#define WERR_UNKNOWN_PRINTPROCESSOR W_ERROR(ERRunknownprintprocessor)
+#define WERR_INVALID_SEPARATOR_FILE W_ERROR(ERRinvalidseparatorfile)
+#define WERR_INVALID_PRIORITY W_ERROR(ERRinvalidjobpriority)
+#define WERR_INVALID_PRINTER_NAME W_ERROR(ERRinvalidprintername)
+#define WERR_PRINTER_ALREADY_EXISTS W_ERROR(ERRprinteralreadyexists)
+#define WERR_INVALID_PRINTER_COMMAND W_ERROR(ERRinvalidprintercommand)
+#define WERR_INVALID_DATATYPE W_ERROR(ERRinvaliddatatype)
+#define WERR_INVALID_ENVIRONMENT W_ERROR(ERRinvalidenvironment)
+
+#define WERR_UNKNOWN_PRINT_MONITOR W_ERROR(ERRunknownprintmonitor)
+#define WERR_PRINTER_DRIVER_IN_USE W_ERROR(ERRprinterdriverinuse)
+#define WERR_SPOOL_FILE_NOT_FOUND W_ERROR(ERRspoolfilenotfound)
+#define WERR_SPL_NO_STARTDOC W_ERROR(ERRnostartdoc)
+#define WERR_SPL_NO_ADDJOB W_ERROR(ERRnoaddjob)
+#define WERR_PRINT_PROCESSOR_ALREADY_INSTALLED W_ERROR(ERRprintprocessoralreadyinstalled)
+#define WERR_PRINT_MONITOR_ALREADY_INSTALLED W_ERROR(ERRprintmonitoralreadyinstalled)
+#define WERR_INVALID_PRINT_MONITOR W_ERROR(ERRinvalidprintmonitor)
+#define WERR_PRINT_MONITOR_IN_USE W_ERROR(ERRprintmonitorinuse)
+#define WERR_PRINTER_HAS_JOBS_QUEUED W_ERROR(ERRprinterhasjobsqueued)
+
+#define WERR_CLASS_NOT_REGISTERED W_ERROR(0x40154)
+#define WERR_NO_SHUTDOWN_IN_PROGRESS W_ERROR(0x45c)
+#define WERR_SHUTDOWN_ALREADY_IN_PROGRESS W_ERROR(0x45b)
+
+#define WERR_NET_NAME_NOT_FOUND W_ERROR(NERR_BASE+210)
+#define WERR_DEVICE_NOT_SHARED W_ERROR(NERR_BASE+211)
+
+/* DFS errors */
+#define WERR_DFS_NO_SUCH_VOL W_ERROR(NERR_BASE+562)
+#define WERR_DFS_NO_SUCH_SHARE W_ERROR(NERR_BASE+565)
+#define WERR_DFS_NO_SUCH_SERVER W_ERROR(NERR_BASE+573)
+#define WERR_DFS_INTERNAL_ERROR W_ERROR(NERR_BASE+590)
+#define WERR_DFS_CANT_CREATE_JUNCT W_ERROR(NERR_BASE+569)
+
+/* DS errors */
+#define WERR_DS_SERVICE_BUSY W_ERROR(0x0000200e)
+#define WERR_DS_SERVICE_UNAVAILABLE W_ERROR(0x0000200f)
+#define WERR_DS_NO_SUCH_OBJECT W_ERROR(0x00002030)
+#define WERR_DS_OBJ_NOT_FOUND W_ERROR(0x0000208d)
+#define WERR_DS_SCHEMA_NOT_LOADED W_ERROR(0x20de)
+#define WERR_DS_SCHEMA_ALLOC_FAILED W_ERROR(0x20df)
+#define WERR_DS_ATT_SCHEMA_REQ_SYNTAX W_ERROR(0x000020e0)
+#define WERR_DS_DRA_SCHEMA_MISMATCH W_ERROR(0x000020e2)
+#define WERR_DS_DRA_INVALID_PARAMETER W_ERROR(0x000020f5)
+#define WERR_DS_DRA_BAD_DN W_ERROR(0x000020f7)
+#define WERR_DS_DRA_BAD_NC W_ERROR(0x000020f8)
+#define WERR_DS_DRA_INTERNAL_ERROR W_ERROR(0x000020fa)
+#define WERR_DS_DRA_OUT_OF_MEM W_ERROR(0x000020fe)
+#define WERR_DS_SINGLE_VALUE_CONSTRAINT W_ERROR(0x00002081)
+#define WERR_DS_DRA_DB_ERROR W_ERROR(0x00002103)
+#define WERR_DS_DRA_NO_REPLICA W_ERROR(0x00002104)
+#define WERR_DS_DRA_ACCESS_DENIED W_ERROR(0x00002105)
+#define WERR_DS_DNS_LOOKUP_FAILURE W_ERROR(0x0000214c)
+#define WERR_DS_WRONG_LINKED_ATTRIBUTE_SYNTAX W_ERROR(0x00002150)
+#define WERR_DS_NO_MSDS_INTID W_ERROR(0x00002194)
+#define WERR_DS_DUP_MSDS_INTID W_ERROR(0x00002195)
+
+/* SEC errors */
+#define WERR_SEC_E_ENCRYPT_FAILURE W_ERROR(0x80090329)
+#define WERR_SEC_E_DECRYPT_FAILURE W_ERROR(0x80090330)
+#define WERR_SEC_E_ALGORITHM_MISMATCH W_ERROR(0x80090331)
+
+#define WERR_FOOBAR WERR_GENERAL_FAILURE
+
+/*****************************************************************************
+ returns a windows error message. not amazingly helpful, but better than a number.
+ *****************************************************************************/
+const char *win_errstr(WERROR werror);
+
+
+
+#endif
diff --git a/source4/libcli/wrepl/winsrepl.c b/source4/libcli/wrepl/winsrepl.c
index 5b2a9e1e4a..90714f774b 100644
--- a/source4/libcli/wrepl/winsrepl.c
+++ b/source4/libcli/wrepl/winsrepl.c
@@ -37,7 +37,7 @@ static struct wrepl_request *wrepl_request_finished(struct wrepl_request *req, N
*/
static void wrepl_socket_dead(struct wrepl_socket *wrepl_socket, NTSTATUS status)
{
- wrepl_socket->dead = True;
+ wrepl_socket->dead = true;
if (wrepl_socket->packet) {
packet_recv_disable(wrepl_socket->packet);
@@ -148,7 +148,7 @@ static void wrepl_error(void *private, NTSTATUS status)
static int wrepl_socket_destructor(struct wrepl_socket *sock)
{
if (sock->dead) {
- sock->free_skipped = True;
+ sock->free_skipped = true;
return -1;
}
wrepl_socket_dead(sock, NT_STATUS_LOCAL_DISCONNECT);
@@ -387,7 +387,7 @@ static void wrepl_request_trigger_handler(struct event_context *ev, struct timed
/*
trigger an immediate event on a wrepl_request
the return value should only be used in wrepl_request_send()
- this is the only place where req->trigger is True
+ this is the only place where req->trigger is true
*/
static struct wrepl_request *wrepl_request_finished(struct wrepl_request *req, NTSTATUS status)
{
@@ -406,7 +406,7 @@ static struct wrepl_request *wrepl_request_finished(struct wrepl_request *req, N
req->status = status;
if (req->trigger) {
- req->trigger = False;
+ req->trigger = false;
/* a zero timeout means immediate */
te = event_add_timed(req->wrepl_socket->event.ctx,
req, timeval_zero(),
@@ -448,7 +448,7 @@ static int wrepl_send_ctrl_destructor(struct wrepl_send_ctrl_state *s)
/* here, we need to make sure the async request handler is called
* later in the next event_loop and now now
*/
- req->trigger = True;
+ req->trigger = true;
wrepl_request_finished(req, NT_STATUS_OK);
if (s->ctrl.disconnect_after_send) {
@@ -473,7 +473,7 @@ struct wrepl_request *wrepl_request_send(struct wrepl_socket *wrepl_socket,
if (!req) return NULL;
req->wrepl_socket = wrepl_socket;
req->state = WREPL_REQUEST_RECV;
- req->trigger = True;
+ req->trigger = true;
DLIST_ADD_END(wrepl_socket->recv_queue, req, struct wrepl_request *);
talloc_set_destructor(req, wrepl_request_destructor);
@@ -516,7 +516,7 @@ struct wrepl_request *wrepl_request_send(struct wrepl_socket *wrepl_socket,
return wrepl_request_finished(req, req->status);
}
- req->trigger = False;
+ req->trigger = false;
return req;
}
@@ -638,8 +638,8 @@ struct wrepl_request *wrepl_associate_stop_send(struct wrepl_socket *wrepl_socke
ZERO_STRUCT(ctrl);
if (io->in.reason == 0) {
- ctrl.send_only = True;
- ctrl.disconnect_after_send = True;
+ ctrl.send_only = true;
+ ctrl.disconnect_after_send = true;
}
req = wrepl_request_send(wrepl_socket, packet, &ctrl);
diff --git a/source4/libcli/wrepl/winsrepl.h b/source4/libcli/wrepl/winsrepl.h
index 3265024407..8ce8b418a2 100644
--- a/source4/libcli/wrepl/winsrepl.h
+++ b/source4/libcli/wrepl/winsrepl.h
@@ -120,7 +120,7 @@ struct wrepl_pull_table {
#define WREPL_NAME_TYPE(flags) (flags & WREPL_FLAGS_RECORD_TYPE)
#define WREPL_NAME_STATE(flags) ((flags & WREPL_FLAGS_RECORD_STATE)>>2)
#define WREPL_NAME_NODE(flags) ((flags & WREPL_FLAGS_NODE_TYPE)>>5)
-#define WREPL_NAME_IS_STATIC(flags) ((flags & WREPL_FLAGS_IS_STATIC)?True:False)
+#define WREPL_NAME_IS_STATIC(flags) ((flags & WREPL_FLAGS_IS_STATIC)?true:false)
#define WREPL_NAME_FLAGS(type, state, node, is_static) \
(type | (state << 2) | (node << 5) | \