10 #ifndef CRM_COMMON_INTERNAL__H
11 #define CRM_COMMON_INTERNAL__H
16 #include <sys/types.h>
19 #include <libxml/tree.h>
27 const char *peer_user);
32 pcmk__is_privileged(
const char *user)
34 return user && (!strcmp(user,
CRM_DAEMON_USER) || !strcmp(user,
"root"));
39 #if SUPPORT_CIBSECRETS
56 int sequence,
bool bzip);
60 unsigned int sequence,
int max);
62 uid_t uid, gid_t gid);
85 pcmk__open_devnull(
int flags)
89 (void) open(
"/dev/null", flags);
95 # define pcmk__config_err(fmt...) do { \
96 crm_config_error = TRUE; \
100 # define pcmk__config_warn(fmt...) do { \
101 crm_config_warning = TRUE; \
140 const char *expected_name, pid_t *
pid);
147 #define PCMK__OP_FMT "%s_%s_%u"
149 char *
pcmk__op_key(
const char *rsc_id,
const char *op_type, guint interval_ms);
151 const char *op_type);
175 char **result,
unsigned int *result_len);
195 #define pcmk__plural_alt(i, s1, s2) (((i) == 1)? (s1) : (s2))
198 #define pcmk__plural_s(i) pcmk__plural_alt(i, "", "s")
201 pcmk__str_empty(
const char *s)
203 return (s == NULL) || (s[0] ==
'\0');
214 pcmk__list_of_1(GList *list)
216 return list && (list->next == NULL);
221 pcmk__list_of_multiple(GList *list)
223 return list && (list->next != NULL);
228 #define PCMK__FAIL_COUNT_PREFIX "fail-count"
229 #define PCMK__LAST_FAILURE_PREFIX "last-failure"
249 pcmk__fail_attr_name(
const char *prefix,
const char *rsc_id,
const char *op,
252 CRM_CHECK(prefix && rsc_id && op,
return NULL);
257 pcmk__failcount_name(
const char *rsc_id,
const char *op, guint interval_ms)
264 pcmk__lastfailure_name(
const char *rsc_id,
const char *op, guint interval_ms)
#define CRM_CHECK(expr, failure_action)
void crm_schema_init(void)
bool pcmk__ends_with_ext(const char *s, const char *match)
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__guint_from_hash(GHashTable *table, const char *key, guint default_val, guint *result)
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)
void pcmk__close_fds_in_child(bool)
void crm_schema_cleanup(void)
void pcmk__filter_op_for_digest(xmlNode *param_set)
char * pcmk__series_filename(const char *directory, const char *series, int sequence, bool bzip)
#define PCMK__LAST_FAILURE_PREFIX
int daemon(int nochdir, int noclose)
char * pcmk__notify_key(const char *rsc_id, const char *notify_type, const char *op_type)
const char * pcmk_message_name(const char *name)
Get name to be used as identifier for cluster messages.
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)
int pcmk__compress(const char *data, unsigned int length, unsigned int max, char **result, unsigned int *result_len)
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)
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)
int pcmk__lock_pidfile(const char *filename, const char *name)
bool pcmk__ends_with(const char *s, const char *match)
const char * pcmk__get_tmpdir(void)
char * pcmk__add_word(char *list, const char *word)
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)
bool pcmk__starts_with(const char *str, const char *prefix)
Check whether a string starts with a certain sequence.
char * pcmk__uid2username(uid_t uid)
char * crm_strdup_printf(char const *format,...) __attribute__((__format__(__printf__
int pcmk__build_path(const char *path_c, mode_t mode)
int pcmk__set_nonblocking(int fd)