Esempio n. 1
0
void Connection::on_authenticate(const std::string& class_name) {
  if (protocol_version_ == 1) {
    send_credentials(class_name);
  } else {
    send_initial_auth_response(class_name);
  }
}
Esempio n. 2
0
void Connection::on_authenticate() {
  if (protocol_version_ == 1) {
    send_credentials();
  } else {
    send_initial_auth_response();
  }
}
Esempio n. 3
0
/*
 * This function is very close to the cache_write function of the caching
 * library, which is used in the caching daemon. It caches the data with the
 * specified key in the cache entry with entry_name.
 */
int
__cached_write(struct cached_connection_ *connection, const char *entry_name,
    const char *key, size_t key_size, const char *data, size_t data_size)
{
	size_t name_size;
	int error_code;
	int result;

	error_code = -1;
	result = 0;
	result = send_credentials(connection, CET_WRITE_REQUEST);
	if (result != 0)
		goto fin;

	name_size = strlen(entry_name);
	result = safe_write(connection, &name_size, sizeof(size_t));
	if (result != 0)
		goto fin;

	result = safe_write(connection, &key_size, sizeof(size_t));
	if (result != 0)
		goto fin;

	result = safe_write(connection, &data_size, sizeof(size_t));
	if (result != 0)
		goto fin;

	result = safe_write(connection, entry_name, name_size);
	if (result != 0)
		goto fin;

	result = safe_write(connection, key, key_size);
	if (result != 0)
		goto fin;

	result = safe_write(connection, data, data_size);
	if (result != 0)
		goto fin;

	result = safe_read(connection, &error_code, sizeof(int));
	if (result != 0)
		error_code = -1;

fin:
	return (error_code);
}
Esempio n. 4
0
struct cached_connection_ *
__open_cached_mp_read_session(struct cached_connection_params const *params,
	const char *entry_name)
{
	struct cached_connection_ *connection, *retval;
	size_t name_size;
	int error_code;
	int result;

	retval = NULL;
	connection = __open_cached_connection(params);
	if (connection == NULL)
		return (NULL);
	connection->mp_flag = 1;

	result = send_credentials(connection, CET_MP_READ_SESSION_REQUEST);
	if (result != 0)
		goto fin;

	name_size = strlen(entry_name);
	result = safe_write(connection, &name_size, sizeof(size_t));
	if (result != 0)
		goto fin;

	result = safe_write(connection, entry_name, name_size);
	if (result != 0)
		goto fin;

	result = safe_read(connection, &error_code, sizeof(int));
	if (result != 0)
		goto fin;

	if (error_code != 0)
		result = error_code;

fin:
	if (result != 0)
		__close_cached_connection(connection);
	else
		retval = connection;
	return (retval);
}
Esempio n. 5
0
/*
 * This function is very close to the cache_read function of the caching
 * library, which is used in the caching daemon. It reads cached data with the
 * specified key from the cache entry with entry_name.
 */
int
__cached_read(struct cached_connection_ *connection, const char *entry_name,
    const char *key, size_t key_size, char *data, size_t *data_size)
{
	size_t name_size, result_size;
	int error_code, rec_error_code;
	int result;

	assert(connection != NULL);
	result = 0;
	error_code = -1;

	result = send_credentials(connection, CET_READ_REQUEST);
	if (result != 0)
		goto fin;

	name_size = strlen(entry_name);
	result = safe_write(connection, &name_size, sizeof(size_t));
	if (result != 0)
		goto fin;

	result = safe_write(connection, &key_size, sizeof(size_t));
	if (result != 0)
		goto fin;

	result = safe_write(connection, entry_name, name_size);
	if (result != 0)
		goto fin;

	result = safe_write(connection, key, key_size);
	if (result != 0)
		goto fin;

	result = safe_read(connection, &rec_error_code, sizeof(int));
	if (result != 0)
		goto fin;

	if (rec_error_code != 0) {
		error_code = rec_error_code;
		goto fin;
	}

	result = safe_read(connection, &result_size, sizeof(size_t));
	if (result != 0)
		goto fin;

	 if (result_size > *data_size) {
		 *data_size = result_size;
		 error_code = -2;
		 goto fin;
	 }

	result = safe_read(connection, data, result_size);
	if (result != 0)
		goto fin;

	*data_size = result_size;
	error_code = 0;

fin:
	return (error_code);
}