pacemaker  1.1.19-c3c624ea3d
Scalable High-Availability cluster resource manager
systemd.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2016 Andrew Beekhof <andrew@beekhof.net>
3  *
4  * This source code is licensed under the GNU Lesser General Public License
5  * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
6  */
7 
8 #include <crm_internal.h>
9 #include <crm/crm.h>
10 #include <crm/services.h>
11 #include <crm/common/mainloop.h>
12 
13 #include <sys/stat.h>
14 #include <gio/gio.h>
15 #include <services_private.h>
16 #include <systemd.h>
17 #include <dbus/dbus.h>
18 #include <pcmk-dbus.h>
19 
20 gboolean systemd_unit_exec_with_unit(svc_action_t * op, const char *unit);
21 
22 #define BUS_NAME "org.freedesktop.systemd1"
23 #define BUS_NAME_MANAGER BUS_NAME ".Manager"
24 #define BUS_NAME_UNIT BUS_NAME ".Unit"
25 #define BUS_PATH "/org/freedesktop/systemd1"
26 
27 static inline DBusMessage *
28 systemd_new_method(const char *method)
29 {
30  crm_trace("Calling: %s on " BUS_NAME_MANAGER, method);
31  return dbus_message_new_method_call(BUS_NAME, BUS_PATH, BUS_NAME_MANAGER,
32  method);
33 }
34 
35 /*
36  * Functions to manage a static DBus connection
37  */
38 
39 static DBusConnection* systemd_proxy = NULL;
40 
41 static inline DBusPendingCall *
42 systemd_send(DBusMessage *msg,
43  void(*done)(DBusPendingCall *pending, void *user_data),
44  void *user_data, int timeout)
45 {
46  return pcmk_dbus_send(msg, systemd_proxy, done, user_data, timeout);
47 }
48 
49 static inline DBusMessage *
50 systemd_send_recv(DBusMessage *msg, DBusError *error, int timeout)
51 {
52  return pcmk_dbus_send_recv(msg, systemd_proxy, error, timeout);
53 }
54 
66 static DBusMessage *
67 systemd_call_simple_method(const char *method)
68 {
69  DBusMessage *msg = systemd_new_method(method);
70  DBusMessage *reply = NULL;
71  DBusError error;
72 
73  /* Don't call systemd_init() here, because that calls this */
74  CRM_CHECK(systemd_proxy, return NULL);
75 
76  if (msg == NULL) {
77  crm_err("Could not create message to send %s to systemd", method);
78  return NULL;
79  }
80 
81  dbus_error_init(&error);
82  reply = systemd_send_recv(msg, &error, DBUS_TIMEOUT_USE_DEFAULT);
83  dbus_message_unref(msg);
84 
85  if (dbus_error_is_set(&error)) {
86  crm_err("Could not send %s to systemd: %s (%s)",
87  method, error.message, error.name);
88  dbus_error_free(&error);
89  return NULL;
90 
91  } else if (reply == NULL) {
92  crm_err("Could not send %s to systemd: no reply received", method);
93  return NULL;
94  }
95 
96  return reply;
97 }
98 
99 static gboolean
100 systemd_init(void)
101 {
102  static int need_init = 1;
103  /* http://dbus.freedesktop.org/doc/api/html/group__DBusConnection.html */
104 
105  if (systemd_proxy
106  && dbus_connection_get_is_connected(systemd_proxy) == FALSE) {
107  crm_warn("Connection to System DBus is closed. Reconnecting...");
108  pcmk_dbus_disconnect(systemd_proxy);
109  systemd_proxy = NULL;
110  need_init = 1;
111  }
112 
113  if (need_init) {
114  need_init = 0;
115  systemd_proxy = pcmk_dbus_connect();
116  }
117  if (systemd_proxy == NULL) {
118  return FALSE;
119  }
120  return TRUE;
121 }
122 
123 static inline char *
124 systemd_get_property(const char *unit, const char *name,
125  void (*callback)(const char *name, const char *value, void *userdata),
126  void *userdata, DBusPendingCall **pending, int timeout)
127 {
128  return systemd_proxy?
129  pcmk_dbus_get_property(systemd_proxy, BUS_NAME, unit, BUS_NAME_UNIT,
130  name, callback, userdata, pending, timeout)
131  : NULL;
132 }
133 
134 void
136 {
137  if (systemd_proxy) {
138  pcmk_dbus_disconnect(systemd_proxy);
139  systemd_proxy = NULL;
140  }
141 }
142 
143 /*
144  * end of systemd_proxy functions
145  */
146 
155 static const char *
156 systemd_unit_extension(const char *name)
157 {
158  if (name) {
159  const char *dot = strrchr(name, '.');
160 
161  if (dot && (!strcmp(dot, ".service")
162  || !strcmp(dot, ".socket")
163  || !strcmp(dot, ".mount")
164  || !strcmp(dot, ".timer")
165  || !strcmp(dot, ".path"))) {
166  return dot;
167  }
168  }
169  return NULL;
170 }
171 
172 static char *
173 systemd_service_name(const char *name)
174 {
175  if (name == NULL) {
176  return NULL;
177  }
178 
179  if (systemd_unit_extension(name)) {
180  return strdup(name);
181  }
182 
183  return crm_strdup_printf("%s.service", name);
184 }
185 
186 static void
187 systemd_daemon_reload_complete(DBusPendingCall *pending, void *user_data)
188 {
189  DBusError error;
190  DBusMessage *reply = NULL;
191  unsigned int reload_count = GPOINTER_TO_UINT(user_data);
192 
193  dbus_error_init(&error);
194  if(pending) {
195  reply = dbus_pending_call_steal_reply(pending);
196  }
197 
198  if (pcmk_dbus_find_error(pending, reply, &error)) {
199  crm_err("Could not issue systemd reload %d: %s", reload_count, error.message);
200  dbus_error_free(&error);
201 
202  } else {
203  crm_trace("Reload %d complete", reload_count);
204  }
205 
206  if(pending) {
207  dbus_pending_call_unref(pending);
208  }
209  if(reply) {
210  dbus_message_unref(reply);
211  }
212 }
213 
214 static bool
215 systemd_daemon_reload(int timeout)
216 {
217  static unsigned int reload_count = 0;
218  DBusMessage *msg = systemd_new_method("Reload");
219 
220  reload_count++;
221  CRM_ASSERT(msg != NULL);
222  systemd_send(msg, systemd_daemon_reload_complete,
223  GUINT_TO_POINTER(reload_count), timeout);
224  dbus_message_unref(msg);
225 
226  return TRUE;
227 }
228 
229 static bool
230 systemd_mask_error(svc_action_t *op, const char *error)
231 {
232  crm_trace("Could not issue %s for %s: %s", op->action, op->rsc, error);
233  if(strstr(error, "org.freedesktop.systemd1.InvalidName")
234  || strstr(error, "org.freedesktop.systemd1.LoadFailed")
235  || strstr(error, "org.freedesktop.systemd1.NoSuchUnit")) {
236 
237  if (safe_str_eq(op->action, "stop")) {
238  crm_trace("Masking %s failure for %s: unknown services are stopped", op->action, op->rsc);
239  op->rc = PCMK_OCF_OK;
240  return TRUE;
241 
242  } else {
243  crm_trace("Mapping %s failure for %s: unknown services are not installed", op->action, op->rsc);
246  return FALSE;
247  }
248  }
249 
250  return FALSE;
251 }
252 
253 static const char *
254 systemd_loadunit_result(DBusMessage *reply, svc_action_t * op)
255 {
256  const char *path = NULL;
257  DBusError error;
258 
259  if (pcmk_dbus_find_error((void*)&path, reply, &error)) {
260  if(op && !systemd_mask_error(op, error.name)) {
261  crm_err("Could not load systemd unit %s for %s: %s",
262  op->agent, op->id, error.message);
263  }
264  dbus_error_free(&error);
265 
266  } else if(pcmk_dbus_type_check(reply, NULL, DBUS_TYPE_OBJECT_PATH, __FUNCTION__, __LINE__)) {
267  dbus_message_get_args (reply, NULL,
268  DBUS_TYPE_OBJECT_PATH, &path,
269  DBUS_TYPE_INVALID);
270  }
271 
272  if(op) {
273  if (path) {
274  systemd_unit_exec_with_unit(op, path);
275 
276  } else if (op->synchronous == FALSE) {
277  operation_finalize(op);
278  }
279  }
280 
281  return path;
282 }
283 
284 
285 static void
286 systemd_loadunit_cb(DBusPendingCall *pending, void *user_data)
287 {
288  DBusMessage *reply = NULL;
289  svc_action_t * op = user_data;
290 
291  if(pending) {
292  reply = dbus_pending_call_steal_reply(pending);
293  }
294 
295  crm_trace("Got result: %p for %p / %p for %s", reply, pending, op->opaque->pending, op->id);
296 
297  CRM_LOG_ASSERT(pending == op->opaque->pending);
298  services_set_op_pending(op, NULL);
299 
300  systemd_loadunit_result(reply, user_data);
301 
302  if(reply) {
303  dbus_message_unref(reply);
304  }
305 }
306 
307 static char *
308 systemd_unit_by_name(const gchar * arg_name, svc_action_t *op)
309 {
310  DBusMessage *msg;
311  DBusMessage *reply = NULL;
312  DBusPendingCall* pending = NULL;
313  char *name = NULL;
314 
315 /*
316  Equivalent to GetUnit if it's already loaded
317  <method name="LoadUnit">
318  <arg name="name" type="s" direction="in"/>
319  <arg name="unit" type="o" direction="out"/>
320  </method>
321  */
322 
323  if (systemd_init() == FALSE) {
324  return FALSE;
325  }
326 
327  msg = systemd_new_method("LoadUnit");
328  CRM_ASSERT(msg != NULL);
329 
330  name = systemd_service_name(arg_name);
331  CRM_LOG_ASSERT(dbus_message_append_args(msg, DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID));
332  free(name);
333 
334  if(op == NULL || op->synchronous) {
335  const char *unit = NULL;
336  char *munit = NULL;
337 
338  reply = systemd_send_recv(msg, NULL,
339  (op? op->timeout : DBUS_TIMEOUT_USE_DEFAULT));
340  dbus_message_unref(msg);
341 
342  unit = systemd_loadunit_result(reply, op);
343  if(unit) {
344  munit = strdup(unit);
345  }
346  if(reply) {
347  dbus_message_unref(reply);
348  }
349  return munit;
350  }
351 
352  pending = systemd_send(msg, systemd_loadunit_cb, op, op->timeout);
353  if(pending) {
354  services_set_op_pending(op, pending);
355  }
356 
357  dbus_message_unref(msg);
358  return NULL;
359 }
360 
361 GList *
363 {
364  int nfiles = 0;
365  GList *units = NULL;
366  DBusMessageIter args;
367  DBusMessageIter unit;
368  DBusMessageIter elem;
369  DBusMessage *reply = NULL;
370 
371  if (systemd_init() == FALSE) {
372  return NULL;
373  }
374 
375 /*
376  " <method name=\"ListUnitFiles\">\n" \
377  " <arg name=\"files\" type=\"a(ss)\" direction=\"out\"/>\n" \
378  " </method>\n" \
379 */
380 
381  reply = systemd_call_simple_method("ListUnitFiles");
382  if (reply == NULL) {
383  return NULL;
384  }
385  if (!dbus_message_iter_init(reply, &args)) {
386  crm_err("Could not list systemd unit files: systemd reply has no arguments");
387  dbus_message_unref(reply);
388  return NULL;
389  }
390  if (!pcmk_dbus_type_check(reply, &args, DBUS_TYPE_ARRAY,
391  __FUNCTION__, __LINE__)) {
392  crm_err("Could not list systemd unit files: systemd reply has invalid arguments");
393  dbus_message_unref(reply);
394  return NULL;
395  }
396 
397  dbus_message_iter_recurse(&args, &unit);
398  for (; dbus_message_iter_get_arg_type(&unit) != DBUS_TYPE_INVALID;
399  dbus_message_iter_next(&unit)) {
400 
401  DBusBasicValue value;
402  const char *match = NULL;
403  char *unit_name = NULL;
404  char *basename = NULL;
405 
406  if(!pcmk_dbus_type_check(reply, &unit, DBUS_TYPE_STRUCT, __FUNCTION__, __LINE__)) {
407  crm_debug("ListUnitFiles reply has unexpected type");
408  continue;
409  }
410 
411  dbus_message_iter_recurse(&unit, &elem);
412  if(!pcmk_dbus_type_check(reply, &elem, DBUS_TYPE_STRING, __FUNCTION__, __LINE__)) {
413  crm_debug("ListUnitFiles reply does not contain a string");
414  continue;
415  }
416 
417  dbus_message_iter_get_basic(&elem, &value);
418  if (value.str == NULL) {
419  crm_debug("ListUnitFiles reply did not provide a string");
420  continue;
421  }
422  crm_trace("DBus ListUnitFiles listed: %s", value.str);
423 
424  match = systemd_unit_extension(value.str);
425  if (match == NULL) {
426  // This is not a unit file type we know how to manage
427  crm_debug("ListUnitFiles entry '%s' is not supported as resource",
428  value.str);
429  continue;
430  }
431 
432  // ListUnitFiles returns full path names, we just want base name
433  basename = strrchr(value.str, '/');
434  if (basename) {
435  basename = basename + 1;
436  } else {
437  basename = value.str;
438  }
439 
440  if (!strcmp(match, ".service")) {
441  // Service is the "default" unit type, so strip it
442  unit_name = strndup(basename, match - basename);
443  } else {
444  unit_name = strdup(basename);
445  }
446 
447  nfiles++;
448  units = g_list_prepend(units, unit_name);
449  }
450 
451  dbus_message_unref(reply);
452 
453  crm_trace("Found %d manageable systemd unit files", nfiles);
454  units = g_list_sort(units, crm_alpha_sort);
455  return units;
456 }
457 
458 gboolean
459 systemd_unit_exists(const char *name)
460 {
461  char *unit = NULL;
462 
463  /* Note: Makes a blocking dbus calls
464  * Used by resources_find_service_class() when resource class=service
465  */
466  unit = systemd_unit_by_name(name, NULL);
467  if(unit) {
468  free(unit);
469  return TRUE;
470  }
471  return FALSE;
472 }
473 
474 static char *
475 systemd_unit_metadata(const char *name, int timeout)
476 {
477  char *meta = NULL;
478  char *desc = NULL;
479  char *path = systemd_unit_by_name(name, NULL);
480 
481  if (path) {
482  /* TODO: Worth a making blocking call for? Probably not. Possibly if cached. */
483  desc = systemd_get_property(path, "Description", NULL, NULL, NULL,
484  timeout);
485  } else {
486  desc = crm_strdup_printf("Systemd unit file for %s", name);
487  }
488 
489  meta = crm_strdup_printf("<?xml version=\"1.0\"?>\n"
490  "<!DOCTYPE resource-agent SYSTEM \"ra-api-1.dtd\">\n"
491  "<resource-agent name=\"%s\" version=\"" PCMK_DEFAULT_AGENT_VERSION "\">\n"
492  " <version>1.0</version>\n"
493  " <longdesc lang=\"en\">\n"
494  " %s\n"
495  " </longdesc>\n"
496  " <shortdesc lang=\"en\">systemd unit file for %s</shortdesc>\n"
497  " <parameters>\n"
498  " </parameters>\n"
499  " <actions>\n"
500  " <action name=\"start\" timeout=\"100\" />\n"
501  " <action name=\"stop\" timeout=\"100\" />\n"
502  " <action name=\"status\" timeout=\"100\" />\n"
503  " <action name=\"monitor\" timeout=\"100\" interval=\"60\"/>\n"
504  " <action name=\"meta-data\" timeout=\"5\" />\n"
505  " </actions>\n"
506  " <special tag=\"systemd\">\n"
507  " </special>\n" "</resource-agent>\n", name, desc, name);
508  free(desc);
509  free(path);
510  return meta;
511 }
512 
513 static void
514 systemd_exec_result(DBusMessage *reply, svc_action_t *op)
515 {
516  DBusError error;
517 
518  if (pcmk_dbus_find_error((void*)&error, reply, &error)) {
519 
520  /* ignore "already started" or "not running" errors */
521  if (!systemd_mask_error(op, error.name)) {
522  crm_err("Could not issue %s for %s: %s", op->action, op->rsc, error.message);
523  }
524  dbus_error_free(&error);
525 
526  } else {
527  if(!pcmk_dbus_type_check(reply, NULL, DBUS_TYPE_OBJECT_PATH, __FUNCTION__, __LINE__)) {
528  crm_warn("Call to %s passed but return type was unexpected", op->action);
529  op->rc = PCMK_OCF_OK;
530 
531  } else {
532  const char *path = NULL;
533 
534  dbus_message_get_args (reply, NULL,
535  DBUS_TYPE_OBJECT_PATH, &path,
536  DBUS_TYPE_INVALID);
537  crm_info("Call to %s passed: %s", op->action, path);
538  op->rc = PCMK_OCF_OK;
539  }
540  }
541 
542  operation_finalize(op);
543 }
544 
545 static void
546 systemd_async_dispatch(DBusPendingCall *pending, void *user_data)
547 {
548  DBusMessage *reply = NULL;
549  svc_action_t *op = user_data;
550 
551  if(pending) {
552  reply = dbus_pending_call_steal_reply(pending);
553  }
554 
555  crm_trace("Got result: %p for %p for %s, %s", reply, pending, op->rsc, op->action);
556 
557  CRM_LOG_ASSERT(pending == op->opaque->pending);
558  services_set_op_pending(op, NULL);
559  systemd_exec_result(reply, op);
560 
561  if(reply) {
562  dbus_message_unref(reply);
563  }
564 }
565 
566 #define SYSTEMD_OVERRIDE_ROOT "/run/systemd/system/"
567 
568 static void
569 systemd_unit_check(const char *name, const char *state, void *userdata)
570 {
571  svc_action_t * op = userdata;
572 
573  crm_trace("Resource %s has %s='%s'", op->rsc, name, state);
574 
575  if(state == NULL) {
576  op->rc = PCMK_OCF_NOT_RUNNING;
577 
578  } else if (g_strcmp0(state, "active") == 0) {
579  op->rc = PCMK_OCF_OK;
580  } else if (g_strcmp0(state, "reloading") == 0) {
581  op->rc = PCMK_OCF_OK;
582  } else if (g_strcmp0(state, "activating") == 0) {
583  op->rc = PCMK_OCF_PENDING;
584  } else if (g_strcmp0(state, "deactivating") == 0) {
585  op->rc = PCMK_OCF_PENDING;
586  } else {
587  op->rc = PCMK_OCF_NOT_RUNNING;
588  }
589 
590  if (op->synchronous == FALSE) {
591  services_set_op_pending(op, NULL);
592  operation_finalize(op);
593  }
594 }
595 
596 gboolean
598 {
599  const char *method = op->action;
600  DBusMessage *msg = NULL;
601  DBusMessage *reply = NULL;
602 
603  CRM_ASSERT(unit);
604 
605  if (safe_str_eq(op->action, "monitor") || safe_str_eq(method, "status")) {
606  DBusPendingCall *pending = NULL;
607  char *state;
608 
609  state = systemd_get_property(unit, "ActiveState",
610  (op->synchronous? NULL : systemd_unit_check),
611  op, (op->synchronous? NULL : &pending),
612  op->timeout);
613  if (op->synchronous) {
614  systemd_unit_check("ActiveState", state, op);
615  free(state);
616  return op->rc == PCMK_OCF_OK;
617  } else if (pending) {
618  services_set_op_pending(op, pending);
619  return TRUE;
620 
621  } else {
622  return operation_finalize(op);
623  }
624 
625  } else if (g_strcmp0(method, "start") == 0) {
626  FILE *file_strm = NULL;
627  char *override_dir = crm_strdup_printf("%s/%s.service.d", SYSTEMD_OVERRIDE_ROOT, op->agent);
628  char *override_file = crm_strdup_printf("%s/%s.service.d/50-pacemaker.conf", SYSTEMD_OVERRIDE_ROOT, op->agent);
629  mode_t orig_umask;
630 
631  method = "StartUnit";
632  crm_build_path(override_dir, 0755);
633 
634  /* Ensure the override file is world-readable. This is not strictly
635  * necessary, but it avoids a systemd warning in the logs.
636  */
637  orig_umask = umask(S_IWGRP | S_IWOTH);
638  file_strm = fopen(override_file, "w");
639  umask(orig_umask);
640 
641  if (file_strm != NULL) {
642  /* TODO: Insert the start timeout in too */
643  char *override = crm_strdup_printf(
644  "[Unit]\n"
645  "Description=Cluster Controlled %s\n"
646  "Before=pacemaker.service\n"
647  "\n"
648  "[Service]\n"
649  "Restart=no\n",
650  op->agent);
651 
652  int rc = fprintf(file_strm, "%s\n", override);
653 
654  free(override);
655  if (rc < 0) {
656  crm_perror(LOG_ERR, "Cannot write to systemd override file %s", override_file);
657  }
658 
659  } else {
660  crm_err("Cannot open systemd override file %s for writing", override_file);
661  }
662 
663  if (file_strm != NULL) {
664  fflush(file_strm);
665  fclose(file_strm);
666  }
667  systemd_daemon_reload(op->timeout);
668  free(override_file);
669  free(override_dir);
670 
671  } else if (g_strcmp0(method, "stop") == 0) {
672  char *override_file = crm_strdup_printf("%s/%s.service.d/50-pacemaker.conf", SYSTEMD_OVERRIDE_ROOT, op->agent);
673 
674  method = "StopUnit";
675  unlink(override_file);
676  free(override_file);
677  systemd_daemon_reload(op->timeout);
678 
679  } else if (g_strcmp0(method, "restart") == 0) {
680  method = "RestartUnit";
681 
682  } else {
684  goto cleanup;
685  }
686 
687  crm_debug("Calling %s for %s: %s", method, op->rsc, unit);
688 
689  msg = systemd_new_method(method);
690  CRM_ASSERT(msg != NULL);
691 
692  /* (ss) */
693  {
694  const char *replace_s = "replace";
695  char *name = systemd_service_name(op->agent);
696 
697  CRM_LOG_ASSERT(dbus_message_append_args(msg, DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID));
698  CRM_LOG_ASSERT(dbus_message_append_args(msg, DBUS_TYPE_STRING, &replace_s, DBUS_TYPE_INVALID));
699 
700  free(name);
701  }
702 
703  if (op->synchronous == FALSE) {
704  DBusPendingCall *pending = systemd_send(msg, systemd_async_dispatch,
705  op, op->timeout);
706 
707  dbus_message_unref(msg);
708  if(pending) {
709  services_set_op_pending(op, pending);
710  return TRUE;
711 
712  } else {
713  return operation_finalize(op);
714  }
715 
716  } else {
717  reply = systemd_send_recv(msg, NULL, op->timeout);
718  dbus_message_unref(msg);
719  systemd_exec_result(reply, op);
720 
721  if(reply) {
722  dbus_message_unref(reply);
723  }
724  return FALSE;
725  }
726 
727  cleanup:
728  if (op->synchronous == FALSE) {
729  return operation_finalize(op);
730  }
731 
732  return op->rc == PCMK_OCF_OK;
733 }
734 
735 static gboolean
736 systemd_timeout_callback(gpointer p)
737 {
738  svc_action_t * op = p;
739 
740  op->opaque->timerid = 0;
741  crm_warn("%s operation on systemd unit %s named '%s' timed out", op->action, op->agent, op->rsc);
742  operation_finalize(op);
743 
744  return FALSE;
745 }
746 
747 /* For an asynchronous 'op', returns FALSE if 'op' should be free'd by the caller */
748 /* For a synchronous 'op', returns FALSE if 'op' fails */
749 gboolean
751 {
752  char *unit = NULL;
753 
754  CRM_ASSERT(op);
755  CRM_ASSERT(systemd_init());
757  crm_debug("Performing %ssynchronous %s op on systemd unit %s named '%s'",
758  op->synchronous ? "" : "a", op->action, op->agent, op->rsc);
759 
760  if (safe_str_eq(op->action, "meta-data")) {
761  /* TODO: See if we can teach the lrmd not to make these calls synchronously */
762  op->stdout_data = systemd_unit_metadata(op->agent, op->timeout);
763  op->rc = PCMK_OCF_OK;
764 
765  if (op->synchronous == FALSE) {
766  return operation_finalize(op);
767  }
768  return TRUE;
769  }
770 
771  unit = systemd_unit_by_name(op->agent, op);
772  free(unit);
773 
774  if (op->synchronous == FALSE) {
775  if (op->opaque->pending) {
776  op->opaque->timerid = g_timeout_add(op->timeout + 5000, systemd_timeout_callback, op);
778  return TRUE;
779 
780  } else {
781  return operation_finalize(op);
782  }
783  }
784 
785  return op->rc == PCMK_OCF_OK;
786 }
Services API.
#define CRM_CHECK(expr, failure_action)
Definition: logging.h:164
A dumping ground.
void crm_build_path(const char *path_c, mode_t mode)
Create a directory, including any parent directories needed.
Definition: io.c:39
char * id
Definition: services.h:163
void pcmk_dbus_disconnect(DBusConnection *connection)
Definition: dbus.c:55
#define DBUS_TIMEOUT_USE_DEFAULT
Definition: pcmk-dbus.h:14
char * rsc
Definition: services.h:164
#define CRM_LOG_ASSERT(expr)
Definition: logging.h:150
Wrappers for and extensions to glib mainloop.
bool pcmk_dbus_find_error(DBusPendingCall *pending, DBusMessage *reply, DBusError *ret)
Definition: dbus.c:76
char * strndup(const char *str, size_t len)
#define crm_warn(fmt, args...)
Definition: logging.h:249
svc_action_private_t * opaque
Definition: services.h:195
#define crm_debug(fmt, args...)
Definition: logging.h:253
#define BUS_NAME_UNIT
Definition: systemd.c:24
gint crm_alpha_sort(gconstpointer a, gconstpointer b)
Compare two strings alphabetically (case-insensitive)
Definition: strings.c:472
gboolean operation_finalize(svc_action_t *op)
char * stdout_data
Definition: services.h:185
gboolean systemd_unit_exists(const char *name)
Definition: systemd.c:459
#define crm_trace(fmt, args...)
Definition: logging.h:254
#define BUS_NAME
Definition: systemd.c:22
char * agent
Definition: services.h:170
int synchronous
Definition: services.h:181
#define BUS_PATH
Definition: systemd.c:25
char * pcmk_dbus_get_property(DBusConnection *connection, const char *target, const char *obj, const gchar *iface, const char *name, void(*callback)(const char *name, const char *value, void *userdata), void *userdata, DBusPendingCall **pending, int timeout)
Definition: dbus.c:408
#define SYSTEMD_OVERRIDE_ROOT
Definition: systemd.c:566
GList * systemd_unit_listall(void)
Definition: systemd.c:362
DBusPendingCall * pcmk_dbus_send(DBusMessage *msg, DBusConnection *connection, void(*done)(DBusPendingCall *pending, void *user_data), void *user_data, int timeout)
Definition: dbus.c:223
DBusConnection * pcmk_dbus_connect(void)
Definition: dbus.c:36
void services_add_inflight_op(svc_action_t *op)
Definition: services.c:798
void systemd_cleanup(void)
Definition: systemd.c:135
char * action
Definition: services.h:165
#define crm_perror(level, fmt, args...)
Log a system error message.
Definition: logging.h:226
#define crm_err(fmt, args...)
Definition: logging.h:248
#define PCMK_DEFAULT_AGENT_VERSION
Definition: services.h:73
bool pcmk_dbus_type_check(DBusMessage *msg, DBusMessageIter *field, int expected, const char *function, int line)
Definition: dbus.c:270
#define CRM_ASSERT(expr)
Definition: error.h:35
gboolean systemd_unit_exec_with_unit(svc_action_t *op, const char *unit)
Definition: systemd.c:597
#define safe_str_eq(a, b)
Definition: util.h:72
char * crm_strdup_printf(char const *format,...) __attribute__((__format__(__printf__
DBusMessage * pcmk_dbus_send_recv(DBusMessage *msg, DBusConnection *connection, DBusError *error, int timeout)
Definition: dbus.c:159
gboolean systemd_unit_exec(svc_action_t *op)
Definition: systemd.c:750
#define crm_info(fmt, args...)
Definition: logging.h:251
#define BUS_NAME_MANAGER
Definition: systemd.c:23