diff --git a/.gitignore b/.gitignore index 63ce607e4e..9b7834facd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,250 +1,250 @@ # Common \#* .\#* GPATH GRTAGS GTAGS TAGS Makefile Makefile.in .deps .dirstamp .libs *.pc *.pyc *.bz2 *.tar.gz *.tgz *.la *.lo *.o *~ *.gcda *.gcno # Autobuild aclocal.m4 autoconf autoheader autom4te.cache/ automake build.counter /confdefs.h config.log config.status configure /conftest* include/stamp-* libtool libtool.m4 ltdl.m4 libltdl /m4/argz.m4 /m4/ltargz.m4 /m4/ltoptions.m4 /m4/ltsugar.m4 /m4/ltversion.m4 /m4/lt~obsolete.m4 ylwrap # Configure targets /cts/CTS.py /cts/CTSlab.py /cts/CTSvars.py /cts/LSBDummy /cts/OCFIPraTest.py /cts/benchmark/clubench /cts/cluster_test /cts/cts /cts/cts-cli /cts/cts-coverage /cts/cts-exec /cts/cts-fencing /cts/cts-log-watcher /cts/cts-regression /cts/cts-scheduler /cts/cts-support /cts/fence_dummy /cts/lxc_autogen.sh /cts/pacemaker-cts-dummyd /cts/pacemaker-cts-dummyd@.service /daemons/execd/pacemaker_remote /daemons/execd/pacemaker_remote.service /daemons/fenced/fence_legacy /daemons/pacemakerd/pacemaker /daemons/pacemakerd/pacemaker.combined.upstart /daemons/pacemakerd/pacemaker.service /daemons/pacemakerd/pacemaker.upstart /doc/Doxyfile /extra/logrotate/pacemaker /extra/resources/ClusterMon /extra/resources/HealthSMART /extra/resources/SysInfo /extra/resources/ifspeed /extra/resources/o2cb include/config.h include/config.h.in include/crm_config.h /tools/cibsecret /tools/crm_error /tools/crm_failcount /tools/crm_master /tools/crm_mon.service /tools/crm_mon.upstart /tools/crm_report /tools/crm_rule /tools/crm_standby /tools/pcmk_simtimes /tools/report.collector /tools/report.common # Build targets *.7 *.7.xml *.7.html *.8 *.8.xml *.8.html /daemons/attrd/pacemaker-attrd /daemons/based/pacemaker-based -/daemons/based/cibmon /daemons/controld/pacemaker-controld /daemons/execd/cts-exec-helper /daemons/execd/pacemaker-execd /daemons/execd/pacemaker-remoted /daemons/fenced/cts-fence-helper /daemons/fenced/pacemaker-fenced /daemons/fenced/pacemaker-fenced.xml /daemons/pacemakerd/pacemakerd /daemons/schedulerd/pacemaker-schedulerd /daemons/schedulerd/pacemaker-schedulerd.xml /doc/.ABI-build /doc/HTML /doc/abi_dumps /doc/abi-check /doc/api/* /doc/compat_reports /doc/crm_fencing.html /doc/sphinx/*/_build /doc/sphinx/*/conf.py /doc/sphinx/shared/images/*.png /lib/common/md5.c /maint/testcc_helper.cc /maint/testcc_*_h /maint/mocked/based scratch /tools/attrd_updater /tools/cibadmin /tools/crmadmin /tools/crm_attribute /tools/crm_diff /tools/crm_mon /tools/crm_node /tools/crm_resource /tools/crm_shadow /tools/crm_simulate /tools/crm_ticket /tools/crm_verify /tools/iso8601 /tools/stonith_admin xml/crm.dtd xml/pacemaker*.rng xml/versions.rng xml/api/api-result*.rng lib/gnu/libgnu.a lib/gnu/stdalign.h *.coverity # Packager artifacts *.rpm /mock /pacemaker.spec /rpm/[A-Z]* # make dist/export working directory pacemaker-[a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9] # Test detritus /cts/.regression.failed.diff /cts/scheduler/*.ref /cts/scheduler/*.up /cts/scheduler/*.up.err /cts/scheduler/bug-rh-1097457.log /cts/scheduler/bug-rh-1097457.trs /cts/scheduler/shadow.* /cts/test-suite.log /lib/*/tests/*/*.log /lib/*/tests/*/*_test /lib/*/tests/*/*.trs /xml/test-*/*.up /xml/test-*/*.up.err /xml/assets/*.rng /xml/assets/diffview.js /xml/assets/xmlcatalog # Release maintenance detritus /maint/gnulib # Formerly built files (helps when jumping back and forth in checkout) /.ABI-build /Doxyfile /HTML /abi_dumps /abi-check /compat_reports /compile /attrd /cib /config.guess /config.sub /coverage.sh /crmd /cts/HBDummy +/daemons/based/cibmon /depcomp /doc/*.build /doc/*/en-US/Ap-*.xml /doc/*/en-US/Ch-*.xml /doc/*/publican.cfg /doc/*/publish /doc/*/tmp/** /doc/Clusters_from_Scratch.txt /doc/Pacemaker_Explained.txt /doc/acls.html /doc/publican-catalog* /doc/shared/en-US/*.xml /doc/shared/en-US/images/pcmk-*.png /doc/shared/en-US/images/Policy-Engine-*.png /fencing /install-sh /lib/common/tests/flags/pcmk__clear_flags_as /lib/common/tests/flags/pcmk__set_flags_as /lib/common/tests/flags/pcmk_all_flags_set /lib/common/tests/flags/pcmk_any_flags_set /lib/common/tests/operations/parse_op_key /lib/common/tests/strings/pcmk__btoa /lib/common/tests/strings/pcmk__parse_ll_range /lib/common/tests/strings/pcmk__scan_double /lib/common/tests/strings/pcmk__str_any_of /lib/common/tests/strings/pcmk__strcmp /lib/common/tests/strings/pcmk__char_in_any_str /lib/common/tests/utils/pcmk_str_is_infinity /lib/common/tests/utils/pcmk_str_is_minus_infinity /lib/pengine/tests/rules/pe_cron_range_satisfied /lrmd /ltmain.sh /mcp /missing /pacemaker-*.spec /pengine /py-compile /test-driver #Other coverity-* logs *.patch *.diff *.sed *.orig *.rej *.swp diff --git a/daemons/based/Makefile.am b/daemons/based/Makefile.am index d91b7e4b6f..053d93cea6 100644 --- a/daemons/based/Makefile.am +++ b/daemons/based/Makefile.am @@ -1,50 +1,47 @@ # -# Copyright 2004-2020 the Pacemaker project contributors +# Copyright 2004-2021 the Pacemaker project contributors # # The version control history for this file may have further details. # # This source code is licensed under the GNU General Public License version 2 # or later (GPLv2+) WITHOUT ANY WARRANTY. # include $(top_srcdir)/mk/common.mk EXTRA_DIST = cib.pam halibdir = $(CRM_DAEMON_DIR) COMMONLIBS = $(top_builddir)/lib/common/libcrmcommon.la \ $(top_builddir)/lib/cib/libcib.la -halib_PROGRAMS = pacemaker-based cibmon +halib_PROGRAMS = pacemaker-based noinst_HEADERS = pacemaker-based.h pacemaker_based_CFLAGS = $(CFLAGS_HARDENED_EXE) pacemaker_based_LDFLAGS = $(LDFLAGS_HARDENED_EXE) pacemaker_based_LDADD = $(top_builddir)/lib/cluster/libcrmcluster.la \ $(COMMONLIBS) $(CLUSTERLIBS) pacemaker_based_SOURCES = pacemaker-based.c \ based_callbacks.c \ based_common.c \ based_io.c \ based_messages.c \ based_notify.c \ based_remote.c -cibmon_LDADD = $(COMMONLIBS) -cibmon_SOURCES = cibmon.c - clean-generic: rm -f *.log *.debug *.xml *~ if BUILD_LEGACY_LINKS install-exec-hook: $(MKDIR_P) -- $(DESTDIR)$(CRM_DAEMON_DIR) cd $(DESTDIR)$(CRM_DAEMON_DIR) && rm -f cib && $(LN_S) pacemaker-based cib uninstall-hook: cd $(DESTDIR)$(CRM_DAEMON_DIR) && rm -f cib endif diff --git a/daemons/based/cibmon.c b/daemons/based/cibmon.c deleted file mode 100644 index 5bdc27e06c..0000000000 --- a/daemons/based/cibmon.c +++ /dev/null @@ -1,250 +0,0 @@ -/* - * Copyright 2004-2020 the Pacemaker project contributors - * - * The version control history for this file may have further details. - * - * This source code is licensed under the GNU General Public License version 2 - * or later (GPLv2+) WITHOUT ANY WARRANTY. - */ - -#include - -#include - -#include - -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include - -#include -#include - -#include - -#ifdef HAVE_GETOPT_H -# include -#endif - -static int max_failures = 30; - -static gboolean log_diffs = FALSE; -static gboolean log_updates = FALSE; - -static GMainLoop *mainloop = NULL; -void usage(const char *cmd, crm_exit_t exit_status); -void cib_connection_destroy(gpointer user_data); - -void cibmon_shutdown(int nsig); -void cibmon_diff(const char *event, xmlNode * msg); - -static cib_t *cib = NULL; -static xmlNode *cib_copy = NULL; - -#define OPTARGS "V?m:du" - -int -main(int argc, char **argv) -{ - int argerr = 0; - int flag; - int attempts = 0; - int rc = pcmk_ok; - -#ifdef HAVE_GETOPT_H - int option_index = 0; - - static struct option long_options[] = { - /* Top-level Options */ - {"verbose", 0, 0, 'V'}, - {"help", 0, 0, '?'}, - {"log-diffs", 0, 0, 'd'}, - {"log-updates", 0, 0, 'u'}, - {"max-conn-fail", 1, 0, 'm'}, - {0, 0, 0, 0} - }; -#endif - - crm_log_cli_init("cibmon"); - - crm_signal_handler(SIGTERM, cibmon_shutdown); - - while (1) { -#ifdef HAVE_GETOPT_H - flag = getopt_long(argc, argv, OPTARGS, long_options, &option_index); -#else - flag = getopt(argc, argv, OPTARGS); -#endif - if (flag == -1) - break; - - switch (flag) { - case 'V': - crm_bump_log_level(argc, argv); - break; - case '?': - usage(crm_system_name, CRM_EX_OK); - break; - case 'd': - log_diffs = TRUE; - break; - case 'u': - log_updates = TRUE; - break; - case 'm': - max_failures = crm_parse_int(optarg, "30"); - break; - default: - printf("Argument code 0%o (%c)" " is not (?yet?) supported\n", flag, flag); - ++argerr; - break; - } - } - - if (optind < argc) { - printf("non-option ARGV-elements: "); - while (optind < argc) - printf("%s ", argv[optind++]); - printf("\n"); - } - - if (optind > argc) { - ++argerr; - } - - if (argerr) { - usage(crm_system_name, CRM_EX_USAGE); - } - - cib = cib_new(); - - do { - sleep(1); - rc = cib->cmds->signon(cib, crm_system_name, cib_query); - - } while (rc == -ENOTCONN && attempts++ < max_failures); - - if (rc != pcmk_ok) { - crm_err("Signon to CIB failed: %s", pcmk_strerror(rc)); - goto fail; - } - - crm_debug("Setting dnotify"); - rc = cib->cmds->set_connection_dnotify(cib, cib_connection_destroy); - if (rc != pcmk_ok) { - crm_err("Failed to set dnotify callback: %s", pcmk_strerror(rc)); - goto fail; - } - - crm_debug("Setting diff callback"); - rc = cib->cmds->add_notify_callback(cib, T_CIB_DIFF_NOTIFY, cibmon_diff); - if (rc != pcmk_ok) { - crm_err("Failed to set diff callback: %s", pcmk_strerror(rc)); - goto fail; - } - - mainloop = g_main_loop_new(NULL, FALSE); - crm_info("Starting mainloop"); - g_main_loop_run(mainloop); - crm_trace("%s exiting normally", crm_system_name); - fflush(stderr); - return CRM_EX_OK; - -fail: - crm_err("Setup failed, could not monitor CIB actions"); - return CRM_EX_ERROR; -} - -void -usage(const char *cmd, crm_exit_t exit_status) -{ - FILE *stream; - - stream = (exit_status == CRM_EX_OK)? stdout : stderr; - fflush(stream); - - crm_exit(exit_status); -} - -void -cib_connection_destroy(gpointer user_data) -{ - cib_t *conn = user_data; - - crm_err("Connection to the CIB terminated... exiting"); - conn->cmds->signoff(conn); /* Ensure IPC is cleaned up */ - g_main_loop_quit(mainloop); - return; -} - -void -cibmon_diff(const char *event, xmlNode * msg) -{ - int rc = -1; - const char *op = NULL; - unsigned int log_level = LOG_INFO; - - xmlNode *diff = NULL; - xmlNode *cib_last = NULL; - xmlNode *update = get_message_xml(msg, F_CIB_UPDATE); - - if (msg == NULL) { - crm_err("NULL update"); - return; - } - - crm_element_value_int(msg, F_CIB_RC, &rc); - op = crm_element_value(msg, F_CIB_OPERATION); - diff = get_message_xml(msg, F_CIB_UPDATE_RESULT); - - if (rc < pcmk_ok) { - log_level = LOG_WARNING; - do_crm_log(log_level, "[%s] %s ABORTED: %s", event, op, pcmk_strerror(rc)); - return; - } - - if (log_diffs) { - xml_log_patchset(log_level, op, diff); - } - - if (log_updates && update != NULL) { - crm_log_xml_trace(update, "raw_update"); - } - - if (cib_copy != NULL) { - cib_last = cib_copy; - cib_copy = NULL; - rc = cib_process_diff(op, cib_force_diff, NULL, NULL, diff, cib_last, &cib_copy, NULL); - - if (rc != pcmk_ok) { - crm_debug("Update didn't apply, requesting full copy: %s", pcmk_strerror(rc)); - free_xml(cib_copy); - cib_copy = NULL; - } - } - - if (cib_copy == NULL) { - rc = cib->cmds->query(cib, NULL, &cib_copy, cib_scope_local | cib_sync_call); - } - - if(rc == -EACCES) { - crm_exit(CRM_EX_INSUFFICIENT_PRIV); - } - - free_xml(cib_last); -} - -void -cibmon_shutdown(int nsig) -{ - crm_exit(CRM_EX_OK); -}