Exemplo n.º 1
0
NTSTATUS smb2srv_open_lookup(struct smbXsrv_connection *conn,
                             uint64_t persistent_id,
                             uint64_t volatile_id,
                             NTTIME now,
                             struct smbXsrv_open **_open)
{
    struct smbXsrv_open_table *table = conn->open_table;
    uint32_t local_id = volatile_id & UINT32_MAX;
    uint64_t local_zeros = volatile_id & 0xFFFFFFFF00000000LLU;
    uint32_t global_id = persistent_id & UINT32_MAX;
    uint64_t global_zeros = persistent_id & 0xFFFFFFFF00000000LLU;

    if (local_zeros != 0) {
        return NT_STATUS_FILE_CLOSED;
    }

    if (global_zeros != 0) {
        return NT_STATUS_FILE_CLOSED;
    }

    if (global_id == 0) {
        return NT_STATUS_FILE_CLOSED;
    }

    return smbXsrv_open_local_lookup(table, local_id, global_id, now, _open);
}
Exemplo n.º 2
0
NTSTATUS smb1srv_open_lookup(struct smbXsrv_connection *conn,
			     uint16_t fnum, NTTIME now,
			     struct smbXsrv_open **_open)
{
	struct smbXsrv_open_table *table = conn->client->open_table;
	uint32_t local_id = fnum;
	uint32_t global_id = 0;

	return smbXsrv_open_local_lookup(table, local_id, global_id, now, _open);
}
Exemplo n.º 3
0
NTSTATUS smb2srv_open_lookup(struct smbXsrv_connection *conn,
			     uint64_t persistent_id,
			     uint64_t volatile_id,
			     NTTIME now,
			     struct smbXsrv_open **_open)
{
	struct smbXsrv_open_table *table = conn->client->open_table;
	uint32_t local_id = volatile_id & UINT32_MAX;
	uint64_t local_zeros = volatile_id & 0xFFFFFFFF00000000LLU;
	uint32_t global_id = persistent_id & UINT32_MAX;
	uint64_t global_zeros = persistent_id & 0xFFFFFFFF00000000LLU;
	NTSTATUS status;

	if (local_zeros != 0) {
		return NT_STATUS_FILE_CLOSED;
	}

	if (global_zeros != 0) {
		return NT_STATUS_FILE_CLOSED;
	}

	if (global_id == 0) {
		return NT_STATUS_FILE_CLOSED;
	}

	status = smbXsrv_open_local_lookup(table, local_id, global_id, now,
					   _open);
	if (!NT_STATUS_IS_OK(status)) {
		return status;
	}

	/*
	 * Clear the replay cache for this create_guid if it exists:
	 * This is based on the assumption that this lookup will be
	 * triggered by a client request using the file-id for lookup.
	 * Hence the client has proven that it has in fact seen the
	 * reply to its initial create call. So subsequent create replays
	 * should be treated as invalid. Hence the index for create_guid
	 * lookup needs to be removed.
	 */
	status = smbXsrv_open_clear_replay_cache(*_open);

	return status;
}
Exemplo n.º 4
0
NTSTATUS smb2srv_open_lookup_replay_cache(struct smbXsrv_connection *conn,
					  const struct GUID *create_guid,
					  NTTIME now, /* TODO: needed ? */
					  struct smbXsrv_open **_open)
{
	NTSTATUS status;
	char *guid_string;
	struct GUID_txt_buf buf;
	uint32_t local_id = 0;
	struct smbXsrv_open_table *table = conn->client->open_table;
	struct db_context *db = table->local.replay_cache_db_ctx;

	if (GUID_all_zero(create_guid)) {
		return NT_STATUS_NOT_FOUND;
	}

	guid_string = GUID_buf_string(create_guid, &buf);
	if (guid_string == NULL) {
		return NT_STATUS_INVALID_PARAMETER;
	}

	status = dbwrap_fetch_uint32_bystring(db, guid_string, &local_id);
	if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND)) {
		return status;
	}
	if (!NT_STATUS_IS_OK(status)) {
		DBG_ERR("failed to fetch local_id from replay cache: %s\n",
			nt_errstr(status));
		return status;
	}

	status = smbXsrv_open_local_lookup(table, local_id, 0, /* global_id */
					   now, _open);
	if (!NT_STATUS_IS_OK(status)) {
		DBG_ERR("smbXsrv_open_local_lookup failed for local_id %u\n",
			(unsigned)local_id);
	}

	return status;
}