pacemaker  1.1.24-3850484742
Scalable High-Availability cluster resource manager
Macros | Functions | Variables
ipc.c File Reference
#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.h>
#include <crm/common/ipc_internal.h>
Include dependency graph for ipc.c:

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)
 
crm_client_tcrm_client_get (qb_ipcs_connection_t *c)
 
crm_client_tcrm_client_get_by_id (const char *id)
 
const char * crm_client_name (crm_client_t *c)
 
void crm_client_init (void)
 
void crm_client_cleanup (void)
 
void crm_client_disconnect_all (qb_ipcs_service_t *service)
 
crm_client_tcrm_client_alloc (void *key)
 Allocate a new crm_client_t object and generate its ID. More...
 
crm_client_tcrm_client_new (qb_ipcs_connection_t *c, uid_t uid_client, gid_t gid_client)
 
void crm_client_destroy (crm_client_t *c)
 
bool crm_set_client_queue_max (crm_client_t *client, const char *qmax)
 Raise IPC eviction threshold for a client, if allowed. More...
 
int crm_ipcs_client_pid (qb_ipcs_connection_t *c)
 
xmlNode * crm_ipcs_recv (crm_client_t *c, void *data, size_t size, uint32_t *id, uint32_t *flags)
 
ssize_t crm_ipcs_flush_events (crm_client_t *c)
 
ssize_t crm_ipc_prepare (uint32_t request, xmlNode *message, struct iovec **result, uint32_t max_send_size)
 
ssize_t crm_ipcs_sendv (crm_client_t *c, struct iovec *iov, enum crm_ipc_flags flags)
 
ssize_t crm_ipcs_send (crm_client_t *c, uint32_t request, xmlNode *message, enum crm_ipc_flags flags)
 
void crm_ipcs_send_ack (crm_client_t *c, uint32_t request, uint32_t flags, const char *tag, const char *function, int line)
 
crm_ipc_tcrm_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)
 
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)
 

Variables

GHashTable * client_connections = NULL
 

Macro Definition Documentation

◆ MAX_MSG_SIZE

#define MAX_MSG_SIZE   128*1024 /* 128k default */

Definition at line 853 of file ipc.c.

◆ MIN_MSG_SIZE

#define MIN_MSG_SIZE   12336 /* sizeof(struct qb_ipc_connection_response) */

Definition at line 852 of file ipc.c.

◆ PCMK_IPC_DEFAULT_QUEUE_MAX

#define PCMK_IPC_DEFAULT_QUEUE_MAX   500

Definition at line 45 of file ipc.c.

◆ PCMK_IPC_VERSION

#define PCMK_IPC_VERSION   1

Definition at line 42 of file ipc.c.

Function Documentation

◆ create_hello_message()

xmlNode* create_hello_message ( const char *  uuid,
const char *  client_name,
const char *  major_version,
const char *  minor_version 
)

Definition at line 1550 of file ipc.c.

◆ create_reply_adv()

xmlNode* create_reply_adv ( xmlNode *  original_request,
xmlNode *  xml_response_data,
const char *  origin 
)

Definition at line 154 of file ipc.c.

◆ create_request_adv()

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 
)

Definition at line 109 of file ipc.c.

◆ crm_client_alloc()

crm_client_t* crm_client_alloc ( void *  key)

Allocate a new crm_client_t object and generate its ID.

Parameters
[in]keyWhat to use as connections hash table key (NULL to use ID)
Returns
Pointer to new crm_client_t (asserts on failure)

Definition at line 360 of file ipc.c.

◆ crm_client_cleanup()

void crm_client_cleanup ( void  )

Definition at line 265 of file ipc.c.

◆ crm_client_destroy()

void crm_client_destroy ( crm_client_t c)

Definition at line 415 of file ipc.c.

◆ crm_client_disconnect_all()

void crm_client_disconnect_all ( qb_ipcs_service_t *  service)

Definition at line 278 of file ipc.c.

◆ crm_client_get()

crm_client_t* crm_client_get ( qb_ipcs_connection_t *  c)

Definition at line 211 of file ipc.c.

◆ crm_client_get_by_id()

crm_client_t* crm_client_get_by_id ( const char *  id)

Definition at line 222 of file ipc.c.

◆ crm_client_init()

void crm_client_init ( void  )

Definition at line 256 of file ipc.c.

◆ crm_client_name()

const char* crm_client_name ( crm_client_t c)

Definition at line 242 of file ipc.c.

◆ crm_client_new()

crm_client_t* crm_client_new ( qb_ipcs_connection_t *  c,
uid_t  uid_client,
gid_t  gid_client 
)

Definition at line 369 of file ipc.c.

◆ crm_ipc_buffer()

const char* crm_ipc_buffer ( crm_ipc_t client)

Definition at line 1185 of file ipc.c.

◆ crm_ipc_buffer_flags()

uint32_t crm_ipc_buffer_flags ( crm_ipc_t client)

Definition at line 1192 of file ipc.c.

◆ crm_ipc_close()

void crm_ipc_close ( crm_ipc_t client)

Definition at line 992 of file ipc.c.

◆ crm_ipc_connect()

bool crm_ipc_connect ( crm_ipc_t client)

Establish an IPC connection to a Pacemaker component.

Parameters
[in]clientConnection instance obtained from crm_ipc_new()
Returns
TRUE on success, FALSE otherwise (in which case errno will be set; specifically, in case of discovering the remote side is not authentic, its value is set to ECONNABORTED).

Definition at line 924 of file ipc.c.

◆ crm_ipc_connected()

bool crm_ipc_connected ( crm_ipc_t client)

Definition at line 1044 of file ipc.c.

◆ crm_ipc_default_buffer_size()

unsigned int crm_ipc_default_buffer_size ( void  )

Definition at line 71 of file ipc.c.

◆ crm_ipc_destroy()

void crm_ipc_destroy ( crm_ipc_t client)

Definition at line 1007 of file ipc.c.

◆ crm_ipc_get_fd()

int crm_ipc_get_fd ( crm_ipc_t client)

Definition at line 1030 of file ipc.c.

◆ crm_ipc_is_authentic_process()

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.

Parameters
[in]sockIPC related, connected Unix socket to check peer of
[in]refuidreferential UID to check against
[in]refgidreferential GID to check against
[out]gotpidto 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]gotuidto optionally store obtained UID of the peer
[out]gotgidto optionally store obtained GID of the peer
Returns
0 if IPC related socket's peer is not authentic given the referential credentials (see above), 1 if it is, negative value on error (generally expressing -errno unless it was zero even on nonhappy path, -pcmk_err_generic is returned then; no message is directly emitted)
Note
While this function is tolerant on what constitutes authorized IPC daemon process (its effective user matches UID=0 or refuid, or at least its group matches refroup), 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).

Definition at line 1422 of file ipc.c.

◆ crm_ipc_name()

const char* crm_ipc_name ( crm_ipc_t client)

Definition at line 1206 of file ipc.c.

◆ crm_ipc_new()

crm_ipc_t* crm_ipc_new ( const char *  name,
size_t  max_size 
)

Definition at line 894 of file ipc.c.

◆ crm_ipc_prepare()

ssize_t crm_ipc_prepare ( uint32_t  request,
xmlNode *  message,
struct iovec **  result,
uint32_t  max_send_size 
)

Definition at line 658 of file ipc.c.

◆ crm_ipc_read()

long crm_ipc_read ( crm_ipc_t client)

Definition at line 1138 of file ipc.c.

◆ crm_ipc_ready()

int crm_ipc_ready ( crm_ipc_t client)

Check whether an IPC connection is ready to be read.

Parameters
[in]clientConnection to check
Returns
Positive value if ready to be read, 0 if not ready, -errno on error

Definition at line 1076 of file ipc.c.

◆ crm_ipc_send()

int crm_ipc_send ( crm_ipc_t client,
xmlNode *  message,
enum crm_ipc_flags  flags,
int32_t  ms_timeout,
xmlNode **  reply 
)

Definition at line 1288 of file ipc.c.

◆ crm_ipcs_client_pid()

int crm_ipcs_client_pid ( qb_ipcs_connection_t *  c)

Definition at line 484 of file ipc.c.

◆ crm_ipcs_flush_events()

ssize_t crm_ipcs_flush_events ( crm_client_t c)

Definition at line 577 of file ipc.c.

◆ crm_ipcs_recv()

xmlNode* crm_ipcs_recv ( crm_client_t c,
void *  data,
size_t  size,
uint32_t id,
uint32_t flags 
)

Definition at line 494 of file ipc.c.

◆ crm_ipcs_send()

ssize_t crm_ipcs_send ( crm_client_t c,
uint32_t  request,
xmlNode *  message,
enum crm_ipc_flags  flags 
)

Definition at line 810 of file ipc.c.

◆ crm_ipcs_send_ack()

void crm_ipcs_send_ack ( crm_client_t c,
uint32_t  request,
uint32_t  flags,
const char *  tag,
const char *  function,
int  line 
)

Definition at line 835 of file ipc.c.

◆ crm_ipcs_sendv()

ssize_t crm_ipcs_sendv ( crm_client_t c,
struct iovec *  iov,
enum crm_ipc_flags  flags 
)

Definition at line 737 of file ipc.c.

◆ crm_set_client_queue_max()

bool crm_set_client_queue_max ( crm_client_t client,
const char *  qmax 
)

Raise IPC eviction threshold for a client, if allowed.

Parameters
[in,out]clientClient to modify
[in]queue_maxNew threshold (as string)
Returns
TRUE if change was allowed, FALSE otherwise

Definition at line 470 of file ipc.c.

◆ pcmk__ipc_is_authentic_process_active()

int pcmk__ipc_is_authentic_process_active ( const char *  name,
uid_t  refuid,
gid_t  refgid,
pid_t *  gotpid 
)

Definition at line 1484 of file ipc.c.

Variable Documentation

◆ client_connections

GHashTable* client_connections = NULL

Definition at line 208 of file ipc.c.