This file is indexed.

/usr/include/pacemaker/crm/services.h is in libcrmcluster4-dev 1.1.10+git20130802-1ubuntu2.4.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
/*
 * Copyright (C) 2010 Andrew Beekhof <andrew@beekhof.net>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

/**
 * \file
 * \brief Services API
 * \ingroup core
 */

#ifndef __PCMK_SERVICES__
#  define __PCMK_SERVICES__

#  ifdef __cplusplus
extern "C" {
#  endif

#  include <glib.h>
#  include <stdio.h>

#  ifndef OCF_ROOT_DIR
#    define OCF_ROOT_DIR "/usr/lib/ocf"
#  endif

#  ifndef LSB_ROOT_DIR
#    define LSB_ROOT_DIR "/etc/init.d"
#  endif

/* TODO: Autodetect these two ?*/
#  ifndef SYSTEMCTL
#    define SYSTEMCTL "/bin/systemctl"
#  endif

#  ifndef SERVICE_SCRIPT
#    define SERVICE_SCRIPT "/sbin/service"
#  endif

/* *INDENT-OFF* */
enum lsb_exitcode {
    PCMK_LSB_OK                  = 0,
    PCMK_LSB_UNKNOWN_ERROR       = 1,
    PCMK_LSB_INVALID_PARAM       = 2,
    PCMK_LSB_UNIMPLEMENT_FEATURE = 3,
    PCMK_LSB_INSUFFICIENT_PRIV   = 4,
    PCMK_LSB_NOT_INSTALLED       = 5,
    PCMK_LSB_NOT_CONFIGURED      = 6,
    PCMK_LSB_NOT_RUNNING         = 7,

    /* 150-199	reserved for application use */
    PCMK_LSB_SIGNAL        = 194,
    PCMK_LSB_NOT_SUPPORTED = 195,
    PCMK_LSB_PENDING       = 196,
    PCMK_LSB_CANCELLED     = 197,
    PCMK_LSB_TIMEOUT       = 198,
    PCMK_LSB_OTHER_ERROR   = 199,
};

/* The return codes for the status operation are not the same for other
 * operatios - go figure */
enum lsb_status_exitcode {
    PCMK_LSB_STATUS_OK             = 0,
    PCMK_LSB_STATUS_VAR_PID        = 1,
    PCMK_LSB_STATUS_VAR_LOCK       = 2,
    PCMK_LSB_STATUS_NOT_RUNNING    = 3,
    PCMK_LSB_STATUS_NOT_INSTALLED  = 4,

    /* 150-199 reserved for application use */
    PCMK_LSB_STATUS_SIGNAL        = 194,
    PCMK_LSB_STATUS_NOT_SUPPORTED = 195,
    PCMK_LSB_STATUS_PENDING       = 196,
    PCMK_LSB_STATUS_CANCELLED     = 197,
    PCMK_LSB_STATUS_TIMEOUT       = 198,
    PCMK_LSB_STATUS_OTHER_ERROR   = 199,
};

enum ocf_exitcode {
    PCMK_OCF_OK                   = 0,
    PCMK_OCF_UNKNOWN_ERROR        = 1,
    PCMK_OCF_INVALID_PARAM        = 2,
    PCMK_OCF_UNIMPLEMENT_FEATURE  = 3,
    PCMK_OCF_INSUFFICIENT_PRIV    = 4,
    PCMK_OCF_NOT_INSTALLED        = 5,
    PCMK_OCF_NOT_CONFIGURED       = 6,
    PCMK_OCF_NOT_RUNNING          = 7,
    PCMK_OCF_RUNNING_MASTER       = 8,
    PCMK_OCF_FAILED_MASTER        = 9,

    /* 150-199	reserved for application use */
    PCMK_OCF_SIGNAL        = 194,
    PCMK_OCF_NOT_SUPPORTED = 195,
    PCMK_OCF_PENDING       = 196,
    PCMK_OCF_CANCELLED     = 197,
    PCMK_OCF_TIMEOUT       = 198,
    PCMK_OCF_OTHER_ERROR   = 199, /* Keep the same codes as PCMK_LSB */
};

enum op_status {
    PCMK_LRM_OP_PENDING = -1,
    PCMK_LRM_OP_DONE,
    PCMK_LRM_OP_CANCELLED,
    PCMK_LRM_OP_TIMEOUT,
    PCMK_LRM_OP_NOTSUPPORTED,
    PCMK_LRM_OP_ERROR
};

enum nagios_exitcode {
    NAGIOS_STATE_OK        = 0,
    NAGIOS_STATE_WARNING   = 1,
    NAGIOS_STATE_CRITICAL  = 2,
    NAGIOS_STATE_UNKNOWN   = 3,
    NAGIOS_STATE_DEPENDENT = 4,

    NAGIOS_INSUFFICIENT_PRIV = 100,
    NAGIOS_NOT_INSTALLED     = 101,
};
/* *INDENT-ON* */

    typedef struct svc_action_private_s svc_action_private_t;
    typedef struct svc_action_s {
        char *id;
        char *rsc;
        char *action;
        int interval;

        char *standard;
        char *provider;
        char *agent;

        int timeout;
        GHashTable *params;

        int rc;
        int pid;
        int cancel;
        int status;
        int sequence;
        int expected_rc;

        char *stderr_data;
        char *stdout_data;

    /**
     * Data stored by the creator of the action.
     *
     * This may be used to hold data that is needed later on by a callback,
     * for example.
     */
        void *cb_data;

        svc_action_private_t *opaque;

    } svc_action_t;

/**
 * Get a list of files or directories in a given path
 *
 * \param[in] root full path to a directory to read
 * \param[in] files true to get a list of files, false for a list of directories
 *
 * \return a list of what was found.  The list items are gchar *.  This list _must_
 *         be destroyed using g_list_free_full(list, free).
 */
    GList *get_directory_list(const char *root, gboolean files, gboolean executable);

/**
 * Get a list of services
 *
 * \return a list of services.  The list items are gchar *.  This list _must_
 *         be destroyed using g_list_free_full(list, free).
 */
    GList *services_list(void);

/**
 * Get a list of providers
 *
 * \param[in] the standard for providers to check for (such as "ocf")
 *
 * \return a list of providers.  The list items are gchar *.  This list _must_
 *         be destroyed using g_list_free_full(list, free).
 */
    GList *resources_list_providers(const char *standard);

/**
 * Get a list of resource agents
 *
 * \param[in] the standard for research agents to check for
 *            (such as "ocf", "lsb", or "windows")
 *
 * \return a list of resource agents.  The list items are gchar *.  This list _must_
 *         be destroyed using g_list_free_full(list, free).
 */
    GList *resources_list_agents(const char *standard, const char *provider);

/**
 * Get list of available standards
 *
 * \return a list of resource standards. The list items are char *. This list _must_
 *         be destroyed using g_list_free_full(list, free).
 */
    GList *resources_list_standards(void);

    svc_action_t *services_action_create(const char *name, const char *action,
                                         int interval /* ms */ , int timeout /* ms */ );

/**
 * Create a resources action.
 *
 * \param[in] timeout the timeout in milliseconds
 * \param[in] interval how often to repeat this action, in milliseconds.
 *            If this value is 0, only execute this action one time.
 *
 * \post After the call, 'params' is owned, and later free'd by the svc_action_t result
 */
    svc_action_t *resources_action_create(const char *name, const char *standard,
                                          const char *provider, const char *agent,
                                          const char *action, int interval /* ms */ ,
                                          int timeout /* ms */ , GHashTable * params);

/**
 * Kick a recurring action so it is scheduled immediately for re-execution
 */
    gboolean services_action_kick(const char *name, const char *action, int interval /* ms */);

/**
 * Utilize services API to execute an arbitrary command.
 *
 * This API has useful infrastructure in place to be able to run a command
 * in the background and get notified via a callback when the command finishes.
 *
 * \param[in] exec command to execute
 * \param[in] args arguments to the command, NULL terminated
 *
 * \return a svc_action_t object, used to pass to the execute function
 * (services_action_sync() or services_action_async()) and is
 * provided to the callback.
 */
    svc_action_t *services_action_create_generic(const char *exec, const char *args[]);

    void
     services_action_free(svc_action_t * op);

    gboolean services_action_sync(svc_action_t * op);

/**
 * Run an action asynchronously.
 *
 * \param[in] op services action data
 * \param[in] action_callback callback for when the action completes
 *
 * \retval TRUE succesfully started execution
 * \retval FALSE failed to start execution, no callback will be received
 */
    gboolean services_action_async(svc_action_t * op, void (*action_callback) (svc_action_t *));

    gboolean services_action_cancel(const char *name, const char *action, int interval);

    static inline const char *services_lrm_status_str(enum op_status status) {
        switch (status) {
            case PCMK_LRM_OP_PENDING:
                return "pending";
                case PCMK_LRM_OP_DONE:return "complete";
                case PCMK_LRM_OP_CANCELLED:return "Cancelled";
                case PCMK_LRM_OP_TIMEOUT:return "Timed Out";
                case PCMK_LRM_OP_NOTSUPPORTED:return "NOT SUPPORTED";
                case PCMK_LRM_OP_ERROR:return "Error";
                default:return "UNKNOWN!";
    }} static inline const char *services_ocf_exitcode_str(enum ocf_exitcode code) {
        switch (code) {
            case PCMK_OCF_OK:
                return "OCF_OK";
            case PCMK_OCF_UNKNOWN_ERROR:
                return "OCF_UNKNOWN_ERROR";
            case PCMK_OCF_INVALID_PARAM:
                return "OCF_INVALID_PARAM";
            case PCMK_OCF_UNIMPLEMENT_FEATURE:
                return "OCF_UNIMPLEMENT_FEATURE";
            case PCMK_OCF_INSUFFICIENT_PRIV:
                return "OCF_INSUFFICIENT_PRIV";
            case PCMK_OCF_NOT_INSTALLED:
                return "OCF_NOT_INSTALLED";
            case PCMK_OCF_NOT_CONFIGURED:
                return "OCF_NOT_CONFIGURED";
            case PCMK_OCF_NOT_RUNNING:
                return "OCF_NOT_RUNNING";
            case PCMK_OCF_RUNNING_MASTER:
                return "OCF_RUNNING_MASTER";
            case PCMK_OCF_FAILED_MASTER:
                return "OCF_FAILED_MASTER";
            case PCMK_OCF_SIGNAL:
                return "OCF_SIGNAL";
            case PCMK_OCF_NOT_SUPPORTED:
                return "OCF_NOT_SUPPORTED";
            case PCMK_OCF_PENDING:
                return "OCF_PENDING";
            case PCMK_OCF_CANCELLED:
                return "OCF_CANCELLED";
            case PCMK_OCF_TIMEOUT:
                return "OCF_TIMEOUT";
            case PCMK_OCF_OTHER_ERROR:
                return "OCF_OTHER_ERROR";
            default:
                return "unknown";
        }
    }

    static inline enum ocf_exitcode
     services_get_ocf_exitcode(char *action, int lsb_exitcode) {
        if (action != NULL && strcmp("status", action) == 0) {
            switch (lsb_exitcode) {
                case PCMK_LSB_STATUS_OK:
                    return PCMK_OCF_OK;
                case PCMK_LSB_STATUS_VAR_PID:
                    return PCMK_OCF_NOT_RUNNING;
                case PCMK_LSB_STATUS_VAR_LOCK:
                    return PCMK_OCF_NOT_RUNNING;
                case PCMK_LSB_STATUS_NOT_RUNNING:
                    return PCMK_OCF_NOT_RUNNING;
                case PCMK_LSB_STATUS_NOT_INSTALLED:
                    return PCMK_OCF_UNKNOWN_ERROR;
                default:
                    return PCMK_OCF_UNKNOWN_ERROR;
            }

        } else if (lsb_exitcode > PCMK_LSB_NOT_RUNNING) {
            return PCMK_OCF_UNKNOWN_ERROR;
        }

        /* For non-status operations, the PCMK_LSB and PCMK_OCF share error code meaning
         * for rc <= 7 */
        return (enum ocf_exitcode)lsb_exitcode;
    }

#  ifdef __cplusplus
}
#  endif

#endif                          /* __PCMK_SERVICES__ */