10 #ifndef CRM_COMMON_INTERNAL__H 11 #define CRM_COMMON_INTERNAL__H 18 #include <sys/types.h> 21 #include <libxml/tree.h> 32 const char *peer_user);
37 pcmk__is_privileged(
const char *user)
39 return user && (!strcmp(user,
CRM_DAEMON_USER) || !strcmp(user,
"root"));
44 #if SUPPORT_CIBSECRETS 61 int sequence,
bool bzip);
65 unsigned int sequence,
int max);
67 uid_t uid, gid_t gid);
90 pcmk__open_devnull(
int flags)
94 (void) open(
"/dev/null",
flags);
107 # define pcmk__config_err(fmt...) do { \ 108 pcmk__config_error = true; \ 119 # define pcmk__config_warn(fmt...) do { \ 120 pcmk__config_warning = true; \ 138 # define pcmk__log_else(level, else_action) do { \ 139 static struct qb_log_callsite *trace_cs = NULL; \ 141 if (trace_cs == NULL) { \ 142 trace_cs = qb_log_callsite_get(__func__, __FILE__, "log_else", \ 143 level, __LINE__, 0); \ 145 if (!crm_is_callsite_active(trace_cs, level, 0)) { \ 197 const char *expected_name, pid_t *
pid);
204 #define PCMK__OP_FMT "%s_%s_%u" 206 char *
pcmk__op_key(
const char *rsc_id,
const char *op_type, guint interval_ms);
208 const char *op_type);
231 static inline uint64_t
232 pcmk__set_flags_as(
const char *
function,
int line, uint8_t log_level,
233 const char *flag_type,
const char *
target,
234 uint64_t flag_group, uint64_t
flags,
const char *flags_str)
236 uint64_t result = flag_group |
flags;
238 if (result != flag_group) {
240 "%s flags 0x%.8llx (%s) for %s set by %s:%d",
241 ((flag_type == NULL)?
"Group of" : flag_type),
242 (
unsigned long long)
flags,
243 ((flags_str == NULL)?
"flags" : flags_str),
265 static inline uint64_t
266 pcmk__clear_flags_as(
const char *
function,
int line, uint8_t log_level,
267 const char *flag_type,
const char *
target,
268 uint64_t flag_group, uint64_t
flags,
const char *flags_str)
270 uint64_t result = flag_group & ~
flags;
272 if (result != flag_group) {
274 "%s flags 0x%.8llx (%s) for %s cleared by %s:%d",
275 ((flag_type == NULL)?
"Group of" : flag_type),
276 (
unsigned long long)
flags,
277 ((flags_str == NULL)?
"flags" : flags_str),
307 pcmk__realloc(
void *ptr,
size_t size)
314 new_ptr = realloc(ptr,
size);
315 if (new_ptr == NULL) {
328 #define PCMK__RC_ERROR pcmk__rc_error_quark() 329 #define PCMK__EXITC_ERROR pcmk__exitc_error_quark() 339 pcmk__list_of_1(GList *list)
341 return list && (list->next == NULL);
346 pcmk__list_of_multiple(GList *list)
348 return list && (list->next != NULL);
353 #define PCMK__FAIL_COUNT_PREFIX "fail-count" 354 #define PCMK__LAST_FAILURE_PREFIX "last-failure" 374 pcmk__fail_attr_name(
const char *prefix,
const char *rsc_id,
const char *op,
377 CRM_CHECK(prefix && rsc_id && op,
return NULL);
382 pcmk__failcount_name(
const char *rsc_id,
const char *op, guint interval_ms)
389 pcmk__lastfailure_name(
const char *rsc_id,
const char *op, guint interval_ms)
#define CRM_CHECK(expr, failure_action)
const char * pcmk__message_name(const char *name)
Get name to be used as identifier for cluster messages.
void crm_schema_init(void)
int pcmk__read_pidfile(const char *filename, pid_t *pid)
int pcmk__read_series_sequence(const char *directory, const char *series, unsigned int *seq)
int pcmk__write_sync(int fd, const char *contents)
int pcmk__substitute_secrets(const char *rsc_id, GHashTable *params)
bool pcmk__verify_digest(xmlNode *input, const char *expected)
struct mainloop_io_s mainloop_io_t
void pcmk__close_fds_in_child(bool)
void crm_schema_cleanup(void)
void pcmk__filter_op_for_digest(xmlNode *param_set)
GQuark pcmk__exitc_error_quark(void)
char * pcmk__series_filename(const char *directory, const char *series, int sequence, bool bzip)
Wrappers for and extensions to glib mainloop.
#define PCMK__LAST_FAILURE_PREFIX
Wrappers for and extensions to libqb logging.
int pcmk__effective_rc(int rc)
#define do_crm_log_unlikely(level, fmt, args...)
Log a message that is likely to be filtered out.
int daemon(int nochdir, int noclose)
char * pcmk__notify_key(const char *rsc_id, const char *notify_type, const char *op_type)
struct crm_ipc_s crm_ipc_t
int pcmk__real_path(const char *path, char **resolved_path)
unsigned int pcmk__procfs_num_cores(void)
const char * pcmk__update_acl_user(xmlNode *request, const char *field, const char *peer_user)
bool pcmk__daemon_can_write(const char *dir, const char *file)
#define PCMK__FAIL_COUNT_PREFIX
int pcmk__pid_active(pid_t pid, const char *daemon)
int pcmk__file_contents(const char *filename, char **contents)
pid_t pcmk__locate_sbd(void)
char * pcmk__op_key(const char *rsc_id, const char *op_type, guint interval_ms)
Generate an operation key (RESOURCE_ACTION_INTERVAL)
void pcmk__write_series_sequence(const char *directory, const char *series, unsigned int sequence, int max)
pid_t pcmk__procfs_pid_of(const char *name)
void pcmk__daemonize(const char *name, const char *pidfile)
int pcmk__lock_pidfile(const char *filename, const char *name)
const char * pcmk__get_tmpdir(void)
int pcmk__pidfile_matches(const char *filename, pid_t expected_pid, const char *expected_name, pid_t *pid)
char * pcmk__transition_key(int transition_id, int action_id, int target_rc, const char *node)
int pcmk__chown_series_sequence(const char *directory, const char *series, uid_t uid, gid_t gid)
void pcmk__sync_directory(const char *name)
void pcmk__panic(const char *origin)
char * pcmk__uid2username(uid_t uid)
int pcmk__add_mainloop_ipc(crm_ipc_t *ipc, int priority, void *userdata, struct ipc_client_callbacks *callbacks, mainloop_io_t **source)
Connect to IPC and add it as a main loop source.
char * crm_strdup_printf(char const *format,...) __attribute__((__format__(__printf__
GQuark pcmk__rc_error_quark(void)
int pcmk__build_path(const char *path_c, mode_t mode)
int pcmk__set_nonblocking(int fd)