mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
r25554: Convert last instances of BOOL, True and False to the standard types.
This commit is contained in:
parent
b7371f1a19
commit
566aa14139
@ -235,15 +235,15 @@ void creds_client_authenticator(struct creds_CredentialState *creds,
|
|||||||
/*
|
/*
|
||||||
check that a credentials reply from a server is correct
|
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)
|
const struct netr_Credential *received_credentials)
|
||||||
{
|
{
|
||||||
if (!received_credentials ||
|
if (!received_credentials ||
|
||||||
memcmp(received_credentials->data, creds->server.data, 8) != 0) {
|
memcmp(received_credentials->data, creds->server.data, 8) != 0) {
|
||||||
DEBUG(2,("credentials check failed\n"));
|
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
|
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)
|
const struct netr_Credential *received_credentials)
|
||||||
{
|
{
|
||||||
if (memcmp(received_credentials->data, creds->client.data, 8) != 0) {
|
if (memcmp(received_credentials->data, creds->client.data, 8) != 0) {
|
||||||
DEBUG(2,("credentials check failed\n"));
|
DEBUG(2,("credentials check failed\n"));
|
||||||
dump_data_pw("client creds", creds->client.data, 8);
|
dump_data_pw("client creds", creds->client.data, 8);
|
||||||
dump_data_pw("calc creds", received_credentials->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,
|
NTSTATUS creds_server_step_check(struct creds_CredentialState *creds,
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
as the in blob
|
as the in blob
|
||||||
*/
|
*/
|
||||||
static void sess_crypt_blob(DATA_BLOB *out, const DATA_BLOB *in, const DATA_BLOB *session_key,
|
static void sess_crypt_blob(DATA_BLOB *out, const DATA_BLOB *in, const DATA_BLOB *session_key,
|
||||||
BOOL forward)
|
bool forward)
|
||||||
{
|
{
|
||||||
int i, k;
|
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);
|
memset(src.data+8, 0, dlen);
|
||||||
memcpy(src.data+8, str, slen);
|
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);
|
data_blob_free(&src);
|
||||||
|
|
||||||
@ -112,7 +112,7 @@ char *sess_decrypt_string(TALLOC_CTX *mem_ctx,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
sess_crypt_blob(&out, blob, session_key, False);
|
sess_crypt_blob(&out, blob, session_key, false);
|
||||||
|
|
||||||
if (IVAL(out.data, 4) != 1) {
|
if (IVAL(out.data, 4) != 1) {
|
||||||
DEBUG(0,("Unexpected revision number %d in session crypted string\n",
|
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);
|
memset(src.data+8, 0, dlen);
|
||||||
memcpy(src.data+8, blob_in->data, blob_in->length);
|
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);
|
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;
|
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) {
|
if (IVAL(out.data, 4) != 1) {
|
||||||
DEBUG(2,("Unexpected revision number %d in session crypted secret (BLOB)\n",
|
DEBUG(2,("Unexpected revision number %d in session crypted secret (BLOB)\n",
|
||||||
|
@ -34,11 +34,11 @@
|
|||||||
It takes a password ('unix' string), a 8 byte "crypt key"
|
It takes a password ('unix' string), a 8 byte "crypt key"
|
||||||
and puts 24 bytes of encrypted password into p24
|
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];
|
uint8_t p21[21];
|
||||||
|
|
||||||
memset(p21,'\0',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
|
* @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;
|
int len;
|
||||||
void *wpwd;
|
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
|
/* We don't want to return fixed data, as most callers
|
||||||
* don't check */
|
* don't check */
|
||||||
mdfour(p16, (const uint8_t *)passwd, strlen(passwd));
|
mdfour(p16, (const uint8_t *)passwd, strlen(passwd));
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
len -= 2;
|
len -= 2;
|
||||||
mdfour(p16, wpwd, len);
|
mdfour(p16, wpwd, len);
|
||||||
|
|
||||||
talloc_free(wpwd);
|
talloc_free(wpwd);
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the DES forward-only Hash of the users password in DOS ASCII charset
|
* Creates the DES forward-only Hash of the users password in DOS ASCII charset
|
||||||
* @param passwd password in 'unix' charset.
|
* @param passwd password in 'unix' charset.
|
||||||
* @param p16 return password hashed with DES, caller allocated 16 byte buffer
|
* @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
|
* @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;
|
fstring dospwd;
|
||||||
ZERO_STRUCT(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);
|
E_P16((const uint8_t *)dospwd, p16);
|
||||||
|
|
||||||
if (strlen(dospwd) > 14) {
|
if (strlen(dospwd) > 14) {
|
||||||
ret = False;
|
ret = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ZERO_STRUCT(dospwd);
|
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 */
|
/* 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,
|
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])
|
uint8_t kr_buf[16])
|
||||||
{
|
{
|
||||||
void *user;
|
void *user;
|
||||||
@ -125,7 +125,7 @@ BOOL ntv2_owf_gen(const uint8_t owf[16],
|
|||||||
HMACMD5Context ctx;
|
HMACMD5Context ctx;
|
||||||
TALLOC_CTX *mem_ctx = talloc_init("ntv2_owf_gen for %s\\%s", domain_in, user_in);
|
TALLOC_CTX *mem_ctx = talloc_init("ntv2_owf_gen for %s\\%s", domain_in, user_in);
|
||||||
if (!mem_ctx) {
|
if (!mem_ctx) {
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!user_in) {
|
if (!user_in) {
|
||||||
@ -139,14 +139,14 @@ BOOL ntv2_owf_gen(const uint8_t owf[16],
|
|||||||
user_in = strupper_talloc(mem_ctx, user_in);
|
user_in = strupper_talloc(mem_ctx, user_in);
|
||||||
if (user_in == NULL) {
|
if (user_in == NULL) {
|
||||||
talloc_free(mem_ctx);
|
talloc_free(mem_ctx);
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (upper_case_domain) {
|
if (upper_case_domain) {
|
||||||
domain_in = strupper_talloc(mem_ctx, domain_in);
|
domain_in = strupper_talloc(mem_ctx, domain_in);
|
||||||
if (domain_in == NULL) {
|
if (domain_in == NULL) {
|
||||||
talloc_free(mem_ctx);
|
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) {
|
if (user_byte_len == (ssize_t)-1) {
|
||||||
DEBUG(0, ("push_uss2_talloc() for user returned -1 (probably talloc() failure)\n"));
|
DEBUG(0, ("push_uss2_talloc() for user returned -1 (probably talloc() failure)\n"));
|
||||||
talloc_free(mem_ctx);
|
talloc_free(mem_ctx);
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
domain_byte_len = push_ucs2_talloc(mem_ctx, &domain, domain_in);
|
domain_byte_len = push_ucs2_talloc(mem_ctx, &domain, domain_in);
|
||||||
if (domain_byte_len == (ssize_t)-1) {
|
if (domain_byte_len == (ssize_t)-1) {
|
||||||
DEBUG(0, ("push_ucs2_talloc() for domain returned -1 (probably talloc() failure)\n"));
|
DEBUG(0, ("push_ucs2_talloc() for domain returned -1 (probably talloc() failure)\n"));
|
||||||
talloc_free(mem_ctx);
|
talloc_free(mem_ctx);
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SMB_ASSERT(user_byte_len >= 2);
|
SMB_ASSERT(user_byte_len >= 2);
|
||||||
@ -185,7 +185,7 @@ BOOL ntv2_owf_gen(const uint8_t owf[16],
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
talloc_free(mem_ctx);
|
talloc_free(mem_ctx);
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Does the des encryption from the NT or LM MD4 hash. */
|
/* 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;
|
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 char *user, const char *domain, const uint8_t nt_hash[16],
|
||||||
const DATA_BLOB *server_chal,
|
const DATA_BLOB *server_chal,
|
||||||
const DATA_BLOB *names_blob,
|
const DATA_BLOB *names_blob,
|
||||||
@ -406,8 +406,8 @@ BOOL SMBNTLMv2encrypt_hash(TALLOC_CTX *mem_ctx,
|
|||||||
the username and domain.
|
the username and domain.
|
||||||
This prevents username swapping during the auth exchange
|
This prevents username swapping during the auth exchange
|
||||||
*/
|
*/
|
||||||
if (!ntv2_owf_gen(nt_hash, user, domain, True, ntlm_v2_hash)) {
|
if (!ntv2_owf_gen(nt_hash, user, domain, true, ntlm_v2_hash)) {
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nt_response) {
|
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 *user, const char *domain,
|
||||||
const char *password,
|
const char *password,
|
||||||
const DATA_BLOB *server_chal,
|
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
|
encode a password buffer with a unicode password. The buffer
|
||||||
is filled with random data to make it harder to attack.
|
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];
|
uint8_t new_pw[512];
|
||||||
size_t new_pw_len;
|
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);
|
SIVAL(buffer, 512, new_pw_len);
|
||||||
ZERO_STRUCT(new_pw);
|
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
|
*new_pw_len is the length in bytes of the possibly mulitbyte
|
||||||
returned password including termination.
|
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 new_pwrd_size, uint32_t *new_pw_len,
|
||||||
int string_flags)
|
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 */
|
/* Password cannot be longer than the size of the password buffer */
|
||||||
if ( (byte_len < 0) || (byte_len > 512)) {
|
if ( (byte_len < 0) || (byte_len > 512)) {
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* decode into the return buffer. Buffer length supplied */
|
/* 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));
|
DEBUG(100,("original char len:%d\n", byte_len/2));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -309,7 +309,7 @@ struct cldap_request *cldap_search_send(struct cldap_socket *cldap,
|
|||||||
req->state = CLDAP_REQUEST_SEND;
|
req->state = CLDAP_REQUEST_SEND;
|
||||||
req->timeout = io->in.timeout;
|
req->timeout = io->in.timeout;
|
||||||
req->num_retries = io->in.retries;
|
req->num_retries = io->in.retries;
|
||||||
req->is_reply = False;
|
req->is_reply = false;
|
||||||
req->asn1 = asn1_init(req);
|
req->asn1 = asn1_init(req);
|
||||||
if (!req->asn1) {
|
if (!req->asn1) {
|
||||||
goto failed;
|
goto failed;
|
||||||
@ -337,7 +337,7 @@ struct cldap_request *cldap_search_send(struct cldap_socket *cldap,
|
|||||||
search->deref = LDAP_DEREFERENCE_NEVER;
|
search->deref = LDAP_DEREFERENCE_NEVER;
|
||||||
search->timelimit = 0;
|
search->timelimit = 0;
|
||||||
search->sizelimit = 0;
|
search->sizelimit = 0;
|
||||||
search->attributesonly = False;
|
search->attributesonly = false;
|
||||||
search->num_attributes = str_list_length(io->in.attributes);
|
search->num_attributes = str_list_length(io->in.attributes);
|
||||||
search->attributes = io->in.attributes;
|
search->attributes = io->in.attributes;
|
||||||
search->tree = ldb_parse_tree(req, io->in.filter);
|
search->tree = ldb_parse_tree(req, io->in.filter);
|
||||||
@ -378,7 +378,7 @@ NTSTATUS cldap_reply_send(struct cldap_socket *cldap, struct cldap_reply *io)
|
|||||||
|
|
||||||
req->cldap = cldap;
|
req->cldap = cldap;
|
||||||
req->state = CLDAP_REQUEST_SEND;
|
req->state = CLDAP_REQUEST_SEND;
|
||||||
req->is_reply = True;
|
req->is_reply = true;
|
||||||
req->asn1 = asn1_init(req);
|
req->asn1 = asn1_init(req);
|
||||||
if (!req->asn1) {
|
if (!req->asn1) {
|
||||||
goto failed;
|
goto failed;
|
||||||
|
@ -30,24 +30,24 @@
|
|||||||
/*
|
/*
|
||||||
wrapper around smbcli_sock_connect()
|
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;
|
struct smbcli_socket *sock;
|
||||||
|
|
||||||
sock = smbcli_sock_connect_byname(server, 0, NULL, NULL);
|
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) {
|
if (!cli->transport) {
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* wrapper around smbcli_transport_connect() */
|
/* 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 *calling,
|
||||||
struct nbt_name *called)
|
struct nbt_name *called)
|
||||||
{
|
{
|
||||||
@ -68,7 +68,7 @@ NTSTATUS smbcli_session_setup(struct smbcli_state *cli,
|
|||||||
struct smb_composite_sesssetup setup;
|
struct smb_composite_sesssetup setup;
|
||||||
NTSTATUS status;
|
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;
|
if (!cli->session) return NT_STATUS_UNSUCCESSFUL;
|
||||||
|
|
||||||
setup.in.sesskey = cli->transport->negotiate.sesskey;
|
setup.in.sesskey = cli->transport->negotiate.sesskey;
|
||||||
@ -91,7 +91,7 @@ NTSTATUS smbcli_tconX(struct smbcli_state *cli, const char *sharename,
|
|||||||
TALLOC_CTX *mem_ctx;
|
TALLOC_CTX *mem_ctx;
|
||||||
NTSTATUS status;
|
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;
|
if (!cli->tree) return NT_STATUS_UNSUCCESSFUL;
|
||||||
|
|
||||||
mem_ctx = talloc_init("tcon");
|
mem_ctx = talloc_init("tcon");
|
||||||
@ -216,7 +216,7 @@ bool smbcli_parse_unc(const char *unc_name, TALLOC_CTX *mem_ctx,
|
|||||||
|
|
||||||
if (strncmp(unc_name, "\\\\", 2) &&
|
if (strncmp(unc_name, "\\\\", 2) &&
|
||||||
strncmp(unc_name, "//", 2)) {
|
strncmp(unc_name, "//", 2)) {
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
*hostname = talloc_strdup(mem_ctx, &unc_name[2]);
|
*hostname = talloc_strdup(mem_ctx, &unc_name[2]);
|
||||||
@ -228,13 +228,13 @@ bool smbcli_parse_unc(const char *unc_name, TALLOC_CTX *mem_ctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (*hostname && *sharename) {
|
if (*hostname && *sharename) {
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
talloc_free(*hostname);
|
talloc_free(*hostname);
|
||||||
talloc_free(*sharename);
|
talloc_free(*sharename);
|
||||||
*hostname = *sharename = NULL;
|
*hostname = *sharename = NULL;
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
struct delete_state {
|
struct delete_state {
|
||||||
struct smbcli_tree *tree;
|
struct smbcli_tree *tree;
|
||||||
int total_deleted;
|
int total_deleted;
|
||||||
BOOL failed;
|
bool failed;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -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))) {
|
if (NT_STATUS_IS_ERR(smbcli_rmdir(dstate->tree, s))) {
|
||||||
DEBUG(2,("Failed to delete %s - %s\n",
|
DEBUG(2,("Failed to delete %s - %s\n",
|
||||||
s, smbcli_errstr(dstate->tree)));
|
s, smbcli_errstr(dstate->tree)));
|
||||||
dstate->failed = True;
|
dstate->failed = true;
|
||||||
}
|
}
|
||||||
dstate->total_deleted++;
|
dstate->total_deleted++;
|
||||||
} else {
|
} else {
|
||||||
if (NT_STATUS_IS_ERR(smbcli_unlink(dstate->tree, s))) {
|
if (NT_STATUS_IS_ERR(smbcli_unlink(dstate->tree, s))) {
|
||||||
DEBUG(2,("Failed to delete %s - %s\n",
|
DEBUG(2,("Failed to delete %s - %s\n",
|
||||||
s, smbcli_errstr(dstate->tree)));
|
s, smbcli_errstr(dstate->tree)));
|
||||||
dstate->failed = True;
|
dstate->failed = true;
|
||||||
}
|
}
|
||||||
dstate->total_deleted++;
|
dstate->total_deleted++;
|
||||||
}
|
}
|
||||||
@ -87,7 +87,7 @@ int smbcli_deltree(struct smbcli_tree *tree, const char *dname)
|
|||||||
|
|
||||||
dstate.tree = tree;
|
dstate.tree = tree;
|
||||||
dstate.total_deleted = 0;
|
dstate.total_deleted = 0;
|
||||||
dstate.failed = False;
|
dstate.failed = false;
|
||||||
|
|
||||||
/* it might be a file */
|
/* it might be a file */
|
||||||
if (NT_STATUS_IS_OK(smbcli_unlink(tree, dname))) {
|
if (NT_STATUS_IS_OK(smbcli_unlink(tree, dname))) {
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
static NTSTATUS smbcli_link_internal(struct smbcli_tree *tree,
|
static NTSTATUS smbcli_link_internal(struct smbcli_tree *tree,
|
||||||
const char *fname_src,
|
const char *fname_src,
|
||||||
const char *fname_dst, BOOL hard_link)
|
const char *fname_dst, bool hard_link)
|
||||||
{
|
{
|
||||||
union smb_setfileinfo parms;
|
union smb_setfileinfo parms;
|
||||||
NTSTATUS status;
|
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,
|
NTSTATUS smbcli_unix_symlink(struct smbcli_tree *tree, const char *fname_src,
|
||||||
const char *fname_dst)
|
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,
|
NTSTATUS smbcli_unix_hardlink(struct smbcli_tree *tree, const char *fname_src,
|
||||||
const char *fname_dst)
|
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.
|
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;
|
union smb_setfileinfo parms;
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
|
@ -37,7 +37,7 @@ struct search_private {
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
Interpret a long filename structure.
|
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,
|
const union smb_search_data *info,
|
||||||
struct clilist_file_info *finfo)
|
struct clilist_file_info *finfo)
|
||||||
{
|
{
|
||||||
@ -65,14 +65,14 @@ static BOOL interpret_long_filename(enum smb_search_data_level level,
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
DEBUG(0,("Unhandled level %d in interpret_long_filename\n", (int)level));
|
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 */
|
/* 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 search_private *state = (struct search_private*) private;
|
||||||
struct clilist_file_info *tdl;
|
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,
|
struct clilist_file_info,
|
||||||
state->dirlist_len + 1);
|
state->dirlist_len + 1);
|
||||||
if (!tdl) {
|
if (!tdl) {
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
state->dirlist = tdl;
|
state->dirlist = tdl;
|
||||||
state->dirlist_len++;
|
state->dirlist_len++;
|
||||||
@ -94,7 +94,7 @@ static BOOL smbcli_list_new_callback(void *private, const union smb_search_data
|
|||||||
state->total_received++;
|
state->total_received++;
|
||||||
state->ff_searchcount++;
|
state->ff_searchcount++;
|
||||||
|
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int smbcli_list_new(struct smbcli_tree *tree, const char *Mask, uint16_t attribute,
|
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;
|
union smb_search_next next_parms;
|
||||||
struct search_private state; /* for callbacks */
|
struct search_private state; /* for callbacks */
|
||||||
int received = 0;
|
int received = 0;
|
||||||
BOOL first = True;
|
bool first = true;
|
||||||
int num_received = 0;
|
int num_received = 0;
|
||||||
int max_matches = 512;
|
int max_matches = 512;
|
||||||
char *mask;
|
char *mask;
|
||||||
@ -159,7 +159,7 @@ int smbcli_list_new(struct smbcli_tree *tree, const char *Mask, uint16_t attribu
|
|||||||
received = first_parms.t2ffirst.out.count;
|
received = first_parms.t2ffirst.out.count;
|
||||||
if (received <= 0) break;
|
if (received <= 0) break;
|
||||||
if (ff_eos) break;
|
if (ff_eos) break;
|
||||||
first = False;
|
first = false;
|
||||||
} else {
|
} else {
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
|
|
||||||
@ -203,7 +203,7 @@ int smbcli_list_new(struct smbcli_tree *tree, const char *Mask, uint16_t attribu
|
|||||||
Interpret a short filename structure.
|
Interpret a short filename structure.
|
||||||
The length of the structure is returned.
|
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,
|
const union smb_search_data *info,
|
||||||
struct clilist_file_info *finfo)
|
struct clilist_file_info *finfo)
|
||||||
{
|
{
|
||||||
@ -223,14 +223,14 @@ static BOOL interpret_short_filename(enum smb_search_data_level level,
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
DEBUG(0,("Unhandled level %d in interpret_short_filename\n", (int)level));
|
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 */
|
/* 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 search_private *state = (struct search_private*) private;
|
||||||
struct clilist_file_info *tdl;
|
struct clilist_file_info *tdl;
|
||||||
@ -242,7 +242,7 @@ static BOOL smbcli_list_old_callback(void *private, const union smb_search_data
|
|||||||
state->dirlist_len + 1);
|
state->dirlist_len + 1);
|
||||||
|
|
||||||
if (!tdl) {
|
if (!tdl) {
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
state->dirlist = tdl;
|
state->dirlist = tdl;
|
||||||
state->dirlist_len++;
|
state->dirlist_len++;
|
||||||
@ -253,7 +253,7 @@ static BOOL smbcli_list_old_callback(void *private, const union smb_search_data
|
|||||||
state->ff_searchcount++;
|
state->ff_searchcount++;
|
||||||
state->id = file->search.id; /* return resume info */
|
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,
|
int smbcli_list_old(struct smbcli_tree *tree, const char *Mask, uint16_t attribute,
|
||||||
@ -265,7 +265,7 @@ int smbcli_list_old(struct smbcli_tree *tree, const char *Mask, uint16_t attribu
|
|||||||
struct search_private state; /* for callbacks */
|
struct search_private state; /* for callbacks */
|
||||||
const int num_asked = 500;
|
const int num_asked = 500;
|
||||||
int received = 0;
|
int received = 0;
|
||||||
BOOL first = True;
|
bool first = true;
|
||||||
int num_received = 0;
|
int num_received = 0;
|
||||||
char *mask;
|
char *mask;
|
||||||
int i;
|
int i;
|
||||||
@ -303,7 +303,7 @@ int smbcli_list_old(struct smbcli_tree *tree, const char *Mask, uint16_t attribu
|
|||||||
|
|
||||||
received = first_parms.search_first.out.count;
|
received = first_parms.search_first.out.count;
|
||||||
if (received <= 0) break;
|
if (received <= 0) break;
|
||||||
first = False;
|
first = false;
|
||||||
} else {
|
} else {
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
start a message sequence
|
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)
|
int *grp)
|
||||||
{
|
{
|
||||||
struct smbcli_request *req;
|
struct smbcli_request *req;
|
||||||
@ -38,20 +38,20 @@ BOOL smbcli_message_start(struct smbcli_tree *tree, const char *host, const char
|
|||||||
!smbcli_request_receive(req) ||
|
!smbcli_request_receive(req) ||
|
||||||
smbcli_is_error(tree)) {
|
smbcli_is_error(tree)) {
|
||||||
smbcli_request_destroy(req);
|
smbcli_request_destroy(req);
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
*grp = SVAL(req->in.vwv, VWV(0));
|
*grp = SVAL(req->in.vwv, VWV(0));
|
||||||
smbcli_request_destroy(req);
|
smbcli_request_destroy(req);
|
||||||
|
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
send a message
|
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;
|
struct smbcli_request *req;
|
||||||
|
|
||||||
@ -64,17 +64,17 @@ BOOL smbcli_message_text(struct smbcli_tree *tree, char *msg, int len, int grp)
|
|||||||
!smbcli_request_receive(req) ||
|
!smbcli_request_receive(req) ||
|
||||||
smbcli_is_error(tree)) {
|
smbcli_is_error(tree)) {
|
||||||
smbcli_request_destroy(req);
|
smbcli_request_destroy(req);
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
smbcli_request_destroy(req);
|
smbcli_request_destroy(req);
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
end a message
|
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;
|
struct smbcli_request *req;
|
||||||
|
|
||||||
@ -85,10 +85,10 @@ BOOL smbcli_message_end(struct smbcli_tree *tree, int grp)
|
|||||||
!smbcli_request_receive(req) ||
|
!smbcli_request_receive(req) ||
|
||||||
smbcli_is_error(tree)) {
|
smbcli_is_error(tree)) {
|
||||||
smbcli_request_destroy(req);
|
smbcli_request_destroy(req);
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
smbcli_request_destroy(req);
|
smbcli_request_destroy(req);
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,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.mincnt = readsize;
|
||||||
parms.readx.in.maxcnt = readsize;
|
parms.readx.in.maxcnt = readsize;
|
||||||
parms.readx.in.remaining = size - total;
|
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;
|
parms.readx.out.data = buf + total;
|
||||||
|
|
||||||
status = smb_raw_read(tree, &parms);
|
status = smb_raw_read(tree, &parms);
|
||||||
|
@ -53,7 +53,7 @@ _PUBLIC_ NTSTATUS composite_wait(struct composite_context *c)
|
|||||||
{
|
{
|
||||||
if (c == NULL) return NT_STATUS_NO_MEMORY;
|
if (c == NULL) return NT_STATUS_NO_MEMORY;
|
||||||
|
|
||||||
c->used_wait = True;
|
c->used_wait = true;
|
||||||
|
|
||||||
while (c->state < COMPOSITE_STATE_DONE) {
|
while (c->state < COMPOSITE_STATE_DONE) {
|
||||||
if (event_loop_once(c->event_ctx) != 0) {
|
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
|
* Some composite helpers that are handy if you write larger composite
|
||||||
* functions.
|
* 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)) {
|
if (NT_STATUS_IS_OK(ctx->status)) {
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
ctx->state = COMPOSITE_STATE_ERROR;
|
ctx->state = COMPOSITE_STATE_ERROR;
|
||||||
if (ctx->async.fn != NULL) {
|
if (ctx->async.fn != NULL) {
|
||||||
ctx->async.fn(ctx);
|
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));
|
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) {
|
if (p != NULL) {
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
composite_error(ctx, NT_STATUS_NO_MEMORY);
|
composite_error(ctx, NT_STATUS_NO_MEMORY);
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
_PUBLIC_ void composite_done(struct composite_context *ctx)
|
_PUBLIC_ void composite_done(struct composite_context *ctx)
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#include "libcli/ldap/ldap.h"
|
#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;
|
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));
|
asn1_push_tag(data, ASN1_CONTEXT(tree->operation==LDB_OP_AND?0:1));
|
||||||
for (i=0; i<tree->u.list.num_elements; i++) {
|
for (i=0; i<tree->u.list.num_elements; i++) {
|
||||||
if (!ldap_push_filter(data, tree->u.list.elements[i])) {
|
if (!ldap_push_filter(data, tree->u.list.elements[i])) {
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
asn1_pop_tag(data);
|
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:
|
case LDB_OP_NOT:
|
||||||
asn1_push_tag(data, ASN1_CONTEXT(2));
|
asn1_push_tag(data, ASN1_CONTEXT(2));
|
||||||
if (!ldap_push_filter(data, tree->u.isnot.child)) {
|
if (!ldap_push_filter(data, tree->u.isnot.child)) {
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
asn1_pop_tag(data);
|
asn1_pop_tag(data);
|
||||||
break;
|
break;
|
||||||
@ -166,7 +166,7 @@ static BOOL ldap_push_filter(struct asn1_data *data, struct ldb_parse_tree *tree
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
return !data->has_error;
|
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);
|
struct asn1_data *data = asn1_init(mem_ctx);
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
if (!data) return False;
|
if (!data) return false;
|
||||||
|
|
||||||
asn1_push_tag(data, ASN1_SEQUENCE(0));
|
asn1_push_tag(data, ASN1_SEQUENCE(0));
|
||||||
asn1_write_Integer(data, msg->messageid);
|
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);
|
asn1_pop_tag(data);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
asn1_pop_tag(data);
|
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);
|
asn1_write_BOOLEAN(data, r->attributesonly);
|
||||||
|
|
||||||
if (!ldap_push_filter(data, r->tree)) {
|
if (!ldap_push_filter(data, r->tree)) {
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
asn1_push_tag(data, ASN1_SEQUENCE(0));
|
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;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg->controls != NULL) {
|
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++) {
|
for (i = 0; msg->controls[i] != NULL; i++) {
|
||||||
if (!ldap_encode_control(mem_ctx, data, msg->controls[i])) {
|
if (!ldap_encode_control(mem_ctx, data, msg->controls[i])) {
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -486,12 +486,12 @@ BOOL ldap_encode(struct ldap_message *msg, DATA_BLOB *result, TALLOC_CTX *mem_ct
|
|||||||
|
|
||||||
if (data->has_error) {
|
if (data->has_error) {
|
||||||
asn1_free(data);
|
asn1_free(data);
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
*result = data_blob_talloc(mem_ctx, data->data, data->length);
|
*result = data_blob_talloc(mem_ctx, data->data, data->length);
|
||||||
asn1_free(data);
|
asn1_free(data);
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *blob2string_talloc(TALLOC_CTX *mem_ctx,
|
static const char *blob2string_talloc(TALLOC_CTX *mem_ctx,
|
||||||
@ -503,16 +503,16 @@ static const char *blob2string_talloc(TALLOC_CTX *mem_ctx,
|
|||||||
return result;
|
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,
|
struct asn1_data *data,
|
||||||
const char **result)
|
const char **result)
|
||||||
{
|
{
|
||||||
DATA_BLOB string;
|
DATA_BLOB string;
|
||||||
if (!asn1_read_OctetString(data, mem_ctx, &string))
|
if (!asn1_read_OctetString(data, mem_ctx, &string))
|
||||||
return False;
|
return false;
|
||||||
*result = blob2string_talloc(mem_ctx, string);
|
*result = blob2string_talloc(mem_ctx, string);
|
||||||
data_blob_free(&string);
|
data_blob_free(&string);
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ldap_decode_response(TALLOC_CTX *mem_ctx,
|
static void ldap_decode_response(TALLOC_CTX *mem_ctx,
|
||||||
|
@ -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,
|
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)) {
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
DEBUG(1, ("Failed to inquire of target's available sasl mechs in rootdse search: %s\n",
|
DEBUG(1, ("Failed to inquire of target's available sasl mechs in rootdse search: %s\n",
|
||||||
nt_errstr(status)));
|
nt_errstr(status)));
|
||||||
|
@ -226,7 +226,7 @@ static void ldap_io_handler(struct event_context *ev, struct fd_event *fde,
|
|||||||
parse a ldap URL
|
parse a ldap URL
|
||||||
*/
|
*/
|
||||||
static NTSTATUS ldap_parse_basic_url(TALLOC_CTX *mem_ctx, const char *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;
|
int tmp_port = 0;
|
||||||
char protocol[11];
|
char protocol[11];
|
||||||
@ -243,10 +243,10 @@ static NTSTATUS ldap_parse_basic_url(TALLOC_CTX *mem_ctx, const char *url,
|
|||||||
|
|
||||||
if (strequal(protocol, "ldap")) {
|
if (strequal(protocol, "ldap")) {
|
||||||
*port = 389;
|
*port = 389;
|
||||||
*ldaps = False;
|
*ldaps = false;
|
||||||
} else if (strequal(protocol, "ldaps")) {
|
} else if (strequal(protocol, "ldaps")) {
|
||||||
*port = 636;
|
*port = 636;
|
||||||
*ldaps = True;
|
*ldaps = true;
|
||||||
} else {
|
} else {
|
||||||
DEBUG(0, ("unrecognised ldap protocol (%s)!\n", protocol));
|
DEBUG(0, ("unrecognised ldap protocol (%s)!\n", protocol));
|
||||||
return NT_STATUS_PROTOCOL_UNREACHABLE;
|
return NT_STATUS_PROTOCOL_UNREACHABLE;
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -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,
|
NTSTATUS ildap_search_bytree(struct ldap_connection *conn, const char *basedn,
|
||||||
int scope, struct ldb_parse_tree *tree,
|
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_req,
|
||||||
struct ldb_control ***control_res,
|
struct ldb_control ***control_res,
|
||||||
struct ldap_message ***results)
|
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);
|
req = ldap_request_send(conn, msg);
|
||||||
talloc_steal(msg, req);
|
talloc_steal(msg, req);
|
||||||
|
|
||||||
for (i=n=0;True;i++) {
|
for (i=n=0;true;i++) {
|
||||||
struct ldap_message *res;
|
struct ldap_message *res;
|
||||||
status = ldap_result_n(req, i, &res);
|
status = ldap_result_n(req, i, &res);
|
||||||
if (!NT_STATUS_IS_OK(status)) break;
|
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,
|
NTSTATUS ildap_search(struct ldap_connection *conn, const char *basedn,
|
||||||
int scope, const char *expression,
|
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_req,
|
||||||
struct ldb_control ***control_res,
|
struct ldb_control ***control_res,
|
||||||
struct ldap_message ***results)
|
struct ldap_message ***results)
|
||||||
|
@ -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)
|
struct ldb_message_element *attrib)
|
||||||
{
|
{
|
||||||
attrib->values = talloc_realloc(mem_ctx,
|
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,
|
DATA_BLOB,
|
||||||
attrib->num_values+1);
|
attrib->num_values+1);
|
||||||
if (attrib->values == NULL)
|
if (attrib->values == NULL)
|
||||||
return False;
|
return false;
|
||||||
|
|
||||||
attrib->values[attrib->num_values].data = talloc_steal(attrib->values,
|
attrib->values[attrib->num_values].data = talloc_steal(attrib->values,
|
||||||
value->data);
|
value->data);
|
||||||
attrib->values[attrib->num_values].length = value->length;
|
attrib->values[attrib->num_values].length = value->length;
|
||||||
attrib->num_values += 1;
|
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,
|
const struct ldb_message_element *attrib,
|
||||||
struct ldb_message_element **attribs,
|
struct ldb_message_element **attribs,
|
||||||
int *num_attribs)
|
int *num_attribs)
|
||||||
@ -60,16 +60,16 @@ BOOL add_attrib_to_array_talloc(TALLOC_CTX *mem_ctx,
|
|||||||
*num_attribs+1);
|
*num_attribs+1);
|
||||||
|
|
||||||
if (*attribs == NULL)
|
if (*attribs == NULL)
|
||||||
return False;
|
return false;
|
||||||
|
|
||||||
(*attribs)[*num_attribs] = *attrib;
|
(*attribs)[*num_attribs] = *attrib;
|
||||||
talloc_steal(*attribs, attrib->values);
|
talloc_steal(*attribs, attrib->values);
|
||||||
talloc_steal(*attribs, attrib->name);
|
talloc_steal(*attribs, attrib->name);
|
||||||
*num_attribs += 1;
|
*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 *mod,
|
||||||
struct ldap_mod **mods,
|
struct ldap_mod **mods,
|
||||||
int *num_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);
|
*mods = talloc_realloc(mem_ctx, *mods, struct ldap_mod, (*num_mods)+1);
|
||||||
|
|
||||||
if (*mods == NULL)
|
if (*mods == NULL)
|
||||||
return False;
|
return false;
|
||||||
|
|
||||||
(*mods)[*num_mods] = *mod;
|
(*mods)[*num_mods] = *mod;
|
||||||
*num_mods += 1;
|
*num_mods += 1;
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ _PUBLIC_ struct nbt_name_request *nbt_name_query_send(struct nbt_name_socket *nb
|
|||||||
io->in.dest_addr, lp_nbt_port(global_loadparm));
|
io->in.dest_addr, lp_nbt_port(global_loadparm));
|
||||||
if (dest == NULL) goto failed;
|
if (dest == NULL) goto failed;
|
||||||
req = nbt_name_request_send(nbtsock, dest, packet,
|
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;
|
if (req == NULL) goto failed;
|
||||||
|
|
||||||
talloc_free(packet);
|
talloc_free(packet);
|
||||||
@ -161,7 +161,7 @@ _PUBLIC_ struct nbt_name_request *nbt_name_status_send(struct nbt_name_socket *n
|
|||||||
io->in.dest_addr, lp_nbt_port(global_loadparm));
|
io->in.dest_addr, lp_nbt_port(global_loadparm));
|
||||||
if (dest == NULL) goto failed;
|
if (dest == NULL) goto failed;
|
||||||
req = nbt_name_request_send(nbtsock, dest, packet,
|
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;
|
if (req == NULL) goto failed;
|
||||||
|
|
||||||
talloc_free(packet);
|
talloc_free(packet);
|
||||||
|
@ -72,7 +72,7 @@ struct nbt_name_request *nbt_name_refresh_send(struct nbt_name_socket *nbtsock,
|
|||||||
io->in.dest_addr, lp_nbt_port(global_loadparm));
|
io->in.dest_addr, lp_nbt_port(global_loadparm));
|
||||||
if (dest == NULL) goto failed;
|
if (dest == NULL) goto failed;
|
||||||
req = nbt_name_request_send(nbtsock, dest, packet,
|
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;
|
if (req == NULL) goto failed;
|
||||||
|
|
||||||
talloc_free(packet);
|
talloc_free(packet);
|
||||||
@ -242,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.dest_addr = state->wins_servers[0];
|
||||||
state->io->in.address = io->in.addresses[0];
|
state->io->in.address = io->in.addresses[0];
|
||||||
state->io->in.nb_flags = io->in.nb_flags;
|
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.ttl = io->in.ttl;
|
||||||
state->io->in.timeout = 2;
|
state->io->in.timeout = 2;
|
||||||
state->io->in.retries = 2;
|
state->io->in.retries = 2;
|
||||||
|
@ -80,7 +80,7 @@ struct nbt_name_request *nbt_name_register_send(struct nbt_name_socket *nbtsock,
|
|||||||
io->in.dest_addr, lp_nbt_port(global_loadparm));
|
io->in.dest_addr, lp_nbt_port(global_loadparm));
|
||||||
if (dest == NULL) goto failed;
|
if (dest == NULL) goto failed;
|
||||||
req = nbt_name_request_send(nbtsock, dest, packet,
|
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;
|
if (req == NULL) goto failed;
|
||||||
|
|
||||||
talloc_free(packet);
|
talloc_free(packet);
|
||||||
@ -166,7 +166,7 @@ static void name_register_bcast_handler(struct nbt_name_request *req)
|
|||||||
|
|
||||||
status = nbt_name_register_recv(state->req, state, state->io);
|
status = nbt_name_register_recv(state->req, state, state->io);
|
||||||
if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
|
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 */
|
/* all done */
|
||||||
c->state = COMPOSITE_STATE_DONE;
|
c->state = COMPOSITE_STATE_DONE;
|
||||||
c->status = NT_STATUS_OK;
|
c->status = NT_STATUS_OK;
|
||||||
@ -174,7 +174,7 @@ static void name_register_bcast_handler(struct nbt_name_request *req)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* the registration timed out - good, send the demand */
|
/* 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->io->in.retries = 0;
|
||||||
state->req = nbt_name_register_send(state->nbtsock, state->io);
|
state->req = nbt_name_register_send(state->nbtsock, state->io);
|
||||||
if (state->req == NULL) {
|
if (state->req == NULL) {
|
||||||
@ -226,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.dest_addr = io->in.dest_addr;
|
||||||
state->io->in.address = io->in.address;
|
state->io->in.address = io->in.address;
|
||||||
state->io->in.nb_flags = io->in.nb_flags;
|
state->io->in.nb_flags = io->in.nb_flags;
|
||||||
state->io->in.register_demand = False;
|
state->io->in.register_demand = false;
|
||||||
state->io->in.broadcast = True;
|
state->io->in.broadcast = true;
|
||||||
state->io->in.multi_homed = False;
|
state->io->in.multi_homed = false;
|
||||||
state->io->in.ttl = io->in.ttl;
|
state->io->in.ttl = io->in.ttl;
|
||||||
state->io->in.timeout = 1;
|
state->io->in.timeout = 1;
|
||||||
state->io->in.retries = 2;
|
state->io->in.retries = 2;
|
||||||
@ -379,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.dest_addr = state->wins_servers[0];
|
||||||
state->io->in.address = io->in.addresses[0];
|
state->io->in.address = io->in.addresses[0];
|
||||||
state->io->in.nb_flags = io->in.nb_flags;
|
state->io->in.nb_flags = io->in.nb_flags;
|
||||||
state->io->in.broadcast = False;
|
state->io->in.broadcast = false;
|
||||||
state->io->in.register_demand = False;
|
state->io->in.register_demand = false;
|
||||||
state->io->in.multi_homed = (io->in.nb_flags & NBT_NM_GROUP)?False:True;
|
state->io->in.multi_homed = (io->in.nb_flags & NBT_NM_GROUP)?false:true;
|
||||||
state->io->in.ttl = io->in.ttl;
|
state->io->in.ttl = io->in.ttl;
|
||||||
state->io->in.timeout = 3;
|
state->io->in.timeout = 3;
|
||||||
state->io->in.retries = 2;
|
state->io->in.retries = 2;
|
||||||
|
@ -70,7 +70,7 @@ struct nbt_name_request *nbt_name_release_send(struct nbt_name_socket *nbtsock,
|
|||||||
io->in.dest_addr, lp_nbt_port(global_loadparm));
|
io->in.dest_addr, lp_nbt_port(global_loadparm));
|
||||||
if (dest == NULL) goto failed;
|
if (dest == NULL) goto failed;
|
||||||
req = nbt_name_request_send(nbtsock, dest, packet,
|
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;
|
if (req == NULL) goto failed;
|
||||||
|
|
||||||
talloc_free(packet);
|
talloc_free(packet);
|
||||||
|
@ -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,
|
/* see if we have pushed the remaing string allready,
|
||||||
* if so we use a label pointer to this string
|
* 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)) {
|
if (NT_STATUS_IS_OK(status)) {
|
||||||
uint8_t b[2];
|
uint8_t b[2];
|
||||||
|
|
||||||
|
@ -241,7 +241,7 @@ static void nbt_name_socket_recv(struct nbt_name_socket *nbtsock)
|
|||||||
/* we know we won't need any more retries - the server
|
/* we know we won't need any more retries - the server
|
||||||
has received our request */
|
has received our request */
|
||||||
req->num_retries = 0;
|
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,
|
/* although there can be a timeout in the packet, w2k3 screws it up,
|
||||||
so better to set it ourselves */
|
so better to set it ourselves */
|
||||||
req->timeout = lp_parm_int(global_loadparm, NULL, "nbt", "wack_timeout", 30);
|
req->timeout = lp_parm_int(global_loadparm, NULL, "nbt", "wack_timeout", 30);
|
||||||
@ -355,7 +355,7 @@ struct nbt_name_request *nbt_name_request_send(struct nbt_name_socket *nbtsock,
|
|||||||
struct socket_address *dest,
|
struct socket_address *dest,
|
||||||
struct nbt_name_packet *request,
|
struct nbt_name_packet *request,
|
||||||
int timeout, int retries,
|
int timeout, int retries,
|
||||||
BOOL allow_multiple_replies)
|
bool allow_multiple_replies)
|
||||||
{
|
{
|
||||||
struct nbt_name_request *req;
|
struct nbt_name_request *req;
|
||||||
int id;
|
int id;
|
||||||
@ -367,7 +367,7 @@ struct nbt_name_request *nbt_name_request_send(struct nbt_name_socket *nbtsock,
|
|||||||
req->nbtsock = nbtsock;
|
req->nbtsock = nbtsock;
|
||||||
req->allow_multiple_replies = allow_multiple_replies;
|
req->allow_multiple_replies = allow_multiple_replies;
|
||||||
req->state = NBT_REQUEST_SEND;
|
req->state = NBT_REQUEST_SEND;
|
||||||
req->is_reply = False;
|
req->is_reply = false;
|
||||||
req->timeout = timeout;
|
req->timeout = timeout;
|
||||||
req->num_retries = retries;
|
req->num_retries = retries;
|
||||||
req->dest = dest;
|
req->dest = dest;
|
||||||
@ -431,7 +431,7 @@ NTSTATUS nbt_name_reply_send(struct nbt_name_socket *nbtsock,
|
|||||||
req->dest = dest;
|
req->dest = dest;
|
||||||
if (talloc_reference(req, dest) == NULL) goto failed;
|
if (talloc_reference(req, dest) == NULL) goto failed;
|
||||||
req->state = NBT_REQUEST_SEND;
|
req->state = NBT_REQUEST_SEND;
|
||||||
req->is_reply = True;
|
req->is_reply = true;
|
||||||
|
|
||||||
talloc_set_destructor(req, nbt_name_request_destructor);
|
talloc_set_destructor(req, nbt_name_request_destructor);
|
||||||
|
|
||||||
|
@ -23,9 +23,9 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
send an ack for an oplock break request
|
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;
|
struct smbcli_request *req;
|
||||||
|
|
||||||
req = smbcli_request_setup(tree, SMBlockingX, 8, 0);
|
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
|
set the oplock handler for a connection
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
_PUBLIC_ void smbcli_oplock_handler(struct smbcli_transport *transport,
|
_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)
|
void *private)
|
||||||
{
|
{
|
||||||
transport->oplock.handler = handler;
|
transport->oplock.handler = handler;
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
Initialize the session context
|
Initialize the session context
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
struct smbcli_session *smbcli_session_init(struct smbcli_transport *transport,
|
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;
|
struct smbcli_session *session;
|
||||||
uint16_t flags2;
|
uint16_t flags2;
|
||||||
|
@ -72,7 +72,8 @@ static NTSTATUS smbcli_transport_finish_recv(void *private, DATA_BLOB blob);
|
|||||||
create a transport structure based on an established socket
|
create a transport structure based on an established socket
|
||||||
*/
|
*/
|
||||||
struct smbcli_transport *smbcli_transport_init(struct smbcli_socket *sock,
|
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;
|
struct smbcli_transport *transport;
|
||||||
|
|
||||||
@ -261,7 +262,7 @@ NTSTATUS smbcli_transport_connect_recv(struct smbcli_request *req)
|
|||||||
/*
|
/*
|
||||||
send a session request (if needed)
|
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 *calling,
|
||||||
struct nbt_name *called)
|
struct nbt_name *called)
|
||||||
{
|
{
|
||||||
@ -269,7 +270,7 @@ BOOL smbcli_transport_connect(struct smbcli_transport *transport,
|
|||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
|
|
||||||
if (transport->socket->port == 445) {
|
if (transport->socket->port == 445) {
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
req = smbcli_transport_connect_send(transport,
|
req = smbcli_transport_connect_send(transport,
|
||||||
@ -500,16 +501,16 @@ error:
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
process some read/write requests that are pending
|
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;
|
NTSTATUS status;
|
||||||
size_t npending;
|
size_t npending;
|
||||||
|
|
||||||
packet_queue_run(transport->packet);
|
packet_queue_run(transport->packet);
|
||||||
if (transport->socket->sock == NULL) {
|
if (transport->socket->sock == NULL) {
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = socket_pending(transport->socket->sock, &npending);
|
status = socket_pending(transport->socket->sock, &npending);
|
||||||
@ -517,9 +518,9 @@ BOOL smbcli_transport_process(struct smbcli_transport *transport)
|
|||||||
packet_recv(transport->packet);
|
packet_recv(transport->packet);
|
||||||
}
|
}
|
||||||
if (transport->socket->sock == NULL) {
|
if (transport->socket->sock == NULL) {
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
Initialize the tree context
|
Initialize the tree context
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
struct smbcli_tree *smbcli_tree_init(struct smbcli_session *session,
|
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;
|
struct smbcli_tree *tree;
|
||||||
|
|
||||||
@ -189,7 +189,7 @@ NTSTATUS smbcli_tree_full_connection(TALLOC_CTX *parent_ctx,
|
|||||||
io.in.service = service;
|
io.in.service = service;
|
||||||
io.in.service_type = service_type;
|
io.in.service_type = service_type;
|
||||||
io.in.credentials = credentials;
|
io.in.credentials = credentials;
|
||||||
io.in.fallback_to_anonymous = False;
|
io.in.fallback_to_anonymous = false;
|
||||||
io.in.workgroup = lp_workgroup(global_loadparm);
|
io.in.workgroup = lp_workgroup(global_loadparm);
|
||||||
|
|
||||||
status = smb_composite_connect(&io, parent_ctx, ev);
|
status = smb_composite_connect(&io, parent_ctx, ev);
|
||||||
|
@ -333,7 +333,7 @@ NTSTATUS ea_pull_name_list(const DATA_BLOB *blob,
|
|||||||
/*
|
/*
|
||||||
put a ea_name list into a data 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)
|
DATA_BLOB *data, uint_t num_names, struct ea_name *eas)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@ -344,7 +344,7 @@ BOOL ea_push_name_list(TALLOC_CTX *mem_ctx,
|
|||||||
|
|
||||||
*data = data_blob_talloc(mem_ctx, NULL, ea_size);
|
*data = data_blob_talloc(mem_ctx, NULL, ea_size);
|
||||||
if (data->data == NULL) {
|
if (data->data == NULL) {
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SIVAL(data->data, 0, ea_size);
|
SIVAL(data->data, 0, ea_size);
|
||||||
@ -357,5 +357,5 @@ BOOL ea_push_name_list(TALLOC_CTX *mem_ctx,
|
|||||||
off += 1+nlen+1;
|
off += 1+nlen+1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -426,7 +426,7 @@ struct smbcli_request *smb_raw_open_send(struct smbcli_tree *tree, union smb_ope
|
|||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
struct smbcli_request *req = NULL;
|
struct smbcli_request *req = NULL;
|
||||||
BOOL bigoffset = False;
|
bool bigoffset = false;
|
||||||
|
|
||||||
switch (parms->generic.level) {
|
switch (parms->generic.level) {
|
||||||
case RAW_OPEN_T2OPEN:
|
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);
|
smbcli_req_append_string(req, parms->openxreadx.in.fname, STR_TERMINATE);
|
||||||
|
|
||||||
if (tree->session->transport->negotiate.capabilities & CAP_LARGE_FILES) {
|
if (tree->session->transport->negotiate.capabilities & CAP_LARGE_FILES) {
|
||||||
bigoffset = True;
|
bigoffset = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
smbcli_chained_request_setup(req, SMBreadX, bigoffset ? 12 : 10, 0);
|
smbcli_chained_request_setup(req, SMBreadX, bigoffset ? 12 : 10, 0);
|
||||||
|
@ -144,8 +144,8 @@ NTSTATUS smb_raw_negotiate_recv(struct smbcli_request *req)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (transport->negotiate.capabilities & CAP_RAW_MODE) {
|
if (transport->negotiate.capabilities & CAP_RAW_MODE) {
|
||||||
transport->negotiate.readbraw_supported = True;
|
transport->negotiate.readbraw_supported = true;
|
||||||
transport->negotiate.writebraw_supported = True;
|
transport->negotiate.writebraw_supported = true;
|
||||||
}
|
}
|
||||||
} else if (transport->negotiate.protocol >= PROTOCOL_LANMAN1) {
|
} else if (transport->negotiate.protocol >= PROTOCOL_LANMAN1) {
|
||||||
SMBCLI_CHECK_WCT(req, 13);
|
SMBCLI_CHECK_WCT(req, 13);
|
||||||
|
@ -31,13 +31,13 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
struct smbcli_request *smb_raw_read_send(struct smbcli_tree *tree, union smb_read *parms)
|
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;
|
struct smbcli_request *req = NULL;
|
||||||
|
|
||||||
switch (parms->generic.level) {
|
switch (parms->generic.level) {
|
||||||
case RAW_READ_READBRAW:
|
case RAW_READ_READBRAW:
|
||||||
if (tree->session->transport->negotiate.capabilities & CAP_LARGE_FILES) {
|
if (tree->session->transport->negotiate.capabilities & CAP_LARGE_FILES) {
|
||||||
bigoffset = True;
|
bigoffset = true;
|
||||||
}
|
}
|
||||||
SETUP_REQUEST(SMBreadbraw, bigoffset? 10:8, 0);
|
SETUP_REQUEST(SMBreadbraw, bigoffset? 10:8, 0);
|
||||||
SSVAL(req->out.vwv, VWV(0), parms->readbraw.in.file.fnum);
|
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:
|
case RAW_READ_READX:
|
||||||
if (tree->session->transport->negotiate.capabilities & CAP_LARGE_FILES) {
|
if (tree->session->transport->negotiate.capabilities & CAP_LARGE_FILES) {
|
||||||
bigoffset = True;
|
bigoffset = true;
|
||||||
}
|
}
|
||||||
SETUP_REQUEST(SMBreadX, bigoffset ? 12 : 10, 0);
|
SETUP_REQUEST(SMBreadX, bigoffset ? 12 : 10, 0);
|
||||||
SSVAL(req->out.vwv, VWV(0), SMB_CHAIN_NONE);
|
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)
|
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;
|
struct smbcli_request *req = NULL;
|
||||||
|
|
||||||
switch (parms->generic.level) {
|
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:
|
case RAW_WRITE_WRITEX:
|
||||||
if (tree->session->transport->negotiate.capabilities & CAP_LARGE_FILES) {
|
if (tree->session->transport->negotiate.capabilities & CAP_LARGE_FILES) {
|
||||||
bigoffset = True;
|
bigoffset = true;
|
||||||
}
|
}
|
||||||
SETUP_REQUEST(SMBwriteX, bigoffset ? 14 : 12, parms->writex.in.count);
|
SETUP_REQUEST(SMBwriteX, bigoffset ? 14 : 12, parms->writex.in.count);
|
||||||
SSVAL(req->out.vwv, VWV(0), SMB_CHAIN_NONE);
|
SSVAL(req->out.vwv, VWV(0), SMB_CHAIN_NONE);
|
||||||
|
@ -309,7 +309,7 @@ NTSTATUS smbcli_chained_advance(struct smbcli_request *req)
|
|||||||
/*
|
/*
|
||||||
send a message
|
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) {
|
if (IVAL(req->out.buffer, 0) == 0) {
|
||||||
_smb_setlen(req->out.buffer, req->out.size - NBT_HDR_SIZE);
|
_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);
|
smbcli_transport_send(req);
|
||||||
|
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
receive a response to a packet
|
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
|
/* req can be NULL when a send has failed. This eliminates lots of NULL
|
||||||
checks in each module */
|
checks in each module */
|
||||||
if (!req) return False;
|
if (!req) return false;
|
||||||
|
|
||||||
/* keep receiving packets until this one is replied to */
|
/* keep receiving packets until this one is replied to */
|
||||||
while (req->state <= SMBCLI_REQUEST_RECV) {
|
while (req->state <= SMBCLI_REQUEST_RECV) {
|
||||||
if (event_loop_once(req->transport->socket->event.ctx) != 0) {
|
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
|
receive another reply to a request - this is used for requests that
|
||||||
have multi-part replies (such as SMBtrans2)
|
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;
|
req->state = SMBCLI_REQUEST_RECV;
|
||||||
DLIST_ADD(req->transport->pending_recv, req);
|
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
|
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
|
/* we must be very fussy about what we consider an oplock break to avoid
|
||||||
matching readbraw replies */
|
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(hdr, HDR_MID) != 0xFFFF ||
|
||||||
SVAL(vwv,VWV(6)) != 0 ||
|
SVAL(vwv,VWV(6)) != 0 ||
|
||||||
SVAL(vwv,VWV(7)) != 0) {
|
SVAL(vwv,VWV(7)) != 0) {
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (transport->oplock.handler) {
|
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);
|
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 */
|
/* 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);
|
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
|
/* check that a lump of data in a request is within the bounds of the data section of
|
||||||
the packet */
|
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! */
|
/* be careful with wraparound! */
|
||||||
if (ptr < req->in.data ||
|
if (ptr < req->in.data ||
|
||||||
ptr >= req->in.data + req->in.data_size ||
|
ptr >= req->in.data + req->in.data_size ||
|
||||||
count > req->in.data_size ||
|
count > req->in.data_size ||
|
||||||
ptr + count > req->in.data + 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
|
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)) {
|
if (smbcli_req_data_oob(req, src, len)) {
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(dest, src, len);
|
memcpy(dest, src, len);
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
/*
|
/*
|
||||||
Handle setfileinfo/setpathinfo passthu constructions
|
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,
|
enum smb_setfileinfo_level level,
|
||||||
union smb_setfileinfo *parms,
|
union smb_setfileinfo *parms,
|
||||||
DATA_BLOB *blob)
|
DATA_BLOB *blob)
|
||||||
@ -36,7 +36,7 @@ BOOL smb_raw_setfileinfo_passthru(TALLOC_CTX *mem_ctx,
|
|||||||
|
|
||||||
#define NEED_BLOB(n) do { \
|
#define NEED_BLOB(n) do { \
|
||||||
*blob = data_blob_talloc(mem_ctx, NULL, n); \
|
*blob = data_blob_talloc(mem_ctx, NULL, n); \
|
||||||
if (blob->data == NULL) return False; \
|
if (blob->data == NULL) return false; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
switch (level) {
|
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);
|
smbcli_push_nttime(blob->data, 24, parms->basic_info.in.change_time);
|
||||||
SIVAL(blob->data, 32, parms->basic_info.in.attrib);
|
SIVAL(blob->data, 32, parms->basic_info.in.attrib);
|
||||||
SIVAL(blob->data, 36, 0); /* padding */
|
SIVAL(blob->data, 36, 0); /* padding */
|
||||||
return True;
|
return true;
|
||||||
|
|
||||||
case RAW_SFILEINFO_DISPOSITION_INFORMATION:
|
case RAW_SFILEINFO_DISPOSITION_INFORMATION:
|
||||||
NEED_BLOB(4);
|
NEED_BLOB(4);
|
||||||
SIVAL(blob->data, 0, parms->disposition_info.in.delete_on_close);
|
SIVAL(blob->data, 0, parms->disposition_info.in.delete_on_close);
|
||||||
return True;
|
return true;
|
||||||
|
|
||||||
case RAW_SFILEINFO_ALLOCATION_INFORMATION:
|
case RAW_SFILEINFO_ALLOCATION_INFORMATION:
|
||||||
NEED_BLOB(8);
|
NEED_BLOB(8);
|
||||||
SBVAL(blob->data, 0, parms->allocation_info.in.alloc_size);
|
SBVAL(blob->data, 0, parms->allocation_info.in.alloc_size);
|
||||||
return True;
|
return true;
|
||||||
|
|
||||||
case RAW_SFILEINFO_END_OF_FILE_INFORMATION:
|
case RAW_SFILEINFO_END_OF_FILE_INFORMATION:
|
||||||
NEED_BLOB(8);
|
NEED_BLOB(8);
|
||||||
SBVAL(blob->data, 0, parms->end_of_file_info.in.size);
|
SBVAL(blob->data, 0, parms->end_of_file_info.in.size);
|
||||||
return True;
|
return true;
|
||||||
|
|
||||||
case RAW_SFILEINFO_RENAME_INFORMATION:
|
case RAW_SFILEINFO_RENAME_INFORMATION:
|
||||||
NEED_BLOB(12);
|
NEED_BLOB(12);
|
||||||
@ -73,17 +73,17 @@ BOOL smb_raw_setfileinfo_passthru(TALLOC_CTX *mem_ctx,
|
|||||||
parms->rename_information.in.new_name,
|
parms->rename_information.in.new_name,
|
||||||
STR_UNICODE|STR_TERMINATE);
|
STR_UNICODE|STR_TERMINATE);
|
||||||
SIVAL(blob->data, 8, len - 2);
|
SIVAL(blob->data, 8, len - 2);
|
||||||
return True;
|
return true;
|
||||||
|
|
||||||
case RAW_SFILEINFO_POSITION_INFORMATION:
|
case RAW_SFILEINFO_POSITION_INFORMATION:
|
||||||
NEED_BLOB(8);
|
NEED_BLOB(8);
|
||||||
SBVAL(blob->data, 0, parms->position_information.in.position);
|
SBVAL(blob->data, 0, parms->position_information.in.position);
|
||||||
return True;
|
return true;
|
||||||
|
|
||||||
case RAW_SFILEINFO_MODE_INFORMATION:
|
case RAW_SFILEINFO_MODE_INFORMATION:
|
||||||
NEED_BLOB(4);
|
NEED_BLOB(4);
|
||||||
SIVAL(blob->data, 0, parms->mode_information.in.mode);
|
SIVAL(blob->data, 0, parms->mode_information.in.mode);
|
||||||
return True;
|
return true;
|
||||||
|
|
||||||
case RAW_FILEINFO_SEC_DESC: {
|
case RAW_FILEINFO_SEC_DESC: {
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
@ -91,9 +91,9 @@ BOOL smb_raw_setfileinfo_passthru(TALLOC_CTX *mem_ctx,
|
|||||||
status = ndr_push_struct_blob(blob, mem_ctx,
|
status = ndr_push_struct_blob(blob, mem_ctx,
|
||||||
parms->set_secdesc.in.sd,
|
parms->set_secdesc.in.sd,
|
||||||
(ndr_push_flags_fn_t)ndr_push_security_descriptor);
|
(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 */
|
/* Unhandled levels */
|
||||||
@ -107,16 +107,16 @@ BOOL smb_raw_setfileinfo_passthru(TALLOC_CTX *mem_ctx,
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
DEBUG(0,("Unhandled setfileinfo passthru level %d\n", level));
|
DEBUG(0,("Unhandled setfileinfo passthru level %d\n", level));
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Handle setfileinfo/setpathinfo trans2 backend.
|
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,
|
TALLOC_CTX *mem_ctx,
|
||||||
union smb_setfileinfo *parms,
|
union smb_setfileinfo *parms,
|
||||||
DATA_BLOB *blob)
|
DATA_BLOB *blob)
|
||||||
@ -127,7 +127,7 @@ static BOOL smb_raw_setinfo_backend(struct smbcli_tree *tree,
|
|||||||
case RAW_SFILEINFO_SETATTRE:
|
case RAW_SFILEINFO_SETATTRE:
|
||||||
case RAW_SFILEINFO_SEC_DESC:
|
case RAW_SFILEINFO_SEC_DESC:
|
||||||
/* not handled here */
|
/* not handled here */
|
||||||
return False;
|
return false;
|
||||||
|
|
||||||
case RAW_SFILEINFO_STANDARD:
|
case RAW_SFILEINFO_STANDARD:
|
||||||
NEED_BLOB(12);
|
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);
|
blob->data, 4, parms->standard.in.access_time);
|
||||||
raw_push_dos_date2(tree->session->transport,
|
raw_push_dos_date2(tree->session->transport,
|
||||||
blob->data, 8, parms->standard.in.write_time);
|
blob->data, 8, parms->standard.in.write_time);
|
||||||
return True;
|
return true;
|
||||||
|
|
||||||
case RAW_SFILEINFO_EA_SET:
|
case RAW_SFILEINFO_EA_SET:
|
||||||
NEED_BLOB(ea_list_size(parms->ea_set.in.num_eas, parms->ea_set.in.eas));
|
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);
|
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_INFO:
|
||||||
case RAW_SFILEINFO_BASIC_INFORMATION:
|
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, 76, parms->unix_basic.in.unique_id);
|
||||||
SBVAL(blob->data, 84, parms->unix_basic.in.permissions);
|
SBVAL(blob->data, 84, parms->unix_basic.in.permissions);
|
||||||
SBVAL(blob->data, 92, parms->unix_basic.in.nlink);
|
SBVAL(blob->data, 92, parms->unix_basic.in.nlink);
|
||||||
return True;
|
return true;
|
||||||
|
|
||||||
case RAW_SFILEINFO_UNIX_INFO2:
|
case RAW_SFILEINFO_UNIX_INFO2:
|
||||||
NEED_BLOB(116);
|
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);
|
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, 108, parms->unix_info2.in.file_flags);
|
||||||
SIVAL(blob->data, 112, parms->unix_info2.in.flags_mask);
|
SIVAL(blob->data, 112, parms->unix_info2.in.flags_mask);
|
||||||
return True;
|
return true;
|
||||||
|
|
||||||
case RAW_SFILEINFO_DISPOSITION_INFO:
|
case RAW_SFILEINFO_DISPOSITION_INFO:
|
||||||
case RAW_SFILEINFO_DISPOSITION_INFORMATION:
|
case RAW_SFILEINFO_DISPOSITION_INFORMATION:
|
||||||
@ -230,7 +230,7 @@ static BOOL smb_raw_setinfo_backend(struct smbcli_tree *tree,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -39,7 +39,7 @@ _PUBLIC_ NTSTATUS smb_raw_shadow_data(struct smbcli_tree *tree,
|
|||||||
nt.ntioctl.level = RAW_IOCTL_NTIOCTL;
|
nt.ntioctl.level = RAW_IOCTL_NTIOCTL;
|
||||||
nt.ntioctl.in.function = FSCTL_GET_SHADOW_COPY_DATA;
|
nt.ntioctl.in.function = FSCTL_GET_SHADOW_COPY_DATA;
|
||||||
nt.ntioctl.in.file.fnum = info->in.file.fnum;
|
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.filter = 0;
|
||||||
nt.ntioctl.in.max_data = info->in.max_data;
|
nt.ntioctl.in.max_data = info->in.max_data;
|
||||||
nt.ntioctl.in.blob = data_blob(NULL, 0);
|
nt.ntioctl.in.blob = data_blob(NULL, 0);
|
||||||
|
@ -27,13 +27,13 @@
|
|||||||
/*
|
/*
|
||||||
check out of bounds for incoming data
|
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)
|
uint_t offset, uint_t count)
|
||||||
{
|
{
|
||||||
uint8_t *ptr;
|
uint8_t *ptr;
|
||||||
|
|
||||||
if (count == 0) {
|
if (count == 0) {
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ptr = req->in.hdr + offset;
|
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 ||
|
ptr >= req->in.data + req->in.data_size ||
|
||||||
count > req->in.data_size ||
|
count > req->in.data_size ||
|
||||||
ptr + count > req->in.data + req->in.data_size) {
|
ptr + count > req->in.data + req->in.data_size) {
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -28,41 +28,41 @@
|
|||||||
/***********************************************************
|
/***********************************************************
|
||||||
SMB signing - Common code before we set a new signing implementation
|
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) {
|
if (sign_info->doing_signing) {
|
||||||
DEBUG(5, ("SMB Signing already in progress, so we don't start it again\n"));
|
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) {
|
if (!sign_info->allow_smb_signing) {
|
||||||
DEBUG(5, ("SMB Signing has been locally disabled\n"));
|
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
|
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)) {
|
if (!set_smb_signing_common(&transport->negotiate.sign_info)) {
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(transport->negotiate.sec_mode &
|
if (!(transport->negotiate.sec_mode &
|
||||||
(NEGOTIATE_SECURITY_SIGNATURES_REQUIRED|NEGOTIATE_SECURITY_SIGNATURES_ENABLED))) {
|
(NEGOTIATE_SECURITY_SIGNATURES_REQUIRED|NEGOTIATE_SECURITY_SIGNATURES_ENABLED))) {
|
||||||
DEBUG(5, ("SMB Signing is not negotiated by the peer\n"));
|
DEBUG(5, ("SMB Signing is not negotiated by the peer\n"));
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* These calls are INCOMPATIBLE with SMB signing */
|
/* These calls are INCOMPATIBLE with SMB signing */
|
||||||
transport->negotiate.readbraw_supported = False;
|
transport->negotiate.readbraw_supported = false;
|
||||||
transport->negotiate.writebraw_supported = False;
|
transport->negotiate.writebraw_supported = false;
|
||||||
|
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mark_packet_signed(struct request_buffer *out)
|
void mark_packet_signed(struct request_buffer *out)
|
||||||
@ -73,17 +73,17 @@ void mark_packet_signed(struct request_buffer *out)
|
|||||||
SSVAL(out->hdr, HDR_FLG2, flags2);
|
SSVAL(out->hdr, HDR_FLG2, flags2);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL signing_good(struct smb_signing_context *sign_info,
|
bool signing_good(struct smb_signing_context *sign_info,
|
||||||
unsigned int seq, BOOL good)
|
unsigned int seq, bool good)
|
||||||
{
|
{
|
||||||
if (good) {
|
if (good) {
|
||||||
if (!sign_info->doing_signing) {
|
if (!sign_info->doing_signing) {
|
||||||
DEBUG(5, ("Seen valid packet, so turning signing on\n"));
|
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) {
|
if (!sign_info->seen_valid) {
|
||||||
DEBUG(5, ("Seen valid packet, so marking signing as 'seen valid'\n"));
|
DEBUG(5, ("Seen valid packet, so marking signing as 'seen valid'\n"));
|
||||||
sign_info->seen_valid = True;
|
sign_info->seen_valid = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!sign_info->seen_valid) {
|
if (!sign_info->seen_valid) {
|
||||||
@ -91,14 +91,14 @@ BOOL signing_good(struct smb_signing_context *sign_info,
|
|||||||
DEBUG(5, ("signing_good: signing negotiated but not required and peer\n"
|
DEBUG(5, ("signing_good: signing negotiated but not required and peer\n"
|
||||||
"isn't sending correct signatures. Turning off.\n"));
|
"isn't sending correct signatures. Turning off.\n"));
|
||||||
smbcli_set_signing_off(sign_info);
|
smbcli_set_signing_off(sign_info);
|
||||||
return True;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
/* bad packet after signing started - fail and disconnect. */
|
/* bad packet after signing started - fail and disconnect. */
|
||||||
DEBUG(0, ("signing_good: BAD SIG: seq %u\n", seq));
|
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)
|
void sign_outgoing_message(struct request_buffer *out, DATA_BLOB *mac_key, unsigned int seq_num)
|
||||||
@ -133,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...*/
|
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 calc_md5_mac[16];
|
||||||
uint8_t *server_sent_mac;
|
uint8_t *server_sent_mac;
|
||||||
uint8_t sequence_buf[8];
|
uint8_t sequence_buf[8];
|
||||||
@ -146,12 +146,12 @@ BOOL check_signed_incoming_message(struct request_buffer *in, DATA_BLOB *mac_key
|
|||||||
|
|
||||||
/* room enough for the signature? */
|
/* room enough for the signature? */
|
||||||
if (in->size < NBT_HDR_SIZE + HDR_SS_FIELD + 8) {
|
if (in->size < NBT_HDR_SIZE + HDR_SS_FIELD + 8) {
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mac_key->length) {
|
if (!mac_key->length) {
|
||||||
/* NO key yet */
|
/* NO key yet */
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* its quite bogus to be guessing sequence numbers, but very useful
|
/* its quite bogus to be guessing sequence numbers, but very useful
|
||||||
@ -258,24 +258,24 @@ void smbcli_request_calculate_sign_mac(struct smbcli_request *req)
|
|||||||
@note Used as an initialisation only - it will not correctly
|
@note Used as an initialisation only - it will not correctly
|
||||||
shut down a real signing mechanism
|
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"));
|
DEBUG(5, ("Shutdown SMB signing\n"));
|
||||||
sign_info->doing_signing = False;
|
sign_info->doing_signing = false;
|
||||||
sign_info->next_seq_num = 0;
|
sign_info->next_seq_num = 0;
|
||||||
data_blob_free(&sign_info->mac_key);
|
data_blob_free(&sign_info->mac_key);
|
||||||
sign_info->signing_state = SMB_SIGNING_ENGINE_OFF;
|
sign_info->signing_state = SMB_SIGNING_ENGINE_OFF;
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
SMB signing - TEMP implementation - setup the MAC key.
|
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)) {
|
if (!smbcli_set_smb_signing_common(transport)) {
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
DEBUG(5, ("BSRSPYL SMB signing enabled\n"));
|
DEBUG(5, ("BSRSPYL SMB signing enabled\n"));
|
||||||
smbcli_set_signing_off(&transport->negotiate.sign_info);
|
smbcli_set_signing_off(&transport->negotiate.sign_info);
|
||||||
@ -283,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.mac_key = data_blob(NULL, 0);
|
||||||
transport->negotiate.sign_info.signing_state = SMB_SIGNING_ENGINE_BSRSPYL;
|
transport->negotiate.sign_info.signing_state = SMB_SIGNING_ENGINE_BSRSPYL;
|
||||||
|
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************
|
/***********************************************************
|
||||||
@ -291,22 +291,22 @@ BOOL smbcli_temp_set_signing(struct smbcli_transport *transport)
|
|||||||
************************************************************/
|
************************************************************/
|
||||||
/**
|
/**
|
||||||
* Check a packet supplied by the server.
|
* Check a packet supplied by the server.
|
||||||
* @return False if we had an established signing connection
|
* @return false if we had an established signing connection
|
||||||
* which had a back checksum, True otherwise
|
* 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)
|
switch (req->transport->negotiate.sign_info.signing_state)
|
||||||
{
|
{
|
||||||
case SMB_SIGNING_ENGINE_OFF:
|
case SMB_SIGNING_ENGINE_OFF:
|
||||||
return True;
|
return true;
|
||||||
case SMB_SIGNING_ENGINE_BSRSPYL:
|
case SMB_SIGNING_ENGINE_BSRSPYL:
|
||||||
case SMB_SIGNING_ENGINE_ON:
|
case SMB_SIGNING_ENGINE_ON:
|
||||||
{
|
{
|
||||||
if (req->in.size < (HDR_SS_FIELD + 8)) {
|
if (req->in.size < (HDR_SS_FIELD + 8)) {
|
||||||
return False;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
good = check_signed_incoming_message(&req->in,
|
good = check_signed_incoming_message(&req->in,
|
||||||
&req->transport->negotiate.sign_info.mac_key,
|
&req->transport->negotiate.sign_info.mac_key,
|
||||||
@ -317,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.
|
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,
|
struct smb_signing_context *sign_info,
|
||||||
const DATA_BLOB *user_session_key,
|
const DATA_BLOB *user_session_key,
|
||||||
const DATA_BLOB *response)
|
const DATA_BLOB *response)
|
||||||
@ -354,19 +354,19 @@ BOOL smbcli_simple_set_signing(TALLOC_CTX *mem_ctx,
|
|||||||
|
|
||||||
sign_info->signing_state = SMB_SIGNING_ENGINE_ON;
|
sign_info->signing_state = SMB_SIGNING_ENGINE_ON;
|
||||||
|
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************
|
/***********************************************************
|
||||||
SMB signing - Simple implementation - setup the MAC key.
|
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 user_session_key,
|
||||||
const DATA_BLOB response)
|
const DATA_BLOB response)
|
||||||
{
|
{
|
||||||
if (!smbcli_set_smb_signing_common(transport)) {
|
if (!smbcli_set_smb_signing_common(transport)) {
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return smbcli_simple_set_signing(transport,
|
return smbcli_simple_set_signing(transport,
|
||||||
@ -380,21 +380,21 @@ bool smbcli_init_signing(struct smbcli_transport *transport)
|
|||||||
{
|
{
|
||||||
transport->negotiate.sign_info.mac_key = data_blob(NULL, 0);
|
transport->negotiate.sign_info.mac_key = data_blob(NULL, 0);
|
||||||
if (!smbcli_set_signing_off(&transport->negotiate.sign_info)) {
|
if (!smbcli_set_signing_off(&transport->negotiate.sign_info)) {
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (lp_client_signing(global_loadparm)) {
|
switch (lp_client_signing(global_loadparm)) {
|
||||||
case SMB_SIGNING_OFF:
|
case SMB_SIGNING_OFF:
|
||||||
transport->negotiate.sign_info.allow_smb_signing = False;
|
transport->negotiate.sign_info.allow_smb_signing = false;
|
||||||
break;
|
break;
|
||||||
case SMB_SIGNING_SUPPORTED:
|
case SMB_SIGNING_SUPPORTED:
|
||||||
case SMB_SIGNING_AUTO:
|
case SMB_SIGNING_AUTO:
|
||||||
transport->negotiate.sign_info.allow_smb_signing = True;
|
transport->negotiate.sign_info.allow_smb_signing = true;
|
||||||
break;
|
break;
|
||||||
case SMB_SIGNING_REQUIRED:
|
case SMB_SIGNING_REQUIRED:
|
||||||
transport->negotiate.sign_info.allow_smb_signing = True;
|
transport->negotiate.sign_info.allow_smb_signing = true;
|
||||||
transport->negotiate.sign_info.mandatory_signing = True;
|
transport->negotiate.sign_info.mandatory_signing = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ struct composite_context *resolve_name_bcast_send(TALLOC_CTX *mem_ctx,
|
|||||||
}
|
}
|
||||||
address_list[count] = NULL;
|
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);
|
talloc_free(address_list);
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
|
@ -99,8 +99,8 @@ struct composite_context *resolve_name_nbtlist_send(TALLOC_CTX *mem_ctx,
|
|||||||
struct event_context *event_ctx,
|
struct event_context *event_ctx,
|
||||||
struct nbt_name *name,
|
struct nbt_name *name,
|
||||||
const char **address_list,
|
const char **address_list,
|
||||||
BOOL broadcast,
|
bool broadcast,
|
||||||
BOOL wins_lookup)
|
bool wins_lookup)
|
||||||
{
|
{
|
||||||
struct composite_context *c;
|
struct composite_context *c;
|
||||||
struct nbtlist_state *state;
|
struct nbtlist_state *state;
|
||||||
@ -193,7 +193,7 @@ NTSTATUS resolve_name_nbtlist_recv(struct composite_context *c,
|
|||||||
NTSTATUS resolve_name_nbtlist(struct nbt_name *name,
|
NTSTATUS resolve_name_nbtlist(struct nbt_name *name,
|
||||||
TALLOC_CTX *mem_ctx,
|
TALLOC_CTX *mem_ctx,
|
||||||
const char **address_list,
|
const char **address_list,
|
||||||
BOOL broadcast, BOOL wins_lookup,
|
bool broadcast, bool wins_lookup,
|
||||||
const char **reply_addr)
|
const char **reply_addr)
|
||||||
{
|
{
|
||||||
struct composite_context *c = resolve_name_nbtlist_send(mem_ctx, NULL, name, address_list,
|
struct composite_context *c = resolve_name_nbtlist_send(mem_ctx, NULL, name, address_list,
|
||||||
|
@ -34,7 +34,7 @@ struct composite_context *resolve_name_wins_send(
|
|||||||
{
|
{
|
||||||
const char **address_list = lp_wins_server_list(global_loadparm);
|
const char **address_list = lp_wins_server_list(global_loadparm);
|
||||||
if (address_list == NULL) return NULL;
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -241,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)
|
const struct dom_sid *sid)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!domain_sid || !sid) {
|
if (!domain_sid || !sid) {
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (domain_sid->num_auths > sid->num_auths) {
|
if (domain_sid->num_auths > sid->num_auths) {
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = domain_sid->num_auths-1; i >= 0; --i) {
|
for (i = domain_sid->num_auths-1; i >= 0; --i) {
|
||||||
if (domain_sid->sub_auths[i] != sid->sub_auths[i]) {
|
if (domain_sid->sub_auths[i] != sid->sub_auths[i]) {
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,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;
|
uint64_t mask;
|
||||||
|
|
||||||
if (privilege < 1 || privilege > 64) {
|
if (privilege < 1 || privilege > 64) {
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
mask = sec_privilege_mask(privilege);
|
mask = sec_privilege_mask(privilege);
|
||||||
if (token->privilege_mask & mask) {
|
if (token->privilege_mask & mask) {
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -32,7 +32,7 @@ struct flag_map {
|
|||||||
/*
|
/*
|
||||||
map a series of letter codes into a uint32_t
|
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)
|
uint32_t *flags, size_t *len)
|
||||||
{
|
{
|
||||||
const char *str0 = str;
|
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) {
|
if (map[i].name == NULL) {
|
||||||
DEBUG(1, ("Unknown flag - %s in %s\n", str, str0));
|
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
|
decode an ACE
|
||||||
return True on success, False on failure
|
return true on success, false on failure
|
||||||
note that this routine modifies the string
|
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 struct dom_sid *domain_sid)
|
||||||
{
|
{
|
||||||
const char *tok[6];
|
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;
|
tok[0] = str;
|
||||||
for (i=0;i<5;i++) {
|
for (i=0;i<5;i++) {
|
||||||
char *ptr = strchr(str, ';');
|
char *ptr = strchr(str, ';');
|
||||||
if (ptr == NULL) return False;
|
if (ptr == NULL) return false;
|
||||||
*ptr = 0;
|
*ptr = 0;
|
||||||
str = ptr+1;
|
str = ptr+1;
|
||||||
tok[i+1] = str;
|
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 */
|
/* parse ace type */
|
||||||
if (!sddl_map_flags(ace_types, tok[0], &v, NULL)) {
|
if (!sddl_map_flags(ace_types, tok[0], &v, NULL)) {
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
ace->type = v;
|
ace->type = v;
|
||||||
|
|
||||||
/* ace flags */
|
/* ace flags */
|
||||||
if (!sddl_map_flags(ace_flags, tok[1], &v, NULL)) {
|
if (!sddl_map_flags(ace_flags, tok[1], &v, NULL)) {
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
ace->flags = v;
|
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);
|
ace->access_mask = strtol(tok[2], NULL, 16);
|
||||||
} else {
|
} else {
|
||||||
if (!sddl_map_flags(ace_access_mask, tok[2], &v, NULL)) {
|
if (!sddl_map_flags(ace_access_mask, tok[2], &v, NULL)) {
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
ace->access_mask = v;
|
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],
|
NTSTATUS status = GUID_from_string(tok[3],
|
||||||
&ace->object.object.type.type);
|
&ace->object.object.type.type);
|
||||||
if (!NT_STATUS_IS_OK(status)) {
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
ace->object.object.flags |= SEC_ACE_OBJECT_TYPE_PRESENT;
|
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],
|
NTSTATUS status = GUID_from_string(tok[4],
|
||||||
&ace->object.object.inherited_type.inherited_type);
|
&ace->object.object.inherited_type.inherited_type);
|
||||||
if (!NT_STATUS_IS_OK(status)) {
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
ace->object.object.flags |= SEC_ACE_INHERITED_OBJECT_TYPE_PRESENT;
|
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];
|
s = tok[5];
|
||||||
sid = sddl_decode_sid(mem_ctx, &s, domain_sid);
|
sid = sddl_decode_sid(mem_ctx, &s, domain_sid);
|
||||||
if (sid == NULL) {
|
if (sid == NULL) {
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
ace->trustee = *sid;
|
ace->trustee = *sid;
|
||||||
talloc_steal(mem_ctx, sid->sub_auths);
|
talloc_steal(mem_ctx, sid->sub_auths);
|
||||||
talloc_free(sid);
|
talloc_free(sid);
|
||||||
|
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct flag_map acl_flags[] = {
|
static const struct flag_map acl_flags[] = {
|
||||||
@ -388,7 +388,7 @@ failed:
|
|||||||
turn a set of flags into a string
|
turn a set of flags into a string
|
||||||
*/
|
*/
|
||||||
static char *sddl_flags_to_string(TALLOC_CTX *mem_ctx, const struct flag_map *map,
|
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;
|
int i;
|
||||||
char *s;
|
char *s;
|
||||||
@ -477,13 +477,13 @@ static char *sddl_encode_ace(TALLOC_CTX *mem_ctx, const struct security_ace *ace
|
|||||||
return NULL;
|
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;
|
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;
|
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) {
|
if (s_mask == NULL) {
|
||||||
s_mask = talloc_asprintf(tmp_ctx, "0x%08x", ace->access_mask);
|
s_mask = talloc_asprintf(tmp_ctx, "0x%08x", ace->access_mask);
|
||||||
if (s_mask == NULL) goto failed;
|
if (s_mask == NULL) goto failed;
|
||||||
@ -525,7 +525,7 @@ static char *sddl_encode_acl(TALLOC_CTX *mem_ctx, const struct security_acl *acl
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* add any ACL flags */
|
/* 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;
|
if (sddl == NULL) goto failed;
|
||||||
|
|
||||||
/* now the ACEs, encoded in braces */
|
/* now the ACEs, encoded in braces */
|
||||||
|
@ -242,77 +242,77 @@ NTSTATUS security_descriptor_dacl_del(struct security_descriptor *sd,
|
|||||||
/*
|
/*
|
||||||
compare two security ace structures
|
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)
|
const struct security_ace *ace2)
|
||||||
{
|
{
|
||||||
if (ace1 == ace2) return True;
|
if (ace1 == ace2) return true;
|
||||||
if (!ace1 || !ace2) return False;
|
if (!ace1 || !ace2) return false;
|
||||||
if (ace1->type != ace2->type) return False;
|
if (ace1->type != ace2->type) return false;
|
||||||
if (ace1->flags != ace2->flags) return False;
|
if (ace1->flags != ace2->flags) return false;
|
||||||
if (ace1->access_mask != ace2->access_mask) return False;
|
if (ace1->access_mask != ace2->access_mask) return false;
|
||||||
if (!dom_sid_equal(&ace1->trustee, &ace2->trustee)) return False;
|
if (!dom_sid_equal(&ace1->trustee, &ace2->trustee)) return false;
|
||||||
|
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
compare two security acl structures
|
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)
|
const struct security_acl *acl2)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (acl1 == acl2) return True;
|
if (acl1 == acl2) return true;
|
||||||
if (!acl1 || !acl2) return False;
|
if (!acl1 || !acl2) return false;
|
||||||
if (acl1->revision != acl2->revision) return False;
|
if (acl1->revision != acl2->revision) return false;
|
||||||
if (acl1->num_aces != acl2->num_aces) return False;
|
if (acl1->num_aces != acl2->num_aces) return false;
|
||||||
|
|
||||||
for (i=0;i<acl1->num_aces;i++) {
|
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.
|
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)
|
const struct security_descriptor *sd2)
|
||||||
{
|
{
|
||||||
if (sd1 == sd2) return True;
|
if (sd1 == sd2) return true;
|
||||||
if (!sd1 || !sd2) return False;
|
if (!sd1 || !sd2) return false;
|
||||||
if (sd1->revision != sd2->revision) return False;
|
if (sd1->revision != sd2->revision) return false;
|
||||||
if (sd1->type != sd2->type) 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->owner_sid, sd2->owner_sid)) return false;
|
||||||
if (!dom_sid_equal(sd1->group_sid, sd2->group_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->sacl, sd2->sacl)) return false;
|
||||||
if (!security_acl_equal(sd1->dacl, sd2->dacl)) 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
|
compare two security descriptors, but allow certain (missing) parts
|
||||||
to be masked out of the comparison
|
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,
|
const struct security_descriptor *sd2,
|
||||||
uint32_t mask)
|
uint32_t mask)
|
||||||
{
|
{
|
||||||
if (sd1 == sd2) return True;
|
if (sd1 == sd2) return true;
|
||||||
if (!sd1 || !sd2) return False;
|
if (!sd1 || !sd2) return false;
|
||||||
if (sd1->revision != sd2->revision) return False;
|
if (sd1->revision != sd2->revision) return false;
|
||||||
if ((sd1->type & mask) != (sd2->type & mask)) 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->owner_sid, sd2->owner_sid)) return false;
|
||||||
if (!dom_sid_equal(sd1->group_sid, sd2->group_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_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 ((mask & SEC_DESC_SACL_PRESENT) && !security_acl_equal(sd1->sacl, sd2->sacl)) return false;
|
||||||
|
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -79,19 +79,19 @@ void security_token_debug(int dbg_lev, const struct security_token *token)
|
|||||||
|
|
||||||
/* These really should be cheaper... */
|
/* 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)) {
|
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);
|
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);
|
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;
|
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);
|
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);
|
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;
|
int i;
|
||||||
for (i = 0; i < token->num_sids; i++) {
|
for (i = 0; i < token->num_sids; i++) {
|
||||||
if (dom_sid_equal(token->sids[i], sid)) {
|
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);
|
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);
|
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;
|
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);
|
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);
|
return security_token_has_sid_string(token, SID_NT_AUTHENTICATED_USERS);
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ NTSTATUS smb2_cancel(struct smb2_request *r)
|
|||||||
|
|
||||||
/* we don't want a seqmun for a SMB2 Cancel */
|
/* we don't want a seqmun for a SMB2 Cancel */
|
||||||
old_seqnum = r->transport->seqnum;
|
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;
|
r->transport->seqnum = old_seqnum;
|
||||||
NT_STATUS_HAVE_NO_MEMORY(c);
|
NT_STATUS_HAVE_NO_MEMORY(c);
|
||||||
c->seqnum = 0;
|
c->seqnum = 0;
|
||||||
|
@ -31,7 +31,7 @@ struct smb2_request *smb2_close_send(struct smb2_tree *tree, struct smb2_close *
|
|||||||
{
|
{
|
||||||
struct smb2_request *req;
|
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;
|
if (req == NULL) return NULL;
|
||||||
|
|
||||||
SSVAL(req->out.body, 0x02, io->in.flags);
|
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);
|
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.flags = SVAL(req->in.body, 0x02);
|
||||||
io->out._pad = IVAL(req->in.body, 0x04);
|
io->out._pad = IVAL(req->in.body, 0x04);
|
||||||
|
@ -69,7 +69,7 @@ static void continue_session(struct composite_context *creq)
|
|||||||
c->status = smb2_session_setup_spnego_recv(creq);
|
c->status = smb2_session_setup_spnego_recv(creq);
|
||||||
if (!composite_is_ok(c)) return;
|
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;
|
if (composite_nomem(state->tree, c)) return;
|
||||||
|
|
||||||
state->tcon.in.unknown1 = 0x09;
|
state->tcon.in.unknown1 = 0x09;
|
||||||
@ -99,7 +99,7 @@ static void continue_negprot(struct smb2_request *req)
|
|||||||
c->status = smb2_negprot_recv(req, c, &state->negprot);
|
c->status = smb2_negprot_recv(req, c, &state->negprot);
|
||||||
if (!composite_is_ok(c)) return;
|
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;
|
if (composite_nomem(state->session, c)) return;
|
||||||
|
|
||||||
creq = smb2_session_setup_spnego_send(state->session, state->credentials);
|
creq = smb2_session_setup_spnego_send(state->session, state->credentials);
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
*/
|
*/
|
||||||
NTSTATUS smb2_create_blob_add(TALLOC_CTX *mem_ctx, DATA_BLOB *blob,
|
NTSTATUS smb2_create_blob_add(TALLOC_CTX *mem_ctx, DATA_BLOB *blob,
|
||||||
uint32_t tag,
|
uint32_t tag,
|
||||||
DATA_BLOB add, BOOL last)
|
DATA_BLOB add, bool last)
|
||||||
{
|
{
|
||||||
uint32_t ofs = blob->length;
|
uint32_t ofs = blob->length;
|
||||||
uint8_t pad = smb2_padding_size(add.length, 8);
|
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;
|
NTSTATUS status;
|
||||||
DATA_BLOB blob = data_blob(NULL, 0);
|
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;
|
if (req == NULL) return NULL;
|
||||||
|
|
||||||
SSVAL(req->out.body, 0x02, io->in.oplock_flags);
|
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,
|
DATA_BLOB b = data_blob_talloc(req, NULL,
|
||||||
ea_list_size_chained(io->in.eas.num_eas, io->in.eas.eas));
|
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);
|
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)) {
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
talloc_free(req);
|
talloc_free(req);
|
||||||
return NULL;
|
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
|
/* an empty MxAc tag seems to be used to ask the server to
|
||||||
return the maximum access mask allowed on the file */
|
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)) {
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
talloc_free(req);
|
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);
|
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.oplock_flags = SVAL(req->in.body, 0x02);
|
||||||
io->out.create_action = IVAL(req->in.body, 0x04);
|
io->out.create_action = IVAL(req->in.body, 0x04);
|
||||||
|
@ -32,7 +32,7 @@ struct smb2_request *smb2_find_send(struct smb2_tree *tree, struct smb2_find *io
|
|||||||
struct smb2_request *req;
|
struct smb2_request *req;
|
||||||
NTSTATUS status;
|
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;
|
if (req == NULL) return NULL;
|
||||||
|
|
||||||
SCVAL(req->out.body, 0x02, io->in.level);
|
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);
|
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,
|
status = smb2_pull_o16s32_blob(&req->in, mem_ctx,
|
||||||
req->in.body+0x02, &io->out.blob);
|
req->in.body+0x02, &io->out.blob);
|
||||||
|
@ -30,7 +30,7 @@ struct smb2_request *smb2_flush_send(struct smb2_tree *tree, struct smb2_flush *
|
|||||||
{
|
{
|
||||||
struct smb2_request *req;
|
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;
|
if (req == NULL) return NULL;
|
||||||
|
|
||||||
SSVAL(req->out.body, 0x02, 0); /* pad? */
|
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);
|
return smb2_request_destroy(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
SMB2_CHECK_PACKET_RECV(req, 0x04, False);
|
SMB2_CHECK_PACKET_RECV(req, 0x04, false);
|
||||||
|
|
||||||
return smb2_request_destroy(req);
|
return smb2_request_destroy(req);
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ struct smb2_request *smb2_getinfo_send(struct smb2_tree *tree, struct smb2_getin
|
|||||||
{
|
{
|
||||||
struct smb2_request *req;
|
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;
|
if (req == NULL) return NULL;
|
||||||
|
|
||||||
/* this seems to be a bug, they use 0x29 but only send 0x28 bytes */
|
/* 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);
|
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);
|
status = smb2_pull_o16s16_blob(&req->in, mem_ctx, req->in.body+0x02, &io->out.blob);
|
||||||
if (!NT_STATUS_IS_OK(status)) {
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
|
@ -31,7 +31,7 @@ struct smb2_request *smb2_ioctl_send(struct smb2_tree *tree, struct smb2_ioctl *
|
|||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
struct smb2_request *req;
|
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);
|
io->in.in.length+io->in.out.length);
|
||||||
if (req == NULL) return NULL;
|
if (req == NULL) return NULL;
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ NTSTATUS smb2_ioctl_recv(struct smb2_request *req,
|
|||||||
return smb2_request_destroy(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._pad = SVAL(req->in.body, 0x02);
|
||||||
io->out.function = IVAL(req->in.body, 0x04);
|
io->out.function = IVAL(req->in.body, 0x04);
|
||||||
|
@ -30,7 +30,7 @@ struct smb2_request *smb2_keepalive_send(struct smb2_transport *transport)
|
|||||||
{
|
{
|
||||||
struct smb2_request *req;
|
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;
|
if (req == NULL) return NULL;
|
||||||
|
|
||||||
SSVAL(req->out.body, 0x02, 0);
|
SSVAL(req->out.body, 0x02, 0);
|
||||||
@ -51,7 +51,7 @@ NTSTATUS smb2_keepalive_recv(struct smb2_request *req)
|
|||||||
return smb2_request_destroy(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);
|
return smb2_request_destroy(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ struct smb2_request *smb2_lock_send(struct smb2_tree *tree, struct smb2_lock *io
|
|||||||
{
|
{
|
||||||
struct smb2_request *req;
|
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;
|
if (req == NULL) return NULL;
|
||||||
|
|
||||||
SSVAL(req->out.body, 0x02, io->in.unknown1);
|
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);
|
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);
|
io->out.unknown1 = SVAL(req->in.body, 0x02);
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ struct smb2_request *smb2_logoff_send(struct smb2_session *session)
|
|||||||
{
|
{
|
||||||
struct smb2_request *req;
|
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;
|
if (req == NULL) return NULL;
|
||||||
|
|
||||||
SBVAL(req->out.hdr, SMB2_HDR_UID, session->uid);
|
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);
|
return smb2_request_destroy(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
SMB2_CHECK_PACKET_RECV(req, 0x04, False);
|
SMB2_CHECK_PACKET_RECV(req, 0x04, false);
|
||||||
return smb2_request_destroy(req);
|
return smb2_request_destroy(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ struct smb2_request *smb2_negprot_send(struct smb2_transport *transport,
|
|||||||
{
|
{
|
||||||
struct smb2_request *req;
|
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;
|
if (req == NULL) return NULL;
|
||||||
|
|
||||||
/* this seems to be a bug, they use 0x24 but the length is 0x26 */
|
/* 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);
|
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._pad = SVAL(req->in.body, 0x02);
|
||||||
io->out.unknown2 = IVAL(req->in.body, 0x04);
|
io->out.unknown2 = IVAL(req->in.body, 0x04);
|
||||||
|
@ -32,7 +32,7 @@ struct smb2_request *smb2_notify_send(struct smb2_tree *tree, struct smb2_notify
|
|||||||
struct smb2_request *req;
|
struct smb2_request *req;
|
||||||
uint32_t old_timeout;
|
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;
|
if (req == NULL) return NULL;
|
||||||
|
|
||||||
SSVAL(req->out.hdr, SMB2_HDR_UNKNOWN1, 0x0030);
|
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);
|
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);
|
status = smb2_pull_o16s32_blob(&req->in, mem_ctx, req->in.body+0x02, &blob);
|
||||||
if (!NT_STATUS_IS_OK(status)) {
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
|
@ -30,7 +30,7 @@ struct smb2_request *smb2_read_send(struct smb2_tree *tree, struct smb2_read *io
|
|||||||
{
|
{
|
||||||
struct smb2_request *req;
|
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;
|
if (req == NULL) return NULL;
|
||||||
|
|
||||||
SSVAL(req->out.body, 0x02, 0); /* pad */
|
SSVAL(req->out.body, 0x02, 0); /* pad */
|
||||||
@ -59,7 +59,7 @@ NTSTATUS smb2_read_recv(struct smb2_request *req,
|
|||||||
return smb2_request_destroy(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);
|
status = smb2_pull_o16s32_blob(&req->in, mem_ctx, req->in.body+0x02, &io->out.data);
|
||||||
if (!NT_STATUS_IS_OK(status)) {
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
initialise a smb2 request
|
initialise a smb2 request
|
||||||
*/
|
*/
|
||||||
struct smb2_request *smb2_request_init(struct smb2_transport *transport, uint16_t opcode,
|
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)
|
uint32_t body_dynamic_size)
|
||||||
{
|
{
|
||||||
struct smb2_request *req;
|
struct smb2_request *req;
|
||||||
@ -113,7 +113,7 @@ struct smb2_request *smb2_request_init(struct smb2_transport *transport, uint16_
|
|||||||
initialise a smb2 request for tree operations
|
initialise a smb2 request for tree operations
|
||||||
*/
|
*/
|
||||||
struct smb2_request *smb2_request_init_tree(struct smb2_tree *tree, uint16_t opcode,
|
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)
|
uint32_t body_dynamic_size)
|
||||||
{
|
{
|
||||||
struct smb2_request *req = smb2_request_init(tree->session->transport, opcode,
|
struct smb2_request *req = smb2_request_init(tree->session->transport, opcode,
|
||||||
@ -157,16 +157,16 @@ NTSTATUS smb2_request_destroy(struct smb2_request *req)
|
|||||||
/*
|
/*
|
||||||
receive a response to a packet
|
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
|
/* req can be NULL when a send has failed. This eliminates lots of NULL
|
||||||
checks in each module */
|
checks in each module */
|
||||||
if (!req) return False;
|
if (!req) return false;
|
||||||
|
|
||||||
/* keep receiving packets until this one is replied to */
|
/* keep receiving packets until this one is replied to */
|
||||||
while (req->state <= SMB2_REQUEST_RECV) {
|
while (req->state <= SMB2_REQUEST_RECV) {
|
||||||
if (event_loop_once(req->transport->socket->event.ctx) != 0) {
|
if (event_loop_once(req->transport->socket->event.ctx) != 0) {
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,13 +174,13 @@ BOOL smb2_request_receive(struct smb2_request *req)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Return true if the last packet was in error */
|
/* 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 NT_STATUS_IS_ERR(req->status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return true if the last packet was OK */
|
/* 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);
|
return NT_STATUS_IS_OK(req->status);
|
||||||
}
|
}
|
||||||
@ -188,16 +188,16 @@ BOOL smb2_request_is_ok(struct smb2_request *req)
|
|||||||
/*
|
/*
|
||||||
check if a range in the reply body is out of bounds
|
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! */
|
/* be careful with wraparound! */
|
||||||
if (ptr < buf->body ||
|
if (ptr < buf->body ||
|
||||||
ptr >= buf->body + buf->body_size ||
|
ptr >= buf->body + buf->body_size ||
|
||||||
size > buf->body_size ||
|
size > buf->body_size ||
|
||||||
ptr + size > buf->body + 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)
|
size_t smb2_padding_size(uint32_t offset, size_t n)
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
initialise a smb2_session structure
|
initialise a smb2_session structure
|
||||||
*/
|
*/
|
||||||
struct smb2_session *smb2_session_init(struct smb2_transport *transport,
|
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;
|
struct smb2_session *session;
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
@ -68,7 +68,7 @@ struct smb2_request *smb2_session_setup_send(struct smb2_session *session,
|
|||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
|
|
||||||
req = smb2_request_init(session->transport, SMB2_OP_SESSSETUP,
|
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;
|
if (req == NULL) return NULL;
|
||||||
|
|
||||||
SBVAL(req->out.hdr, SMB2_HDR_UID, session->uid);
|
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);
|
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._pad = SVAL(req->in.body, 0x02);
|
||||||
io->out.uid = BVAL(req->in.hdr, SMB2_HDR_UID);
|
io->out.uid = BVAL(req->in.hdr, SMB2_HDR_UID);
|
||||||
|
@ -32,7 +32,7 @@ struct smb2_request *smb2_setinfo_send(struct smb2_tree *tree, struct smb2_setin
|
|||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
struct smb2_request *req;
|
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;
|
if (req == NULL) return NULL;
|
||||||
|
|
||||||
SSVAL(req->out.body, 0x02, io->in.level);
|
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);
|
return smb2_request_destroy(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
SMB2_CHECK_PACKET_RECV(req, 0x02, False);
|
SMB2_CHECK_PACKET_RECV(req, 0x02, false);
|
||||||
|
|
||||||
return smb2_request_destroy(req);
|
return smb2_request_destroy(req);
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
initialise a smb2_session structure
|
initialise a smb2_session structure
|
||||||
*/
|
*/
|
||||||
struct smb2_tree *smb2_tree_init(struct smb2_session *session,
|
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;
|
struct smb2_tree *tree;
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ struct smb2_request *smb2_tree_connect_send(struct smb2_tree *tree,
|
|||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
|
|
||||||
req = smb2_request_init(tree->session->transport, SMB2_OP_TCON,
|
req = smb2_request_init(tree->session->transport, SMB2_OP_TCON,
|
||||||
0x08, True, 0);
|
0x08, true, 0);
|
||||||
if (req == NULL) return NULL;
|
if (req == NULL) return NULL;
|
||||||
|
|
||||||
SBVAL(req->out.hdr, SMB2_HDR_UID, tree->session->uid);
|
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);
|
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);
|
io->out.tid = IVAL(req->in.hdr, SMB2_HDR_TID);
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ struct smb2_request *smb2_tdis_send(struct smb2_tree *tree)
|
|||||||
{
|
{
|
||||||
struct smb2_request *req;
|
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;
|
if (req == NULL) return NULL;
|
||||||
|
|
||||||
SSVAL(req->out.body, 0x02, 0);
|
SSVAL(req->out.body, 0x02, 0);
|
||||||
@ -51,7 +51,7 @@ NTSTATUS smb2_tdis_recv(struct smb2_request *req)
|
|||||||
return smb2_request_destroy(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);
|
return smb2_request_destroy(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,7 +193,7 @@ static NTSTATUS smb2_transport_finish_recv(void *private, DATA_BLOB blob)
|
|||||||
|
|
||||||
if (NT_STATUS_EQUAL(req->status, STATUS_PENDING)) {
|
if (NT_STATUS_EQUAL(req->status, STATUS_PENDING)) {
|
||||||
if (flags & 0x00000002) {
|
if (flags & 0x00000002) {
|
||||||
req->cancel.can_cancel = True;
|
req->cancel.can_cancel = true;
|
||||||
req->cancel.pending_id = IVAL(hdr, SMB2_HDR_PID);
|
req->cancel.pending_id = IVAL(hdr, SMB2_HDR_PID);
|
||||||
for (i=0; i< req->cancel.do_cancel; i++) {
|
for (i=0; i< req->cancel.do_cancel; i++) {
|
||||||
smb2_cancel(req);
|
smb2_cancel(req);
|
||||||
|
@ -31,7 +31,7 @@ struct smb2_request *smb2_write_send(struct smb2_tree *tree, struct smb2_write *
|
|||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
struct smb2_request *req;
|
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;
|
if (req == NULL) return NULL;
|
||||||
|
|
||||||
status = smb2_push_o16s32_blob(&req->out, 0x02, io->in.data);
|
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);
|
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._pad = SVAL(req->in.body, 0x02);
|
||||||
io->out.nwritten = IVAL(req->in.body, 0x04);
|
io->out.nwritten = IVAL(req->in.body, 0x04);
|
||||||
|
@ -116,12 +116,12 @@ static NTSTATUS connect_session_setup_anon(struct composite_context *c,
|
|||||||
status = smb_composite_sesssetup_recv(state->creq);
|
status = smb_composite_sesssetup_recv(state->creq);
|
||||||
NT_STATUS_NOT_OK_RETURN(status);
|
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;
|
state->session->vuid = state->io_setup->out.vuid;
|
||||||
|
|
||||||
/* setup for a tconx */
|
/* 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);
|
NT_STATUS_HAVE_NO_MEMORY(io->out.tree);
|
||||||
|
|
||||||
state->io_tcon = talloc(c, union smb_tcon);
|
state->io_tcon = talloc(c, union smb_tcon);
|
||||||
@ -203,7 +203,7 @@ static NTSTATUS connect_session_setup(struct composite_context *c,
|
|||||||
state->session->vuid = state->io_setup->out.vuid;
|
state->session->vuid = state->io_setup->out.vuid;
|
||||||
|
|
||||||
/* setup for a tconx */
|
/* 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);
|
NT_STATUS_HAVE_NO_MEMORY(io->out.tree);
|
||||||
|
|
||||||
state->io_tcon = talloc(c, union smb_tcon);
|
state->io_tcon = talloc(c, union smb_tcon);
|
||||||
@ -251,7 +251,7 @@ static NTSTATUS connect_negprot(struct composite_context *c,
|
|||||||
NT_STATUS_NOT_OK_RETURN(status);
|
NT_STATUS_NOT_OK_RETURN(status);
|
||||||
|
|
||||||
/* next step is a session setup */
|
/* 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);
|
NT_STATUS_HAVE_NO_MEMORY(state->session);
|
||||||
|
|
||||||
state->io_setup = talloc(c, struct smb_composite_sesssetup);
|
state->io_setup = talloc(c, struct smb_composite_sesssetup);
|
||||||
@ -307,7 +307,7 @@ static NTSTATUS connect_socket(struct composite_context *c,
|
|||||||
NT_STATUS_NOT_OK_RETURN(status);
|
NT_STATUS_NOT_OK_RETURN(status);
|
||||||
|
|
||||||
/* the socket is up - we can initialise the smbcli transport layer */
|
/* 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);
|
NT_STATUS_HAVE_NO_MEMORY(state->transport);
|
||||||
|
|
||||||
if (is_ipaddress(state->sock->hostname) &&
|
if (is_ipaddress(state->sock->hostname) &&
|
||||||
|
@ -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 = io->in.service;
|
||||||
state->connect->in.service_type = io->in.service_type;
|
state->connect->in.service_type = io->in.service_type;
|
||||||
state->connect->in.credentials = io->in.credentials;
|
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->connect->in.workgroup = io->in.workgroup;
|
||||||
|
|
||||||
state->creq = smb_composite_connect_send(state->connect, state, event_ctx);
|
state->creq = smb_composite_connect_send(state->connect, state, event_ctx);
|
||||||
|
@ -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 = io->in.service;
|
||||||
state->connect->in.service_type = io->in.service_type;
|
state->connect->in.service_type = io->in.service_type;
|
||||||
state->connect->in.credentials = io->in.credentials;
|
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->connect->in.workgroup = io->in.workgroup;
|
||||||
|
|
||||||
c->state = COMPOSITE_STATE_IN_PROGRESS;
|
c->state = COMPOSITE_STATE_IN_PROGRESS;
|
||||||
|
@ -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.mincnt = MIN(32768, io->out.size);
|
||||||
state->io_read->readx.in.maxcnt = state->io_read->readx.in.mincnt;
|
state->io_read->readx.in.maxcnt = state->io_read->readx.in.mincnt;
|
||||||
state->io_read->readx.in.remaining = 0;
|
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->io_read->readx.out.data = io->out.data;
|
||||||
|
|
||||||
state->req = smb_raw_read_send(tree, state->io_read);
|
state->req = smb_raw_read_send(tree, state->io_read);
|
||||||
|
@ -37,41 +37,41 @@ void asn1_free(struct asn1_data *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* write to the ASN1 buffer, advancing the buffer pointer */
|
/* 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) {
|
if (data->length < data->ofs+len) {
|
||||||
uint8_t *newp;
|
uint8_t *newp;
|
||||||
newp = talloc_realloc(data, data->data, uint8_t, data->ofs+len);
|
newp = talloc_realloc(data, data->data, uint8_t, data->ofs+len);
|
||||||
if (!newp) {
|
if (!newp) {
|
||||||
asn1_free(data);
|
asn1_free(data);
|
||||||
data->has_error = True;
|
data->has_error = true;
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
data->data = newp;
|
data->data = newp;
|
||||||
data->length = data->ofs+len;
|
data->length = data->ofs+len;
|
||||||
}
|
}
|
||||||
memcpy(data->data + data->ofs, p, len);
|
memcpy(data->data + data->ofs, p, len);
|
||||||
data->ofs += len;
|
data->ofs += len;
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* useful fn for writing a uint8_t */
|
/* 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);
|
return asn1_write(data, &v, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* push a tag onto the asn1 data buffer. Used for nested structures */
|
/* 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;
|
struct nesting *nesting;
|
||||||
|
|
||||||
asn1_write_uint8(data, tag);
|
asn1_write_uint8(data, tag);
|
||||||
nesting = talloc(data, struct nesting);
|
nesting = talloc(data, struct nesting);
|
||||||
if (!nesting) {
|
if (!nesting) {
|
||||||
data->has_error = True;
|
data->has_error = true;
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
nesting->start = data->ofs;
|
nesting->start = data->ofs;
|
||||||
@ -81,7 +81,7 @@ BOOL asn1_push_tag(struct asn1_data *data, uint8_t tag)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* pop a tag */
|
/* pop a tag */
|
||||||
BOOL asn1_pop_tag(struct asn1_data *data)
|
bool asn1_pop_tag(struct asn1_data *data)
|
||||||
{
|
{
|
||||||
struct nesting *nesting;
|
struct nesting *nesting;
|
||||||
size_t len;
|
size_t len;
|
||||||
@ -89,8 +89,8 @@ BOOL asn1_pop_tag(struct asn1_data *data)
|
|||||||
nesting = data->nesting;
|
nesting = data->nesting;
|
||||||
|
|
||||||
if (!nesting) {
|
if (!nesting) {
|
||||||
data->has_error = True;
|
data->has_error = true;
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
len = data->ofs - (nesting->start+1);
|
len = data->ofs - (nesting->start+1);
|
||||||
/* yes, this is ugly. We don't know in advance how many bytes the length
|
/* 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 */
|
need to correct our mistake */
|
||||||
if (len > 0xFFFFFF) {
|
if (len > 0xFFFFFF) {
|
||||||
data->data[nesting->start] = 0x84;
|
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);
|
memmove(data->data+nesting->start+5, data->data+nesting->start+1, len);
|
||||||
data->data[nesting->start+1] = (len>>24) & 0xFF;
|
data->data[nesting->start+1] = (len>>24) & 0xFF;
|
||||||
data->data[nesting->start+2] = (len>>16) & 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;
|
data->data[nesting->start+4] = len&0xff;
|
||||||
} else if (len > 0xFFFF) {
|
} else if (len > 0xFFFF) {
|
||||||
data->data[nesting->start] = 0x83;
|
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);
|
memmove(data->data+nesting->start+4, data->data+nesting->start+1, len);
|
||||||
data->data[nesting->start+1] = (len>>16) & 0xFF;
|
data->data[nesting->start+1] = (len>>16) & 0xFF;
|
||||||
data->data[nesting->start+2] = (len>>8) & 0xFF;
|
data->data[nesting->start+2] = (len>>8) & 0xFF;
|
||||||
data->data[nesting->start+3] = len&0xff;
|
data->data[nesting->start+3] = len&0xff;
|
||||||
} else if (len > 255) {
|
} else if (len > 255) {
|
||||||
data->data[nesting->start] = 0x82;
|
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);
|
memmove(data->data+nesting->start+3, data->data+nesting->start+1, len);
|
||||||
data->data[nesting->start+1] = len>>8;
|
data->data[nesting->start+1] = len>>8;
|
||||||
data->data[nesting->start+2] = len&0xff;
|
data->data[nesting->start+2] = len&0xff;
|
||||||
} else if (len > 127) {
|
} else if (len > 127) {
|
||||||
data->data[nesting->start] = 0x81;
|
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);
|
memmove(data->data+nesting->start+2, data->data+nesting->start+1, len);
|
||||||
data->data[nesting->start+1] = len;
|
data->data[nesting->start+1] = len;
|
||||||
} else {
|
} else {
|
||||||
@ -134,20 +134,20 @@ BOOL asn1_pop_tag(struct asn1_data *data)
|
|||||||
|
|
||||||
data->nesting = nesting->next;
|
data->nesting = nesting->next;
|
||||||
talloc_free(nesting);
|
talloc_free(nesting);
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* "i" is the one's complement representation, as is the normal result of an
|
/* "i" is the one's complement representation, as is the normal result of an
|
||||||
* implicit signed->unsigned conversion */
|
* 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;
|
uint8_t lowest = i & 0xFF;
|
||||||
|
|
||||||
i = i >> 8;
|
i = i >> 8;
|
||||||
if (i != 0)
|
if (i != 0)
|
||||||
if (!push_int_bigendian(data, i, negative))
|
if (!push_int_bigendian(data, i, negative))
|
||||||
return False;
|
return false;
|
||||||
|
|
||||||
if (data->nesting->start+1 == data->ofs) {
|
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) {
|
if (negative) {
|
||||||
/* Don't write leading 0xff's */
|
/* Don't write leading 0xff's */
|
||||||
if (lowest == 0xFF)
|
if (lowest == 0xFF)
|
||||||
return True;
|
return true;
|
||||||
|
|
||||||
if ((lowest & 0x80) == 0) {
|
if ((lowest & 0x80) == 0) {
|
||||||
/* The only exception for a leading 0xff is if
|
/* The only exception for a leading 0xff is if
|
||||||
* the highest bit is 0, which would indicate
|
* the highest bit is 0, which would indicate
|
||||||
* a positive value */
|
* a positive value */
|
||||||
if (!asn1_write_uint8(data, 0xff))
|
if (!asn1_write_uint8(data, 0xff))
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (lowest & 0x80) {
|
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
|
* this would indicate a negative number. Push
|
||||||
* a 0 to indicate a positive one */
|
* a 0 to indicate a positive one */
|
||||||
if (!asn1_write_uint8(data, 0))
|
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
|
/* write an Integer without the tag framing. Needed for example for the LDAP
|
||||||
* Abandon Operation */
|
* 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) {
|
if (i == -1) {
|
||||||
/* -1 is special as it consists of all-0xff bytes. In
|
/* -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 */
|
/* 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_push_tag(data, ASN1_INTEGER)) return false;
|
||||||
if (!asn1_write_implicit_Integer(data, i)) return False;
|
if (!asn1_write_implicit_Integer(data, i)) return false;
|
||||||
return asn1_pop_tag(data);
|
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;
|
uint_t v, v2;
|
||||||
const char *p = (const char *)OID;
|
const char *p = (const char *)OID;
|
||||||
@ -213,16 +213,16 @@ BOOL ber_write_OID_String(DATA_BLOB *blob, const char *OID)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
v = strtoul(p, &newp, 10);
|
v = strtoul(p, &newp, 10);
|
||||||
if (newp[0] != '.') return False;
|
if (newp[0] != '.') return false;
|
||||||
p = newp + 1;
|
p = newp + 1;
|
||||||
|
|
||||||
v2 = strtoul(p, &newp, 10);
|
v2 = strtoul(p, &newp, 10);
|
||||||
if (newp[0] != '.') return False;
|
if (newp[0] != '.') return false;
|
||||||
p = newp + 1;
|
p = newp + 1;
|
||||||
|
|
||||||
/*the ber representation can't use more space then the string one */
|
/*the ber representation can't use more space then the string one */
|
||||||
*blob = data_blob(NULL, strlen(OID));
|
*blob = data_blob(NULL, strlen(OID));
|
||||||
if (!blob->data) return False;
|
if (!blob->data) return false;
|
||||||
|
|
||||||
blob->data[0] = 40*v + v2;
|
blob->data[0] = 40*v + v2;
|
||||||
|
|
||||||
@ -235,7 +235,7 @@ BOOL ber_write_OID_String(DATA_BLOB *blob, const char *OID)
|
|||||||
p = newp;
|
p = newp;
|
||||||
} else {
|
} else {
|
||||||
data_blob_free(blob);
|
data_blob_free(blob);
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
if (v >= (1<<28)) blob->data[i++] = (0x80 | ((v>>28)&0x7f));
|
if (v >= (1<<28)) blob->data[i++] = (0x80 | ((v>>28)&0x7f));
|
||||||
if (v >= (1<<21)) blob->data[i++] = (0x80 | ((v>>21)&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;
|
blob->length = i;
|
||||||
|
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* write an object ID to a ASN1 buffer */
|
/* 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;
|
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)) {
|
if (!ber_write_OID_String(&blob, OID)) {
|
||||||
data->has_error = True;
|
data->has_error = true;
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!asn1_write(data, blob.data, blob.length)) {
|
if (!asn1_write(data, blob.data, blob.length)) {
|
||||||
data->has_error = True;
|
data->has_error = true;
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
data_blob_free(&blob);
|
data_blob_free(&blob);
|
||||||
return asn1_pop_tag(data);
|
return asn1_pop_tag(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* write an octet string */
|
/* 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_push_tag(data, ASN1_OCTET_STRING);
|
||||||
asn1_write(data, p, length);
|
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 */
|
/* 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));
|
asn1_write(data, s, strlen(s));
|
||||||
return !data->has_error;
|
return !data->has_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* write a general string */
|
/* 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_push_tag(data, ASN1_GENERAL_STRING);
|
||||||
asn1_write_LDAPString(data, s);
|
asn1_write_LDAPString(data, s);
|
||||||
@ -294,7 +294,7 @@ BOOL asn1_write_GeneralString(struct asn1_data *data, const char *s)
|
|||||||
return !data->has_error;
|
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_push_tag(data, ASN1_CONTEXT_SIMPLE(num));
|
||||||
asn1_write(data, blob->data, blob->length);
|
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 */
|
/* 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_push_tag(data, ASN1_BOOLEAN);
|
||||||
asn1_write_uint8(data, v ? 0xFF : 0);
|
asn1_write_uint8(data, v ? 0xFF : 0);
|
||||||
@ -311,140 +311,140 @@ BOOL asn1_write_BOOLEAN(struct asn1_data *data, BOOL v)
|
|||||||
return !data->has_error;
|
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;
|
uint8_t tmp = 0;
|
||||||
asn1_start_tag(data, ASN1_BOOLEAN);
|
asn1_start_tag(data, ASN1_BOOLEAN);
|
||||||
asn1_read_uint8(data, &tmp);
|
asn1_read_uint8(data, &tmp);
|
||||||
if (tmp == 0xFF) {
|
if (tmp == 0xFF) {
|
||||||
*v = True;
|
*v = true;
|
||||||
} else {
|
} else {
|
||||||
*v = False;
|
*v = false;
|
||||||
}
|
}
|
||||||
asn1_end_tag(data);
|
asn1_end_tag(data);
|
||||||
return !data->has_error;
|
return !data->has_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check a BOOLEAN */
|
/* 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;
|
uint8_t b = 0;
|
||||||
|
|
||||||
asn1_read_uint8(data, &b);
|
asn1_read_uint8(data, &b);
|
||||||
if (b != ASN1_BOOLEAN) {
|
if (b != ASN1_BOOLEAN) {
|
||||||
data->has_error = True;
|
data->has_error = true;
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
asn1_read_uint8(data, &b);
|
asn1_read_uint8(data, &b);
|
||||||
if (b != v) {
|
if (b != v) {
|
||||||
data->has_error = True;
|
data->has_error = true;
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
return !data->has_error;
|
return !data->has_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* load a struct asn1_data structure with a lump of data, ready to be parsed */
|
/* 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);
|
ZERO_STRUCTP(data);
|
||||||
data->data = talloc_memdup(data, blob.data, blob.length);
|
data->data = talloc_memdup(data, blob.data, blob.length);
|
||||||
if (!data->data) {
|
if (!data->data) {
|
||||||
data->has_error = True;
|
data->has_error = true;
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
data->length = blob.length;
|
data->length = blob.length;
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Peek into an ASN1 buffer, not advancing the pointer */
|
/* 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)
|
if (data->has_error)
|
||||||
return False;
|
return false;
|
||||||
|
|
||||||
if (len < 0 || data->ofs + len < data->ofs || data->ofs + len < len)
|
if (len < 0 || data->ofs + len < data->ofs || data->ofs + len < len)
|
||||||
return False;
|
return false;
|
||||||
|
|
||||||
if (data->ofs + len > data->length) {
|
if (data->ofs + len > data->length) {
|
||||||
/* we need to mark the buffer as consumed, so the caller knows
|
/* we need to mark the buffer as consumed, so the caller knows
|
||||||
this was an out of data error, and not a decode error */
|
this was an out of data error, and not a decode error */
|
||||||
data->ofs = data->length;
|
data->ofs = data->length;
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(p, data->data + data->ofs, len);
|
memcpy(p, data->data + data->ofs, len);
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* read from a ASN1 buffer, advancing the buffer pointer */
|
/* 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)) {
|
if (!asn1_peek(data, p, len)) {
|
||||||
data->has_error = True;
|
data->has_error = true;
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
data->ofs += len;
|
data->ofs += len;
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* read a uint8_t from a ASN1 buffer */
|
/* 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);
|
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);
|
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;
|
uint8_t b;
|
||||||
|
|
||||||
if (asn1_tag_remaining(data) <= 0) {
|
if (asn1_tag_remaining(data) <= 0) {
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!asn1_peek_uint8(data, &b))
|
if (!asn1_peek_uint8(data, &b))
|
||||||
return False;
|
return false;
|
||||||
|
|
||||||
return (b == tag);
|
return (b == tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* start reading a nested asn1 structure */
|
/* 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;
|
uint8_t b;
|
||||||
struct nesting *nesting;
|
struct nesting *nesting;
|
||||||
|
|
||||||
if (!asn1_read_uint8(data, &b))
|
if (!asn1_read_uint8(data, &b))
|
||||||
return False;
|
return false;
|
||||||
|
|
||||||
if (b != tag) {
|
if (b != tag) {
|
||||||
data->has_error = True;
|
data->has_error = true;
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
nesting = talloc(data, struct nesting);
|
nesting = talloc(data, struct nesting);
|
||||||
if (!nesting) {
|
if (!nesting) {
|
||||||
data->has_error = True;
|
data->has_error = true;
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!asn1_read_uint8(data, &b)) {
|
if (!asn1_read_uint8(data, &b)) {
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (b & 0x80) {
|
if (b & 0x80) {
|
||||||
int n = b & 0x7f;
|
int n = b & 0x7f;
|
||||||
if (!asn1_read_uint8(data, &b))
|
if (!asn1_read_uint8(data, &b))
|
||||||
return False;
|
return false;
|
||||||
nesting->taglen = b;
|
nesting->taglen = b;
|
||||||
while (n > 1) {
|
while (n > 1) {
|
||||||
if (!asn1_read_uint8(data, &b))
|
if (!asn1_read_uint8(data, &b))
|
||||||
return False;
|
return false;
|
||||||
nesting->taglen = (nesting->taglen << 8) | b;
|
nesting->taglen = (nesting->taglen << 8) | b;
|
||||||
n--;
|
n--;
|
||||||
}
|
}
|
||||||
@ -455,32 +455,32 @@ BOOL asn1_start_tag(struct asn1_data *data, uint8_t tag)
|
|||||||
nesting->next = data->nesting;
|
nesting->next = data->nesting;
|
||||||
data->nesting = nesting;
|
data->nesting = nesting;
|
||||||
if (asn1_tag_remaining(data) == -1) {
|
if (asn1_tag_remaining(data) == -1) {
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
return !data->has_error;
|
return !data->has_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* stop reading a tag */
|
/* stop reading a tag */
|
||||||
BOOL asn1_end_tag(struct asn1_data *data)
|
bool asn1_end_tag(struct asn1_data *data)
|
||||||
{
|
{
|
||||||
struct nesting *nesting;
|
struct nesting *nesting;
|
||||||
|
|
||||||
/* make sure we read it all */
|
/* make sure we read it all */
|
||||||
if (asn1_tag_remaining(data) != 0) {
|
if (asn1_tag_remaining(data) != 0) {
|
||||||
data->has_error = True;
|
data->has_error = true;
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
nesting = data->nesting;
|
nesting = data->nesting;
|
||||||
|
|
||||||
if (!nesting) {
|
if (!nesting) {
|
||||||
data->has_error = True;
|
data->has_error = true;
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
data->nesting = nesting->next;
|
data->nesting = nesting->next;
|
||||||
talloc_free(nesting);
|
talloc_free(nesting);
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* work out how many bytes are left in this nested tag */
|
/* work out how many bytes are left in this nested tag */
|
||||||
@ -492,26 +492,26 @@ int asn1_tag_remaining(struct asn1_data *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!data->nesting) {
|
if (!data->nesting) {
|
||||||
data->has_error = True;
|
data->has_error = true;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
remaining = data->nesting->taglen - (data->ofs - data->nesting->start);
|
remaining = data->nesting->taglen - (data->ofs - data->nesting->start);
|
||||||
if (remaining > (data->length - data->ofs)) {
|
if (remaining > (data->length - data->ofs)) {
|
||||||
data->has_error = True;
|
data->has_error = true;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return remaining;
|
return remaining;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* read an object ID from a data blob */
|
/* 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;
|
int i;
|
||||||
uint8_t *b;
|
uint8_t *b;
|
||||||
uint_t v;
|
uint_t v;
|
||||||
char *tmp_oid = NULL;
|
char *tmp_oid = NULL;
|
||||||
|
|
||||||
if (blob.length < 2) return False;
|
if (blob.length < 2) return false;
|
||||||
|
|
||||||
b = blob.data;
|
b = blob.data;
|
||||||
|
|
||||||
@ -531,82 +531,82 @@ BOOL ber_read_OID_String(TALLOC_CTX *mem_ctx, DATA_BLOB blob, const char **OID)
|
|||||||
|
|
||||||
if (v != 0) {
|
if (v != 0) {
|
||||||
talloc_free(tmp_oid);
|
talloc_free(tmp_oid);
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
*OID = tmp_oid;
|
*OID = tmp_oid;
|
||||||
return True;
|
return true;
|
||||||
|
|
||||||
nomem:
|
nomem:
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* read an object ID from a ASN1 buffer */
|
/* 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;
|
DATA_BLOB blob;
|
||||||
int len;
|
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);
|
len = asn1_tag_remaining(data);
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
data->has_error = True;
|
data->has_error = true;
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
blob = data_blob(NULL, len);
|
blob = data_blob(NULL, len);
|
||||||
if (!blob.data) {
|
if (!blob.data) {
|
||||||
data->has_error = True;
|
data->has_error = true;
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
asn1_read(data, blob.data, len);
|
asn1_read(data, blob.data, len);
|
||||||
asn1_end_tag(data);
|
asn1_end_tag(data);
|
||||||
if (data->has_error) {
|
if (data->has_error) {
|
||||||
data_blob_free(&blob);
|
data_blob_free(&blob);
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ber_read_OID_String(mem_ctx, blob, OID)) {
|
if (!ber_read_OID_String(mem_ctx, blob, OID)) {
|
||||||
data->has_error = True;
|
data->has_error = true;
|
||||||
data_blob_free(&blob);
|
data_blob_free(&blob);
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
data_blob_free(&blob);
|
data_blob_free(&blob);
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check that the next object ID is correct */
|
/* 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;
|
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) {
|
if (strcmp(id, OID) != 0) {
|
||||||
talloc_free(discard_const(id));
|
talloc_free(discard_const(id));
|
||||||
data->has_error = True;
|
data->has_error = true;
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
talloc_free(discard_const(id));
|
talloc_free(discard_const(id));
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* read a LDAPString from a ASN1 buffer */
|
/* 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;
|
int len;
|
||||||
len = asn1_tag_remaining(data);
|
len = asn1_tag_remaining(data);
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
data->has_error = True;
|
data->has_error = true;
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
*s = talloc_array(mem_ctx, char, len+1);
|
*s = talloc_array(mem_ctx, char, len+1);
|
||||||
if (! *s) {
|
if (! *s) {
|
||||||
data->has_error = True;
|
data->has_error = true;
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
asn1_read(data, *s, len);
|
asn1_read(data, *s, len);
|
||||||
(*s)[len] = 0;
|
(*s)[len] = 0;
|
||||||
@ -615,29 +615,29 @@ BOOL asn1_read_LDAPString(struct asn1_data *data, TALLOC_CTX *mem_ctx, char **s)
|
|||||||
|
|
||||||
|
|
||||||
/* read a GeneralString from a ASN1 buffer */
|
/* 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_start_tag(data, ASN1_GENERAL_STRING)) return false;
|
||||||
if (!asn1_read_LDAPString(data, mem_ctx, s)) return False;
|
if (!asn1_read_LDAPString(data, mem_ctx, s)) return false;
|
||||||
return asn1_end_tag(data);
|
return asn1_end_tag(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* read a octet string blob */
|
/* 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;
|
int len;
|
||||||
ZERO_STRUCTP(blob);
|
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);
|
len = asn1_tag_remaining(data);
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
data->has_error = True;
|
data->has_error = true;
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
*blob = data_blob_talloc(mem_ctx, NULL, len+1);
|
*blob = data_blob_talloc(mem_ctx, NULL, len+1);
|
||||||
if (!blob->data) {
|
if (!blob->data) {
|
||||||
data->has_error = True;
|
data->has_error = true;
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
asn1_read(data, blob->data, len);
|
asn1_read(data, blob->data, len);
|
||||||
asn1_end_tag(data);
|
asn1_end_tag(data);
|
||||||
@ -647,25 +647,25 @@ BOOL asn1_read_OctetString(struct asn1_data *data, TALLOC_CTX *mem_ctx, DATA_BLO
|
|||||||
if (data->has_error) {
|
if (data->has_error) {
|
||||||
data_blob_free(blob);
|
data_blob_free(blob);
|
||||||
*blob = data_blob(NULL, 0);
|
*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;
|
int len;
|
||||||
ZERO_STRUCTP(blob);
|
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);
|
len = asn1_tag_remaining(data);
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
data->has_error = True;
|
data->has_error = true;
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
*blob = data_blob(NULL, len);
|
*blob = data_blob(NULL, len);
|
||||||
if ((len != 0) && (!blob->data)) {
|
if ((len != 0) && (!blob->data)) {
|
||||||
data->has_error = True;
|
data->has_error = true;
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
asn1_read(data, blob->data, len);
|
asn1_read(data, blob->data, len);
|
||||||
asn1_end_tag(data);
|
asn1_end_tag(data);
|
||||||
@ -673,13 +673,13 @@ BOOL asn1_read_ContextSimple(struct asn1_data *data, uint8_t num, DATA_BLOB *blo
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* read an interger without tag*/
|
/* 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;
|
uint8_t b;
|
||||||
*i = 0;
|
*i = 0;
|
||||||
|
|
||||||
while (!data->has_error && asn1_tag_remaining(data)>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;
|
*i = (*i << 8) + b;
|
||||||
}
|
}
|
||||||
return !data->has_error;
|
return !data->has_error;
|
||||||
@ -687,21 +687,21 @@ BOOL asn1_read_implicit_Integer(struct asn1_data *data, int *i)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* read an interger */
|
/* 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;
|
*i = 0;
|
||||||
|
|
||||||
if (!asn1_start_tag(data, ASN1_INTEGER)) return False;
|
if (!asn1_start_tag(data, ASN1_INTEGER)) return false;
|
||||||
if (!asn1_read_implicit_Integer(data, i)) return False;
|
if (!asn1_read_implicit_Integer(data, i)) return false;
|
||||||
return asn1_end_tag(data);
|
return asn1_end_tag(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* read an interger */
|
/* 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;
|
*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) {
|
while (!data->has_error && asn1_tag_remaining(data)>0) {
|
||||||
uint8_t b;
|
uint8_t b;
|
||||||
asn1_read_uint8(data, &b);
|
asn1_read_uint8(data, &b);
|
||||||
@ -711,23 +711,23 @@ BOOL asn1_read_enumerated(struct asn1_data *data, int *v)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* check a enumarted value is correct */
|
/* 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;
|
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_read_uint8(data, &b);
|
||||||
asn1_end_tag(data);
|
asn1_end_tag(data);
|
||||||
|
|
||||||
if (v != b)
|
if (v != b)
|
||||||
data->has_error = False;
|
data->has_error = false;
|
||||||
|
|
||||||
return !data->has_error;
|
return !data->has_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* write an enumarted value to the stream */
|
/* 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_write_uint8(data, v);
|
||||||
asn1_pop_tag(data);
|
asn1_pop_tag(data);
|
||||||
return !data->has_error;
|
return !data->has_error;
|
||||||
|
@ -61,7 +61,7 @@ static NTSTATUS smblsa_connect(struct smbcli_state *cli)
|
|||||||
return NT_STATUS_NO_MEMORY;
|
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) {
|
if (lsa->ipc_tree == NULL) {
|
||||||
return NT_STATUS_NO_MEMORY;
|
return NT_STATUS_NO_MEMORY;
|
||||||
}
|
}
|
||||||
|
@ -1162,7 +1162,7 @@ static const struct {
|
|||||||
/*
|
/*
|
||||||
check if a DOS encoded NTSTATUS code maps to the given NTSTATUS code
|
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
|
/* 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
|
the mapping of dos codes, as we want to catch the cases where
|
||||||
|
@ -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)
|
static void wrepl_socket_dead(struct wrepl_socket *wrepl_socket, NTSTATUS status)
|
||||||
{
|
{
|
||||||
wrepl_socket->dead = True;
|
wrepl_socket->dead = true;
|
||||||
|
|
||||||
if (wrepl_socket->packet) {
|
if (wrepl_socket->packet) {
|
||||||
packet_recv_disable(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)
|
static int wrepl_socket_destructor(struct wrepl_socket *sock)
|
||||||
{
|
{
|
||||||
if (sock->dead) {
|
if (sock->dead) {
|
||||||
sock->free_skipped = True;
|
sock->free_skipped = true;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
wrepl_socket_dead(sock, NT_STATUS_LOCAL_DISCONNECT);
|
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
|
trigger an immediate event on a wrepl_request
|
||||||
the return value should only be used in wrepl_request_send()
|
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)
|
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;
|
req->status = status;
|
||||||
|
|
||||||
if (req->trigger) {
|
if (req->trigger) {
|
||||||
req->trigger = False;
|
req->trigger = false;
|
||||||
/* a zero timeout means immediate */
|
/* a zero timeout means immediate */
|
||||||
te = event_add_timed(req->wrepl_socket->event.ctx,
|
te = event_add_timed(req->wrepl_socket->event.ctx,
|
||||||
req, timeval_zero(),
|
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
|
/* here, we need to make sure the async request handler is called
|
||||||
* later in the next event_loop and now now
|
* later in the next event_loop and now now
|
||||||
*/
|
*/
|
||||||
req->trigger = True;
|
req->trigger = true;
|
||||||
wrepl_request_finished(req, NT_STATUS_OK);
|
wrepl_request_finished(req, NT_STATUS_OK);
|
||||||
|
|
||||||
if (s->ctrl.disconnect_after_send) {
|
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;
|
if (!req) return NULL;
|
||||||
req->wrepl_socket = wrepl_socket;
|
req->wrepl_socket = wrepl_socket;
|
||||||
req->state = WREPL_REQUEST_RECV;
|
req->state = WREPL_REQUEST_RECV;
|
||||||
req->trigger = True;
|
req->trigger = true;
|
||||||
|
|
||||||
DLIST_ADD_END(wrepl_socket->recv_queue, req, struct wrepl_request *);
|
DLIST_ADD_END(wrepl_socket->recv_queue, req, struct wrepl_request *);
|
||||||
talloc_set_destructor(req, wrepl_request_destructor);
|
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);
|
return wrepl_request_finished(req, req->status);
|
||||||
}
|
}
|
||||||
|
|
||||||
req->trigger = False;
|
req->trigger = false;
|
||||||
return req;
|
return req;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -638,8 +638,8 @@ struct wrepl_request *wrepl_associate_stop_send(struct wrepl_socket *wrepl_socke
|
|||||||
|
|
||||||
ZERO_STRUCT(ctrl);
|
ZERO_STRUCT(ctrl);
|
||||||
if (io->in.reason == 0) {
|
if (io->in.reason == 0) {
|
||||||
ctrl.send_only = True;
|
ctrl.send_only = true;
|
||||||
ctrl.disconnect_after_send = True;
|
ctrl.disconnect_after_send = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
req = wrepl_request_send(wrepl_socket, packet, &ctrl);
|
req = wrepl_request_send(wrepl_socket, packet, &ctrl);
|
||||||
|
@ -120,7 +120,7 @@ struct wrepl_pull_table {
|
|||||||
#define WREPL_NAME_TYPE(flags) (flags & WREPL_FLAGS_RECORD_TYPE)
|
#define WREPL_NAME_TYPE(flags) (flags & WREPL_FLAGS_RECORD_TYPE)
|
||||||
#define WREPL_NAME_STATE(flags) ((flags & WREPL_FLAGS_RECORD_STATE)>>2)
|
#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_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) \
|
#define WREPL_NAME_FLAGS(type, state, node, is_static) \
|
||||||
(type | (state << 2) | (node << 5) | \
|
(type | (state << 2) | (node << 5) | \
|
||||||
|
@ -57,7 +57,7 @@ struct composite_context* libnet_GroupInfo_send(struct libnet_context *ctx,
|
|||||||
{
|
{
|
||||||
struct composite_context *c;
|
struct composite_context *c;
|
||||||
struct group_info_state *s;
|
struct group_info_state *s;
|
||||||
BOOL prereq_met = False;
|
bool prereq_met = false;
|
||||||
struct composite_context *lookup_req;
|
struct composite_context *lookup_req;
|
||||||
|
|
||||||
/* composite context allocation and setup */
|
/* composite context allocation and setup */
|
||||||
|
@ -926,7 +926,7 @@ static NTSTATUS libnet_Join_primary_domain(struct libnet_context *ctx,
|
|||||||
r2->in.netbios_name = netbios_name;
|
r2->in.netbios_name = netbios_name;
|
||||||
r2->in.level = LIBNET_JOINDOMAIN_AUTOMATIC;
|
r2->in.level = LIBNET_JOINDOMAIN_AUTOMATIC;
|
||||||
r2->in.acct_type = acct_type;
|
r2->in.acct_type = acct_type;
|
||||||
r2->in.recreate_account = False;
|
r2->in.recreate_account = false;
|
||||||
status = libnet_JoinDomain(ctx, r2, r2);
|
status = libnet_JoinDomain(ctx, r2, r2);
|
||||||
if (!NT_STATUS_IS_OK(status)) {
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
r->out.error_string = talloc_steal(mem_ctx, r2->out.error_string);
|
r->out.error_string = talloc_steal(mem_ctx, r2->out.error_string);
|
||||||
|
@ -260,7 +260,7 @@ struct composite_context* libnet_LookupName_send(struct libnet_context *ctx,
|
|||||||
struct composite_context *c;
|
struct composite_context *c;
|
||||||
struct lookup_name_state *s;
|
struct lookup_name_state *s;
|
||||||
struct rpc_request *lookup_req;
|
struct rpc_request *lookup_req;
|
||||||
BOOL prereq_met = False;
|
bool prereq_met = false;
|
||||||
|
|
||||||
c = composite_create(mem_ctx, ctx->event_ctx);
|
c = composite_create(mem_ctx, ctx->event_ctx);
|
||||||
if (c == NULL) return NULL;
|
if (c == NULL) return NULL;
|
||||||
|
@ -247,7 +247,7 @@ static NTSTATUS samsync_ldb_handle_user(TALLOC_CTX *mem_ctx,
|
|||||||
struct ldb_message **remote_msgs = NULL;
|
struct ldb_message **remote_msgs = NULL;
|
||||||
int ret, i;
|
int ret, i;
|
||||||
uint32_t acb;
|
uint32_t acb;
|
||||||
BOOL add = False;
|
bool add = false;
|
||||||
const char *attrs[] = { NULL };
|
const char *attrs[] = { NULL };
|
||||||
/* we may change this to a global search, then fill in only the things not in ldap later */
|
/* we may change this to a global search, then fill in only the things not in ldap later */
|
||||||
const char *remote_attrs[] = { "userPrincipalName", "servicePrincipalName",
|
const char *remote_attrs[] = { "userPrincipalName", "servicePrincipalName",
|
||||||
@ -275,7 +275,7 @@ static NTSTATUS samsync_ldb_handle_user(TALLOC_CTX *mem_ctx,
|
|||||||
ldb_errstring(state->sam_ldb));
|
ldb_errstring(state->sam_ldb));
|
||||||
return NT_STATUS_INTERNAL_DB_CORRUPTION;
|
return NT_STATUS_INTERNAL_DB_CORRUPTION;
|
||||||
} else if (ret == 0) {
|
} else if (ret == 0) {
|
||||||
add = True;
|
add = true;
|
||||||
} else if (ret > 1) {
|
} else if (ret > 1) {
|
||||||
*error_string = talloc_asprintf(mem_ctx, "More than one user with SID: %s in local LDB",
|
*error_string = talloc_asprintf(mem_ctx, "More than one user with SID: %s in local LDB",
|
||||||
dom_sid_string(mem_ctx, user_sid));
|
dom_sid_string(mem_ctx, user_sid));
|
||||||
@ -517,7 +517,7 @@ static NTSTATUS samsync_ldb_handle_group(TALLOC_CTX *mem_ctx,
|
|||||||
struct ldb_message *msg;
|
struct ldb_message *msg;
|
||||||
struct ldb_message **msgs;
|
struct ldb_message **msgs;
|
||||||
int ret;
|
int ret;
|
||||||
BOOL add = False;
|
bool add = false;
|
||||||
const char *attrs[] = { NULL };
|
const char *attrs[] = { NULL };
|
||||||
|
|
||||||
msg = ldb_msg_new(mem_ctx);
|
msg = ldb_msg_new(mem_ctx);
|
||||||
@ -534,7 +534,7 @@ static NTSTATUS samsync_ldb_handle_group(TALLOC_CTX *mem_ctx,
|
|||||||
*error_string = talloc_asprintf(mem_ctx, "gendb_search failed: %s", ldb_errstring(state->sam_ldb));
|
*error_string = talloc_asprintf(mem_ctx, "gendb_search failed: %s", ldb_errstring(state->sam_ldb));
|
||||||
return NT_STATUS_INTERNAL_DB_CORRUPTION;
|
return NT_STATUS_INTERNAL_DB_CORRUPTION;
|
||||||
} else if (ret == 0) {
|
} else if (ret == 0) {
|
||||||
add = True;
|
add = true;
|
||||||
} else if (ret > 1) {
|
} else if (ret > 1) {
|
||||||
*error_string = talloc_asprintf(mem_ctx, "More than one group/alias with SID: %s",
|
*error_string = talloc_asprintf(mem_ctx, "More than one group/alias with SID: %s",
|
||||||
dom_sid_string(mem_ctx,
|
dom_sid_string(mem_ctx,
|
||||||
@ -729,7 +729,7 @@ static NTSTATUS samsync_ldb_handle_alias(TALLOC_CTX *mem_ctx,
|
|||||||
struct ldb_message *msg;
|
struct ldb_message *msg;
|
||||||
struct ldb_message **msgs;
|
struct ldb_message **msgs;
|
||||||
int ret;
|
int ret;
|
||||||
BOOL add = False;
|
bool add = false;
|
||||||
const char *attrs[] = { NULL };
|
const char *attrs[] = { NULL };
|
||||||
|
|
||||||
msg = ldb_msg_new(mem_ctx);
|
msg = ldb_msg_new(mem_ctx);
|
||||||
@ -746,7 +746,7 @@ static NTSTATUS samsync_ldb_handle_alias(TALLOC_CTX *mem_ctx,
|
|||||||
*error_string = talloc_asprintf(mem_ctx, "gendb_search failed: %s", ldb_errstring(state->sam_ldb));
|
*error_string = talloc_asprintf(mem_ctx, "gendb_search failed: %s", ldb_errstring(state->sam_ldb));
|
||||||
return NT_STATUS_INTERNAL_DB_CORRUPTION;
|
return NT_STATUS_INTERNAL_DB_CORRUPTION;
|
||||||
} else if (ret == 0) {
|
} else if (ret == 0) {
|
||||||
add = True;
|
add = true;
|
||||||
} else if (ret > 1) {
|
} else if (ret > 1) {
|
||||||
*error_string = talloc_asprintf(mem_ctx, "More than one group/alias with SID: %s",
|
*error_string = talloc_asprintf(mem_ctx, "More than one group/alias with SID: %s",
|
||||||
dom_sid_string(mem_ctx,
|
dom_sid_string(mem_ctx,
|
||||||
|
@ -62,7 +62,7 @@ struct composite_context* libnet_CreateUser_send(struct libnet_context *ctx,
|
|||||||
struct composite_context *c;
|
struct composite_context *c;
|
||||||
struct create_user_state *s;
|
struct create_user_state *s;
|
||||||
struct composite_context *create_req;
|
struct composite_context *create_req;
|
||||||
BOOL prereq_met = False;
|
bool prereq_met = false;
|
||||||
|
|
||||||
/* composite context allocation and setup */
|
/* composite context allocation and setup */
|
||||||
c = composite_create(mem_ctx, ctx->event_ctx);
|
c = composite_create(mem_ctx, ctx->event_ctx);
|
||||||
@ -231,7 +231,7 @@ struct composite_context *libnet_DeleteUser_send(struct libnet_context *ctx,
|
|||||||
struct composite_context *c;
|
struct composite_context *c;
|
||||||
struct delete_user_state *s;
|
struct delete_user_state *s;
|
||||||
struct composite_context *delete_req;
|
struct composite_context *delete_req;
|
||||||
BOOL prereq_met = False;
|
bool prereq_met = false;
|
||||||
|
|
||||||
/* composite context allocation and setup */
|
/* composite context allocation and setup */
|
||||||
c = composite_create(mem_ctx, ctx->event_ctx);
|
c = composite_create(mem_ctx, ctx->event_ctx);
|
||||||
@ -402,7 +402,7 @@ struct composite_context *libnet_ModifyUser_send(struct libnet_context *ctx,
|
|||||||
struct composite_context *c;
|
struct composite_context *c;
|
||||||
struct modify_user_state *s;
|
struct modify_user_state *s;
|
||||||
struct composite_context *userinfo_req;
|
struct composite_context *userinfo_req;
|
||||||
BOOL prereq_met = False;
|
bool prereq_met = false;
|
||||||
|
|
||||||
c = composite_create(mem_ctx, ctx->event_ctx);
|
c = composite_create(mem_ctx, ctx->event_ctx);
|
||||||
if (c == NULL) return NULL;
|
if (c == NULL) return NULL;
|
||||||
@ -629,7 +629,7 @@ struct composite_context* libnet_UserInfo_send(struct libnet_context *ctx,
|
|||||||
struct composite_context *c;
|
struct composite_context *c;
|
||||||
struct user_info_state *s;
|
struct user_info_state *s;
|
||||||
struct composite_context *lookup_req;
|
struct composite_context *lookup_req;
|
||||||
BOOL prereq_met = False;
|
bool prereq_met = false;
|
||||||
|
|
||||||
/* composite context allocation and setup */
|
/* composite context allocation and setup */
|
||||||
c = composite_create(mem_ctx, ctx->event_ctx);
|
c = composite_create(mem_ctx, ctx->event_ctx);
|
||||||
@ -878,7 +878,7 @@ struct composite_context* libnet_UserList_send(struct libnet_context *ctx,
|
|||||||
struct composite_context *c;
|
struct composite_context *c;
|
||||||
struct userlist_state *s;
|
struct userlist_state *s;
|
||||||
struct rpc_request *query_req;
|
struct rpc_request *query_req;
|
||||||
BOOL prereq_met = False;
|
bool prereq_met = false;
|
||||||
|
|
||||||
/* composite context allocation and setup */
|
/* composite context allocation and setup */
|
||||||
c = composite_create(mem_ctx, ctx->event_ctx);
|
c = composite_create(mem_ctx, ctx->event_ctx);
|
||||||
@ -952,7 +952,7 @@ static void continue_domain_queried(struct rpc_request *req)
|
|||||||
struct composite_context *c;
|
struct composite_context *c;
|
||||||
struct userlist_state *s;
|
struct userlist_state *s;
|
||||||
struct rpc_request *enum_req;
|
struct rpc_request *enum_req;
|
||||||
BOOL prereq_met = False;
|
bool prereq_met = false;
|
||||||
|
|
||||||
c = talloc_get_type(req->async.private_data, struct composite_context);
|
c = talloc_get_type(req->async.private_data, struct composite_context);
|
||||||
s = talloc_get_type(c->private_data, struct userlist_state);
|
s = talloc_get_type(c->private_data, struct userlist_state);
|
||||||
|
@ -81,7 +81,7 @@ static NTSTATUS fix_user(TALLOC_CTX *mem_ctx,
|
|||||||
} else {
|
} else {
|
||||||
user->lmpassword = keys.keys.keys2.lmpassword.pwd;
|
user->lmpassword = keys.keys.keys2.lmpassword.pwd;
|
||||||
}
|
}
|
||||||
user->lm_password_present = True;
|
user->lm_password_present = true;
|
||||||
}
|
}
|
||||||
if (keys.keys.keys2.ntpassword.length == 16) {
|
if (keys.keys.keys2.ntpassword.length == 16) {
|
||||||
if (rid_crypt) {
|
if (rid_crypt) {
|
||||||
@ -90,7 +90,7 @@ static NTSTATUS fix_user(TALLOC_CTX *mem_ctx,
|
|||||||
} else {
|
} else {
|
||||||
user->ntpassword = keys.keys.keys2.ntpassword.pwd;
|
user->ntpassword = keys.keys.keys2.ntpassword.pwd;
|
||||||
}
|
}
|
||||||
user->nt_password_present = True;
|
user->nt_password_present = true;
|
||||||
}
|
}
|
||||||
/* TODO: rid decrypt history fields */
|
/* TODO: rid decrypt history fields */
|
||||||
} else {
|
} else {
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
#include "librpc/gen_ndr/ndr_lsa.h"
|
#include "librpc/gen_ndr/ndr_lsa.h"
|
||||||
|
|
||||||
|
|
||||||
BOOL samr_domain_opened(struct libnet_context *ctx, const char *domain_name,
|
bool samr_domain_opened(struct libnet_context *ctx, const char *domain_name,
|
||||||
struct composite_context **parent_ctx,
|
struct composite_context **parent_ctx,
|
||||||
struct libnet_DomainOpen *domain_open,
|
struct libnet_DomainOpen *domain_open,
|
||||||
void (*continue_fn)(struct composite_context*),
|
void (*continue_fn)(struct composite_context*),
|
||||||
@ -37,7 +37,7 @@ BOOL samr_domain_opened(struct libnet_context *ctx, const char *domain_name,
|
|||||||
{
|
{
|
||||||
struct composite_context *domopen_req;
|
struct composite_context *domopen_req;
|
||||||
|
|
||||||
if (parent_ctx == NULL || *parent_ctx == NULL) return False;
|
if (parent_ctx == NULL || *parent_ctx == NULL) return false;
|
||||||
|
|
||||||
if (domain_name == NULL) {
|
if (domain_name == NULL) {
|
||||||
/*
|
/*
|
||||||
@ -52,7 +52,7 @@ BOOL samr_domain_opened(struct libnet_context *ctx, const char *domain_name,
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
composite_error(*parent_ctx, NT_STATUS_INVALID_PARAMETER);
|
composite_error(*parent_ctx, NT_STATUS_INVALID_PARAMETER);
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -71,20 +71,20 @@ BOOL samr_domain_opened(struct libnet_context *ctx, const char *domain_name,
|
|||||||
} else {
|
} else {
|
||||||
/* domain has already been opened and it's the same domain
|
/* domain has already been opened and it's the same domain
|
||||||
as requested */
|
as requested */
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* send request to open the domain */
|
/* send request to open the domain */
|
||||||
domopen_req = libnet_DomainOpen_send(ctx, domain_open, monitor);
|
domopen_req = libnet_DomainOpen_send(ctx, domain_open, monitor);
|
||||||
if (composite_nomem(domopen_req, *parent_ctx)) return False;
|
if (composite_nomem(domopen_req, *parent_ctx)) return false;
|
||||||
|
|
||||||
composite_continue(*parent_ctx, domopen_req, continue_fn, *parent_ctx);
|
composite_continue(*parent_ctx, domopen_req, continue_fn, *parent_ctx);
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BOOL lsa_domain_opened(struct libnet_context *ctx, const char *domain_name,
|
bool lsa_domain_opened(struct libnet_context *ctx, const char *domain_name,
|
||||||
struct composite_context **parent_ctx,
|
struct composite_context **parent_ctx,
|
||||||
struct libnet_DomainOpen *domain_open,
|
struct libnet_DomainOpen *domain_open,
|
||||||
void (*continue_fn)(struct composite_context*),
|
void (*continue_fn)(struct composite_context*),
|
||||||
@ -92,7 +92,7 @@ BOOL lsa_domain_opened(struct libnet_context *ctx, const char *domain_name,
|
|||||||
{
|
{
|
||||||
struct composite_context *domopen_req;
|
struct composite_context *domopen_req;
|
||||||
|
|
||||||
if (parent_ctx == NULL || *parent_ctx == NULL) return False;
|
if (parent_ctx == NULL || *parent_ctx == NULL) return false;
|
||||||
|
|
||||||
if (domain_name == NULL) {
|
if (domain_name == NULL) {
|
||||||
/*
|
/*
|
||||||
@ -109,7 +109,7 @@ BOOL lsa_domain_opened(struct libnet_context *ctx, const char *domain_name,
|
|||||||
composite_error(*parent_ctx, NT_STATUS_INVALID_PARAMETER);
|
composite_error(*parent_ctx, NT_STATUS_INVALID_PARAMETER);
|
||||||
/* this ensures the calling function exits and composite function error
|
/* this ensures the calling function exits and composite function error
|
||||||
gets noticed quickly */
|
gets noticed quickly */
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -128,15 +128,15 @@ BOOL lsa_domain_opened(struct libnet_context *ctx, const char *domain_name,
|
|||||||
} else {
|
} else {
|
||||||
/* domain has already been opened and it's the same domain
|
/* domain has already been opened and it's the same domain
|
||||||
as requested */
|
as requested */
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* send request to open the domain */
|
/* send request to open the domain */
|
||||||
domopen_req = libnet_DomainOpen_send(ctx, domain_open, monitor);
|
domopen_req = libnet_DomainOpen_send(ctx, domain_open, monitor);
|
||||||
/* see the comment above to find out why true is returned here */
|
/* see the comment above to find out why true is returned here */
|
||||||
if (composite_nomem(domopen_req, *parent_ctx)) return True;
|
if (composite_nomem(domopen_req, *parent_ctx)) return true;
|
||||||
|
|
||||||
composite_continue(*parent_ctx, domopen_req, continue_fn, *parent_ctx);
|
composite_continue(*parent_ctx, domopen_req, continue_fn, *parent_ctx);
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -662,7 +662,7 @@ static NTSTATUS usermod_change(struct composite_context *c,
|
|||||||
uint16_t level = 27;
|
uint16_t level = 27;
|
||||||
|
|
||||||
/* prepare UserInfo level and data based on bitmask field */
|
/* prepare UserInfo level and data based on bitmask field */
|
||||||
do_set = usermod_setfields(s, &level, i, False);
|
do_set = usermod_setfields(s, &level, i, false);
|
||||||
|
|
||||||
if (level < 1 || level > 26) {
|
if (level < 1 || level > 26) {
|
||||||
/* apparently there's a field that the setfields routine
|
/* apparently there's a field that the setfields routine
|
||||||
@ -752,7 +752,7 @@ static void continue_usermod_user_queried(struct rpc_request *req)
|
|||||||
of many) */
|
of many) */
|
||||||
s->info = *s->queryuser.out.info;
|
s->info = *s->queryuser.out.info;
|
||||||
|
|
||||||
usermod_setfields(s, &level, i, True);
|
usermod_setfields(s, &level, i, true);
|
||||||
|
|
||||||
/* prepare rpc call arguments */
|
/* prepare rpc call arguments */
|
||||||
s->setuser.in.user_handle = &s->user_handle;
|
s->setuser.in.user_handle = &s->user_handle;
|
||||||
|
@ -32,10 +32,10 @@
|
|||||||
|
|
||||||
extern int winbindd_fd;
|
extern int winbindd_fd;
|
||||||
|
|
||||||
static char winbind_separator_int(BOOL strict)
|
static char winbind_separator_int(bool strict)
|
||||||
{
|
{
|
||||||
struct winbindd_response response;
|
struct winbindd_response response;
|
||||||
static BOOL got_sep;
|
static bool got_sep;
|
||||||
static char sep;
|
static char sep;
|
||||||
|
|
||||||
if (got_sep)
|
if (got_sep)
|
||||||
@ -56,7 +56,7 @@ static char winbind_separator_int(BOOL strict)
|
|||||||
}
|
}
|
||||||
|
|
||||||
sep = response.data.info.winbind_separator;
|
sep = response.data.info.winbind_separator;
|
||||||
got_sep = True;
|
got_sep = true;
|
||||||
|
|
||||||
if (!sep) {
|
if (!sep) {
|
||||||
d_fprintf(stderr, "winbind separator was NULL!\n");
|
d_fprintf(stderr, "winbind separator was NULL!\n");
|
||||||
@ -72,7 +72,7 @@ static char winbind_separator_int(BOOL strict)
|
|||||||
|
|
||||||
static char winbind_separator(void)
|
static char winbind_separator(void)
|
||||||
{
|
{
|
||||||
return winbind_separator_int(False);
|
return winbind_separator_int(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *get_winbind_domain(void)
|
static const char *get_winbind_domain(void)
|
||||||
@ -101,7 +101,7 @@ static const char *get_winbind_domain(void)
|
|||||||
/* Copy of parse_domain_user from winbindd_util.c. Parse a string of the
|
/* Copy of parse_domain_user from winbindd_util.c. Parse a string of the
|
||||||
form DOMAIN/user into a domain and a user */
|
form DOMAIN/user into a domain and a user */
|
||||||
|
|
||||||
static BOOL parse_wbinfo_domain_user(const char *domuser, fstring domain,
|
static bool parse_wbinfo_domain_user(const char *domuser, fstring domain,
|
||||||
fstring user)
|
fstring user)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -110,7 +110,7 @@ static BOOL parse_wbinfo_domain_user(const char *domuser, fstring domain,
|
|||||||
if (!p) {
|
if (!p) {
|
||||||
fstrcpy(user, domuser);
|
fstrcpy(user, domuser);
|
||||||
fstrcpy(domain, get_winbind_domain());
|
fstrcpy(domain, get_winbind_domain());
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
fstrcpy(user, p+1);
|
fstrcpy(user, p+1);
|
||||||
@ -118,12 +118,12 @@ static BOOL parse_wbinfo_domain_user(const char *domuser, fstring domain,
|
|||||||
domain[PTR_DIFF(p, domuser)] = 0;
|
domain[PTR_DIFF(p, domuser)] = 0;
|
||||||
strupper_m(domain);
|
strupper_m(domain);
|
||||||
|
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* pull pwent info for a given user */
|
/* pull pwent info for a given user */
|
||||||
|
|
||||||
static BOOL wbinfo_get_userinfo(char *user)
|
static bool wbinfo_get_userinfo(char *user)
|
||||||
{
|
{
|
||||||
struct winbindd_request request;
|
struct winbindd_request request;
|
||||||
struct winbindd_response response;
|
struct winbindd_response response;
|
||||||
@ -139,7 +139,7 @@ static BOOL wbinfo_get_userinfo(char *user)
|
|||||||
result = winbindd_request_response(WINBINDD_GETPWNAM, &request, &response);
|
result = winbindd_request_response(WINBINDD_GETPWNAM, &request, &response);
|
||||||
|
|
||||||
if (result != NSS_STATUS_SUCCESS)
|
if (result != NSS_STATUS_SUCCESS)
|
||||||
return False;
|
return false;
|
||||||
|
|
||||||
d_printf( "%s:%s:%d:%d:%s:%s:%s\n",
|
d_printf( "%s:%s:%d:%d:%s:%s:%s\n",
|
||||||
response.data.pw.pw_name,
|
response.data.pw.pw_name,
|
||||||
@ -150,11 +150,11 @@ static BOOL wbinfo_get_userinfo(char *user)
|
|||||||
response.data.pw.pw_dir,
|
response.data.pw.pw_dir,
|
||||||
response.data.pw.pw_shell );
|
response.data.pw.pw_shell );
|
||||||
|
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* pull pwent info for a given uid */
|
/* pull pwent info for a given uid */
|
||||||
static BOOL wbinfo_get_uidinfo(int uid)
|
static bool wbinfo_get_uidinfo(int uid)
|
||||||
{
|
{
|
||||||
struct winbindd_request request;
|
struct winbindd_request request;
|
||||||
struct winbindd_response response;
|
struct winbindd_response response;
|
||||||
@ -168,7 +168,7 @@ static BOOL wbinfo_get_uidinfo(int uid)
|
|||||||
result = winbindd_request_response(WINBINDD_GETPWUID, &request, &response);
|
result = winbindd_request_response(WINBINDD_GETPWUID, &request, &response);
|
||||||
|
|
||||||
if (result != NSS_STATUS_SUCCESS)
|
if (result != NSS_STATUS_SUCCESS)
|
||||||
return False;
|
return false;
|
||||||
|
|
||||||
d_printf( "%s:%s:%d:%d:%s:%s:%s\n",
|
d_printf( "%s:%s:%d:%d:%s:%s:%s\n",
|
||||||
response.data.pw.pw_name,
|
response.data.pw.pw_name,
|
||||||
@ -179,11 +179,11 @@ static BOOL wbinfo_get_uidinfo(int uid)
|
|||||||
response.data.pw.pw_dir,
|
response.data.pw.pw_dir,
|
||||||
response.data.pw.pw_shell );
|
response.data.pw.pw_shell );
|
||||||
|
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* pull grent for a given group */
|
/* pull grent for a given group */
|
||||||
static BOOL wbinfo_get_groupinfo(char *group)
|
static bool wbinfo_get_groupinfo(char *group)
|
||||||
{
|
{
|
||||||
struct winbindd_request request;
|
struct winbindd_request request;
|
||||||
struct winbindd_response response;
|
struct winbindd_response response;
|
||||||
@ -200,19 +200,19 @@ static BOOL wbinfo_get_groupinfo(char *group)
|
|||||||
&response);
|
&response);
|
||||||
|
|
||||||
if ( result != NSS_STATUS_SUCCESS)
|
if ( result != NSS_STATUS_SUCCESS)
|
||||||
return False;
|
return false;
|
||||||
|
|
||||||
d_printf( "%s:%s:%d\n",
|
d_printf( "%s:%s:%d\n",
|
||||||
response.data.gr.gr_name,
|
response.data.gr.gr_name,
|
||||||
response.data.gr.gr_passwd,
|
response.data.gr.gr_passwd,
|
||||||
response.data.gr.gr_gid );
|
response.data.gr.gr_gid );
|
||||||
|
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* List groups a user is a member of */
|
/* List groups a user is a member of */
|
||||||
|
|
||||||
static BOOL wbinfo_get_usergroups(char *user)
|
static bool wbinfo_get_usergroups(char *user)
|
||||||
{
|
{
|
||||||
struct winbindd_request request;
|
struct winbindd_request request;
|
||||||
struct winbindd_response response;
|
struct winbindd_response response;
|
||||||
@ -229,19 +229,19 @@ static BOOL wbinfo_get_usergroups(char *user)
|
|||||||
result = winbindd_request_response(WINBINDD_GETGROUPS, &request, &response);
|
result = winbindd_request_response(WINBINDD_GETGROUPS, &request, &response);
|
||||||
|
|
||||||
if (result != NSS_STATUS_SUCCESS)
|
if (result != NSS_STATUS_SUCCESS)
|
||||||
return False;
|
return false;
|
||||||
|
|
||||||
for (i = 0; i < response.data.num_entries; i++)
|
for (i = 0; i < response.data.num_entries; i++)
|
||||||
d_printf("%d\n", (int)((gid_t *)response.extra_data.data)[i]);
|
d_printf("%d\n", (int)((gid_t *)response.extra_data.data)[i]);
|
||||||
|
|
||||||
SAFE_FREE(response.extra_data.data);
|
SAFE_FREE(response.extra_data.data);
|
||||||
|
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* List group SIDs a user SID is a member of */
|
/* List group SIDs a user SID is a member of */
|
||||||
static BOOL wbinfo_get_usersids(char *user_sid)
|
static bool wbinfo_get_usersids(char *user_sid)
|
||||||
{
|
{
|
||||||
struct winbindd_request request;
|
struct winbindd_request request;
|
||||||
struct winbindd_response response;
|
struct winbindd_response response;
|
||||||
@ -258,7 +258,7 @@ static BOOL wbinfo_get_usersids(char *user_sid)
|
|||||||
result = winbindd_request_response(WINBINDD_GETUSERSIDS, &request, &response);
|
result = winbindd_request_response(WINBINDD_GETUSERSIDS, &request, &response);
|
||||||
|
|
||||||
if (result != NSS_STATUS_SUCCESS)
|
if (result != NSS_STATUS_SUCCESS)
|
||||||
return False;
|
return false;
|
||||||
|
|
||||||
s = (const char *)response.extra_data.data;
|
s = (const char *)response.extra_data.data;
|
||||||
for (i = 0; i < response.data.num_entries; i++) {
|
for (i = 0; i < response.data.num_entries; i++) {
|
||||||
@ -268,10 +268,10 @@ static BOOL wbinfo_get_usersids(char *user_sid)
|
|||||||
|
|
||||||
SAFE_FREE(response.extra_data.data);
|
SAFE_FREE(response.extra_data.data);
|
||||||
|
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL wbinfo_get_userdomgroups(const char *user_sid)
|
static bool wbinfo_get_userdomgroups(const char *user_sid)
|
||||||
{
|
{
|
||||||
struct winbindd_request request;
|
struct winbindd_request request;
|
||||||
struct winbindd_response response;
|
struct winbindd_response response;
|
||||||
@ -287,19 +287,19 @@ static BOOL wbinfo_get_userdomgroups(const char *user_sid)
|
|||||||
&response);
|
&response);
|
||||||
|
|
||||||
if (result != NSS_STATUS_SUCCESS)
|
if (result != NSS_STATUS_SUCCESS)
|
||||||
return False;
|
return false;
|
||||||
|
|
||||||
if (response.data.num_entries != 0)
|
if (response.data.num_entries != 0)
|
||||||
printf("%s", (char *)response.extra_data.data);
|
printf("%s", (char *)response.extra_data.data);
|
||||||
|
|
||||||
SAFE_FREE(response.extra_data.data);
|
SAFE_FREE(response.extra_data.data);
|
||||||
|
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert NetBIOS name to IP */
|
/* Convert NetBIOS name to IP */
|
||||||
|
|
||||||
static BOOL wbinfo_wins_byname(char *name)
|
static bool wbinfo_wins_byname(char *name)
|
||||||
{
|
{
|
||||||
struct winbindd_request request;
|
struct winbindd_request request;
|
||||||
struct winbindd_response response;
|
struct winbindd_response response;
|
||||||
@ -313,19 +313,19 @@ static BOOL wbinfo_wins_byname(char *name)
|
|||||||
|
|
||||||
if (winbindd_request_response(WINBINDD_WINS_BYNAME, &request, &response) !=
|
if (winbindd_request_response(WINBINDD_WINS_BYNAME, &request, &response) !=
|
||||||
NSS_STATUS_SUCCESS) {
|
NSS_STATUS_SUCCESS) {
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Display response */
|
/* Display response */
|
||||||
|
|
||||||
d_printf("%s\n", response.data.winsresp);
|
d_printf("%s\n", response.data.winsresp);
|
||||||
|
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert IP to NetBIOS name */
|
/* Convert IP to NetBIOS name */
|
||||||
|
|
||||||
static BOOL wbinfo_wins_byip(char *ip)
|
static bool wbinfo_wins_byip(char *ip)
|
||||||
{
|
{
|
||||||
struct winbindd_request request;
|
struct winbindd_request request;
|
||||||
struct winbindd_response response;
|
struct winbindd_response response;
|
||||||
@ -339,19 +339,19 @@ static BOOL wbinfo_wins_byip(char *ip)
|
|||||||
|
|
||||||
if (winbindd_request_response(WINBINDD_WINS_BYIP, &request, &response) !=
|
if (winbindd_request_response(WINBINDD_WINS_BYIP, &request, &response) !=
|
||||||
NSS_STATUS_SUCCESS) {
|
NSS_STATUS_SUCCESS) {
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Display response */
|
/* Display response */
|
||||||
|
|
||||||
d_printf("%s\n", response.data.winsresp);
|
d_printf("%s\n", response.data.winsresp);
|
||||||
|
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* List trusted domains */
|
/* List trusted domains */
|
||||||
|
|
||||||
static BOOL wbinfo_list_domains(BOOL list_all_domains)
|
static bool wbinfo_list_domains(bool list_all_domains)
|
||||||
{
|
{
|
||||||
struct winbindd_request request;
|
struct winbindd_request request;
|
||||||
struct winbindd_response response;
|
struct winbindd_response response;
|
||||||
@ -365,7 +365,7 @@ static BOOL wbinfo_list_domains(BOOL list_all_domains)
|
|||||||
|
|
||||||
if (winbindd_request_response(WINBINDD_LIST_TRUSTDOM, &request, &response) !=
|
if (winbindd_request_response(WINBINDD_LIST_TRUSTDOM, &request, &response) !=
|
||||||
NSS_STATUS_SUCCESS)
|
NSS_STATUS_SUCCESS)
|
||||||
return False;
|
return false;
|
||||||
|
|
||||||
/* Display response */
|
/* Display response */
|
||||||
|
|
||||||
@ -379,7 +379,7 @@ static BOOL wbinfo_list_domains(BOOL list_all_domains)
|
|||||||
if (p == 0) {
|
if (p == 0) {
|
||||||
d_fprintf(stderr, "Got invalid response: %s\n",
|
d_fprintf(stderr, "Got invalid response: %s\n",
|
||||||
extra_data);
|
extra_data);
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
*p = 0;
|
*p = 0;
|
||||||
d_printf("%s\n", name);
|
d_printf("%s\n", name);
|
||||||
@ -388,20 +388,20 @@ static BOOL wbinfo_list_domains(BOOL list_all_domains)
|
|||||||
SAFE_FREE(response.extra_data.data);
|
SAFE_FREE(response.extra_data.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* List own domain */
|
/* List own domain */
|
||||||
|
|
||||||
static BOOL wbinfo_list_own_domain(void)
|
static bool wbinfo_list_own_domain(void)
|
||||||
{
|
{
|
||||||
d_printf("%s\n", get_winbind_domain());
|
d_printf("%s\n", get_winbind_domain());
|
||||||
|
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* show sequence numbers */
|
/* show sequence numbers */
|
||||||
static BOOL wbinfo_show_sequence(const char *domain)
|
static bool wbinfo_show_sequence(const char *domain)
|
||||||
{
|
{
|
||||||
struct winbindd_request request;
|
struct winbindd_request request;
|
||||||
struct winbindd_response response;
|
struct winbindd_response response;
|
||||||
@ -416,7 +416,7 @@ static BOOL wbinfo_show_sequence(const char *domain)
|
|||||||
|
|
||||||
if (winbindd_request_response(WINBINDD_SHOW_SEQUENCE, &request, &response) !=
|
if (winbindd_request_response(WINBINDD_SHOW_SEQUENCE, &request, &response) !=
|
||||||
NSS_STATUS_SUCCESS)
|
NSS_STATUS_SUCCESS)
|
||||||
return False;
|
return false;
|
||||||
|
|
||||||
/* Display response */
|
/* Display response */
|
||||||
|
|
||||||
@ -426,12 +426,12 @@ static BOOL wbinfo_show_sequence(const char *domain)
|
|||||||
SAFE_FREE(response.extra_data.data);
|
SAFE_FREE(response.extra_data.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Show domain info */
|
/* Show domain info */
|
||||||
|
|
||||||
static BOOL wbinfo_domain_info(const char *domain_name)
|
static bool wbinfo_domain_info(const char *domain_name)
|
||||||
{
|
{
|
||||||
struct winbindd_request request;
|
struct winbindd_request request;
|
||||||
struct winbindd_response response;
|
struct winbindd_response response;
|
||||||
@ -448,7 +448,7 @@ static BOOL wbinfo_domain_info(const char *domain_name)
|
|||||||
|
|
||||||
if (winbindd_request_response(WINBINDD_DOMAIN_INFO, &request, &response) !=
|
if (winbindd_request_response(WINBINDD_DOMAIN_INFO, &request, &response) !=
|
||||||
NSS_STATUS_SUCCESS)
|
NSS_STATUS_SUCCESS)
|
||||||
return False;
|
return false;
|
||||||
|
|
||||||
/* Display response */
|
/* Display response */
|
||||||
|
|
||||||
@ -465,11 +465,11 @@ static BOOL wbinfo_domain_info(const char *domain_name)
|
|||||||
d_printf("Primary : %s\n",
|
d_printf("Primary : %s\n",
|
||||||
response.data.domain_info.primary ? "Yes" : "No");
|
response.data.domain_info.primary ? "Yes" : "No");
|
||||||
|
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get a foreign DC's name */
|
/* Get a foreign DC's name */
|
||||||
static BOOL wbinfo_getdcname(const char *domain_name)
|
static bool wbinfo_getdcname(const char *domain_name)
|
||||||
{
|
{
|
||||||
struct winbindd_request request;
|
struct winbindd_request request;
|
||||||
struct winbindd_response response;
|
struct winbindd_response response;
|
||||||
@ -484,19 +484,19 @@ static BOOL wbinfo_getdcname(const char *domain_name)
|
|||||||
if (winbindd_request_response(WINBINDD_GETDCNAME, &request, &response) !=
|
if (winbindd_request_response(WINBINDD_GETDCNAME, &request, &response) !=
|
||||||
NSS_STATUS_SUCCESS) {
|
NSS_STATUS_SUCCESS) {
|
||||||
d_fprintf(stderr, "Could not get dc name for %s\n", domain_name);
|
d_fprintf(stderr, "Could not get dc name for %s\n", domain_name);
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Display response */
|
/* Display response */
|
||||||
|
|
||||||
d_printf("%s\n", response.data.dc_name);
|
d_printf("%s\n", response.data.dc_name);
|
||||||
|
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check trust account password */
|
/* Check trust account password */
|
||||||
|
|
||||||
static BOOL wbinfo_check_secret(void)
|
static bool wbinfo_check_secret(void)
|
||||||
{
|
{
|
||||||
struct winbindd_response response;
|
struct winbindd_response response;
|
||||||
NSS_STATUS result;
|
NSS_STATUS result;
|
||||||
@ -518,7 +518,7 @@ static BOOL wbinfo_check_secret(void)
|
|||||||
|
|
||||||
/* Convert uid to sid */
|
/* Convert uid to sid */
|
||||||
|
|
||||||
static BOOL wbinfo_uid_to_sid(uid_t uid)
|
static bool wbinfo_uid_to_sid(uid_t uid)
|
||||||
{
|
{
|
||||||
struct winbindd_request request;
|
struct winbindd_request request;
|
||||||
struct winbindd_response response;
|
struct winbindd_response response;
|
||||||
@ -532,18 +532,18 @@ static BOOL wbinfo_uid_to_sid(uid_t uid)
|
|||||||
|
|
||||||
if (winbindd_request_response(WINBINDD_UID_TO_SID, &request, &response) !=
|
if (winbindd_request_response(WINBINDD_UID_TO_SID, &request, &response) !=
|
||||||
NSS_STATUS_SUCCESS)
|
NSS_STATUS_SUCCESS)
|
||||||
return False;
|
return false;
|
||||||
|
|
||||||
/* Display response */
|
/* Display response */
|
||||||
|
|
||||||
d_printf("%s\n", response.data.sid.sid);
|
d_printf("%s\n", response.data.sid.sid);
|
||||||
|
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert gid to sid */
|
/* Convert gid to sid */
|
||||||
|
|
||||||
static BOOL wbinfo_gid_to_sid(gid_t gid)
|
static bool wbinfo_gid_to_sid(gid_t gid)
|
||||||
{
|
{
|
||||||
struct winbindd_request request;
|
struct winbindd_request request;
|
||||||
struct winbindd_response response;
|
struct winbindd_response response;
|
||||||
@ -557,18 +557,18 @@ static BOOL wbinfo_gid_to_sid(gid_t gid)
|
|||||||
|
|
||||||
if (winbindd_request_response(WINBINDD_GID_TO_SID, &request, &response) !=
|
if (winbindd_request_response(WINBINDD_GID_TO_SID, &request, &response) !=
|
||||||
NSS_STATUS_SUCCESS)
|
NSS_STATUS_SUCCESS)
|
||||||
return False;
|
return false;
|
||||||
|
|
||||||
/* Display response */
|
/* Display response */
|
||||||
|
|
||||||
d_printf("%s\n", response.data.sid.sid);
|
d_printf("%s\n", response.data.sid.sid);
|
||||||
|
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert sid to uid */
|
/* Convert sid to uid */
|
||||||
|
|
||||||
static BOOL wbinfo_sid_to_uid(char *sid)
|
static bool wbinfo_sid_to_uid(char *sid)
|
||||||
{
|
{
|
||||||
struct winbindd_request request;
|
struct winbindd_request request;
|
||||||
struct winbindd_response response;
|
struct winbindd_response response;
|
||||||
@ -582,16 +582,16 @@ static BOOL wbinfo_sid_to_uid(char *sid)
|
|||||||
|
|
||||||
if (winbindd_request_response(WINBINDD_SID_TO_UID, &request, &response) !=
|
if (winbindd_request_response(WINBINDD_SID_TO_UID, &request, &response) !=
|
||||||
NSS_STATUS_SUCCESS)
|
NSS_STATUS_SUCCESS)
|
||||||
return False;
|
return false;
|
||||||
|
|
||||||
/* Display response */
|
/* Display response */
|
||||||
|
|
||||||
d_printf("%d\n", (int)response.data.uid);
|
d_printf("%d\n", (int)response.data.uid);
|
||||||
|
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL wbinfo_sid_to_gid(char *sid)
|
static bool wbinfo_sid_to_gid(char *sid)
|
||||||
{
|
{
|
||||||
struct winbindd_request request;
|
struct winbindd_request request;
|
||||||
struct winbindd_response response;
|
struct winbindd_response response;
|
||||||
@ -605,18 +605,18 @@ static BOOL wbinfo_sid_to_gid(char *sid)
|
|||||||
|
|
||||||
if (winbindd_request_response(WINBINDD_SID_TO_GID, &request, &response) !=
|
if (winbindd_request_response(WINBINDD_SID_TO_GID, &request, &response) !=
|
||||||
NSS_STATUS_SUCCESS)
|
NSS_STATUS_SUCCESS)
|
||||||
return False;
|
return false;
|
||||||
|
|
||||||
/* Display response */
|
/* Display response */
|
||||||
|
|
||||||
d_printf("%d\n", (int)response.data.gid);
|
d_printf("%d\n", (int)response.data.gid);
|
||||||
|
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert sid to string */
|
/* Convert sid to string */
|
||||||
|
|
||||||
static BOOL wbinfo_lookupsid(char *sid)
|
static bool wbinfo_lookupsid(char *sid)
|
||||||
{
|
{
|
||||||
struct winbindd_request request;
|
struct winbindd_request request;
|
||||||
struct winbindd_response response;
|
struct winbindd_response response;
|
||||||
@ -630,7 +630,7 @@ static BOOL wbinfo_lookupsid(char *sid)
|
|||||||
|
|
||||||
if (winbindd_request_response(WINBINDD_LOOKUPSID, &request, &response) !=
|
if (winbindd_request_response(WINBINDD_LOOKUPSID, &request, &response) !=
|
||||||
NSS_STATUS_SUCCESS)
|
NSS_STATUS_SUCCESS)
|
||||||
return False;
|
return false;
|
||||||
|
|
||||||
/* Display response */
|
/* Display response */
|
||||||
|
|
||||||
@ -638,7 +638,7 @@ static BOOL wbinfo_lookupsid(char *sid)
|
|||||||
winbind_separator(), response.data.name.name,
|
winbind_separator(), response.data.name.name,
|
||||||
response.data.name.type);
|
response.data.name.type);
|
||||||
|
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *sid_type_lookup(enum lsa_SidType r)
|
static const char *sid_type_lookup(enum lsa_SidType r)
|
||||||
@ -659,7 +659,7 @@ static const char *sid_type_lookup(enum lsa_SidType r)
|
|||||||
|
|
||||||
/* Convert string to sid */
|
/* Convert string to sid */
|
||||||
|
|
||||||
static BOOL wbinfo_lookupname(char *name)
|
static bool wbinfo_lookupname(char *name)
|
||||||
{
|
{
|
||||||
struct winbindd_request request;
|
struct winbindd_request request;
|
||||||
struct winbindd_response response;
|
struct winbindd_response response;
|
||||||
@ -674,18 +674,18 @@ static BOOL wbinfo_lookupname(char *name)
|
|||||||
|
|
||||||
if (winbindd_request_response(WINBINDD_LOOKUPNAME, &request, &response) !=
|
if (winbindd_request_response(WINBINDD_LOOKUPNAME, &request, &response) !=
|
||||||
NSS_STATUS_SUCCESS)
|
NSS_STATUS_SUCCESS)
|
||||||
return False;
|
return false;
|
||||||
|
|
||||||
/* Display response */
|
/* Display response */
|
||||||
|
|
||||||
d_printf("%s %s (%d)\n", response.data.sid.sid, sid_type_lookup(response.data.sid.type), response.data.sid.type);
|
d_printf("%s %s (%d)\n", response.data.sid.sid, sid_type_lookup(response.data.sid.type), response.data.sid.type);
|
||||||
|
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Authenticate a user with a plaintext password */
|
/* Authenticate a user with a plaintext password */
|
||||||
|
|
||||||
static BOOL wbinfo_auth_krb5(char *username, const char *cctype, uint32_t flags)
|
static bool wbinfo_auth_krb5(char *username, const char *cctype, uint32_t flags)
|
||||||
{
|
{
|
||||||
struct winbindd_request request;
|
struct winbindd_request request;
|
||||||
struct winbindd_response response;
|
struct winbindd_response response;
|
||||||
@ -746,7 +746,7 @@ static BOOL wbinfo_auth_krb5(char *username, const char *cctype, uint32_t flags)
|
|||||||
|
|
||||||
/* Authenticate a user with a plaintext password */
|
/* Authenticate a user with a plaintext password */
|
||||||
|
|
||||||
static BOOL wbinfo_auth(char *username)
|
static bool wbinfo_auth(char *username)
|
||||||
{
|
{
|
||||||
struct winbindd_request request;
|
struct winbindd_request request;
|
||||||
struct winbindd_response response;
|
struct winbindd_response response;
|
||||||
@ -786,7 +786,7 @@ static BOOL wbinfo_auth(char *username)
|
|||||||
|
|
||||||
/* Authenticate a user with a challenge/response */
|
/* Authenticate a user with a challenge/response */
|
||||||
|
|
||||||
static BOOL wbinfo_auth_crap(char *username)
|
static bool wbinfo_auth_crap(char *username)
|
||||||
{
|
{
|
||||||
struct winbindd_request request;
|
struct winbindd_request request;
|
||||||
struct winbindd_response response;
|
struct winbindd_response response;
|
||||||
@ -830,7 +830,7 @@ static BOOL wbinfo_auth_crap(char *username)
|
|||||||
mem_ctx = talloc_new(NULL);
|
mem_ctx = talloc_new(NULL);
|
||||||
if (mem_ctx == NULL) {
|
if (mem_ctx == NULL) {
|
||||||
d_printf("talloc_new failed\n");
|
d_printf("talloc_new failed\n");
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
server_chal = data_blob(request.data.auth_crap.chal, 8);
|
server_chal = data_blob(request.data.auth_crap.chal, 8);
|
||||||
@ -843,7 +843,7 @@ static BOOL wbinfo_auth_crap(char *username)
|
|||||||
&lm_response, &nt_response, NULL, NULL)) {
|
&lm_response, &nt_response, NULL, NULL)) {
|
||||||
data_blob_free(&names_blob);
|
data_blob_free(&names_blob);
|
||||||
data_blob_free(&server_chal);
|
data_blob_free(&server_chal);
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
data_blob_free(&names_blob);
|
data_blob_free(&names_blob);
|
||||||
data_blob_free(&server_chal);
|
data_blob_free(&server_chal);
|
||||||
@ -893,7 +893,7 @@ static BOOL wbinfo_auth_crap(char *username)
|
|||||||
|
|
||||||
/* Print domain users */
|
/* Print domain users */
|
||||||
|
|
||||||
static BOOL print_domain_users(const char *domain)
|
static bool print_domain_users(const char *domain)
|
||||||
{
|
{
|
||||||
struct winbindd_request request;
|
struct winbindd_request request;
|
||||||
struct winbindd_response response;
|
struct winbindd_response response;
|
||||||
@ -915,12 +915,12 @@ static BOOL print_domain_users(const char *domain)
|
|||||||
|
|
||||||
if (winbindd_request_response(WINBINDD_LIST_USERS, &request, &response) !=
|
if (winbindd_request_response(WINBINDD_LIST_USERS, &request, &response) !=
|
||||||
NSS_STATUS_SUCCESS)
|
NSS_STATUS_SUCCESS)
|
||||||
return False;
|
return false;
|
||||||
|
|
||||||
/* Look through extra data */
|
/* Look through extra data */
|
||||||
|
|
||||||
if (!response.extra_data.data)
|
if (!response.extra_data.data)
|
||||||
return False;
|
return false;
|
||||||
|
|
||||||
extra_data = (const char *)response.extra_data.data;
|
extra_data = (const char *)response.extra_data.data;
|
||||||
|
|
||||||
@ -929,12 +929,12 @@ static BOOL print_domain_users(const char *domain)
|
|||||||
|
|
||||||
SAFE_FREE(response.extra_data.data);
|
SAFE_FREE(response.extra_data.data);
|
||||||
|
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Print domain groups */
|
/* Print domain groups */
|
||||||
|
|
||||||
static BOOL print_domain_groups(const char *domain)
|
static bool print_domain_groups(const char *domain)
|
||||||
{
|
{
|
||||||
struct winbindd_request request;
|
struct winbindd_request request;
|
||||||
struct winbindd_response response;
|
struct winbindd_response response;
|
||||||
@ -953,12 +953,12 @@ static BOOL print_domain_groups(const char *domain)
|
|||||||
|
|
||||||
if (winbindd_request_response(WINBINDD_LIST_GROUPS, &request, &response) !=
|
if (winbindd_request_response(WINBINDD_LIST_GROUPS, &request, &response) !=
|
||||||
NSS_STATUS_SUCCESS)
|
NSS_STATUS_SUCCESS)
|
||||||
return False;
|
return false;
|
||||||
|
|
||||||
/* Look through extra data */
|
/* Look through extra data */
|
||||||
|
|
||||||
if (!response.extra_data.data)
|
if (!response.extra_data.data)
|
||||||
return False;
|
return false;
|
||||||
|
|
||||||
extra_data = (const char *)response.extra_data.data;
|
extra_data = (const char *)response.extra_data.data;
|
||||||
|
|
||||||
@ -967,10 +967,10 @@ static BOOL print_domain_groups(const char *domain)
|
|||||||
|
|
||||||
SAFE_FREE(response.extra_data.data);
|
SAFE_FREE(response.extra_data.data);
|
||||||
|
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL wbinfo_ping(void)
|
static bool wbinfo_ping(void)
|
||||||
{
|
{
|
||||||
NSS_STATUS result;
|
NSS_STATUS result;
|
||||||
|
|
||||||
@ -1150,7 +1150,7 @@ int main(int argc, char **argv, char **envp)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'm':
|
case 'm':
|
||||||
if (!wbinfo_list_domains(False)) {
|
if (!wbinfo_list_domains(false)) {
|
||||||
d_fprintf(stderr, "Could not list trusted domains\n");
|
d_fprintf(stderr, "Could not list trusted domains\n");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
@ -1210,18 +1210,18 @@ int main(int argc, char **argv, char **envp)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'a': {
|
case 'a': {
|
||||||
BOOL got_error = False;
|
bool got_error = false;
|
||||||
|
|
||||||
if (!wbinfo_auth(string_arg)) {
|
if (!wbinfo_auth(string_arg)) {
|
||||||
d_fprintf(stderr, "Could not authenticate user %s with "
|
d_fprintf(stderr, "Could not authenticate user %s with "
|
||||||
"plaintext password\n", string_arg);
|
"plaintext password\n", string_arg);
|
||||||
got_error = True;
|
got_error = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!wbinfo_auth_crap(string_arg)) {
|
if (!wbinfo_auth_crap(string_arg)) {
|
||||||
d_fprintf(stderr, "Could not authenticate user %s with "
|
d_fprintf(stderr, "Could not authenticate user %s with "
|
||||||
"challenge/response\n", string_arg);
|
"challenge/response\n", string_arg);
|
||||||
got_error = True;
|
got_error = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (got_error)
|
if (got_error)
|
||||||
@ -1253,7 +1253,7 @@ int main(int argc, char **argv, char **envp)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OPT_SEPARATOR: {
|
case OPT_SEPARATOR: {
|
||||||
const char sep = winbind_separator_int(True);
|
const char sep = winbind_separator_int(true);
|
||||||
if ( !sep ) {
|
if ( !sep ) {
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
@ -1261,7 +1261,7 @@ int main(int argc, char **argv, char **envp)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case OPT_LIST_ALL_DOMAINS:
|
case OPT_LIST_ALL_DOMAINS:
|
||||||
if (!wbinfo_list_domains(True)) {
|
if (!wbinfo_list_domains(true)) {
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -46,8 +46,8 @@ struct cvfs_private {
|
|||||||
struct ntvfs_module_context *ntvfs;
|
struct ntvfs_module_context *ntvfs;
|
||||||
struct async_info *pending;
|
struct async_info *pending;
|
||||||
struct cvfs_file *files;
|
struct cvfs_file *files;
|
||||||
BOOL map_generic;
|
bool map_generic;
|
||||||
BOOL map_trans2;
|
bool map_trans2;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -84,15 +84,15 @@ struct async_info {
|
|||||||
#define CIFS_MAP_GENERIC "cifs:map-generic"
|
#define CIFS_MAP_GENERIC "cifs:map-generic"
|
||||||
#define CIFS_MAP_TRANS2 "cifs:map-trans2"
|
#define CIFS_MAP_TRANS2 "cifs:map-trans2"
|
||||||
|
|
||||||
#define CIFS_USE_MACHINE_ACCT_DEFAULT False
|
#define CIFS_USE_MACHINE_ACCT_DEFAULT false
|
||||||
#define CIFS_MAP_GENERIC_DEFAULT False
|
#define CIFS_MAP_GENERIC_DEFAULT false
|
||||||
#define CIFS_MAP_TRANS2_DEFAULT True
|
#define CIFS_MAP_TRANS2_DEFAULT true
|
||||||
|
|
||||||
/*
|
/*
|
||||||
a handler for oplock break events from the server - these need to be passed
|
a handler for oplock break events from the server - these need to be passed
|
||||||
along to the client
|
along to the client
|
||||||
*/
|
*/
|
||||||
static BOOL oplock_handler(struct smbcli_transport *transport, uint16_t tid, uint16_t fnum, uint8_t level, void *p_private)
|
static bool oplock_handler(struct smbcli_transport *transport, uint16_t tid, uint16_t fnum, uint8_t level, void *p_private)
|
||||||
{
|
{
|
||||||
struct cvfs_private *private = p_private;
|
struct cvfs_private *private = p_private;
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
@ -107,13 +107,13 @@ static BOOL oplock_handler(struct smbcli_transport *transport, uint16_t tid, uin
|
|||||||
|
|
||||||
if (!h) {
|
if (!h) {
|
||||||
DEBUG(5,("vfs_cifs: ignoring oplock break level %d for fnum %d\n", level, fnum));
|
DEBUG(5,("vfs_cifs: ignoring oplock break level %d for fnum %d\n", level, fnum));
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG(5,("vfs_cifs: sending oplock break level %d for fnum %d\n", level, fnum));
|
DEBUG(5,("vfs_cifs: sending oplock break level %d for fnum %d\n", level, fnum));
|
||||||
status = ntvfs_send_oplock_break(private->ntvfs, h, level);
|
status = ntvfs_send_oplock_break(private->ntvfs, h, level);
|
||||||
if (!NT_STATUS_IS_OK(status)) return False;
|
if (!NT_STATUS_IS_OK(status)) return false;
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -130,7 +130,7 @@ static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs,
|
|||||||
struct share_config *scfg = ntvfs->ctx->config;
|
struct share_config *scfg = ntvfs->ctx->config;
|
||||||
|
|
||||||
struct cli_credentials *credentials;
|
struct cli_credentials *credentials;
|
||||||
BOOL machine_account;
|
bool machine_account;
|
||||||
|
|
||||||
/* Here we need to determine which server to connect to.
|
/* Here we need to determine which server to connect to.
|
||||||
* For now we use parametric options, type cifs.
|
* For now we use parametric options, type cifs.
|
||||||
@ -197,7 +197,7 @@ static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs,
|
|||||||
io.in.port = 0;
|
io.in.port = 0;
|
||||||
io.in.called_name = host;
|
io.in.called_name = host;
|
||||||
io.in.credentials = credentials;
|
io.in.credentials = credentials;
|
||||||
io.in.fallback_to_anonymous = False;
|
io.in.fallback_to_anonymous = false;
|
||||||
io.in.workgroup = lp_workgroup(global_loadparm);
|
io.in.workgroup = lp_workgroup(global_loadparm);
|
||||||
io.in.service = remote_share;
|
io.in.service = remote_share;
|
||||||
io.in.service_type = "?????";
|
io.in.service_type = "?????";
|
||||||
@ -922,7 +922,7 @@ static NTSTATUS cvfs_lpq(struct ntvfs_module_context *ntvfs,
|
|||||||
static NTSTATUS cvfs_search_first(struct ntvfs_module_context *ntvfs,
|
static NTSTATUS cvfs_search_first(struct ntvfs_module_context *ntvfs,
|
||||||
struct ntvfs_request *req, union smb_search_first *io,
|
struct ntvfs_request *req, union smb_search_first *io,
|
||||||
void *search_private,
|
void *search_private,
|
||||||
BOOL (*callback)(void *, const union smb_search_data *))
|
bool (*callback)(void *, const union smb_search_data *))
|
||||||
{
|
{
|
||||||
struct cvfs_private *private = ntvfs->private_data;
|
struct cvfs_private *private = ntvfs->private_data;
|
||||||
|
|
||||||
@ -935,7 +935,7 @@ static NTSTATUS cvfs_search_first(struct ntvfs_module_context *ntvfs,
|
|||||||
static NTSTATUS cvfs_search_next(struct ntvfs_module_context *ntvfs,
|
static NTSTATUS cvfs_search_next(struct ntvfs_module_context *ntvfs,
|
||||||
struct ntvfs_request *req, union smb_search_next *io,
|
struct ntvfs_request *req, union smb_search_next *io,
|
||||||
void *search_private,
|
void *search_private,
|
||||||
BOOL (*callback)(void *, const union smb_search_data *))
|
bool (*callback)(void *, const union smb_search_data *))
|
||||||
{
|
{
|
||||||
struct cvfs_private *private = ntvfs->private_data;
|
struct cvfs_private *private = ntvfs->private_data;
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
#define O_DIRECTORY 0
|
#define O_DIRECTORY 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define CHECK_READ_ONLY(req) do { if (share_bool_option(ntvfs->ctx->config, SHARE_READONLY, True)) return NT_STATUS_ACCESS_DENIED; } while (0)
|
#define CHECK_READ_ONLY(req) do { if (share_bool_option(ntvfs->ctx->config, SHARE_READONLY, true)) return NT_STATUS_ACCESS_DENIED; } while (0)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
connect to a share - used when a tree_connect operation comes
|
connect to a share - used when a tree_connect operation comes
|
||||||
@ -311,7 +311,7 @@ static NTSTATUS cifspsx_open(struct ntvfs_module_context *ntvfs,
|
|||||||
int fd, flags;
|
int fd, flags;
|
||||||
struct cifspsx_file *f;
|
struct cifspsx_file *f;
|
||||||
int create_flags, rdwr_flags;
|
int create_flags, rdwr_flags;
|
||||||
BOOL readonly;
|
bool readonly;
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
struct ntvfs_handle *handle;
|
struct ntvfs_handle *handle;
|
||||||
|
|
||||||
@ -829,7 +829,7 @@ static NTSTATUS cifspsx_lpq(struct ntvfs_module_context *ntvfs,
|
|||||||
static NTSTATUS cifspsx_search_first(struct ntvfs_module_context *ntvfs,
|
static NTSTATUS cifspsx_search_first(struct ntvfs_module_context *ntvfs,
|
||||||
struct ntvfs_request *req, union smb_search_first *io,
|
struct ntvfs_request *req, union smb_search_first *io,
|
||||||
void *search_private,
|
void *search_private,
|
||||||
BOOL (*callback)(void *, const union smb_search_data *))
|
bool (*callback)(void *, const union smb_search_data *))
|
||||||
{
|
{
|
||||||
struct cifspsx_dir *dir;
|
struct cifspsx_dir *dir;
|
||||||
int i;
|
int i;
|
||||||
@ -903,7 +903,7 @@ static NTSTATUS cifspsx_search_first(struct ntvfs_module_context *ntvfs,
|
|||||||
static NTSTATUS cifspsx_search_next(struct ntvfs_module_context *ntvfs,
|
static NTSTATUS cifspsx_search_next(struct ntvfs_module_context *ntvfs,
|
||||||
struct ntvfs_request *req, union smb_search_next *io,
|
struct ntvfs_request *req, union smb_search_next *io,
|
||||||
void *search_private,
|
void *search_private,
|
||||||
BOOL (*callback)(void *, const union smb_search_data *))
|
bool (*callback)(void *, const union smb_search_data *))
|
||||||
{
|
{
|
||||||
struct cifspsx_dir *dir;
|
struct cifspsx_dir *dir;
|
||||||
int i;
|
int i;
|
||||||
|
@ -126,7 +126,7 @@ static struct brl_handle *brl_tdb_create_handle(TALLOC_CTX *mem_ctx, struct ntvf
|
|||||||
/*
|
/*
|
||||||
see if two locking contexts are equal
|
see if two locking contexts are equal
|
||||||
*/
|
*/
|
||||||
static BOOL brl_tdb_same_context(struct lock_context *ctx1, struct lock_context *ctx2)
|
static bool brl_tdb_same_context(struct lock_context *ctx1, struct lock_context *ctx2)
|
||||||
{
|
{
|
||||||
return (cluster_id_equal(&ctx1->server, &ctx2->server) &&
|
return (cluster_id_equal(&ctx1->server, &ctx2->server) &&
|
||||||
ctx1->smbpid == ctx2->smbpid &&
|
ctx1->smbpid == ctx2->smbpid &&
|
||||||
@ -139,7 +139,7 @@ static BOOL brl_tdb_same_context(struct lock_context *ctx1, struct lock_context
|
|||||||
lck1 is the existing lock. lck2 is the new lock we are
|
lck1 is the existing lock. lck2 is the new lock we are
|
||||||
looking at adding
|
looking at adding
|
||||||
*/
|
*/
|
||||||
static BOOL brl_tdb_overlap(struct lock_struct *lck1,
|
static bool brl_tdb_overlap(struct lock_struct *lck1,
|
||||||
struct lock_struct *lck2)
|
struct lock_struct *lck2)
|
||||||
{
|
{
|
||||||
/* this extra check is not redundent - it copes with locks
|
/* this extra check is not redundent - it copes with locks
|
||||||
@ -147,12 +147,12 @@ static BOOL brl_tdb_overlap(struct lock_struct *lck1,
|
|||||||
if (lck1->size != 0 &&
|
if (lck1->size != 0 &&
|
||||||
lck1->start == lck2->start &&
|
lck1->start == lck2->start &&
|
||||||
lck1->size == lck2->size) {
|
lck1->size == lck2->size) {
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lck1->start >= (lck2->start+lck2->size) ||
|
if (lck1->start >= (lck2->start+lck2->size) ||
|
||||||
lck2->start >= (lck1->start+lck1->size)) {
|
lck2->start >= (lck1->start+lck1->size)) {
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* we have a conflict. Now check to see if lck1 really still
|
/* we have a conflict. Now check to see if lck1 really still
|
||||||
@ -163,28 +163,28 @@ static BOOL brl_tdb_overlap(struct lock_struct *lck1,
|
|||||||
* hasn't been written yet. When clustered this will need to
|
* hasn't been written yet. When clustered this will need to
|
||||||
* call into ctdb */
|
* call into ctdb */
|
||||||
|
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
See if lock2 can be added when lock1 is in place.
|
See if lock2 can be added when lock1 is in place.
|
||||||
*/
|
*/
|
||||||
static BOOL brl_tdb_conflict(struct lock_struct *lck1,
|
static bool brl_tdb_conflict(struct lock_struct *lck1,
|
||||||
struct lock_struct *lck2)
|
struct lock_struct *lck2)
|
||||||
{
|
{
|
||||||
/* pending locks don't conflict with anything */
|
/* pending locks don't conflict with anything */
|
||||||
if (lck1->lock_type >= PENDING_READ_LOCK ||
|
if (lck1->lock_type >= PENDING_READ_LOCK ||
|
||||||
lck2->lock_type >= PENDING_READ_LOCK) {
|
lck2->lock_type >= PENDING_READ_LOCK) {
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lck1->lock_type == READ_LOCK && lck2->lock_type == READ_LOCK) {
|
if (lck1->lock_type == READ_LOCK && lck2->lock_type == READ_LOCK) {
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (brl_tdb_same_context(&lck1->context, &lck2->context) &&
|
if (brl_tdb_same_context(&lck1->context, &lck2->context) &&
|
||||||
lck2->lock_type == READ_LOCK && lck1->ntvfs == lck2->ntvfs) {
|
lck2->lock_type == READ_LOCK && lck1->ntvfs == lck2->ntvfs) {
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return brl_tdb_overlap(lck1, lck2);
|
return brl_tdb_overlap(lck1, lck2);
|
||||||
@ -195,16 +195,16 @@ static BOOL brl_tdb_conflict(struct lock_struct *lck1,
|
|||||||
Check to see if this lock conflicts, but ignore our own locks on the
|
Check to see if this lock conflicts, but ignore our own locks on the
|
||||||
same fnum only.
|
same fnum only.
|
||||||
*/
|
*/
|
||||||
static BOOL brl_tdb_conflict_other(struct lock_struct *lck1, struct lock_struct *lck2)
|
static bool brl_tdb_conflict_other(struct lock_struct *lck1, struct lock_struct *lck2)
|
||||||
{
|
{
|
||||||
/* pending locks don't conflict with anything */
|
/* pending locks don't conflict with anything */
|
||||||
if (lck1->lock_type >= PENDING_READ_LOCK ||
|
if (lck1->lock_type >= PENDING_READ_LOCK ||
|
||||||
lck2->lock_type >= PENDING_READ_LOCK) {
|
lck2->lock_type >= PENDING_READ_LOCK) {
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lck1->lock_type == READ_LOCK && lck2->lock_type == READ_LOCK)
|
if (lck1->lock_type == READ_LOCK && lck2->lock_type == READ_LOCK)
|
||||||
return False;
|
return false;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* note that incoming write calls conflict with existing READ
|
* note that incoming write calls conflict with existing READ
|
||||||
@ -214,7 +214,7 @@ static BOOL brl_tdb_conflict_other(struct lock_struct *lck1, struct lock_struct
|
|||||||
if (brl_tdb_same_context(&lck1->context, &lck2->context) &&
|
if (brl_tdb_same_context(&lck1->context, &lck2->context) &&
|
||||||
lck1->ntvfs == lck2->ntvfs &&
|
lck1->ntvfs == lck2->ntvfs &&
|
||||||
(lck2->lock_type == READ_LOCK || lck1->lock_type == WRITE_LOCK)) {
|
(lck2->lock_type == READ_LOCK || lck1->lock_type == WRITE_LOCK)) {
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return brl_tdb_overlap(lck1, lck2);
|
return brl_tdb_overlap(lck1, lck2);
|
||||||
|
@ -58,7 +58,7 @@ struct notify_list {
|
|||||||
#define NOTIFY_KEY "notify array"
|
#define NOTIFY_KEY "notify array"
|
||||||
|
|
||||||
#define NOTIFY_ENABLE "notify:enable"
|
#define NOTIFY_ENABLE "notify:enable"
|
||||||
#define NOTIFY_ENABLE_DEFAULT True
|
#define NOTIFY_ENABLE_DEFAULT true
|
||||||
|
|
||||||
static NTSTATUS notify_remove_all(struct notify_context *notify);
|
static NTSTATUS notify_remove_all(struct notify_context *notify);
|
||||||
static void notify_handler(struct messaging_context *msg_ctx, void *private_data,
|
static void notify_handler(struct messaging_context *msg_ctx, void *private_data,
|
||||||
@ -86,7 +86,7 @@ struct notify_context *notify_init(TALLOC_CTX *mem_ctx, struct server_id server,
|
|||||||
{
|
{
|
||||||
struct notify_context *notify;
|
struct notify_context *notify;
|
||||||
|
|
||||||
if (share_bool_option(scfg, NOTIFY_ENABLE, NOTIFY_ENABLE_DEFAULT) != True) {
|
if (share_bool_option(scfg, NOTIFY_ENABLE, NOTIFY_ENABLE_DEFAULT) != true) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ _PUBLIC_ struct odb_lock *odb_lock(TALLOC_CTX *mem_ctx,
|
|||||||
*/
|
*/
|
||||||
_PUBLIC_ NTSTATUS odb_open_file(struct odb_lock *lck, void *file_handle,
|
_PUBLIC_ NTSTATUS odb_open_file(struct odb_lock *lck, void *file_handle,
|
||||||
uint32_t stream_id, uint32_t share_access,
|
uint32_t stream_id, uint32_t share_access,
|
||||||
uint32_t access_mask, BOOL delete_on_close,
|
uint32_t access_mask, bool delete_on_close,
|
||||||
const char *path,
|
const char *path,
|
||||||
uint32_t oplock_level, uint32_t *oplock_granted)
|
uint32_t oplock_level, uint32_t *oplock_granted)
|
||||||
{
|
{
|
||||||
@ -139,7 +139,7 @@ _PUBLIC_ NTSTATUS odb_rename(struct odb_lock *lck, const char *path)
|
|||||||
/*
|
/*
|
||||||
update delete on close flag on an open file
|
update delete on close flag on an open file
|
||||||
*/
|
*/
|
||||||
_PUBLIC_ NTSTATUS odb_set_delete_on_close(struct odb_lock *lck, BOOL del_on_close)
|
_PUBLIC_ NTSTATUS odb_set_delete_on_close(struct odb_lock *lck, bool del_on_close)
|
||||||
{
|
{
|
||||||
return ops->odb_set_delete_on_close(lck, del_on_close);
|
return ops->odb_set_delete_on_close(lck, del_on_close);
|
||||||
}
|
}
|
||||||
@ -149,7 +149,7 @@ _PUBLIC_ NTSTATUS odb_set_delete_on_close(struct odb_lock *lck, BOOL del_on_clos
|
|||||||
people still have the file open
|
people still have the file open
|
||||||
*/
|
*/
|
||||||
_PUBLIC_ NTSTATUS odb_get_delete_on_close(struct odb_context *odb,
|
_PUBLIC_ NTSTATUS odb_get_delete_on_close(struct odb_context *odb,
|
||||||
DATA_BLOB *key, BOOL *del_on_close,
|
DATA_BLOB *key, bool *del_on_close,
|
||||||
int *open_count, char **path)
|
int *open_count, char **path)
|
||||||
{
|
{
|
||||||
return ops->odb_get_delete_on_close(odb, key, del_on_close, open_count, path);
|
return ops->odb_get_delete_on_close(odb, key, del_on_close, open_count, path);
|
||||||
|
@ -52,7 +52,7 @@
|
|||||||
struct odb_context {
|
struct odb_context {
|
||||||
struct tdb_wrap *w;
|
struct tdb_wrap *w;
|
||||||
struct ntvfs_context *ntvfs_ctx;
|
struct ntvfs_context *ntvfs_ctx;
|
||||||
BOOL oplocks;
|
bool oplocks;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -266,7 +266,7 @@ static NTSTATUS odb_oplock_break_send(struct odb_context *odb, struct opendb_ent
|
|||||||
*/
|
*/
|
||||||
static NTSTATUS odb_tdb_open_file(struct odb_lock *lck, void *file_handle,
|
static NTSTATUS odb_tdb_open_file(struct odb_lock *lck, void *file_handle,
|
||||||
uint32_t stream_id, uint32_t share_access,
|
uint32_t stream_id, uint32_t share_access,
|
||||||
uint32_t access_mask, BOOL delete_on_close,
|
uint32_t access_mask, bool delete_on_close,
|
||||||
const char *path,
|
const char *path,
|
||||||
uint32_t oplock_level, uint32_t *oplock_granted)
|
uint32_t oplock_level, uint32_t *oplock_granted)
|
||||||
{
|
{
|
||||||
@ -276,7 +276,7 @@ static NTSTATUS odb_tdb_open_file(struct odb_lock *lck, void *file_handle,
|
|||||||
struct opendb_file file;
|
struct opendb_file file;
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
|
|
||||||
if (odb->oplocks == False) {
|
if (odb->oplocks == false) {
|
||||||
oplock_level = OPLOCK_NONE;
|
oplock_level = OPLOCK_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -407,7 +407,7 @@ static NTSTATUS odb_tdb_close_file(struct odb_lock *lck, void *file_handle)
|
|||||||
if (file_handle == file.entries[i].file_handle &&
|
if (file_handle == file.entries[i].file_handle &&
|
||||||
cluster_id_equal(&odb->ntvfs_ctx->server_id, &file.entries[i].server)) {
|
cluster_id_equal(&odb->ntvfs_ctx->server_id, &file.entries[i].server)) {
|
||||||
if (file.entries[i].delete_on_close) {
|
if (file.entries[i].delete_on_close) {
|
||||||
file.delete_on_close = True;
|
file.delete_on_close = true;
|
||||||
}
|
}
|
||||||
if (i < file.num_entries-1) {
|
if (i < file.num_entries-1) {
|
||||||
memmove(file.entries+i, file.entries+i+1,
|
memmove(file.entries+i, file.entries+i+1,
|
||||||
@ -494,7 +494,7 @@ static NTSTATUS odb_tdb_rename(struct odb_lock *lck, const char *path)
|
|||||||
/*
|
/*
|
||||||
update delete on close flag on an open file
|
update delete on close flag on an open file
|
||||||
*/
|
*/
|
||||||
static NTSTATUS odb_tdb_set_delete_on_close(struct odb_lock *lck, BOOL del_on_close)
|
static NTSTATUS odb_tdb_set_delete_on_close(struct odb_lock *lck, bool del_on_close)
|
||||||
{
|
{
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
struct opendb_file file;
|
struct opendb_file file;
|
||||||
@ -512,7 +512,7 @@ static NTSTATUS odb_tdb_set_delete_on_close(struct odb_lock *lck, BOOL del_on_cl
|
|||||||
people still have the file open
|
people still have the file open
|
||||||
*/
|
*/
|
||||||
static NTSTATUS odb_tdb_get_delete_on_close(struct odb_context *odb,
|
static NTSTATUS odb_tdb_get_delete_on_close(struct odb_context *odb,
|
||||||
DATA_BLOB *key, BOOL *del_on_close,
|
DATA_BLOB *key, bool *del_on_close,
|
||||||
int *open_count, char **path)
|
int *open_count, char **path)
|
||||||
{
|
{
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
@ -525,7 +525,7 @@ static NTSTATUS odb_tdb_get_delete_on_close(struct odb_context *odb,
|
|||||||
status = odb_pull_record(lck, &file);
|
status = odb_pull_record(lck, &file);
|
||||||
if (NT_STATUS_EQUAL(NT_STATUS_OBJECT_NAME_NOT_FOUND, status)) {
|
if (NT_STATUS_EQUAL(NT_STATUS_OBJECT_NAME_NOT_FOUND, status)) {
|
||||||
talloc_free(lck);
|
talloc_free(lck);
|
||||||
(*del_on_close) = False;
|
(*del_on_close) = false;
|
||||||
return NT_STATUS_OK;
|
return NT_STATUS_OK;
|
||||||
}
|
}
|
||||||
if (!NT_STATUS_IS_OK(status)) {
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
@ -541,7 +541,7 @@ static NTSTATUS odb_tdb_get_delete_on_close(struct odb_context *odb,
|
|||||||
*path = talloc_strdup(odb, file.path);
|
*path = talloc_strdup(odb, file.path);
|
||||||
NT_STATUS_HAVE_NO_MEMORY(*path);
|
NT_STATUS_HAVE_NO_MEMORY(*path);
|
||||||
if (file.num_entries == 1 && file.entries[0].delete_on_close) {
|
if (file.num_entries == 1 && file.entries[0].delete_on_close) {
|
||||||
(*del_on_close) = True;
|
(*del_on_close) = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -669,7 +669,7 @@ static NTSTATUS ipc_lpq(struct ntvfs_module_context *ntvfs,
|
|||||||
static NTSTATUS ipc_search_first(struct ntvfs_module_context *ntvfs,
|
static NTSTATUS ipc_search_first(struct ntvfs_module_context *ntvfs,
|
||||||
struct ntvfs_request *req, union smb_search_first *io,
|
struct ntvfs_request *req, union smb_search_first *io,
|
||||||
void *search_private,
|
void *search_private,
|
||||||
BOOL (*callback)(void *, const union smb_search_data *))
|
bool (*callback)(void *, const union smb_search_data *))
|
||||||
{
|
{
|
||||||
return NT_STATUS_ACCESS_DENIED;
|
return NT_STATUS_ACCESS_DENIED;
|
||||||
}
|
}
|
||||||
@ -680,7 +680,7 @@ static NTSTATUS ipc_search_first(struct ntvfs_module_context *ntvfs,
|
|||||||
static NTSTATUS ipc_search_next(struct ntvfs_module_context *ntvfs,
|
static NTSTATUS ipc_search_next(struct ntvfs_module_context *ntvfs,
|
||||||
struct ntvfs_request *req, union smb_search_next *io,
|
struct ntvfs_request *req, union smb_search_next *io,
|
||||||
void *search_private,
|
void *search_private,
|
||||||
BOOL (*callback)(void *, const union smb_search_data *))
|
bool (*callback)(void *, const union smb_search_data *))
|
||||||
{
|
{
|
||||||
return NT_STATUS_ACCESS_DENIED;
|
return NT_STATUS_ACCESS_DENIED;
|
||||||
}
|
}
|
||||||
|
@ -841,7 +841,7 @@ static void nbench_search_first_send(struct ntvfs_request *req)
|
|||||||
static NTSTATUS nbench_search_first(struct ntvfs_module_context *ntvfs,
|
static NTSTATUS nbench_search_first(struct ntvfs_module_context *ntvfs,
|
||||||
struct ntvfs_request *req, union smb_search_first *io,
|
struct ntvfs_request *req, union smb_search_first *io,
|
||||||
void *search_private,
|
void *search_private,
|
||||||
BOOL (*callback)(void *, const union smb_search_data *))
|
bool (*callback)(void *, const union smb_search_data *))
|
||||||
{
|
{
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
|
|
||||||
@ -863,7 +863,7 @@ static void nbench_search_next_send(struct ntvfs_request *req)
|
|||||||
static NTSTATUS nbench_search_next(struct ntvfs_module_context *ntvfs,
|
static NTSTATUS nbench_search_next(struct ntvfs_module_context *ntvfs,
|
||||||
struct ntvfs_request *req, union smb_search_next *io,
|
struct ntvfs_request *req, union smb_search_next *io,
|
||||||
void *search_private,
|
void *search_private,
|
||||||
BOOL (*callback)(void *, const union smb_search_data *))
|
bool (*callback)(void *, const union smb_search_data *))
|
||||||
{
|
{
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ _PUBLIC_ const struct ntvfs_critical_sizes *ntvfs_interface_version(void)
|
|||||||
return &critical_sizes;
|
return &critical_sizes;
|
||||||
}
|
}
|
||||||
|
|
||||||
_PUBLIC_ BOOL ntvfs_interface_differs(const struct ntvfs_critical_sizes *const iface)
|
_PUBLIC_ bool ntvfs_interface_differs(const struct ntvfs_critical_sizes *const iface)
|
||||||
{
|
{
|
||||||
/* The comparison would be easier with memcmp, but compiler-interset
|
/* The comparison would be easier with memcmp, but compiler-interset
|
||||||
* alignment padding is not guaranteed to be zeroed.
|
* alignment padding is not guaranteed to be zeroed.
|
||||||
@ -122,28 +122,28 @@ _PUBLIC_ BOOL ntvfs_interface_differs(const struct ntvfs_critical_sizes *const i
|
|||||||
#define FIELD_DIFFERS(field) (iface->field != critical_sizes.field)
|
#define FIELD_DIFFERS(field) (iface->field != critical_sizes.field)
|
||||||
|
|
||||||
if (FIELD_DIFFERS(interface_version))
|
if (FIELD_DIFFERS(interface_version))
|
||||||
return True;
|
return true;
|
||||||
|
|
||||||
if (FIELD_DIFFERS(sizeof_ntvfs_critical_sizes))
|
if (FIELD_DIFFERS(sizeof_ntvfs_critical_sizes))
|
||||||
return True;
|
return true;
|
||||||
|
|
||||||
if (FIELD_DIFFERS(sizeof_ntvfs_context))
|
if (FIELD_DIFFERS(sizeof_ntvfs_context))
|
||||||
return True;
|
return true;
|
||||||
|
|
||||||
if (FIELD_DIFFERS(sizeof_ntvfs_module_context))
|
if (FIELD_DIFFERS(sizeof_ntvfs_module_context))
|
||||||
return True;
|
return true;
|
||||||
|
|
||||||
if (FIELD_DIFFERS(sizeof_ntvfs_ops))
|
if (FIELD_DIFFERS(sizeof_ntvfs_ops))
|
||||||
return True;
|
return true;
|
||||||
|
|
||||||
if (FIELD_DIFFERS(sizeof_ntvfs_async_state))
|
if (FIELD_DIFFERS(sizeof_ntvfs_async_state))
|
||||||
return True;
|
return true;
|
||||||
|
|
||||||
if (FIELD_DIFFERS(sizeof_ntvfs_request))
|
if (FIELD_DIFFERS(sizeof_ntvfs_request))
|
||||||
return True;
|
return true;
|
||||||
|
|
||||||
/* Versions match. */
|
/* Versions match. */
|
||||||
return False;
|
return false;
|
||||||
|
|
||||||
#undef FIELD_DIFFERS
|
#undef FIELD_DIFFERS
|
||||||
}
|
}
|
||||||
|
@ -116,21 +116,21 @@ static NTSTATUS ntvfs_map_async_finish(struct ntvfs_request *req, NTSTATUS statu
|
|||||||
see if a filename ends in EXE COM DLL or SYM. This is needed for the
|
see if a filename ends in EXE COM DLL or SYM. This is needed for the
|
||||||
DENY_DOS mapping for OpenX
|
DENY_DOS mapping for OpenX
|
||||||
*/
|
*/
|
||||||
BOOL is_exe_filename(const char *fname)
|
bool is_exe_filename(const char *fname)
|
||||||
{
|
{
|
||||||
char *p;
|
char *p;
|
||||||
p = strrchr(fname, '.');
|
p = strrchr(fname, '.');
|
||||||
if (!p) {
|
if (!p) {
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
p++;
|
p++;
|
||||||
if (strcasecmp(p, "EXE") == 0 ||
|
if (strcasecmp(p, "EXE") == 0 ||
|
||||||
strcasecmp(p, "COM") == 0 ||
|
strcasecmp(p, "COM") == 0 ||
|
||||||
strcasecmp(p, "DLL") == 0 ||
|
strcasecmp(p, "DLL") == 0 ||
|
||||||
strcasecmp(p, "SYM") == 0) {
|
strcasecmp(p, "SYM") == 0) {
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1247,7 +1247,7 @@ _PUBLIC_ NTSTATUS ntvfs_map_read(struct ntvfs_module_context *ntvfs,
|
|||||||
}
|
}
|
||||||
|
|
||||||
rd2->readx.level = RAW_READ_READX;
|
rd2->readx.level = RAW_READ_READX;
|
||||||
rd2->readx.in.read_for_execute = False;
|
rd2->readx.in.read_for_execute = false;
|
||||||
|
|
||||||
switch (rd->generic.level) {
|
switch (rd->generic.level) {
|
||||||
case RAW_READ_READX:
|
case RAW_READ_READX:
|
||||||
|
@ -149,7 +149,7 @@ _PUBLIC_ NTSTATUS ntvfs_copy(struct ntvfs_request *req, struct smb_copy *cp)
|
|||||||
|
|
||||||
/* directory search */
|
/* directory search */
|
||||||
_PUBLIC_ NTSTATUS ntvfs_search_first(struct ntvfs_request *req, union smb_search_first *io, void *private,
|
_PUBLIC_ NTSTATUS ntvfs_search_first(struct ntvfs_request *req, union smb_search_first *io, void *private,
|
||||||
BOOL ntvfs_callback(void *private, const union smb_search_data *file))
|
bool ntvfs_callback(void *private, const union smb_search_data *file))
|
||||||
{
|
{
|
||||||
struct ntvfs_module_context *ntvfs = req->ctx->modules;
|
struct ntvfs_module_context *ntvfs = req->ctx->modules;
|
||||||
if (!ntvfs->ops->search_first) {
|
if (!ntvfs->ops->search_first) {
|
||||||
@ -159,7 +159,7 @@ _PUBLIC_ NTSTATUS ntvfs_search_first(struct ntvfs_request *req, union smb_search
|
|||||||
}
|
}
|
||||||
|
|
||||||
_PUBLIC_ NTSTATUS ntvfs_search_next(struct ntvfs_request *req, union smb_search_next *io, void *private,
|
_PUBLIC_ NTSTATUS ntvfs_search_next(struct ntvfs_request *req, union smb_search_next *io, void *private,
|
||||||
BOOL ntvfs_callback(void *private, const union smb_search_data *file))
|
bool ntvfs_callback(void *private, const union smb_search_data *file))
|
||||||
{
|
{
|
||||||
struct ntvfs_module_context *ntvfs = req->ctx->modules;
|
struct ntvfs_module_context *ntvfs = req->ctx->modules;
|
||||||
if (!ntvfs->ops->search_next) {
|
if (!ntvfs->ops->search_next) {
|
||||||
@ -469,7 +469,7 @@ _PUBLIC_ NTSTATUS ntvfs_next_open(struct ntvfs_module_context *ntvfs,
|
|||||||
_PUBLIC_ NTSTATUS ntvfs_next_search_first(struct ntvfs_module_context *ntvfs,
|
_PUBLIC_ NTSTATUS ntvfs_next_search_first(struct ntvfs_module_context *ntvfs,
|
||||||
struct ntvfs_request *req,
|
struct ntvfs_request *req,
|
||||||
union smb_search_first *io, void *private,
|
union smb_search_first *io, void *private,
|
||||||
BOOL (*callback)(void *private, const union smb_search_data *file))
|
bool (*callback)(void *private, const union smb_search_data *file))
|
||||||
{
|
{
|
||||||
if (!ntvfs->next || !ntvfs->next->ops->search_first) {
|
if (!ntvfs->next || !ntvfs->next->ops->search_first) {
|
||||||
return NT_STATUS_NOT_IMPLEMENTED;
|
return NT_STATUS_NOT_IMPLEMENTED;
|
||||||
@ -480,7 +480,7 @@ _PUBLIC_ NTSTATUS ntvfs_next_search_first(struct ntvfs_module_context *ntvfs,
|
|||||||
_PUBLIC_ NTSTATUS ntvfs_next_search_next(struct ntvfs_module_context *ntvfs,
|
_PUBLIC_ NTSTATUS ntvfs_next_search_next(struct ntvfs_module_context *ntvfs,
|
||||||
struct ntvfs_request *req,
|
struct ntvfs_request *req,
|
||||||
union smb_search_next *io, void *private,
|
union smb_search_next *io, void *private,
|
||||||
BOOL (*callback)(void *private, const union smb_search_data *file))
|
bool (*callback)(void *private, const union smb_search_data *file))
|
||||||
{
|
{
|
||||||
if (!ntvfs->next || !ntvfs->next->ops->search_next) {
|
if (!ntvfs->next || !ntvfs->next->ops->search_next) {
|
||||||
return NT_STATUS_NOT_IMPLEMENTED;
|
return NT_STATUS_NOT_IMPLEMENTED;
|
||||||
|
@ -112,7 +112,7 @@ _PUBLIC_ NTSTATUS ntvfs_handle_set_backend_data(struct ntvfs_handle *h,
|
|||||||
TALLOC_CTX *private_data)
|
TALLOC_CTX *private_data)
|
||||||
{
|
{
|
||||||
struct ntvfs_handle_data *d;
|
struct ntvfs_handle_data *d;
|
||||||
BOOL first_time = h->backend_data?False:True;
|
bool first_time = h->backend_data?false:true;
|
||||||
|
|
||||||
for (d=h->backend_data; d; d = d->next) {
|
for (d=h->backend_data; d; d = d->next) {
|
||||||
if (d->owner != ntvfs) continue;
|
if (d->owner != ntvfs) continue;
|
||||||
|
@ -365,7 +365,7 @@ NTSTATUS pvfs_acl_query(struct pvfs_state *pvfs,
|
|||||||
/*
|
/*
|
||||||
check the read only bit against any of the write access bits
|
check the read only bit against any of the write access bits
|
||||||
*/
|
*/
|
||||||
static BOOL pvfs_read_only(struct pvfs_state *pvfs, uint32_t access_mask)
|
static bool pvfs_read_only(struct pvfs_state *pvfs, uint32_t access_mask)
|
||||||
{
|
{
|
||||||
if ((pvfs->flags & PVFS_FLAG_READONLY) &&
|
if ((pvfs->flags & PVFS_FLAG_READONLY) &&
|
||||||
(access_mask & (SEC_FILE_WRITE_DATA |
|
(access_mask & (SEC_FILE_WRITE_DATA |
|
||||||
@ -376,9 +376,9 @@ static BOOL pvfs_read_only(struct pvfs_state *pvfs, uint32_t access_mask)
|
|||||||
SEC_STD_WRITE_DAC |
|
SEC_STD_WRITE_DAC |
|
||||||
SEC_STD_WRITE_OWNER |
|
SEC_STD_WRITE_OWNER |
|
||||||
SEC_DIR_DELETE_CHILD))) {
|
SEC_DIR_DELETE_CHILD))) {
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -548,24 +548,24 @@ NTSTATUS pvfs_access_check_parent(struct pvfs_state *pvfs,
|
|||||||
/*
|
/*
|
||||||
determine if an ACE is inheritable
|
determine if an ACE is inheritable
|
||||||
*/
|
*/
|
||||||
static BOOL pvfs_inheritable_ace(struct pvfs_state *pvfs,
|
static bool pvfs_inheritable_ace(struct pvfs_state *pvfs,
|
||||||
const struct security_ace *ace,
|
const struct security_ace *ace,
|
||||||
BOOL container)
|
bool container)
|
||||||
{
|
{
|
||||||
if (!container) {
|
if (!container) {
|
||||||
return (ace->flags & SEC_ACE_FLAG_OBJECT_INHERIT) != 0;
|
return (ace->flags & SEC_ACE_FLAG_OBJECT_INHERIT) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ace->flags & SEC_ACE_FLAG_CONTAINER_INHERIT) {
|
if (ace->flags & SEC_ACE_FLAG_CONTAINER_INHERIT) {
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ace->flags & SEC_ACE_FLAG_OBJECT_INHERIT) &&
|
if ((ace->flags & SEC_ACE_FLAG_OBJECT_INHERIT) &&
|
||||||
!(ace->flags & SEC_ACE_FLAG_NO_PROPAGATE_INHERIT)) {
|
!(ace->flags & SEC_ACE_FLAG_NO_PROPAGATE_INHERIT)) {
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -576,7 +576,7 @@ static BOOL pvfs_inheritable_ace(struct pvfs_state *pvfs,
|
|||||||
static NTSTATUS pvfs_acl_inherit_aces(struct pvfs_state *pvfs,
|
static NTSTATUS pvfs_acl_inherit_aces(struct pvfs_state *pvfs,
|
||||||
struct security_descriptor *parent_sd,
|
struct security_descriptor *parent_sd,
|
||||||
struct security_descriptor *sd,
|
struct security_descriptor *sd,
|
||||||
BOOL container)
|
bool container)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -663,7 +663,7 @@ NTSTATUS pvfs_acl_inherit(struct pvfs_state *pvfs,
|
|||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
struct pvfs_filename *parent;
|
struct pvfs_filename *parent;
|
||||||
struct security_descriptor *parent_sd, *sd;
|
struct security_descriptor *parent_sd, *sd;
|
||||||
BOOL container;
|
bool container;
|
||||||
|
|
||||||
/* form the parents path */
|
/* form the parents path */
|
||||||
status = pvfs_resolve_parent(pvfs, req, name, &parent);
|
status = pvfs_resolve_parent(pvfs, req, name, &parent);
|
||||||
@ -716,7 +716,7 @@ NTSTATUS pvfs_acl_inherit(struct pvfs_state *pvfs,
|
|||||||
|
|
||||||
sd->type |= SEC_DESC_DACL_PRESENT;
|
sd->type |= SEC_DESC_DACL_PRESENT;
|
||||||
|
|
||||||
container = (name->dos.attrib & FILE_ATTRIBUTE_DIRECTORY) ? True:False;
|
container = (name->dos.attrib & FILE_ATTRIBUTE_DIRECTORY) ? true:false;
|
||||||
|
|
||||||
/* fill in the aces from the parent */
|
/* fill in the aces from the parent */
|
||||||
status = pvfs_acl_inherit_aces(pvfs, parent_sd, sd, container);
|
status = pvfs_acl_inherit_aces(pvfs, parent_sd, sd, container);
|
||||||
|
@ -33,13 +33,13 @@ struct name_cache_entry {
|
|||||||
|
|
||||||
struct pvfs_dir {
|
struct pvfs_dir {
|
||||||
struct pvfs_state *pvfs;
|
struct pvfs_state *pvfs;
|
||||||
BOOL no_wildcard;
|
bool no_wildcard;
|
||||||
char *single_name;
|
char *single_name;
|
||||||
const char *pattern;
|
const char *pattern;
|
||||||
off_t offset;
|
off_t offset;
|
||||||
DIR *dir;
|
DIR *dir;
|
||||||
const char *unix_path;
|
const char *unix_path;
|
||||||
BOOL end_of_search;
|
bool end_of_search;
|
||||||
struct name_cache_entry *name_cache;
|
struct name_cache_entry *name_cache;
|
||||||
uint32_t name_cache_index;
|
uint32_t name_cache_index;
|
||||||
};
|
};
|
||||||
@ -69,8 +69,8 @@ static NTSTATUS pvfs_list_no_wildcard(struct pvfs_state *pvfs, struct pvfs_filen
|
|||||||
}
|
}
|
||||||
|
|
||||||
dir->pvfs = pvfs;
|
dir->pvfs = pvfs;
|
||||||
dir->no_wildcard = True;
|
dir->no_wildcard = true;
|
||||||
dir->end_of_search = False;
|
dir->end_of_search = false;
|
||||||
dir->unix_path = talloc_strdup(dir, name->full_name);
|
dir->unix_path = talloc_strdup(dir, name->full_name);
|
||||||
if (!dir->unix_path) {
|
if (!dir->unix_path) {
|
||||||
return NT_STATUS_NO_MEMORY;
|
return NT_STATUS_NO_MEMORY;
|
||||||
@ -145,8 +145,8 @@ NTSTATUS pvfs_list_start(struct pvfs_state *pvfs, struct pvfs_filename *name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
dir->pvfs = pvfs;
|
dir->pvfs = pvfs;
|
||||||
dir->no_wildcard = False;
|
dir->no_wildcard = false;
|
||||||
dir->end_of_search = False;
|
dir->end_of_search = false;
|
||||||
dir->offset = DIR_OFFSET_DOT;
|
dir->offset = DIR_OFFSET_DOT;
|
||||||
dir->name_cache = talloc_zero_array(dir,
|
dir->name_cache = talloc_zero_array(dir,
|
||||||
struct name_cache_entry,
|
struct name_cache_entry,
|
||||||
@ -187,7 +187,7 @@ const char *pvfs_list_next(struct pvfs_dir *dir, off_t *ofs)
|
|||||||
|
|
||||||
/* non-wildcard searches are easy */
|
/* non-wildcard searches are easy */
|
||||||
if (dir->no_wildcard) {
|
if (dir->no_wildcard) {
|
||||||
dir->end_of_search = True;
|
dir->end_of_search = true;
|
||||||
if (*ofs != 0) return NULL;
|
if (*ofs != 0) return NULL;
|
||||||
(*ofs)++;
|
(*ofs)++;
|
||||||
return dir->single_name;
|
return dir->single_name;
|
||||||
@ -246,7 +246,7 @@ const char *pvfs_list_next(struct pvfs_dir *dir, off_t *ofs)
|
|||||||
return dname;
|
return dname;
|
||||||
}
|
}
|
||||||
|
|
||||||
dir->end_of_search = True;
|
dir->end_of_search = true;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,9 +259,9 @@ const char *pvfs_list_unix_path(struct pvfs_dir *dir)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
return True if end of search has been reached
|
return true if end of search has been reached
|
||||||
*/
|
*/
|
||||||
BOOL pvfs_list_eos(struct pvfs_dir *dir, off_t ofs)
|
bool pvfs_list_eos(struct pvfs_dir *dir, off_t ofs)
|
||||||
{
|
{
|
||||||
return dir->end_of_search;
|
return dir->end_of_search;
|
||||||
}
|
}
|
||||||
@ -274,7 +274,7 @@ NTSTATUS pvfs_list_seek(struct pvfs_dir *dir, const char *name, off_t *ofs)
|
|||||||
struct dirent *de;
|
struct dirent *de;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
dir->end_of_search = False;
|
dir->end_of_search = false;
|
||||||
|
|
||||||
if (ISDOT(name)) {
|
if (ISDOT(name)) {
|
||||||
dir->offset = DIR_OFFSET_DOTDOT;
|
dir->offset = DIR_OFFSET_DOTDOT;
|
||||||
@ -313,7 +313,7 @@ NTSTATUS pvfs_list_seek(struct pvfs_dir *dir, const char *name, off_t *ofs)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dir->end_of_search = True;
|
dir->end_of_search = true;
|
||||||
|
|
||||||
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
|
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
|
||||||
}
|
}
|
||||||
@ -326,7 +326,7 @@ NTSTATUS pvfs_list_seek_ofs(struct pvfs_dir *dir, uint32_t resume_key, off_t *of
|
|||||||
struct dirent *de;
|
struct dirent *de;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
dir->end_of_search = False;
|
dir->end_of_search = false;
|
||||||
|
|
||||||
if (resume_key == DIR_OFFSET_DOT) {
|
if (resume_key == DIR_OFFSET_DOT) {
|
||||||
*ofs = DIR_OFFSET_DOTDOT;
|
*ofs = DIR_OFFSET_DOTDOT;
|
||||||
@ -341,7 +341,7 @@ NTSTATUS pvfs_list_seek_ofs(struct pvfs_dir *dir, uint32_t resume_key, off_t *of
|
|||||||
if (resume_key == DIR_OFFSET_BASE) {
|
if (resume_key == DIR_OFFSET_BASE) {
|
||||||
rewinddir(dir->dir);
|
rewinddir(dir->dir);
|
||||||
if ((de=readdir(dir->dir)) == NULL) {
|
if ((de=readdir(dir->dir)) == NULL) {
|
||||||
dir->end_of_search = True;
|
dir->end_of_search = true;
|
||||||
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
|
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
|
||||||
}
|
}
|
||||||
*ofs = telldir(dir->dir) + DIR_OFFSET_BASE;
|
*ofs = telldir(dir->dir) + DIR_OFFSET_BASE;
|
||||||
@ -374,7 +374,7 @@ NTSTATUS pvfs_list_seek_ofs(struct pvfs_dir *dir, uint32_t resume_key, off_t *of
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dir->end_of_search = True;
|
dir->end_of_search = true;
|
||||||
|
|
||||||
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
|
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
|
||||||
}
|
}
|
||||||
@ -383,21 +383,21 @@ NTSTATUS pvfs_list_seek_ofs(struct pvfs_dir *dir, uint32_t resume_key, off_t *of
|
|||||||
/*
|
/*
|
||||||
see if a directory is empty
|
see if a directory is empty
|
||||||
*/
|
*/
|
||||||
BOOL pvfs_directory_empty(struct pvfs_state *pvfs, struct pvfs_filename *name)
|
bool pvfs_directory_empty(struct pvfs_state *pvfs, struct pvfs_filename *name)
|
||||||
{
|
{
|
||||||
struct dirent *de;
|
struct dirent *de;
|
||||||
DIR *dir = opendir(name->full_name);
|
DIR *dir = opendir(name->full_name);
|
||||||
if (dir == NULL) {
|
if (dir == NULL) {
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((de = readdir(dir))) {
|
while ((de = readdir(dir))) {
|
||||||
if (!ISDOT(de->d_name) && !ISDOTDOT(de->d_name)) {
|
if (!ISDOT(de->d_name) && !ISDOTDOT(de->d_name)) {
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ static void pvfs_pending_lock_continue(void *private, enum pvfs_wait_notice reas
|
|||||||
enum brl_type rw;
|
enum brl_type rw;
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
int i;
|
int i;
|
||||||
BOOL timed_out;
|
bool timed_out;
|
||||||
|
|
||||||
timed_out = (reason != PVFS_WAIT_EVENT);
|
timed_out = (reason != PVFS_WAIT_EVENT);
|
||||||
|
|
||||||
@ -136,7 +136,7 @@ static void pvfs_pending_lock_continue(void *private, enum pvfs_wait_notice reas
|
|||||||
}
|
}
|
||||||
if (NT_STATUS_IS_OK(status)) {
|
if (NT_STATUS_IS_OK(status)) {
|
||||||
f->lock_count++;
|
f->lock_count++;
|
||||||
timed_out = False;
|
timed_out = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if we have failed and timed out, or succeeded, then we
|
/* if we have failed and timed out, or succeeded, then we
|
||||||
|
@ -58,7 +58,7 @@ static void pvfs_notify_send_next(struct event_context *ev, struct timed_event *
|
|||||||
send a reply to a pending notify request
|
send a reply to a pending notify request
|
||||||
*/
|
*/
|
||||||
static void pvfs_notify_send(struct pvfs_notify_buffer *notify_buffer,
|
static void pvfs_notify_send(struct pvfs_notify_buffer *notify_buffer,
|
||||||
NTSTATUS status, BOOL immediate)
|
NTSTATUS status, bool immediate)
|
||||||
{
|
{
|
||||||
struct notify_pending *pending = notify_buffer->pending;
|
struct notify_pending *pending = notify_buffer->pending;
|
||||||
struct ntvfs_request *req;
|
struct ntvfs_request *req;
|
||||||
@ -118,7 +118,7 @@ static int pvfs_notify_destructor(struct pvfs_notify_buffer *n)
|
|||||||
{
|
{
|
||||||
notify_remove(n->f->pvfs->notify_context, n);
|
notify_remove(n->f->pvfs->notify_context, n);
|
||||||
n->f->notify_buffer = NULL;
|
n->f->notify_buffer = NULL;
|
||||||
pvfs_notify_send(n, NT_STATUS_OK, True);
|
pvfs_notify_send(n, NT_STATUS_OK, true);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,7 +161,7 @@ static void pvfs_notify_callback(void *private, const struct notify_event *ev)
|
|||||||
|
|
||||||
/* send what we have, unless its the first part of a rename */
|
/* send what we have, unless its the first part of a rename */
|
||||||
if (ev->action != NOTIFY_ACTION_OLD_NAME) {
|
if (ev->action != NOTIFY_ACTION_OLD_NAME) {
|
||||||
pvfs_notify_send(n, NT_STATUS_OK, True);
|
pvfs_notify_send(n, NT_STATUS_OK, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,7 +169,7 @@ static void pvfs_notify_callback(void *private, const struct notify_event *ev)
|
|||||||
setup a notify buffer on a directory handle
|
setup a notify buffer on a directory handle
|
||||||
*/
|
*/
|
||||||
static NTSTATUS pvfs_notify_setup(struct pvfs_state *pvfs, struct pvfs_file *f,
|
static NTSTATUS pvfs_notify_setup(struct pvfs_state *pvfs, struct pvfs_file *f,
|
||||||
uint32_t buffer_size, uint32_t filter, BOOL recursive)
|
uint32_t buffer_size, uint32_t filter, bool recursive)
|
||||||
{
|
{
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
struct notify_entry e;
|
struct notify_entry e;
|
||||||
@ -206,9 +206,9 @@ static void pvfs_notify_end(void *private, enum pvfs_wait_notice reason)
|
|||||||
struct pvfs_notify_buffer *notify_buffer = talloc_get_type(private,
|
struct pvfs_notify_buffer *notify_buffer = talloc_get_type(private,
|
||||||
struct pvfs_notify_buffer);
|
struct pvfs_notify_buffer);
|
||||||
if (reason == PVFS_WAIT_CANCEL) {
|
if (reason == PVFS_WAIT_CANCEL) {
|
||||||
pvfs_notify_send(notify_buffer, NT_STATUS_CANCELLED, False);
|
pvfs_notify_send(notify_buffer, NT_STATUS_CANCELLED, false);
|
||||||
} else {
|
} else {
|
||||||
pvfs_notify_send(notify_buffer, NT_STATUS_OK, True);
|
pvfs_notify_send(notify_buffer, NT_STATUS_OK, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,7 +277,7 @@ NTSTATUS pvfs_notify(struct ntvfs_module_context *ntvfs,
|
|||||||
}
|
}
|
||||||
|
|
||||||
req->async_states->state |= NTVFS_ASYNC_STATE_ASYNC;
|
req->async_states->state |= NTVFS_ASYNC_STATE_ASYNC;
|
||||||
pvfs_notify_send(f->notify_buffer, NT_STATUS_OK, False);
|
pvfs_notify_send(f->notify_buffer, NT_STATUS_OK, false);
|
||||||
|
|
||||||
return NT_STATUS_OK;
|
return NT_STATUS_OK;
|
||||||
}
|
}
|
||||||
|
@ -186,7 +186,7 @@ static NTSTATUS pvfs_open_directory(struct pvfs_state *pvfs,
|
|||||||
uint32_t create_action;
|
uint32_t create_action;
|
||||||
uint32_t access_mask = io->generic.in.access_mask;
|
uint32_t access_mask = io->generic.in.access_mask;
|
||||||
struct odb_lock *lck;
|
struct odb_lock *lck;
|
||||||
BOOL del_on_close;
|
bool del_on_close;
|
||||||
uint32_t create_options;
|
uint32_t create_options;
|
||||||
uint32_t share_access;
|
uint32_t share_access;
|
||||||
|
|
||||||
@ -268,14 +268,14 @@ static NTSTATUS pvfs_open_directory(struct pvfs_state *pvfs,
|
|||||||
f->handle->seek_offset = 0;
|
f->handle->seek_offset = 0;
|
||||||
f->handle->position = 0;
|
f->handle->position = 0;
|
||||||
f->handle->mode = 0;
|
f->handle->mode = 0;
|
||||||
f->handle->sticky_write_time = False;
|
f->handle->sticky_write_time = false;
|
||||||
f->handle->open_completed = False;
|
f->handle->open_completed = false;
|
||||||
|
|
||||||
if ((create_options & NTCREATEX_OPTIONS_DELETE_ON_CLOSE) &&
|
if ((create_options & NTCREATEX_OPTIONS_DELETE_ON_CLOSE) &&
|
||||||
pvfs_directory_empty(pvfs, f->handle->name)) {
|
pvfs_directory_empty(pvfs, f->handle->name)) {
|
||||||
del_on_close = True;
|
del_on_close = true;
|
||||||
} else {
|
} else {
|
||||||
del_on_close = False;
|
del_on_close = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name->exists) {
|
if (name->exists) {
|
||||||
@ -305,7 +305,7 @@ static NTSTATUS pvfs_open_directory(struct pvfs_state *pvfs,
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
f->handle->have_opendb_entry = True;
|
f->handle->have_opendb_entry = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
DLIST_ADD(pvfs->files.list, f);
|
DLIST_ADD(pvfs->files.list, f);
|
||||||
@ -357,7 +357,7 @@ static NTSTATUS pvfs_open_directory(struct pvfs_state *pvfs,
|
|||||||
goto cleanup_delete;
|
goto cleanup_delete;
|
||||||
}
|
}
|
||||||
|
|
||||||
f->handle->have_opendb_entry = True;
|
f->handle->have_opendb_entry = true;
|
||||||
|
|
||||||
create_action = NTCREATEX_ACTION_CREATED;
|
create_action = NTCREATEX_ACTION_CREATED;
|
||||||
|
|
||||||
@ -379,7 +379,7 @@ static NTSTATUS pvfs_open_directory(struct pvfs_state *pvfs,
|
|||||||
goto cleanup_delete;
|
goto cleanup_delete;
|
||||||
}
|
}
|
||||||
|
|
||||||
f->handle->open_completed = True;
|
f->handle->open_completed = true;
|
||||||
|
|
||||||
io->generic.out.oplock_level = OPLOCK_NONE;
|
io->generic.out.oplock_level = OPLOCK_NONE;
|
||||||
io->generic.out.file.ntvfs = h;
|
io->generic.out.file.ntvfs = h;
|
||||||
@ -552,7 +552,7 @@ static NTSTATUS pvfs_create_file(struct pvfs_state *pvfs,
|
|||||||
uint32_t access_mask = io->generic.in.access_mask;
|
uint32_t access_mask = io->generic.in.access_mask;
|
||||||
mode_t mode;
|
mode_t mode;
|
||||||
uint32_t attrib;
|
uint32_t attrib;
|
||||||
BOOL del_on_close;
|
bool del_on_close;
|
||||||
struct pvfs_filename *parent;
|
struct pvfs_filename *parent;
|
||||||
uint32_t oplock_level = OPLOCK_NONE, oplock_granted;
|
uint32_t oplock_level = OPLOCK_NONE, oplock_granted;
|
||||||
|
|
||||||
@ -656,9 +656,9 @@ static NTSTATUS pvfs_create_file(struct pvfs_state *pvfs,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (create_options & NTCREATEX_OPTIONS_DELETE_ON_CLOSE) {
|
if (create_options & NTCREATEX_OPTIONS_DELETE_ON_CLOSE) {
|
||||||
del_on_close = True;
|
del_on_close = true;
|
||||||
} else {
|
} else {
|
||||||
del_on_close = False;
|
del_on_close = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pvfs->flags & PVFS_FLAG_FAKE_OPLOCKS) {
|
if (pvfs->flags & PVFS_FLAG_FAKE_OPLOCKS) {
|
||||||
@ -702,9 +702,9 @@ static NTSTATUS pvfs_create_file(struct pvfs_state *pvfs,
|
|||||||
f->handle->seek_offset = 0;
|
f->handle->seek_offset = 0;
|
||||||
f->handle->position = 0;
|
f->handle->position = 0;
|
||||||
f->handle->mode = 0;
|
f->handle->mode = 0;
|
||||||
f->handle->have_opendb_entry = True;
|
f->handle->have_opendb_entry = true;
|
||||||
f->handle->sticky_write_time = False;
|
f->handle->sticky_write_time = false;
|
||||||
f->handle->open_completed = False;
|
f->handle->open_completed = false;
|
||||||
|
|
||||||
DLIST_ADD(pvfs->files.list, f);
|
DLIST_ADD(pvfs->files.list, f);
|
||||||
|
|
||||||
@ -733,7 +733,7 @@ static NTSTATUS pvfs_create_file(struct pvfs_state *pvfs,
|
|||||||
goto cleanup_delete;
|
goto cleanup_delete;
|
||||||
}
|
}
|
||||||
|
|
||||||
f->handle->open_completed = True;
|
f->handle->open_completed = true;
|
||||||
|
|
||||||
notify_trigger(pvfs->notify_context,
|
notify_trigger(pvfs->notify_context,
|
||||||
NOTIFY_ACTION_ADDED,
|
NOTIFY_ACTION_ADDED,
|
||||||
@ -989,8 +989,8 @@ NTSTATUS pvfs_open(struct ntvfs_module_context *ntvfs,
|
|||||||
uint32_t create_options;
|
uint32_t create_options;
|
||||||
uint32_t share_access;
|
uint32_t share_access;
|
||||||
uint32_t access_mask;
|
uint32_t access_mask;
|
||||||
BOOL del_on_close;
|
bool del_on_close;
|
||||||
BOOL stream_existed, stream_truncate=False;
|
bool stream_existed, stream_truncate=false;
|
||||||
uint32_t oplock_level = OPLOCK_NONE, oplock_granted;
|
uint32_t oplock_level = OPLOCK_NONE, oplock_granted;
|
||||||
|
|
||||||
/* use the generic mapping code to avoid implementing all the
|
/* use the generic mapping code to avoid implementing all the
|
||||||
@ -1035,7 +1035,7 @@ NTSTATUS pvfs_open(struct ntvfs_module_context *ntvfs,
|
|||||||
if (name->stream_name == NULL) {
|
if (name->stream_name == NULL) {
|
||||||
flags = O_TRUNC;
|
flags = O_TRUNC;
|
||||||
} else {
|
} else {
|
||||||
stream_truncate = True;
|
stream_truncate = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1053,7 +1053,7 @@ NTSTATUS pvfs_open(struct ntvfs_module_context *ntvfs,
|
|||||||
if (name->stream_name == NULL) {
|
if (name->stream_name == NULL) {
|
||||||
flags = O_TRUNC;
|
flags = O_TRUNC;
|
||||||
} else {
|
} else {
|
||||||
stream_truncate = True;
|
stream_truncate = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1133,9 +1133,9 @@ NTSTATUS pvfs_open(struct ntvfs_module_context *ntvfs,
|
|||||||
f->handle->seek_offset = 0;
|
f->handle->seek_offset = 0;
|
||||||
f->handle->position = 0;
|
f->handle->position = 0;
|
||||||
f->handle->mode = 0;
|
f->handle->mode = 0;
|
||||||
f->handle->have_opendb_entry = False;
|
f->handle->have_opendb_entry = false;
|
||||||
f->handle->sticky_write_time = False;
|
f->handle->sticky_write_time = false;
|
||||||
f->handle->open_completed = False;
|
f->handle->open_completed = false;
|
||||||
|
|
||||||
/* form the lock context used for byte range locking and
|
/* form the lock context used for byte range locking and
|
||||||
opendb locking */
|
opendb locking */
|
||||||
@ -1172,9 +1172,9 @@ NTSTATUS pvfs_open(struct ntvfs_module_context *ntvfs,
|
|||||||
*/
|
*/
|
||||||
if (create_options & NTCREATEX_OPTIONS_DELETE_ON_CLOSE &&
|
if (create_options & NTCREATEX_OPTIONS_DELETE_ON_CLOSE &&
|
||||||
req->ctx->protocol == PROTOCOL_SMB2) {
|
req->ctx->protocol == PROTOCOL_SMB2) {
|
||||||
del_on_close = True;
|
del_on_close = true;
|
||||||
} else {
|
} else {
|
||||||
del_on_close = False;
|
del_on_close = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pvfs->flags & PVFS_FLAG_FAKE_OPLOCKS) {
|
if (pvfs->flags & PVFS_FLAG_FAKE_OPLOCKS) {
|
||||||
@ -1206,7 +1206,7 @@ NTSTATUS pvfs_open(struct ntvfs_module_context *ntvfs,
|
|||||||
oplock_granted = OPLOCK_BATCH;
|
oplock_granted = OPLOCK_BATCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
f->handle->have_opendb_entry = True;
|
f->handle->have_opendb_entry = true;
|
||||||
|
|
||||||
if (access_mask & (SEC_FILE_WRITE_DATA | SEC_FILE_APPEND_DATA)) {
|
if (access_mask & (SEC_FILE_WRITE_DATA | SEC_FILE_APPEND_DATA)) {
|
||||||
flags |= O_RDWR;
|
flags |= O_RDWR;
|
||||||
@ -1273,7 +1273,7 @@ NTSTATUS pvfs_open(struct ntvfs_module_context *ntvfs,
|
|||||||
|
|
||||||
/* mark the open as having completed fully, so delete on close
|
/* mark the open as having completed fully, so delete on close
|
||||||
can now be used */
|
can now be used */
|
||||||
f->handle->open_completed = True;
|
f->handle->open_completed = true;
|
||||||
|
|
||||||
io->generic.out.oplock_level = oplock_granted;
|
io->generic.out.oplock_level = oplock_granted;
|
||||||
io->generic.out.file.ntvfs = h;
|
io->generic.out.file.ntvfs = h;
|
||||||
@ -1379,7 +1379,7 @@ NTSTATUS pvfs_exit(struct ntvfs_module_context *ntvfs,
|
|||||||
*/
|
*/
|
||||||
NTSTATUS pvfs_set_delete_on_close(struct pvfs_state *pvfs,
|
NTSTATUS pvfs_set_delete_on_close(struct pvfs_state *pvfs,
|
||||||
struct ntvfs_request *req,
|
struct ntvfs_request *req,
|
||||||
struct pvfs_file *f, BOOL del_on_close)
|
struct pvfs_file *f, bool del_on_close)
|
||||||
{
|
{
|
||||||
struct odb_lock *lck;
|
struct odb_lock *lck;
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
@ -1532,17 +1532,17 @@ NTSTATUS pvfs_can_stat(struct pvfs_state *pvfs,
|
|||||||
/*
|
/*
|
||||||
determine if delete on close is set on
|
determine if delete on close is set on
|
||||||
*/
|
*/
|
||||||
BOOL pvfs_delete_on_close_set(struct pvfs_state *pvfs, struct pvfs_file_handle *h,
|
bool pvfs_delete_on_close_set(struct pvfs_state *pvfs, struct pvfs_file_handle *h,
|
||||||
int *open_count, char **path)
|
int *open_count, char **path)
|
||||||
{
|
{
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
BOOL del_on_close;
|
bool del_on_close;
|
||||||
|
|
||||||
status = odb_get_delete_on_close(pvfs->odb_context, &h->odb_locking_key,
|
status = odb_get_delete_on_close(pvfs->odb_context, &h->odb_locking_key,
|
||||||
&del_on_close, open_count, path);
|
&del_on_close, open_count, path);
|
||||||
if (!NT_STATUS_IS_OK(status)) {
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
DEBUG(1,("WARNING: unable to determine delete on close status for open file\n"));
|
DEBUG(1,("WARNING: unable to determine delete on close status for open file\n"));
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return del_on_close;
|
return del_on_close;
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user