![]() |
pacemaker
2.0.4-2deceaa
Scalable High-Availability cluster resource manager
|
#include <crm_internal.h>
#include <sys/param.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <grp.h>
#include <errno.h>
#include <fcntl.h>
#include <bzlib.h>
#include <crm/crm.h>
#include <crm/msg_xml.h>
#include <crm/common/ipc.h>
#include <crm/common/ipcs_internal.h>
#include <crm/common/ipc_internal.h>
Go to the source code of this file.
Macros | |
#define | PCMK_IPC_VERSION 1 |
#define | PCMK_IPC_DEFAULT_QUEUE_MAX 500 |
#define | MIN_MSG_SIZE 12336 /* sizeof(struct qb_ipc_connection_response) */ |
#define | MAX_MSG_SIZE 128*1024 /* 128k default */ |
Functions | |
unsigned int | crm_ipc_default_buffer_size (void) |
xmlNode * | create_request_adv (const char *task, xmlNode *msg_data, const char *host_to, const char *sys_to, const char *sys_from, const char *uuid_from, const char *origin) |
xmlNode * | create_reply_adv (xmlNode *original_request, xmlNode *xml_response_data, const char *origin) |
guint | pcmk__ipc_client_count () |
void | pcmk__foreach_ipc_client (GHFunc func, gpointer user_data) |
void | pcmk__foreach_ipc_client_remove (GHRFunc func, gpointer user_data) |
pcmk__client_t * | pcmk__find_client (qb_ipcs_connection_t *c) |
pcmk__client_t * | pcmk__find_client_by_id (const char *id) |
const char * | pcmk__client_name (pcmk__client_t *c) |
const char * | pcmk__client_type_str (enum pcmk__client_type client_type) |
void | pcmk__client_cleanup (void) |
void | pcmk__drop_all_clients (qb_ipcs_service_t *service) |
pcmk__client_t * | pcmk__new_unauth_client (void *key) |
Allocate a new pcmk__client_t object and generate its ID. More... | |
pcmk__client_t * | pcmk__new_client (qb_ipcs_connection_t *c, uid_t uid_client, gid_t gid_client) |
void | pcmk_free_ipc_event (struct iovec *event) |
Free an I/O vector created by pcmk__ipc_prepare_iov() More... | |
void | pcmk__free_client (pcmk__client_t *c) |
bool | pcmk__set_client_queue_max (pcmk__client_t *client, const char *qmax) |
int | pcmk__client_pid (qb_ipcs_connection_t *c) |
xmlNode * | pcmk__client_data2xml (pcmk__client_t *c, void *data, uint32_t *id, uint32_t *flags) |
int | pcmk__ipc_prepare_iov (uint32_t request, xmlNode *message, uint32_t max_send_size, struct iovec **result, ssize_t *bytes) |
int | pcmk__ipc_send_iov (pcmk__client_t *c, struct iovec *iov, uint32_t flags) |
int | pcmk__ipc_send_xml (pcmk__client_t *c, uint32_t request, xmlNode *message, uint32_t flags) |
void | pcmk__ipc_send_ack_as (const char *function, int line, pcmk__client_t *c, uint32_t request, uint32_t flags, const char *tag) |
void | pcmk__serve_based_ipc (qb_ipcs_service_t **ipcs_ro, qb_ipcs_service_t **ipcs_rw, qb_ipcs_service_t **ipcs_shm, struct qb_ipcs_service_handlers *ro_cb, struct qb_ipcs_service_handlers *rw_cb) |
void | pcmk__stop_based_ipc (qb_ipcs_service_t *ipcs_ro, qb_ipcs_service_t *ipcs_rw, qb_ipcs_service_t *ipcs_shm) |
qb_ipcs_service_t * | pcmk__serve_controld_ipc (struct qb_ipcs_service_handlers *cb) |
void | pcmk__serve_attrd_ipc (qb_ipcs_service_t **ipcs, struct qb_ipcs_service_handlers *cb) |
void | pcmk__serve_fenced_ipc (qb_ipcs_service_t **ipcs, struct qb_ipcs_service_handlers *cb) |
crm_ipc_t * | crm_ipc_new (const char *name, size_t max_size) |
bool | crm_ipc_connect (crm_ipc_t *client) |
Establish an IPC connection to a Pacemaker component. More... | |
void | crm_ipc_close (crm_ipc_t *client) |
void | crm_ipc_destroy (crm_ipc_t *client) |
int | crm_ipc_get_fd (crm_ipc_t *client) |
bool | crm_ipc_connected (crm_ipc_t *client) |
int | crm_ipc_ready (crm_ipc_t *client) |
Check whether an IPC connection is ready to be read. More... | |
long | crm_ipc_read (crm_ipc_t *client) |
const char * | crm_ipc_buffer (crm_ipc_t *client) |
uint32_t | crm_ipc_buffer_flags (crm_ipc_t *client) |
const char * | crm_ipc_name (crm_ipc_t *client) |
int | crm_ipc_send (crm_ipc_t *client, xmlNode *message, enum crm_ipc_flags flags, int32_t ms_timeout, xmlNode **reply) |
Send an IPC XML message. More... | |
int | crm_ipc_is_authentic_process (int sock, uid_t refuid, gid_t refgid, pid_t *gotpid, uid_t *gotuid, gid_t *gotgid) |
Check the authenticity of the IPC socket peer process. More... | |
int | pcmk__ipc_is_authentic_process_active (const char *name, uid_t refuid, gid_t refgid, pid_t *gotpid) |
xmlNode * | create_hello_message (const char *uuid, const char *client_name, const char *major_version, const char *minor_version) |
#define MIN_MSG_SIZE 12336 /* sizeof(struct qb_ipc_connection_response) */ |
xmlNode* create_hello_message | ( | const char * | uuid, |
const char * | client_name, | ||
const char * | major_version, | ||
const char * | minor_version | ||
) |
xmlNode* create_reply_adv | ( | xmlNode * | original_request, |
xmlNode * | xml_response_data, | ||
const char * | origin | ||
) |
xmlNode* create_request_adv | ( | const char * | task, |
xmlNode * | msg_data, | ||
const char * | host_to, | ||
const char * | sys_to, | ||
const char * | sys_from, | ||
const char * | uuid_from, | ||
const char * | origin | ||
) |
bool crm_ipc_connect | ( | crm_ipc_t * | client | ) |
Establish an IPC connection to a Pacemaker component.
[in] | client | Connection instance obtained from crm_ipc_new() |
int crm_ipc_is_authentic_process | ( | int | sock, |
uid_t | refuid, | ||
gid_t | refgid, | ||
pid_t * | gotpid, | ||
uid_t * | gotuid, | ||
gid_t * | gotgid | ||
) |
Check the authenticity of the IPC socket peer process.
If everything goes well, peer's authenticity is verified by the means of comparing against provided referential UID and GID (either satisfies), and the result of this check can be deduced from the return value. As an exception, detected UID of 0 ("root") satisfies arbitrary provided referential daemon's credentials.
[in] | sock | IPC related, connected Unix socket to check peer of |
[in] | refuid | referential UID to check against |
[in] | refgid | referential GID to check against |
[out] | gotpid | to optionally store obtained PID of the peer (not available on FreeBSD, special value of 1 used instead, and the caller is required to special case this value respectively) |
[out] | gotuid | to optionally store obtained UID of the peer |
[out] | gotgid | to optionally store obtained GID of the peer |
refuid
, or at least its group matches refgid
), either or both (in case of UID=0) mismatches on the expected credentials of such peer process shall be investigated at the caller when value of 1 gets returned there, since higher-than-expected privileges in respect to the expected/intended credentials possibly violate the least privilege principle and may pose an additional risk (i.e. such accidental inconsistency shall be eventually fixed). crm_ipc_t* crm_ipc_new | ( | const char * | name, |
size_t | max_size | ||
) |
int crm_ipc_ready | ( | crm_ipc_t * | client | ) |
int crm_ipc_send | ( | crm_ipc_t * | client, |
xmlNode * | message, | ||
enum crm_ipc_flags | flags, | ||
int32_t | ms_timeout, | ||
xmlNode ** | reply | ||
) |
Send an IPC XML message.
[in] | client | Connection to IPC server |
[in] | message | XML message to send |
[in] | flags | Bitmask of crm_ipc_flags |
[in] | ms_timeout | Give up if not sent within this much time (5 seconds if 0, or no timeout if negative) |
[out] | reply | Reply from server (or NULL if none) |
xmlNode* pcmk__client_data2xml | ( | pcmk__client_t * | c, |
void * | data, | ||
uint32_t * | id, | ||
uint32_t * | flags | ||
) |
const char* pcmk__client_name | ( | pcmk__client_t * | c | ) |
const char* pcmk__client_type_str | ( | enum pcmk__client_type | client_type | ) |
pcmk__client_t* pcmk__find_client | ( | qb_ipcs_connection_t * | c | ) |
pcmk__client_t* pcmk__find_client_by_id | ( | const char * | id | ) |
void pcmk__foreach_ipc_client | ( | GHFunc | func, |
gpointer | user_data | ||
) |
void pcmk__foreach_ipc_client_remove | ( | GHRFunc | func, |
gpointer | user_data | ||
) |
void pcmk__free_client | ( | pcmk__client_t * | c | ) |
int pcmk__ipc_is_authentic_process_active | ( | const char * | name, |
uid_t | refuid, | ||
gid_t | refgid, | ||
pid_t * | gotpid | ||
) |
int pcmk__ipc_prepare_iov | ( | uint32_t | request, |
xmlNode * | message, | ||
uint32_t | max_send_size, | ||
struct iovec ** | result, | ||
ssize_t * | bytes | ||
) |
void pcmk__ipc_send_ack_as | ( | const char * | function, |
int | line, | ||
pcmk__client_t * | c, | ||
uint32_t | request, | ||
uint32_t | flags, | ||
const char * | tag | ||
) |
int pcmk__ipc_send_iov | ( | pcmk__client_t * | c, |
struct iovec * | iov, | ||
uint32_t | flags | ||
) |
int pcmk__ipc_send_xml | ( | pcmk__client_t * | c, |
uint32_t | request, | ||
xmlNode * | message, | ||
uint32_t | flags | ||
) |
pcmk__client_t* pcmk__new_client | ( | qb_ipcs_connection_t * | c, |
uid_t | uid_client, | ||
gid_t | gid_client | ||
) |
pcmk__client_t* pcmk__new_unauth_client | ( | void * | key | ) |
void pcmk__serve_attrd_ipc | ( | qb_ipcs_service_t ** | ipcs, |
struct qb_ipcs_service_handlers * | cb | ||
) |
void pcmk__serve_based_ipc | ( | qb_ipcs_service_t ** | ipcs_ro, |
qb_ipcs_service_t ** | ipcs_rw, | ||
qb_ipcs_service_t ** | ipcs_shm, | ||
struct qb_ipcs_service_handlers * | ro_cb, | ||
struct qb_ipcs_service_handlers * | rw_cb | ||
) |
qb_ipcs_service_t* pcmk__serve_controld_ipc | ( | struct qb_ipcs_service_handlers * | cb | ) |
void pcmk__serve_fenced_ipc | ( | qb_ipcs_service_t ** | ipcs, |
struct qb_ipcs_service_handlers * | cb | ||
) |
bool pcmk__set_client_queue_max | ( | pcmk__client_t * | client, |
const char * | qmax | ||
) |
void pcmk__stop_based_ipc | ( | qb_ipcs_service_t * | ipcs_ro, |
qb_ipcs_service_t * | ipcs_rw, | ||
qb_ipcs_service_t * | ipcs_shm | ||
) |
void pcmk_free_ipc_event | ( | struct iovec * | event | ) |
Free an I/O vector created by pcmk__ipc_prepare_iov()
[in] | event | I/O vector to free |