├── AUTHORS ├── COPYING ├── COPYING.LIB ├── ChangeLog ├── GNUmakefile ├── Makefile.am ├── NEWS ├── README.md ├── autogen.sh ├── buildversion.sh ├── cluster-glue-fedora.spec ├── cluster-glue-suse.spec ├── config ├── Makefile.am └── byteorder_test.c ├── configure.ac ├── doc ├── Makefile.am ├── ha_logd.xml.in ├── ha_logger.xml.in ├── meatclient.xml.in ├── stonith.xml.in └── stonith │ ├── Makefile.am │ ├── README.bladehpi │ ├── README.cyclades │ ├── README.drac3 │ ├── README.dracmc │ ├── README.external │ ├── README.ibmrsa │ ├── README.ibmrsa-telnet │ ├── README.ipmilan │ ├── README.ippower9258 │ ├── README.meatware │ ├── README.rackpdu │ ├── README.rcd_serial │ ├── README.riloe │ ├── README.vacm │ ├── README.vcenter │ ├── README.wti_mpc │ └── README_kdumpcheck.txt ├── hb_report ├── Makefile.am ├── ha_cf_support.sh ├── openais_conf_support.sh └── utillib.sh ├── include ├── Makefile.am ├── clplumbing │ ├── GSource.h │ ├── GSource_internal.h │ ├── Gmain_timeout.h │ ├── Makefile.am │ ├── apphb_cs.h │ ├── base64.h │ ├── cl_log.h │ ├── cl_misc.h │ ├── cl_pidfile.h │ ├── cl_plugin.h │ ├── cl_poll.h │ ├── cl_quorum.h │ ├── cl_quorumd.h │ ├── cl_random.h │ ├── cl_reboot.h │ ├── cl_signal.h │ ├── cl_syslog.h │ ├── cl_tiebreaker.h │ ├── cl_uuid.h │ ├── coredumps.h │ ├── cpulimits.h │ ├── ipc.h │ ├── loggingdaemon.h │ ├── longclock.h │ ├── lsb_exitcodes.h │ ├── md5.h │ ├── mkstemp_mode.h │ ├── netstring.h │ ├── proctrack.h │ ├── realtime.h │ ├── replytrack.h │ ├── setproctitle.h │ ├── timers.h │ └── uids.h ├── compress.h ├── glue_config.h.in ├── ha_msg.h ├── lha_internal.h ├── lrm │ ├── Makefile.am │ ├── lrm_api.h │ ├── lrm_msg.h │ ├── racommon.h │ └── raexec.h ├── pils │ ├── Makefile.am │ ├── generic.h │ ├── interface.h │ └── plugin.h.in ├── replace_uuid.h └── stonith │ ├── Makefile.am │ ├── expect.h │ ├── st_ttylock.h │ ├── stonith.h │ └── stonith_plugin.h ├── lib ├── Makefile.am ├── clplumbing │ ├── GSource.c │ ├── Makefile.am │ ├── base64.c │ ├── base64_md5_test.c │ ├── cl_compress.c │ ├── cl_log.c │ ├── cl_malloc.c │ ├── cl_misc.c │ ├── cl_msg.c │ ├── cl_msg_types.c │ ├── cl_netstring.c │ ├── cl_pidfile.c │ ├── cl_plugin.c │ ├── cl_poll.c │ ├── cl_random.c │ ├── cl_reboot.c │ ├── cl_signal.c │ ├── cl_syslog.c │ ├── cl_uuid.c │ ├── coredumps.c │ ├── cpulimits.c │ ├── ipcsocket.c │ ├── ipctest.c │ ├── ipctransient.h │ ├── ipctransientclient.c │ ├── ipctransientlib.c │ ├── ipctransientserver.c │ ├── longclock.c │ ├── md5.c │ ├── mkstemp_mode.c │ ├── netstring_test.c │ ├── ocf_ipc.c │ ├── proctrack.c │ ├── realtime.c │ ├── replytrack.c │ ├── setproctitle.c │ ├── timers.c │ ├── transient-test.sh │ └── uids.c ├── lrm │ ├── Makefile.am │ ├── clientlib.c │ ├── lrm_msg.c │ └── racommon.c ├── pils │ ├── Makefile.am │ ├── main.c │ ├── pils.c │ └── test.c ├── plugins │ ├── InterfaceMgr │ │ ├── HBauth.c │ │ ├── Makefile.am │ │ └── generic.c │ ├── Makefile.am │ ├── compress │ │ ├── Makefile.am │ │ ├── bz2.c │ │ └── zlib.c │ ├── lrm │ │ ├── Makefile.am │ │ ├── dbus │ │ │ ├── Makefile.am │ │ │ ├── com.ubuntu.Upstart.Instance.xml │ │ │ ├── com.ubuntu.Upstart.Job.xml │ │ │ └── com.ubuntu.Upstart.xml │ │ ├── raexechb.c │ │ ├── raexeclsb.c │ │ ├── raexecocf.c │ │ ├── raexecupstart.c │ │ ├── upstart-dbus.c │ │ └── upstart-dbus.h │ └── stonith │ │ ├── Makefile.am │ │ ├── apcmaster.c │ │ ├── apcmastersnmp.c │ │ ├── apcmastersnmp.cfg.example │ │ ├── apcsmart.c │ │ ├── apcsmart.cfg.example │ │ ├── baytech.c │ │ ├── bladehpi.c │ │ ├── cyclades.c │ │ ├── drac3.c │ │ ├── drac3_command.c │ │ ├── drac3_command.h │ │ ├── drac3_hash.c │ │ ├── drac3_hash.h │ │ ├── external.c │ │ ├── external │ │ ├── Makefile.am │ │ ├── drac5.in │ │ ├── dracmc-telnet │ │ ├── ec2 │ │ ├── hetzner │ │ ├── hmchttp │ │ ├── ibmrsa │ │ ├── ibmrsa-telnet │ │ ├── ipmi │ │ ├── ippower9258.in │ │ ├── kdumpcheck.in │ │ ├── libvirt │ │ ├── nut │ │ ├── rackpdu │ │ ├── riloe │ │ ├── ssh.in │ │ ├── vcenter │ │ ├── vmware │ │ ├── xen0 │ │ ├── xen0-ha-dom0-stonith-helper │ │ └── xen0-ha.in │ │ ├── ibmhmc.c │ │ ├── ipmi_os_handler.c │ │ ├── ipmilan.c │ │ ├── ipmilan.h │ │ ├── ipmilan_command.c │ │ ├── ipmilan_test.c │ │ ├── meatware.c │ │ ├── null.c │ │ ├── nw_rpc100s.c │ │ ├── rcd_serial.c │ │ ├── rhcs.c │ │ ├── ribcl.py │ │ ├── riloe.c │ │ ├── rps10.c │ │ ├── ssh.c │ │ ├── stonith_config_xml.h │ │ ├── stonith_expect_helpers.h │ │ ├── stonith_plugin_common.h │ │ ├── stonith_signal.h │ │ ├── suicide.c │ │ ├── vacm.c │ │ ├── wti_mpc.c │ │ └── wti_nps.c └── stonith │ ├── Makefile.am │ ├── README │ ├── expect.c │ ├── ha_log.sh │ ├── main.c │ ├── meatclient.c │ ├── st_ttylock.c │ └── stonith.c ├── logd ├── Makefile.am ├── ha_logd.c ├── ha_logger.1 ├── ha_logger.c ├── logd.cf ├── logd.in ├── logd.service.in └── logtest.c ├── lrm ├── Makefile.am ├── admin │ ├── Makefile.am │ ├── cibsecret.in │ ├── lrmadmin.c │ └── lrmadmin.txt ├── lrmd │ ├── Makefile.am │ ├── audit.c │ ├── cib_secrets.c │ ├── lrmd.c │ ├── lrmd.h │ └── lrmd_fdecl.h └── test │ ├── LRMBasicSanityCheck.in │ ├── Makefile.am │ ├── README.regression │ ├── apitest.c │ ├── apitest.exp │ ├── callbacktest.c │ ├── defaults │ ├── descriptions │ ├── evaltest.sh │ ├── language │ ├── lrmadmin-interface │ ├── lrmregtest-lsb │ ├── lrmregtest.in │ ├── plugintest.c │ ├── regression.sh.in │ └── testcases │ ├── BSC │ ├── Makefile.am │ ├── basicset │ ├── common.filter │ ├── flood │ ├── flood.exp │ ├── metadata │ ├── metadata.exp │ ├── ra-list.sh │ ├── rscexec │ ├── rscexec.exp │ ├── rscmgmt │ ├── rscmgmt.exp │ ├── rscmgmt.log_filter │ ├── serialize │ ├── serialize.exp │ ├── stonith │ ├── stonith.exp │ └── xmllint.sh └── replace ├── Makefile.am ├── NoSuchFunctionName.c ├── alphasort.c ├── daemon.c ├── inet_pton.c ├── scandir.c ├── setenv.c ├── strerror.c ├── strlcat.c ├── strlcpy.c ├── strndup.c ├── strnlen.c ├── unsetenv.c └── uuid_parse.c /AUTHORS: -------------------------------------------------------------------------------- 1 | abrugger <> 2 | Alan Robertson 3 | Alessandro Federico 4 | Alex Tsariounov 5 | Andreas Mock 6 | Andrew Beekhof 7 | Ante Karamatic 8 | Bernd Schubert 9 | Borislav Borisov 10 | Darren Mansell 11 | Dave Blaschke 12 | David Lee 13 | Dejan Muhamedagic 14 | Denis Chapligin 15 | Florian Haas 16 | Frederik Schüler 17 | Gao,Yan 18 | Goldwyn Rodrigues 19 | Guochun Shi 20 | Hannes Eder 21 | Helmut Weymann 22 | Hideo Yamauchi 23 | Holger Teutsch 24 | Huang Zhen 25 | Jean Raby 26 | Jochen Roeder 27 | Junko Ikeda 28 | Kacper Kowalik 29 | Kazuhiko Higashi 30 | Kazuhiko Higashi 31 | Kazunori INOUE 32 | Keisuke MORI 33 | kevin <> 34 | Kristoffer Grönlund 35 | Lars Ellenberg 36 | Lars Marowsky-Brée 37 | lclaudio <> 38 | Martin Bene 39 | Martin Gerhard Loschwitz 40 | Michael Prokop <> 41 | Matt Soffen 42 | Nhan Ngo Dinh 43 | panjiam <> 44 | Pádraig Brady 45 | Phil Carns 46 | ram <> 47 | Raoul Bhatia 48 | RaSca 49 | Ruediger Oertel 50 | Satomi Taniguchi 51 | Sean Reifschneider 52 | Sebastian Reitenbach 53 | Senko Rasic 54 | Serge Dubrouski 55 | Simon Horman 56 | Sun Jiang Dong 57 | Takatoshi MATSUO 58 | Tim Serong 59 | Vadym Chepkov 60 | William Seligman 61 | Xiaoxiang Liu 62 | Xinwei Hu 63 | yao zhao 64 | Yixiong Zou 65 | Yoshihiko SATO 66 | Yuichi SEINO 67 | Yusuke Iida 68 | Zhaokai 69 | Huang Zhen 70 | -------------------------------------------------------------------------------- /GNUmakefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2008 Andrew Beekhof 3 | # 4 | # This program is free software; you can redistribute it and/or 5 | # modify it under the terms of the GNU General Public License 6 | # as published by the Free Software Foundation; either version 2 7 | # of the License, or (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program; if not, see . 16 | # 17 | 18 | -include Makefile 19 | 20 | PACKAGE ?= cluster-glue 21 | TARFILE = $(PACKAGE).tar 22 | 23 | RPM_ROOT = $(shell pwd) 24 | RPM_OPTS = --define "_sourcedir $(RPM_ROOT)" \ 25 | --define "_specdir $(RPM_ROOT)" \ 26 | --define "_srcrpmdir $(RPM_ROOT)" 27 | 28 | 29 | getdistro = $(shell test -e /etc/SuSE-release || echo fedora; test -e /etc/SuSE-release && echo suse) 30 | DISTRO ?= $(call getdistro) 31 | TAG ?= HEAD 32 | 33 | tarball: 34 | rm -f $(TARFILE) $(TARFILE).bz2 $(TARFILE).tmp .tarball-version.tmp .tarball-version 35 | ./buildversion.sh $(TAG) > .tarball-version.tmp && mv .tarball-version.tmp .tarball-version 36 | git archive --prefix $(PACKAGE)/ $(TAG) > $(TARFILE).tmp 37 | tar --append --transform 's,^,$(PACKAGE)/,' -f $(TARFILE).tmp .tarball-version 38 | mv $(TARFILE).tmp $(TARFILE) 39 | bzip2 $(TARFILE) 40 | @echo `date`: Rebuilt $(TARFILE).bz2 41 | 42 | srpm: tarball 43 | rm -f *.src.rpm 44 | @echo To create custom builds, edit the flags and options in $(PACKAGE)-$(DISTRO).spec first 45 | rpmbuild -bs --define "dist .$(DISTRO)" $(RPM_OPTS) $(PACKAGE)-$(DISTRO).spec 46 | 47 | rpm: srpm 48 | rpmbuild $(RPM_OPTS) --rebuild $(RPM_ROOT)/*.src.rpm 49 | 50 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2008 Andrew Beekhof 3 | # 4 | # This program is free software; you can redistribute it and/or 5 | # modify it under the terms of the GNU General Public License 6 | # as published by the Free Software Foundation; either version 2 7 | # of the License, or (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program; if not, see . 16 | # 17 | 18 | AUTOMAKE_OPTIONS = foreign 19 | 20 | DISTCHECK_CONFIGURE_FLAGS = \ 21 | --with-systemdsystemunitdir=$$dc_install_base/$(systemdsystemunitdir) 22 | 23 | MAINTAINERCLEANFILES = Makefile.in aclocal.m4 configure DRF/config-h.in \ 24 | DRF/stamp-h.in libtool.m4 ltdl.m4 libltdl.tar 25 | 26 | SUBDIRS = include $(LIBLTDL_DIR) replace lib lrm logd \ 27 | hb_report doc config 28 | 29 | EXTRA_DIST = .tarball-version 30 | .tarball-version: FORCE 31 | @if ./build-version.sh > $@.tmp ; \ 32 | if cmp -s $@.tmp $@ ; then rm -f $@.tmp ; else mv $@.tmp $@; fi ; \ 33 | else \ 34 | rm -f $@.tmp ; \ 35 | fi 36 | 37 | install-exec-local: 38 | $(INSTALL) -d $(DESTDIR)/$(HA_COREDIR) 39 | -$(INSTALL) -d -m 700 -o root $(DESTDIR)/$(HA_COREDIR)/root 40 | -$(INSTALL) -d -m 700 -o nobody $(DESTDIR)/$(HA_COREDIR)/nobody 41 | $(INSTALL) -d -m 700 $(DESTDIR)/$(HA_COREDIR)/$(GLUE_DAEMON_USER) 42 | -chown $(GLUE_DAEMON_USER) $(DESTDIR)/$(HA_COREDIR)/$(GLUE_DAEMON_USER) 43 | # Use chown because $(GLUE_DAEMON_USER) may not exist yet 44 | 45 | dist-clean-local: 46 | rm -f autoconf automake autoheader $(TARFILE) 47 | 48 | .PHONY: FORCE 49 | FORCE: 50 | 51 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # Cluster Glue 3 | 4 | Cluster Glue is a set of libraries, tools and utilities used in the 5 | the Heartbeat/Pacemaker cluster stack. In essence, Glue are the parts 6 | of the cluster stack that don't fit in anywhere else, and aren't big 7 | enough pieces or actively developed enough to qualify as their own 8 | projects. 9 | 10 | Cluster Glue has been managed as a separate Linux-HA sub-project since 11 | its 1.0 release, which coincided with the Heartbeat 2.99 12 | release. Previously, it was a part of the then-monolithic Heartbeat 13 | project, and had no separate name. 14 | 15 | ## Components 16 | 17 | ### Local Resource Manager (LRM) 18 | 19 | The Local Resource Manager is the interface between the Cluster 20 | Resource Manager (Pacemaker) and the resource agents. It is itself not 21 | cluster aware, nor does it apply any policies. It simply processes 22 | commands received from the Cluster Resource Manager, passes them to 23 | resource agents, and reports back success or failure. It particular, 24 | the LRM may 25 | 26 | * start a resource; 27 | * stop a resource; 28 | * monitor a resource; 29 | * report a resource's status; 30 | * list all resource instances it currently controls, and their status. 31 | 32 | ### STONITH 33 | 34 | A mechanism for node fencing. In case a node is considered "dead" by 35 | the cluster as a whole, STONITH ("Shoot The Other Node In The Head") 36 | forcefully removes is from the cluster so it can no longer pose a risk 37 | of interacting with other nodes in an uncoordinated fashion. 38 | 39 | ### hb_report (deprecated) 40 | 41 | An advanced error reporting utility. hb_report-generated tarballs are 42 | frequently requested by the developers to isolate and fix bugs, and 43 | are commonly found as attachments to Bugzilla entries. 44 | 45 | NOTE: hb_report has been integrated into 46 | [crmsh](https://github.com/ClusterLabs/crmsh.git), and is now maintained as part of the 47 | `crmsh` project. 48 | 49 | ### Cluster Plumbing Library 50 | 51 | A low-level library for intra-cluster communications. 52 | 53 | ## Source Code Repository 54 | 55 | Source code for Cluster Glue is being maintained in the 56 | https://github.com/ClusterLabs/cluster-glue git repository. 57 | -------------------------------------------------------------------------------- /buildversion.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | TAG=${1:-HEAD} 3 | if test -d .git && 4 | D=$( git describe --abbrev=12 --long --tags --match glue-\* $TAG ) 5 | then 6 | if [ "$TAG" = "HEAD" ]; then 7 | LATEST_DIRTY_TS=$(git diff --name-only $TAG | xargs -r stat -c %Y | sort -nr | head -n1) 8 | if test -n "$LATEST_DIRTY_TS" ; then 9 | LATEST_DIRTY_YMDHMS=$(date "+%Y%m%d%H%M%S" -d @$LATEST_DIRTY_TS) 10 | D=$D+$LATEST_DIRTY_YMDHMS 11 | fi 12 | fi 13 | echo "${D#glue-}" 14 | elif test -s .tarball-version; then 15 | head -n1 .tarball-version 16 | else 17 | echo "unknown" 18 | exit 1 19 | fi 20 | -------------------------------------------------------------------------------- /config/Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2005 Guochun Shi (gshi@ncsa.uiuc.edu) 3 | # 4 | # This program is free software; you can redistribute it and/or 5 | # modify it under the terms of the GNU General Public License 6 | # as published by the Free Software Foundation; either version 2 7 | # of the License, or (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program; if not, see . 16 | 17 | MAINTAINERCLEANFILES = Makefile.in 18 | EXTRA_DIST = byteorder_test.c 19 | -------------------------------------------------------------------------------- /config/byteorder_test.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int 4 | main () 5 | { 6 | unsigned int a = 0x1234; 7 | 8 | if ( (unsigned int) ( ((unsigned char *)&a)[0]) == 0x34 ) { 9 | printf("little-endian\n"); 10 | return 0; 11 | } else { 12 | printf("big-endian\n"); 13 | return 1; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /doc/Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # heartbeat: Linux-HA heartbeat code 3 | # 4 | # Copyright (C) 2001 Michael Moerz 5 | # 6 | # This program is free software; you can redistribute it and/or 7 | # modify it under the terms of the GNU General Public License 8 | # as published by the Free Software Foundation; either version 2 9 | # of the License, or (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, see . 18 | # 19 | MAINTAINERCLEANFILES = Makefile.in ha_logd.xml ha_logger.xml stonith.xml meatclient.xml 20 | 21 | CLEANFILES = $(man_MANS) 22 | 23 | SUBDIRS = stonith 24 | 25 | hanoarchdir = $(datadir)/heartbeat 26 | 27 | man_MANS = 28 | 29 | if BUILD_DOC 30 | man_MANS += ha_logd.8 ha_logger.8 stonith.8 meatclient.8 31 | 32 | EXTRA_DIST = $(man_MANS) 33 | 34 | STYLESHEET_PREFIX ?= http://docbook.sourceforge.net/release/xsl/current 35 | MANPAGES_STYLESHEET ?= $(STYLESHEET_PREFIX)/manpages/docbook.xsl 36 | HTML_STYLESHEET ?= $(STYLESHEET_PREFIX)/xhtml/docbook.xsl 37 | FO_STYLESHEET ?= $(STYLESHEET_PREFIX)/fo/docbook.xsl 38 | 39 | XSLTPROC_OPTIONS ?= --xinclude 40 | XSLTPROC_MANPAGES_OPTIONS ?= $(XSLTPROC_OPTIONS) 41 | XSLTPROC_HTML_OPTIONS ?= $(XSLTPROC_OPTIONS) 42 | XSLTPROC_FO_OPTIONS ?= $(XSLTPROC_OPTIONS) 43 | 44 | %.5 %.8 %.1: %.xml 45 | $(XSLTPROC) \ 46 | $(XSLTPROC_MANPAGES_OPTIONS) \ 47 | $(MANPAGES_STYLESHEET) $< 48 | 49 | endif 50 | -------------------------------------------------------------------------------- /doc/meatclient.xml.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | December 4, 2009 6 | Cluster Glue 7 | @VERSION@ 8 | 9 | 10 | Gregor 11 | Binder 12 | meatclient 13 | gbinder@sysfive.com 14 | 15 | 16 | Michael 17 | Mörz 18 | man page 19 | mimem@debian.org 20 | 21 | 22 | Simon 23 | Horman 24 | man page 25 | horms@vergenet.net 26 | 27 | 28 | Florian 29 | Haas 30 | man page 31 | florian.haas@linbit.com 32 | 33 | 34 | 35 | 36 | meatclient 37 | 8 38 | System administration utilities 39 | 40 | 41 | meatclient 42 | Manually confirm that a node has been removed from the 43 | cluster 44 | 45 | 46 | meatclient nodename 47 | 48 | 49 | Description 50 | meatclient confirms that a node has been 51 | manually removed from the cluster. It instructs the cluster 52 | manager, via the meatware STONITH plugin, that it is safe to 53 | continue cluster operations. 54 | 55 | 56 | Options 57 | The following options are supported: 58 | 59 | 60 | 61 | nodename 62 | 63 | 64 | nodename is the name of the 65 | cluster node that has been fenced. 66 | 67 | 68 | 69 | 70 | 71 | See also 72 | 73 | heartbeat8, 74 | stonith8 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /doc/stonith/Makefile.am: -------------------------------------------------------------------------------- 1 | # This program is free software; you can redistribute it and/or 2 | # modify it under the terms of the GNU General Public License 3 | # as published by the Free Software Foundation; either version 2 4 | # of the License, or (at your option) any later version. 5 | # 6 | # This program is distributed in the hope that it will be useful, 7 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | # GNU General Public License for more details. 10 | # 11 | # You should have received a copy of the GNU General Public License 12 | # along with this program; if not, see . 13 | # 14 | MAINTAINERCLEANFILES = Makefile.in 15 | 16 | stdocdir = $(docdir)/stonith 17 | 18 | stdoc_DATA = README.bladehpi \ 19 | README.cyclades \ 20 | README.drac3 \ 21 | README.dracmc \ 22 | README.external \ 23 | README.ibmrsa \ 24 | README.ibmrsa-telnet \ 25 | README.meatware \ 26 | README.rackpdu \ 27 | README.rcd_serial \ 28 | README.riloe \ 29 | README.vacm \ 30 | README.wti_mpc \ 31 | README_kdumpcheck.txt \ 32 | README.vcenter 33 | 34 | if IPMILAN_BUILD 35 | stdoc_DATA += README.ipmilan 36 | endif 37 | -------------------------------------------------------------------------------- /doc/stonith/README.cyclades: -------------------------------------------------------------------------------- 1 | STONITH module for Cyclades AlterPath PM 2 | ---------------------------------------- 3 | 4 | This STONITH module talks to Cyclades AlterPath PM series of power managers 5 | via TS, ACS or KVM equipment. 6 | 7 | Access to the frontend device (TS, ACS or KVM) is done via root user with 8 | passwordless ssh. 9 | 10 | For that, it is necessary to create a public/private keypar with _empty_ 11 | passphrase on _each_ machine which is part of the cluster. 12 | 13 | Small HOWTO follows: 14 | 15 | # ssh-keygen -t rsa 16 | Generating public/private rsa key pair. 17 | Enter file in which to save the key (/root/.ssh/id_rsa): 18 | Created directory '/home/root/.ssh'. 19 | Enter passphrase (empty for no passphrase): 20 | Enter same passphrase again: 21 | Your identification has been saved in /root/.ssh/id_rsa. 22 | Your public key has been saved in /root/.ssh/id_rsa.pub. 23 | The key fingerprint is: 24 | dc:e0:71:55:fd:2a:b0:19:d6:3c:48:e5:45:db:b4:be root@hostname.network 25 | 26 | Next step is to append the public key (/root/.ssh/id_rsa.pub) 27 | to the authorized_keys file on the TS/ACS/KVM box. The authorized 28 | keys file location is set at the SSH daemon configuration file. 29 | The default location is /etc/ssh/authorized_keys, so: 30 | 31 | [root@clusterhost]# scp /root/.ssh/id_rsa.pub root@alterpath:/tmp 32 | 33 | login to the TS/ACS/KVM box normally and append the public key. 34 | 35 | # ssh root@alterpath 36 | Password: .... 37 | 38 | [root@CAS root]# cat /tmp/id_rsa.pub >> /etc/ssh/authorized_keys 39 | 40 | The following entries must be present on /etc/ssh/sshd_config for the 41 | passwordless scheme to work properly: 42 | 43 | RSAAuthentication yes 44 | PubkeyAuthentication yes 45 | AuthorizedKeysFile /etc/ssh/authorized_keys 46 | 47 | Next step is to test if the configuration has been done successfully: 48 | 49 | [root@clusterhost root]# ssh root@alterpath 50 | [root@CAS root]# 51 | 52 | If it logins automatically without asking for a password, then everything 53 | has been done correctly! 54 | 55 | Note that such configuration procedure (including generation of the key pair) 56 | has to be done for each machine in the cluster which intends to use the 57 | AlterPath PM as a STONITH device. 58 | 59 | ------ 60 | Any questions please contact Cyclades support at 61 | or 62 | -------------------------------------------------------------------------------- /doc/stonith/README.drac3: -------------------------------------------------------------------------------- 1 | Stonith module for Dell DRACIII remote access card 2 | -------------------------------------------------- 3 | 4 | This module uses the Dell DRACIII PCI card as a stonith device. 5 | It sends the XML commands over HTTPS to the DRACIII web server. 6 | 7 | The card firmware must be version 2.0 at least, with support for SSL based 8 | service and many bug fixes over 1.x versions. 9 | 10 | This module uses libcurl, libxml2 (gnome xml libs) and libssl. 11 | 12 | Any hints, bug reports, improvements, etc. will be apreciated. 13 | 14 | --- 15 | Roberto Moreda http://www.alfa21.com 16 | Alfa21 A Coruña (Spain) 17 | UNIX, Linux & TCP/IP Services - High Availability Solutions 18 | 19 | -------------------------------------------------------------------------------- /doc/stonith/README.ibmrsa: -------------------------------------------------------------------------------- 1 | See 2 | 3 | ftp://ftp.software.ibm.com/systems/support/system_x_pdf/d3basmst.pdf 4 | ftp://ftp.software.ibm.com/systems/support/system_x_pdf/88p9248.pdf 5 | http://www.redbooks.ibm.com/abstracts/sg246495.html 6 | 7 | for documentation about IBM management processors and the 8 | IBMmpcli utility. 9 | 10 | -------------------------------------------------------------------------------- /doc/stonith/README.ibmrsa-telnet: -------------------------------------------------------------------------------- 1 | ibmrsa-telnet - External stonith plugin for HAv2 (http://linux-ha.org/wiki) 2 | Connects to IBM RSA Board via telnet and switches power 3 | of server appropriately. 4 | 5 | Description: 6 | 7 | IBM offers Remote Supervisor Adapters II for several 8 | servers. These RSA boards can be accessed in different ways. 9 | One of that is via telnet. Once logged in you can use 'help' to 10 | show all available commands. With 'power' you can reset, power on and 11 | off the controlled server. This command is used in combination 12 | with python's standard library 'telnetlib' to do it automatically. 13 | 14 | Code snippet for cib 15 | 16 | It's useful to give a location preference so that the stonith agent 17 | is run on the/an other node. This is not necessary as one node can kill 18 | itself via RSA Board. But: If this node becomes crazy my experiences 19 | showed that the node is not able to shoot itself anymore properly. 20 | 21 | You have to adjust parameters, scores and timeout values to fit your 22 | HA environment. 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 | -------------------------------------------------------------------------------- /doc/stonith/README.ippower9258: -------------------------------------------------------------------------------- 1 | IP Power 9258 as external stonith device. 2 | ========================================= 3 | 4 | Device Information 5 | ================== 6 | 7 | Warning: 8 | ======== 9 | 10 | Aviosys provides different types and versions of IP Power 9258. 11 | The device is currently available with four or eight power outlets. 12 | This script was tested with firmware version: V1.55 2009/12/22 13 | 14 | Especially "IP Power 9258 HP" uses a different http command interface. 15 | ====================================================================== 16 | 17 | Resources for device documentation: 18 | 19 | Manufacturer URL: http://www.aviosys.com/ippower9258.htm 20 | Manual URL: http://www.aviosys.com/manual.htm 21 | Manual current version URL: 22 | http://www.aviosys.com/images/9258_manual_20081104.pdf 23 | 24 | The documentation of the http command interface defines three 25 | supported commands: 26 | 27 | GetPower - useful for testing status of the device and of each port 28 | SetPower - used to control status of each power outlet 29 | SetSchedule+Power - useless for stonith 30 | 31 | Common documented structure of these three commands is 32 | 33 | http://username:password@a.b.c.d/Set.cmd?CMD=command[+param=value...] 34 | param is one or more of P60 to P67 and value is 0 or 1 35 | expected response for GetPower is of the format 36 | P60=1,P61=0,P62=1,P63=1,P64=0,P65=0,P66=0,P67=0 37 | SetPower does respond with the same format but restricts the list 38 | to the modified ports. 39 | P60 to P67 represent the status of the power outlet 1 to 8: 0 <=> 40 | power off; 1 <=> power on. 41 | 42 | IP Power 9258 allows to assign port names (pw1Name to pw8Name) to each 43 | port. These names can be used with the web interface (web form with 44 | post-method). 45 | 46 | Script specific notes 47 | ===================== 48 | 49 | There is no documented http command to retrieve port names via the 50 | http command interface. We try to get the hostlist via the web 51 | interface. 52 | 53 | This script assumes a one to one mapping between names of hostlist and 54 | port attributes of power outlet: 55 | 56 | 1st hostname in hostlist connected to 1st power outlet with port 57 | status P60 and port name pw1Name. 58 | ... 59 | 8th hostname in hostlist connected to 8th power outlet with port 60 | status P67 and port name pw8Name. 61 | 62 | If the hostlist parameter is not defined, then all assigned outlets 63 | are inserted into the hostlist. Unused outlets should have empty 64 | names. The node names obviously have to match the corresponding outlet 65 | names. A reserved hostname is "*not-defined*". This is a 66 | sript-internal placeholder for unused outlets. It does not appear in 67 | the hostlist. 68 | 69 | -------------------------------------------------------------------------------- /doc/stonith/README.meatware: -------------------------------------------------------------------------------- 1 | 2 | MEATWARE Module for Linux-HA STONITH 3 | 4 | ABOUT: 5 | 6 | This is a port of the "meatware" stomith method found in the GFS 7 | distribution (see http://globalfilesystem.org/) to the Linux-HA 8 | project. It notifies operators if a node needs to be reset and 9 | waits for confirmation. 10 | 11 | USAGE: 12 | 13 | The module can be used like any other stonith module. It will 14 | syslog a message at CRIT level if it needs an operator to power-cycle 15 | a node on its behalf. 16 | To confirm that a manual reset has been done, execute 17 | 18 | "meatclient -c ". 19 | 20 | If you abort the confirmation, the module will report that the reset 21 | has failed. 22 | 23 | AUTHOR: 24 | 25 | Gregor Binder 26 | 27 | -------------------------------------------------------------------------------- /doc/stonith/README.rackpdu: -------------------------------------------------------------------------------- 1 | APC Rack PDU 2 | 3 | The product information pages: 4 | 5 | http://www.apcc.com/products/family/index.cfm?id=70 6 | 7 | The User's Guide: 8 | 9 | http://www.apcmedia.com/salestools/ASTE-6Z6KAV_R1_EN.pdf 10 | 11 | Apparently, an existing http or telnet session will make the 12 | plugin fail. 13 | 14 | In case your nodes are equipped with multiple power supplies, the 15 | PDU supports synchronous operation on multiple outlets on up to 16 | four Switched Rack PDUs. See the User's Guide for more 17 | information on how to setup outlet groups. 18 | 19 | NB: There has been a report by one user that in case a link 20 | between two PDUs in the chain is broken, the PDU returns success 21 | even though it failed. This needs to be verified. 22 | -------------------------------------------------------------------------------- /doc/stonith/README.riloe: -------------------------------------------------------------------------------- 1 | Note for iLO 3 users 2 | 3 | This plugin doesn't support the iLO version 3. Please use ipmilan 4 | or external/ipmi, iLO3 should support IPMI. 5 | 6 | Alain St-Denis wrote the riloe plugin. Here is short usage: 7 | 8 | primitive st0 stonith:external/riloe \ 9 | hostlist=target-node \ 10 | ilo_hostname=ilo-ip-address \ 11 | ilo_user=admin ilo_password=secret ilo_protocol=2.0 12 | 13 | The following additional parameters are available: 14 | 15 | ilo_can_reset: 16 | Set to "1" if the ilo is capable of rebooting the host. 17 | Defaults to '0'. 18 | 19 | ilo_protocol: 20 | Defaults to 1.2. Set to the protocol version ilo supports. 21 | 22 | ilo_powerdown_method: 23 | "button" or "power", the former simulates pressing the 24 | button, the latter pulling the power plug. Defaults to 25 | "power". The "button" method is easier on the host, but 26 | requires ACPI. "power" should be more reliable, but not to 27 | be used excessively for testing. 28 | 29 | ilo_proxyhost (string): Proxy hostname 30 | proxy hostname if required to access ILO board 31 | 32 | ilo_proxyport (string, [3128]): Proxy port 33 | proxy port if required to access ILO board 34 | parameter will be ignored if proxy hostname is not set 35 | 36 | 37 | -------------------------------------------------------------------------------- /doc/stonith/README.vacm: -------------------------------------------------------------------------------- 1 | 20 December 2000 2 | 3 | I (rather poorly) integrated this contributed stonith driver into the 4 | linux-ha-stonith release. There is a problem that needs to be 5 | resolved by autoconf in that the driver will not compile unless 6 | libvacmclient is installed on the system. 7 | 8 | For now, what I've done is included a line in stonith/Makefile that you can 9 | uncomment if you want to compile the vacm stonith module. Look in the 10 | Makefile in this directory for the following lines and do like it says 11 | 12 | 13 | # If you want the VA Linux Cluster stonith module installed, 14 | # uncomment the following line. You must have the vacmclient library 15 | #VACM_STONITH = vacm_stonith.so 16 | 17 | Please direct questions about the operation of the stonith module to 18 | Mike Tilstra (see the announcement to the linux-ha-dev mailing list 19 | attached below.) 20 | 21 | 22 | -Eric. 23 | eric.ayers@compgen.com 24 | 25 | ------------------------------------------------------------------------------ 26 | 27 | From: Mike Tilstra 28 | Sender: linux-ha-dev-admin@lists.tummy.com 29 | To: linux-ha-dev@lists.tummy.com 30 | Subject: [Linux-ha-dev] stonith module for VACM 31 | Date: Tue, 19 Dec 2000 16:41:38 -0600 32 | 33 | This was in need for some testing I'm doing, so I hacked this up quick. It 34 | works for me, but I'm willing to bet there's atleast one bug in it. 35 | 36 | Figured others might like it. 37 | 38 | ... 39 | -- 40 | Mike Tilstra conrad@sistina.com -------------------------------------------------------------------------------- /doc/stonith/README.vcenter: -------------------------------------------------------------------------------- 1 | VMware vCenter/ESX STONITH Module 2 | ================================= 3 | 4 | 1. Intro 5 | -------- 6 | 7 | VMware vCenter/ESX STONITH Module is intended to provide STONITH support to 8 | clusters in VMware Virtual Infrastructures. It is able to deal with virtual 9 | machines running on physically different HostSystems (e.g. ESX/ESXi) by using 10 | VMware vSphere Web Services SDK http://www.vmware.com/support/developer/vc-sdk/ 11 | and connecting directly on each HostSystem or through a VMware vCenter: in this 12 | last case the module locates the specified virtual machine in the Virtual 13 | Infrastructure and performs actions required by cluster policies. 14 | 15 | 2. Software requirements 16 | ------------------------ 17 | 18 | VMware vSphere CLI, which includes both CLI tools and Perl SDK 19 | http://www.vmware.com/support/developer/vcli/ . The plugin has been tested with 20 | version 4.1 http://www.vmware.com/download/download.do?downloadGroup=VCLI41 21 | 22 | 23 | 3. vCenter/ESX authentication settings 24 | -------------------------------------- 25 | 26 | Create the credentials file with credstore_admin.pl: 27 | 28 | /usr/lib/vmware-vcli/apps/general/credstore_admin.pl \ 29 | -s 10.1.1.1 -u myuser -p mypass 30 | 31 | This should create $HOME/.vmware/credstore/vicredentials.xml 32 | Copy it to a system folder, e.g. /etc 33 | 34 | cp -p $HOME/.vmware/credstore/vicredentials.xml /etc 35 | 36 | 37 | 4. Testing 38 | ---------- 39 | 40 | The plugin can be invoked directly to perform a very first connection test 41 | (replace all the provided sample values): 42 | 43 | VI_SERVER=10.1.1.1 \ 44 | VI_CREDSTORE=/etc/vicredentials.xml \ 45 | HOSTLIST="hostname1=vmname1;hostname2=vmname2" \ 46 | RESETPOWERON=0 \ 47 | /usr/lib/stonith/plugins/external/vcenter gethosts 48 | 49 | If everything works correctly you should get: 50 | 51 | hostname1 52 | hostname2 53 | 54 | When invoked in this way, the plugin connects to VI_SERVER, authenticates with 55 | credentials stored in VI_CREDSTORE and tries to retrieve the list of virtual 56 | machines (case insensitive) matching vmname1 and vmname2 (and any other listed). 57 | When finished, it reports the list back by mapping virtual machine names to 58 | hostnames as provided in HOSTLIST. If you see the full list of hostnames as a 59 | result, then everything is going well. If otherwise you are having a partial or 60 | empty list, you have to check parameters. 61 | 62 | You can even test "reset", "off" and "on" commands, to test (carefully!) the 63 | full chain. E.g. 64 | 65 | VI_SERVER=10.1.1.1 \ 66 | VI_CREDSTORE=/etc/vicredentials.xml \ 67 | HOSTLIST="hostname1=vmname1;hostname2=vmname2" \ 68 | RESETPOWERON=0 \ 69 | /usr/lib/stonith/plugins/external/vcenter reset hostname2 70 | 71 | In the above examples the referring infrastructure is a vCenter with several 72 | ESXi nodes. Server IP and credentials are referred to vCenter. 73 | 74 | 5. CRM configuration 75 | -------------------- 76 | 77 | The following is a sample procedure to setup STONITH for an HA 2-node cluster 78 | (replace all the provided sample values): 79 | 80 | crm configure primitive vfencing stonith::external/vcenter params \ 81 | VI_SERVER="10.1.1.1" VI_CREDSTORE="/etc/vicredentials.xml" \ 82 | HOSTLIST="hostname1=vmname1;hostname2=vmname2" RESETPOWERON="0" \ 83 | op monitor interval="60s" 84 | 85 | crm configure clone Fencing vfencing 86 | 87 | crm configure property stonith-enabled="true" 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /hb_report/Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # heartbeat: Linux-HA heartbeat code 3 | # 4 | # Copyright (C) 2001 Michael Moerz 5 | # 6 | # This program is free software; you can redistribute it and/or 7 | # modify it under the terms of the GNU General Public License 8 | # as published by the Free Software Foundation; either version 2 9 | # of the License, or (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, see . 18 | # 19 | MAINTAINERCLEANFILES = Makefile.in 20 | 21 | hanoarchdir = $(datadir)/$(PACKAGE_NAME) 22 | 23 | hanoarch_DATA = utillib.sh ha_cf_support.sh openais_conf_support.sh 24 | 25 | -------------------------------------------------------------------------------- /hb_report/ha_cf_support.sh: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2007 Dejan Muhamedagic 2 | # 3 | # This program is free software; you can redistribute it and/or 4 | # modify it under the terms of the GNU General Public License 5 | # as published by the Free Software Foundation; either version 2 6 | # of the License, or (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this library; if not, see 15 | # 16 | 17 | # 18 | # Stack specific part (heartbeat) 19 | # ha.cf/logd.cf parsing 20 | # 21 | getcfvar() { 22 | [ -f "$CONF" ] || return 23 | sed 's/#.*//' < $CONF | 24 | grep -w "^$1" | 25 | sed 's/^[^[:space:]]*[[:space:]]*//' 26 | } 27 | iscfvarset() { 28 | test "`getcfvar $1`" 29 | } 30 | iscfvartrue() { 31 | getcfvar "$1" | 32 | egrep -qsi "^(true|y|yes|on|1)" 33 | } 34 | uselogd() { 35 | iscfvartrue use_logd && 36 | return 0 # if use_logd true 37 | iscfvarset logfacility || 38 | iscfvarset logfile || 39 | iscfvarset debugfile || 40 | return 0 # or none of the log options set 41 | false 42 | } 43 | get_hb_logvars() { 44 | # unless logfacility is set to none, heartbeat/ha_logd are 45 | # going to log through syslog 46 | HA_LOGFACILITY=`getcfvar logfacility` 47 | [ "" = "$HA_LOGFACILITY" ] && HA_LOGFACILITY=$DEFAULT_HA_LOGFACILITY 48 | [ none = "$HA_LOGFACILITY" ] && HA_LOGFACILITY="" 49 | HA_LOGFILE=`getcfvar logfile` 50 | HA_DEBUGFILE=`getcfvar debugfile` 51 | } 52 | getlogvars() { 53 | HA_LOGFACILITY=${HA_LOGFACILITY:-$DEFAULT_HA_LOGFACILITY} 54 | HA_LOGLEVEL="info" 55 | cfdebug=`getcfvar debug` # prefer debug level if set 56 | isnumber $cfdebug || cfdebug="" 57 | [ "$cfdebug" ] && [ $cfdebug -gt 0 ] && 58 | HA_LOGLEVEL="debug" 59 | if uselogd; then 60 | [ -f "$LOGD_CF" ] || { 61 | debug "logd used but logd.cf not found: using defaults" 62 | return # no configuration: use defaults 63 | } 64 | debug "reading log settings from $LOGD_CF" 65 | get_logd_logvars 66 | else 67 | debug "reading log settings from $CONF" 68 | get_hb_logvars 69 | fi 70 | } 71 | cluster_info() { 72 | echo "heartbeat version: `$HA_BIN/heartbeat -V`" 73 | } 74 | essential_files() { 75 | cat< 2 | # 3 | # This program is free software; you can redistribute it and/or 4 | # modify it under the terms of the GNU General Public License 5 | # as published by the Free Software Foundation; either version 2 6 | # of the License, or (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this library; if not, see 15 | # 16 | 17 | # 18 | # Stack specific part (openais) 19 | # openais.conf/logd.cf parsing 20 | # 21 | # cut out a stanza 22 | getstanza() { 23 | awk -v name="$1" ' 24 | !in_stanza && NF==2 && /^[a-z][a-z]*[[:space:]]*{/ { # stanza start 25 | if ($1 == name) 26 | in_stanza = 1 27 | } 28 | in_stanza { print } 29 | in_stanza && NF==1 && $1 == "}" { exit } 30 | ' 31 | } 32 | # supply stanza in $1 and variable name in $2 33 | # (stanza is optional) 34 | getcfvar() { 35 | [ -f "$CONF" ] || return 36 | sed 's/#.*//' < $CONF | 37 | if [ $# -eq 2 ]; then 38 | getstanza "$1" 39 | shift 1 40 | else 41 | cat 42 | fi | 43 | awk -v varname="$1" ' 44 | NF==2 && match($1,varname":$")==1 { print $2; exit; } 45 | ' 46 | } 47 | iscfvarset() { 48 | test "`getcfvar $1`" 49 | } 50 | iscfvartrue() { 51 | getcfvar $1 $2 | 52 | egrep -qsi "^(true|y|yes|on|1)" 53 | } 54 | uselogd() { 55 | iscfvartrue use_logd 56 | } 57 | get_ais_logvars() { 58 | if iscfvartrue to_file; then 59 | HA_LOGFILE=`getcfvar logfile` 60 | HA_LOGFILE=${HA_LOGFILE:-"syslog"} 61 | HA_DEBUGFILE=$HA_LOGFILE 62 | elif iscfvartrue to_syslog; then 63 | HA_LOGFACILITY=`getcfvar syslog_facility` 64 | HA_LOGFACILITY=${HA_LOGFACILITY:-"daemon"} 65 | fi 66 | } 67 | getlogvars() { 68 | HA_LOGFACILITY=${HA_LOGFACILITY:-$DEFAULT_HA_LOGFACILITY} 69 | HA_LOGLEVEL="info" 70 | iscfvartrue debug && # prefer debug level if set 71 | HA_LOGLEVEL="debug" 72 | if uselogd; then 73 | [ -f "$LOGD_CF" ] || { 74 | debug "logd used but logd.cf not found: using defaults" 75 | return # no configuration: use defaults 76 | } 77 | debug "reading log settings from $LOGD_CF" 78 | get_logd_logvars 79 | else 80 | debug "reading log settings from $CONF" 81 | get_ais_logvars 82 | fi 83 | } 84 | cluster_info() { 85 | : echo "openais version: how?" 86 | if [ "$CONF" = /etc/corosync/corosync.conf ]; then 87 | /usr/sbin/corosync -v 88 | fi 89 | } 90 | essential_files() { 91 | cat<. 16 | # 17 | 18 | MAINTAINERCLEANFILES = Makefile.in 19 | SUBDIRS = clplumbing pils stonith lrm 20 | 21 | idir=$(includedir)/heartbeat 22 | i_HEADERS = compress.h glue_config.h ha_msg.h 23 | 24 | noinst_HEADERS = config.h lha_internal.h replace_uuid.h 25 | -------------------------------------------------------------------------------- /include/clplumbing/Gmain_timeout.h: -------------------------------------------------------------------------------- 1 | #ifndef _CLPLUMBING_GMAIN_TIMEOUT_H 2 | #define _CLPLUMBING_GMAIN_TIMEOUT_H 3 | #include 4 | /* 5 | * Copyright (C) 2002 Alan Robertson 6 | * This software licensed under the GNU LGPL. 7 | * 8 | * 9 | * This library is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU Lesser General Public 11 | * License as published by the Free Software Foundation; either 12 | * version 2.1 of the License, or (at your option) any later version. 13 | * 14 | * This library is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | * Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public 20 | * License along with this library; if not, see 21 | * 22 | */ 23 | /* 24 | * These functions must work correctly even if someone resets the 25 | * time-of-day clock. The g_main_timeout_add() function does not have 26 | * this property, since it relies on gettimeofday(). 27 | * 28 | * Our functions have the same semantics - except they always work ;-) 29 | * 30 | * This is because we use longclock_t for our time values. 31 | */ 32 | guint Gmain_timeout_add(guint interval 33 | , GSourceFunc function 34 | , gpointer data); 35 | 36 | guint Gmain_timeout_add_full(gint priority 37 | , guint interval 38 | , GSourceFunc function 39 | , gpointer data 40 | , GDestroyNotify notify); 41 | 42 | void Gmain_timeout_remove(guint tag); 43 | #endif 44 | -------------------------------------------------------------------------------- /include/clplumbing/Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # linux-ha: Linux-HA heartbeat code 3 | # 4 | # Copyright (C) 2002 International Business Machines. 5 | # Author: Alan Robertson 6 | # 7 | # This program is free software; you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation; either version 2 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with this program; if not, see 19 | 20 | # 21 | MAINTAINERCLEANFILES = Makefile.in 22 | 23 | idir=$(includedir)/clplumbing 24 | 25 | i_HEADERS = \ 26 | Gmain_timeout.h \ 27 | GSource.h \ 28 | GSource_internal.h \ 29 | apphb_cs.h \ 30 | base64.h \ 31 | cl_log.h \ 32 | cl_poll.h \ 33 | cl_signal.h \ 34 | cl_pidfile.h \ 35 | cl_random.h \ 36 | cl_reboot.h \ 37 | cl_syslog.h \ 38 | cl_uuid.h \ 39 | coredumps.h \ 40 | cpulimits.h \ 41 | ipc.h \ 42 | lsb_exitcodes.h \ 43 | loggingdaemon.h \ 44 | longclock.h \ 45 | mkstemp_mode.h \ 46 | netstring.h \ 47 | proctrack.h \ 48 | realtime.h \ 49 | replytrack.h \ 50 | setproctitle.h \ 51 | timers.h \ 52 | uids.h \ 53 | cl_misc.h \ 54 | md5.h \ 55 | cl_plugin.h \ 56 | cl_tiebreaker.h \ 57 | cl_quorum.h \ 58 | cl_quorumd.h 59 | -------------------------------------------------------------------------------- /include/clplumbing/apphb_cs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002 Alan Robertson 3 | * This software licensed under the GNU LGPL. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, see 17 | * 18 | */ 19 | 20 | #ifndef _CLPLUMBING_APPHB_CS_H 21 | #define _CLPLUMBING_APPHB_CS_H 22 | 23 | /* Internal client-server messages for APP heartbeat service */ 24 | 25 | #ifndef HA_VARRUNDIR 26 | #define HA_VARRUNDIR "/var/run" 27 | #endif 28 | #define APPHBSOCKPATH HA_VARRUNDIR "/heartbeat/apphb.comm" 29 | 30 | #define APPHB_TLEN 8 31 | #define APPHB_OLEN 256 32 | 33 | #define REGISTER "reg" 34 | #define UNREGISTER "unreg" 35 | #define HEARTBEAT "hb" 36 | #define SETINTERVAL "setint" 37 | #define SETWARNTIME "setwarn" 38 | #define SETREBOOT "setboot" 39 | 40 | /* 41 | * These messages are really primitive. 42 | * They don't have any form of version control, they're in host byte order, 43 | * and they're all in binary... 44 | * 45 | * Fortunately, this is a very simple local service ;-) 46 | */ 47 | 48 | /* Generic (no parameter) App heartbeat message */ 49 | struct apphb_msg { 50 | char msgtype [APPHB_TLEN]; 51 | }; 52 | 53 | /* App heartbeat Registration message */ 54 | struct apphb_signupmsg { 55 | char msgtype [APPHB_TLEN]; 56 | char appname [APPHB_OLEN]; 57 | char appinstance [APPHB_OLEN]; 58 | char curdir [APPHB_OLEN]; 59 | pid_t pid; 60 | uid_t uid; 61 | gid_t gid; 62 | }; 63 | 64 | /* App heartbeat setinterval / setwarn message */ 65 | struct apphb_msmsg { 66 | char msgtype [APPHB_TLEN]; 67 | unsigned long ms; 68 | }; 69 | 70 | /* App heartbeat server return code (errno) */ 71 | struct apphb_rc { 72 | int rc; 73 | }; 74 | #endif 75 | -------------------------------------------------------------------------------- /include/clplumbing/base64.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This library is free software; you can redistribute it and/or 3 | * modify it under the terms of the GNU Lesser General Public 4 | * License as published by the Free Software Foundation; either 5 | * version 2.1 of the License, or (at your option) any later version. 6 | * 7 | * This library is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 | * Lesser General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU Lesser General Public 13 | * License along with this library; if not, see 14 | */ 15 | 16 | #ifndef _CLPLUMBING_BASE64_H 17 | # define _CLPLUMBING_BASE64_H 18 | /* 19 | * 20 | * Base64 conversion functions. 21 | * They convert from a binary array into a single string 22 | * in base 64. This is almost (but not quite) like section 5.2 of RFC 1341 23 | * The only difference is that we don't care about line lengths. 24 | * We do use their encoding algorithm. 25 | * 26 | */ 27 | 28 | #define B64inunit 3 29 | #define B64outunit 4 30 | 31 | /* How long will the base64 string be for a particular binary object size? */ 32 | /* This is like strlen() and doesn't include the '\0' byte at the end */ 33 | #define B64_stringlen(bytes) \ 34 | ((((bytes)+(B64inunit-1))/B64inunit)*B64outunit) 35 | 36 | /* How many bytes to you need to malloc to store a base64 string? */ 37 | /* (includes space for the '\0' terminator byte) */ 38 | #define B64_stringspace(bytes) (B64_stringlen(bytes)+1) 39 | 40 | /* How many bytes will a base64 string take up back in binary? */ 41 | /* Note: This may be as much as two 2 bytes more than strictly needed */ 42 | #define B64_maxbytelen(slen) (((slen) / B64outunit)*B64inunit) 43 | 44 | /* Returns strlen() of base64 string returned in "output" */ 45 | int binary_to_base64(const void * data, int nbytes, char * output, int outlen); 46 | 47 | /* Returns the size of the binary object we returned in "output" */ 48 | int base64_to_binary(const char * input, int inlen, void * output, int outlen); 49 | #endif 50 | -------------------------------------------------------------------------------- /include/clplumbing/cl_misc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005 Guochun Shi 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, see 16 | */ 17 | 18 | #ifndef _CLPLUMBING_CL_MISC_H 19 | #define _CLPLUMBING_CL_MISC_H 20 | int cl_str_to_boolean(const char*, int*); 21 | 22 | int cl_file_exists(const char* filename); 23 | 24 | char* cl_get_env(const char* env_name); 25 | 26 | int cl_binary_to_int(const char* data, int len); 27 | 28 | long cl_get_msec(const char * input); /* string to msec */ 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /include/clplumbing/cl_pidfile.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This library is free software; you can redistribute it and/or 3 | * modify it under the terms of the GNU Lesser General Public 4 | * License as published by the Free Software Foundation; either 5 | * version 2.1 of the License, or (at your option) any later version. 6 | * 7 | * This library is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 | * Lesser General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU Lesser General Public 13 | * License along with this library; if not, see 14 | */ 15 | 16 | #ifndef _LOCKFILE_H_ 17 | #define _LOCKFILE_H_ 18 | 19 | int cl_read_pidfile(const char *filename); 20 | int cl_read_pidfile_no_checking(const char *filename); 21 | int cl_lock_pidfile(const char *filename); 22 | int cl_unlock_pidfile(const char *filename); 23 | int IsRunning(long pid); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /include/clplumbing/cl_plugin.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | /* 4 | * cl_manage_plugin.c: This file handle plugin loading and deleting 5 | * 6 | * Copyright (C) 2005 Guochun Shi 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this library; if not, see 20 | */ 21 | 22 | #ifndef __CL_PLUGIN__ 23 | #define __CL_PLUGIN__ 24 | 25 | int cl_remove_plugin(const char* type, const char* pluginname); 26 | void* cl_load_plugin(const char* type, const char* pluginname); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /include/clplumbing/cl_poll.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This library is free software; you can redistribute it and/or 3 | * modify it under the terms of the GNU Lesser General Public 4 | * License as published by the Free Software Foundation; either 5 | * version 2.1 of the License, or (at your option) any later version. 6 | * 7 | * This library is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 | * Lesser General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU Lesser General Public 13 | * License along with this library; if not, see 14 | */ 15 | #ifndef CLPLUMBING_CL_POLL_H 16 | # define CLPLUMBING_CL_POLL_H 17 | 18 | #include 19 | #include 20 | 21 | /* 22 | * Poll the file descriptors described by the NFDS structures starting at 23 | * FDS. If TIMEOUT is nonzero and not -1, allow TIMEOUT milliseconds for 24 | * an event to occur; if TIMEOUT is -1, block until an event occurs. 25 | * Returns the number of file descriptors with events, zero if timed out, 26 | * or -1 for errors. 27 | * 28 | * When available, this function uses POSIX signals, and Linux F_SETSIG() 29 | * calls to provide this capability. When it is not available it 30 | * uses the real poll() call. 31 | * 32 | */ 33 | int cl_poll(struct pollfd *fds, unsigned int nfds, int timeout_ms); 34 | 35 | /* 36 | * Call cl_poll_ignore() when you close a file descriptor you monitored 37 | * via cl_poll() before, or if you don't want it monitored any more. 38 | */ 39 | int cl_poll_ignore(int fd); 40 | 41 | /* Select the signal you want us to use (must be a RT signal) */ 42 | int cl_poll_setsig(int nsig); 43 | 44 | int cl_glibpoll(GPollFD* ufds, guint nfsd, gint timeout); 45 | #endif 46 | -------------------------------------------------------------------------------- /include/clplumbing/cl_quorum.h: -------------------------------------------------------------------------------- 1 | /* 2 | * quorum.h: head file for quorum module 3 | * 4 | * Copyright (C) 2005 Guochun Shi 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, see 18 | */ 19 | 20 | #ifndef _QUORUM_H_ 21 | #define _QUORUM_H_ 22 | 23 | #define HB_QUORUM_TYPE quorum 24 | #define HB_QUORUM_TYPE_S "quorum" 25 | 26 | #define QUORUM_YES 0 27 | #define QUORUM_NO 1 28 | #define QUORUM_TIE 2 29 | typedef void(*callback_t)(void); 30 | /* 31 | * List of functions provided by implementations of the quorum interface. 32 | */ 33 | struct hb_quorum_fns { 34 | 35 | int (*getquorum) (const char* cluster 36 | , int member_count, int member_quorum_votes 37 | , int total_node_count, int total_quorum_votes); 38 | int (*init) (callback_t notify, const char* cluster, const char* quorum_server); 39 | void (*stop) (void); 40 | }; 41 | 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /include/clplumbing/cl_quorumd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * quorum.h: head file for quorum module 3 | * 4 | * Author: Huang Zhen 5 | * Copyright (C) 2006 International Business Machines 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, see 19 | */ 20 | 21 | #ifndef _QUORUMD_H_ 22 | #define _QUORUMD_H_ 23 | 24 | #define HB_QUORUMD_TYPE quorumd 25 | #define HB_QUORUMD_TYPE_S "quorumd" 26 | 27 | #define CONFIGFILE HA_HBCONF_DIR"/quorumd.conf" 28 | #define MAX_DN_LEN 256 29 | #define quorum_log(priority, fmt...); \ 30 | cl_log(priority, fmt); \ 31 | 32 | #define quorum_debug(priority, fmt...); \ 33 | if ( debug_level > 0 ) { \ 34 | cl_log(priority, fmt); \ 35 | } 36 | 37 | /* List of functions provided by implementations of the quorumd interface. */ 38 | struct hb_quorumd_fns { 39 | int (*test) (void); 40 | int (*init) (void); 41 | int (*load_config_file) (void); 42 | int (*dump_data) (int priority); 43 | int (*on_connect) (int sock, gnutls_session session, const char* CN); 44 | }; 45 | 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /include/clplumbing/cl_reboot.h: -------------------------------------------------------------------------------- 1 | #ifndef CLPLUMBING_CL_REBOOT_H 2 | #define CLPLUMBING_CL_REBOOT_H 1 3 | #include 4 | void cl_enable_coredump_before_reboot(gboolean yesno); /* not implemented in all OSes */ 5 | void cl_reboot(int msdelaybeforereboot, const char * reason); 6 | #endif 7 | -------------------------------------------------------------------------------- /include/clplumbing/cl_signal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * cl_signal.h: signal handling routines to be used by Linux-HA programmes 3 | * 4 | * Copyright (C) 2002 Horms 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, see 18 | * 19 | */ 20 | #ifndef _CL_SIGNAL_H 21 | #define _CL_SIGNAL_H 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | typedef struct { 28 | int sig; 29 | void (*handler)(int); 30 | int interrupt; 31 | } cl_signal_mode_t; 32 | 33 | #define CL_SIGNAL(_sig, _handler) \ 34 | cl_signal_set_simple_handler((_sig), (_handler), NULL) 35 | #if HAVE_SIGIGNORE 36 | #define CL_IGNORE_SIG(_sig) sigignore((_sig)) 37 | #else 38 | #define CL_IGNORE_SIG(_sig) CL_SIGNAL((_sig), SIG_IGN) 39 | #endif 40 | #define CL_DEFAULT_SIG(_sig) CL_SIGNAL((_sig), SIG_DFL) 41 | 42 | #define CL_SIGINTERRUPT(_sig, _flag) siginterrupt((_sig), (_flag)) 43 | 44 | #define CL_SIGACTION(_signum, _act, _oldact) \ 45 | sigaction((_signum), (_act), (_oldact)) 46 | #define CL_SIGPROCMASK(_how, _set, _oldset) \ 47 | cl_signal_block_set((_how), (_set), (_oldset)) 48 | #define CL_SIGPENDING(_set) sigpending(_set) 49 | #define CL_SIGSUSPEND(_mask) sigsuspend(_mask) 50 | 51 | #define CL_SIGEMPTYSET(_set) sigemptyset(_set) 52 | #define CL_SIGFILLSET(_set) sigfillset(_set) 53 | #define CL_SIGADDSET(_set, _signum) sigaddset((_set), (_signum)) 54 | #define CL_SIGDELSET(_set, _signum) sigdelset((_set), (_signum)) 55 | #define CL_SIGISMEMBER(_set, _signum) sigmember((_set), (_signum)) 56 | 57 | #define CL_KILL(_pid, _sig) kill((_pid), (_sig)) 58 | 59 | #define CL_PID_EXISTS(_pid) ( CL_KILL((_pid), 0) >= 0 || errno != ESRCH ) 60 | 61 | int 62 | cl_signal_set_handler(int sig, void (*handler)(int), sigset_t *mask 63 | , int flags, struct sigaction *oldact); 64 | 65 | int 66 | cl_signal_set_simple_handler(int sig, void (*handler)(int) 67 | , struct sigaction *oldact); 68 | 69 | int 70 | cl_signal_set_action(int sig, void (*action)(int, siginfo_t *, void *) 71 | , sigset_t *mask, int flags, struct sigaction *oldact); 72 | 73 | int 74 | cl_signal_set_simple_action(int sig, void (*action)(int, siginfo_t *, void *) 75 | , struct sigaction *oldact); 76 | 77 | int 78 | cl_signal_set_interrupt(int sig, int flag); 79 | 80 | int 81 | cl_signal_block(int how, int signal, sigset_t *oldset); 82 | 83 | int 84 | cl_signal_block_set(int how, const sigset_t *set, sigset_t *oldset); 85 | 86 | int 87 | cl_signal_set_handler_mode(const cl_signal_mode_t *mode, sigset_t *set); 88 | 89 | 90 | #endif /* _CL_SIGNAL_H */ 91 | -------------------------------------------------------------------------------- /include/clplumbing/cl_syslog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This library is free software; you can redistribute it and/or 3 | * modify it under the terms of the GNU Lesser General Public 4 | * License as published by the Free Software Foundation; either 5 | * version 2.1 of the License, or (at your option) any later version. 6 | * 7 | * This library is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 | * Lesser General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU Lesser General Public 13 | * License along with this library; if not, see 14 | */ 15 | 16 | /* 17 | * Functions to support syslog. 18 | * David Lee (c) 2005 19 | */ 20 | 21 | #ifndef _CLPLUMBING_CL_SYSLOG_H 22 | #define _CLPLUMBING_CL_SYSLOG_H 23 | 24 | /* Convert string "auth" to equivalent number "LOG_AUTH" etc. */ 25 | int cl_syslogfac_str2int(const char *); 26 | 27 | /* Convert number "LOG_AUTH" to equivalent string "auth" etc. */ 28 | /* Returns static string; caller must NOT free. */ 29 | const char *cl_syslogfac_int2str(int); 30 | 31 | #endif /* _CLPLUMBING_CL_SYSLOG_H */ 32 | -------------------------------------------------------------------------------- /include/clplumbing/cl_tiebreaker.h: -------------------------------------------------------------------------------- 1 | /* 2 | * cl_tiebreaker.h: head file for tiebreaker module 3 | * 4 | * Copyright (C) 2005 Guochun Shi 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, see 18 | */ 19 | 20 | #ifndef _CL_TIEBREAKER_H_ 21 | #define _CL_TIEBREAKER_H_ 22 | 23 | #define HB_TIEBREAKER_TYPE tiebreaker 24 | #define HB_TIEBREAKER_TYPE_S "tiebreaker" 25 | 26 | /* 27 | * List of functions provided by implementations of tiebreaker interface. 28 | */ 29 | struct hb_tiebreaker_fns { 30 | gboolean (*break_tie) (int, int); 31 | }; 32 | 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /include/clplumbing/cl_uuid.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This library is free software; you can redistribute it and/or 3 | * modify it under the terms of the GNU Lesser General Public 4 | * License as published by the Free Software Foundation; either 5 | * version 2.1 of the License, or (at your option) any later version. 6 | * 7 | * This library is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 | * Lesser General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU Lesser General Public 13 | * License along with this library; if not, see 14 | */ 15 | 16 | #ifndef _CL_UUID_H_ 17 | #define _CL_UUID_H_ 18 | #include 19 | 20 | typedef struct cl_uuid_s{ 21 | unsigned char uuid[16]; 22 | }cl_uuid_t; 23 | 24 | void cl_uuid_copy(cl_uuid_t* dst, cl_uuid_t* src); 25 | void cl_uuid_clear(cl_uuid_t* uu); 26 | int cl_uuid_compare(const cl_uuid_t* uu1, const cl_uuid_t* uu2); 27 | void cl_uuid_generate(cl_uuid_t* out); 28 | int cl_uuid_is_null(cl_uuid_t* uu); 29 | int cl_uuid_parse( char *in, cl_uuid_t* uu); 30 | #define UU_UNPARSE_SIZEOF 37 /* Including NULL byte */ 31 | void cl_uuid_unparse(const cl_uuid_t* uu, char *out); 32 | 33 | /* Suitable for ues as a GHashFunc from glib */ 34 | guint cl_uuid_g_hash(gconstpointer uuid_ptr); 35 | /* Suitable for ues as a GEqualFunc from glib */ 36 | gboolean cl_uuid_g_equal(gconstpointer uuid_ptr_a, gconstpointer uuid_ptr_b); 37 | 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /include/clplumbing/coredumps.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Basic Core dump control functions. 3 | * 4 | * Copyright (C) 2004 IBM Corporation 5 | * 6 | * This software licensed under the GNU LGPL. 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this library; if not, see 20 | * 21 | */ 22 | #ifndef _CLPLUMBING_COREFILES_H 23 | # define _CLPLUMBING_COREFILES_H 1 24 | /* Set the root directory of our core directory hierarchy */ 25 | int cl_set_corerootdir(const char * dir); 26 | /* Change directory to the directory our core file needs to go in */ 27 | /* Call after you establish the userid you're running under */ 28 | int cl_cdtocoredir(void); 29 | /* Enable/disable core dumps for ourselves and our child processes */ 30 | int cl_enable_coredumps(int truefalse); 31 | void cl_untaint_coredumps(void); 32 | void cl_set_coredump_signal_handler(int nsig); 33 | void cl_set_all_coredump_signal_handlers(void); 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /include/clplumbing/cpulimits.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This library is free software; you can redistribute it and/or 3 | * modify it under the terms of the GNU Lesser General Public 4 | * License as published by the Free Software Foundation; either 5 | * version 2.1 of the License, or (at your option) any later version. 6 | * 7 | * This library is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 | * Lesser General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU Lesser General Public 13 | * License along with this library; if not, see 14 | */ 15 | 16 | /* 17 | * Functions to put limits on CPU consumption. 18 | * This allows us to better catch runaway realtime processes that 19 | * might otherwise hang the whole system. 20 | * 21 | * The process is basically this: 22 | * - Set the CPU percentage limit with cl_cpu_limit_setpercent() 23 | * according to what you expect the CPU percentage to top out at 24 | * measured over an interval at >= 10 seconds 25 | * - Call cl_cpu_limit_ms_interval() to figure out how often to update 26 | * the CPU limit (it returns milliseconds) 27 | * - At least as often as indicated above, call cl_cpu_limit_update() 28 | * to update our current CPU limit. 29 | * 30 | * These limits are approximate, so be a little conservative. 31 | * If you've gone into an infinite loop, it'll likely get caught ;-) 32 | * 33 | * Note that exceeding the soft CPU limits we set here will cause a 34 | * SIGXCPU signal to be sent. 35 | * 36 | * The default action for this signal is to cause a core dump. 37 | * This is a good choice ;-) 38 | * 39 | * As of this writing, this code will never set the soft CPU limit less 40 | * than two seconds, or greater than 10 seconds. 41 | * 42 | * It will currrently return a limit update interval between 10000 and 43 | * 400000 milliseconds. 44 | * 45 | */ 46 | 47 | /* 48 | * Set expected CPU percentage upper bound 49 | */ 50 | int cl_cpu_limit_setpercent(int ipercent); 51 | 52 | /* 53 | * Update the current CPU limit 54 | */ 55 | int cl_cpu_limit_update(void); 56 | 57 | /* 58 | * How often should we call cl_cpu_limit_update()? 59 | * 60 | * Note: return result is in milliseconds 61 | */ 62 | int cl_cpu_limit_ms_interval(void); 63 | 64 | /* Disable further CPU limits... */ 65 | int cl_cpu_limit_disable(void); 66 | -------------------------------------------------------------------------------- /include/clplumbing/loggingdaemon.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This library is free software; you can redistribute it and/or 3 | * modify it under the terms of the GNU Lesser General Public 4 | * License as published by the Free Software Foundation; either 5 | * version 2.1 of the License, or (at your option) any later version. 6 | * 7 | * This library is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 | * Lesser General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU Lesser General Public 13 | * License along with this library; if not, see 14 | */ 15 | 16 | /* Messages sent to the logging daemon */ 17 | #define LD_LOGIT 2 18 | #define MAXENTITY 64 19 | 20 | /* Message contains following header, followed by the text (char[]) itself */ 21 | struct LogDaemonMsgHdr_s { 22 | int msgtype; 23 | int facility; 24 | int priority; 25 | int msglen; 26 | gboolean use_pri_str; 27 | int entity_pid; 28 | char entity[MAXENTITY]; 29 | TIME_T timestamp; 30 | }; 31 | typedef struct LogDaemonMsgHdr_s LogDaemonMsgHdr; 32 | -------------------------------------------------------------------------------- /include/clplumbing/md5.h: -------------------------------------------------------------------------------- 1 | /* 2 | * md5.h: MD5 and keyed-MD5 algorithms 3 | * 4 | * Author: Sun Jiang Dong 5 | * Copyright (c) 2005 International Business Machines 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, see 19 | * 20 | */ 21 | 22 | #ifndef _MD5_H_ 23 | #define _MD5_H__ 24 | 25 | /* 26 | * MD5: The MD5 Message-Digest Algorithm ( RFC 1321 ) 27 | * return value: 0 - success 28 | * <0 - fail 29 | * Note: The digest buffer should be not less than 16. 30 | * 31 | */ 32 | int MD5( const unsigned char *data 33 | , unsigned long data_len 34 | , unsigned char * digest); 35 | 36 | /* 37 | * HMAC: Keyed-Hashing for Message Authentication 38 | * return value: 0 - success 39 | * <0 - fail 40 | * Note: The digest buffer should be not less than 16. 41 | */ 42 | int HMAC( const unsigned char * key 43 | , unsigned int key_len 44 | , const unsigned char * data 45 | , unsigned long data_len 46 | , unsigned char * digest); 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /include/clplumbing/mkstemp_mode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This library is free software; you can redistribute it and/or 3 | * modify it under the terms of the GNU Lesser General Public 4 | * License as published by the Free Software Foundation; either 5 | * version 2.1 of the License, or (at your option) any later version. 6 | * 7 | * This library is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 | * Lesser General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU Lesser General Public 13 | * License along with this library; if not, see 14 | */ 15 | 16 | /* 17 | * A slightly safer version of mkstemp(3) 18 | * 19 | * In this version, the file is initially created mode 0, (using umask) and 20 | * then chmod-ed to the requested permissions after calling mkstemp(3). 21 | * This guarantees that the file is not even momentarily open beyond the 22 | * requested permissions. 23 | * 24 | * Return values: 25 | * 26 | * Like mkstemp, it returns the file descriptor of the open file, or -1 27 | * on error. 28 | * 29 | * In addition to the errno values documented for mkstemp(3), this functio 30 | * can also fail with any of the errno values documented for chmod(2). 31 | * 32 | */ 33 | int mkstemp_mode(char* template, mode_t requested_filemode); 34 | -------------------------------------------------------------------------------- /include/clplumbing/netstring.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Intracluster message object (struct ha_msg) 3 | * 4 | * Copyright (C) 1999, 2000 Guochun Shi 5 | * This software licensed under the GNU LGPL. 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, see 19 | * 20 | */ 21 | 22 | #ifndef NET_STRING_H 23 | #define NET_STRING_H 24 | #include 25 | #include 26 | #include 27 | 28 | extern gboolean cl_msg_quiet_fmterr; 29 | 30 | /* Convert a message to netstring data */ 31 | char* msg2netstring(const struct ha_msg*, size_t*); 32 | char * msg2netstring_noauth(const struct ha_msg *m, size_t * slen); 33 | 34 | /* Convert netstring data to a message */ 35 | struct ha_msg * netstring2msg(const char*, size_t, int); 36 | 37 | /* Is this netstring authentic? */ 38 | int is_auth_netstring(const char* datap, size_t datalen, 39 | const char* authstring, size_t authlen); 40 | 41 | void cl_set_authentication_computation_method(int (*method)(int authmethod 42 | , const void * data 43 | , size_t datalen 44 | , char * authstr 45 | , size_t authlen)); 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /include/clplumbing/realtime.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This library is free software; you can redistribute it and/or 3 | * modify it under the terms of the GNU Lesser General Public 4 | * License as published by the Free Software Foundation; either 5 | * version 2.1 of the License, or (at your option) any later version. 6 | * 7 | * This library is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 | * Lesser General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU Lesser General Public 13 | * License along with this library; if not, see 14 | */ 15 | 16 | #ifndef _CLPLUMBING_REALTIME_H 17 | # define _CLPLUMBING_REALTIME_H 18 | # include 19 | 20 | #if defined(SCHED_RR) && defined(_POSIX_PRIORITY_SCHEDULING) && !defined(ON_DARWIN) 21 | # define DEFAULT_REALTIME_POLICY SCHED_RR 22 | #endif 23 | 24 | /* 25 | * 26 | * make_realtime() will make the current process a soft realtime process 27 | * and lock it into memory after growing the heap by heapgrowK*1024 bytes 28 | * 29 | * If you set spolicy or priority to <= 0, then defaults will be used. 30 | * Otherwise you need to use a value for spolicy from 31 | * and use an appropriate priority for the given spolicy. 32 | * 33 | * WARNING: badly behaved programs which use the make_realtime() function 34 | * can easily hang the machine. 35 | */ 36 | 37 | void cl_make_realtime 38 | ( int spolicy, /* SCHED_RR or SCHED_FIFO (or SCHED_OTHER) */ 39 | int priority, /* typically 1-99 */ 40 | int stackgrowK, /* Amount to grow stack by */ 41 | int heapgrowK /* Amount to grow heap by */ 42 | ); 43 | 44 | void cl_make_normaltime(void); 45 | 46 | /* Cause calls to make_realtime() to be ignored */ 47 | void cl_disable_realtime(void); 48 | 49 | /* Cause calls to make_realtime() to be accepted. 50 | * This is the default behaviour */ 51 | void cl_enable_realtime(void); 52 | 53 | /* Sleep a really short (the shortest) time */ 54 | int cl_shortsleep(void); 55 | 56 | /* Print messages if we've done (more) non-realtime mallocs */ 57 | void cl_realtime_malloc_check(void); 58 | 59 | /* Number of times we "go to the well" for memory after becoming realtime */ 60 | int cl_nonrealtime_malloc_count(void); 61 | /* Number of bytes we "got from the well" for memory after becoming realtime */ 62 | unsigned long cl_nonrealtime_malloc_size(void); 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /include/clplumbing/setproctitle.h: -------------------------------------------------------------------------------- 1 | /* 2 | * setproctitle.h 3 | * 4 | * The code in this file, setproctitle.h is heavily based on code from 5 | * proftpd, please see the licening information below. 6 | * 7 | * This file added to the heartbeat tree by Horms 8 | * 9 | * Code to portably change the title of a programme as displayed 10 | * by ps(1). 11 | * 12 | * heartbeat: Linux-HA heartbeat code 13 | * 14 | * Copyright (C) 1999,2000,2001 Alan Robertson 15 | * 16 | * This program is free software; you can redistribute it and/or 17 | * modify it under the terms of the GNU General Public License 18 | * as published by the Free Software Foundation; either version 2 19 | * of the License, or (at your option) any later version. 20 | * 21 | * This program is distributed in the hope that it will be useful, 22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24 | * GNU General Public License for more details. 25 | * 26 | * You should have received a copy of the GNU General Public License 27 | * along with this program; if not, see . 28 | */ 29 | 30 | /* 31 | * ProFTPD - FTP server daemon 32 | * Copyright (c) 1997, 1998 Public Flood Software 33 | * Copyright (C) 1999, 2000 MacGyver aka Habeeb J. Dihu 34 | * 35 | * This program is free software; you can redistribute it and/or modify 36 | * it under the terms of the GNU General Public License as published by 37 | * the Free Software Foundation; either version 2 of the License, or 38 | * (at your option) any later version. 39 | * 40 | * This program is distributed in the hope that it will be useful, 41 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 42 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 43 | * GNU General Public License for more details. 44 | * 45 | * You should have received a copy of the GNU General Public License 46 | * along with this program; if not, see . 47 | * 48 | * As a special exemption, Public Flood Software/MacGyver aka Habeeb J. Dihu 49 | * and other respective copyright holders give permission to link this program 50 | * with OpenSSL, and distribute the resulting executable, without including 51 | * the source code for OpenSSL in the source distribution. 52 | */ 53 | 54 | #ifndef _HA_SETPROCTITLE_H 55 | #define _HA_SETPROCTITLE_H 56 | 57 | #include 58 | int init_set_proc_title(int argc, char *argv[], char *envp[]); 59 | 60 | void set_proc_title(const char *fmt,...) G_GNUC_PRINTF(1,2); 61 | 62 | #endif /* _HA_SETPROCTITLE_H */ 63 | -------------------------------------------------------------------------------- /include/clplumbing/timers.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This library is free software; you can redistribute it and/or 3 | * modify it under the terms of the GNU Lesser General Public 4 | * License as published by the Free Software Foundation; either 5 | * version 2.1 of the License, or (at your option) any later version. 6 | * 7 | * This library is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 | * Lesser General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU Lesser General Public 13 | * License along with this library; if not, see 14 | */ 15 | 16 | #ifndef _CLPLUMBING_TIMERS_H 17 | # define _CLPLUMBING_TIMERS_H 18 | int setmsrepeattimer(long ms); 19 | int setmsalarm(long ms); 20 | int cancelmstimer(void); 21 | long mssleep(long ms); 22 | #endif 23 | -------------------------------------------------------------------------------- /include/clplumbing/uids.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This library is free software; you can redistribute it and/or 3 | * modify it under the terms of the GNU Lesser General Public 4 | * License as published by the Free Software Foundation; either 5 | * version 2.1 of the License, or (at your option) any later version. 6 | * 7 | * This library is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 | * Lesser General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU Lesser General Public 13 | * License along with this library; if not, see 14 | */ 15 | 16 | #ifndef CLPLUMBING_UIDS_H 17 | # define CLPLUMBING_UIDS_H 18 | #include 19 | 20 | /* Tell us who you want to be - or zero for nobody */ 21 | int drop_privs(uid_t uid, gid_t gid); 22 | 23 | /* Return to original privileged state */ 24 | int return_to_orig_privs(void); 25 | 26 | /* Drop down to (probably nobody) privileges again */ 27 | int return_to_dropped_privs(void); 28 | 29 | /* Return TRUE if we have full privileges at the moment */ 30 | int cl_have_full_privs(void); 31 | #endif 32 | -------------------------------------------------------------------------------- /include/compress.h: -------------------------------------------------------------------------------- 1 | /* 2 | * compress.h: Compression functions for Linux-HA 3 | * 4 | * Copyright (C) 2005 Guochun Shi 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, see 18 | */ 19 | 20 | #ifndef _COMPRESS_H_ 21 | #define _COMPRESS_H_ 22 | 23 | #define HB_COMPRESS_TYPE compress 24 | #define HB_COMPRESS_TYPE_S "compress" 25 | 26 | /* 27 | * List of functions provided by implementations of the heartbeat 28 | * compress interface. 29 | */ 30 | struct hb_compress_fns { 31 | int (*compress) (char*, size_t*, const char*, size_t); 32 | int (*decompress) (char*, size_t* , const char*, size_t); 33 | const char* (*getname) (void); 34 | }; 35 | 36 | struct ha_msg; 37 | 38 | /* set the compression method*/ 39 | int cl_compress_remove_plugin(const char* pluginname); 40 | int cl_compress_load_plugin(const char* pluginname); 41 | struct hb_compress_fns* cl_get_compress_fns(void); 42 | int cl_set_compress_fns(const char*); 43 | char* cl_compressmsg(struct ha_msg*m, size_t* len); 44 | struct ha_msg* cl_decompressmsg(struct ha_msg* m); 45 | gboolean is_compressed_msg(struct ha_msg* m); 46 | int cl_compress_field(struct ha_msg* msg, int index, char* buf, size_t* buflen); 47 | int cl_decompress_field(struct ha_msg* msg, int index, char* buf, size_t* buflen); 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /include/glue_config.h.in: -------------------------------------------------------------------------------- 1 | /* include/config.h.in. Generated from configure.in by autoheader. */ 2 | 3 | /* Location for daemons */ 4 | #undef GLUE_DAEMON_DIR 5 | 6 | /* Group to run daemons as */ 7 | #undef GLUE_DAEMON_GROUP 8 | 9 | /* User to run daemons as */ 10 | #undef GLUE_DAEMON_USER 11 | 12 | /* Where to keep state files and sockets */ 13 | #undef GLUE_STATE_DIR 14 | 15 | /* Location of shared data */ 16 | #undef GLUE_SHARED_DIR 17 | 18 | /* User to run daemons as */ 19 | #undef HA_CCMUSER 20 | 21 | /* Group to run daemons as */ 22 | #undef HA_APIGROUP 23 | 24 | /* Location for daemons */ 25 | #undef HA_LIBHBDIR 26 | 27 | /* top directory of area to drop core files in */ 28 | #undef HA_COREDIR 29 | 30 | /* top directory for LRM related files */ 31 | #undef LRM_VARLIBDIR 32 | 33 | /* CIB secrets */ 34 | #undef LRM_CIBSECRETS 35 | 36 | /* Logging Daemon IPC socket name */ 37 | #undef HA_LOGDAEMON_IPC 38 | 39 | /* Default logging facility */ 40 | #undef HA_LOG_FACILITY 41 | 42 | /* Default plugin search path */ 43 | #undef PILS_BASE_PLUGINDIR 44 | 45 | /* Where to find plugins */ 46 | #undef HA_PLUGIN_DIR 47 | 48 | /* Location of system configuration files */ 49 | #undef HA_SYSCONFDIR 50 | 51 | /* Web site base URL */ 52 | #undef HA_URLBASE 53 | 54 | /* Whatever this used to mean */ 55 | #undef HA_VARLIBHBDIR 56 | 57 | #undef HA_VARLIBDIR 58 | 59 | /* System lock directory */ 60 | #undef HA_VARLOCKDIR 61 | 62 | /* Where Heartbeat keeps state files and sockets - old name */ 63 | #undef HA_VARRUNDIR 64 | 65 | /* Location for v1 Heartbeat RAs */ 66 | #undef HB_RA_DIR 67 | 68 | /* Where to find LRM plugins */ 69 | #undef LRM_PLUGIN_DIR 70 | 71 | /* Location for LSB RAs */ 72 | #undef LSB_RA_DIR 73 | 74 | /* Location for OCF RAs */ 75 | #undef OCF_RA_DIR 76 | 77 | /* OCF root directory - specified by the OCF standard */ 78 | #undef OCF_ROOT_DIR 79 | 80 | /* Compiling for Darwin platform */ 81 | #undef ON_DARWIN 82 | 83 | /* Compiling for Linux platform */ 84 | #undef ON_LINUX 85 | 86 | /* Current glue version */ 87 | #undef GLUE_VERSION 88 | 89 | /* Build version */ 90 | #undef GLUE_BUILD_VERSION 91 | 92 | /* Location of non-pluing stonith scripts */ 93 | #undef STONITH_EXT_PLUGINDIR 94 | 95 | /* Location of RHCS stonith scripts */ 96 | #undef STONITH_RHCS_PLUGINDIR 97 | 98 | /* Location of stonith plugins */ 99 | #undef STONITH_MODULES 100 | 101 | /* Stonith plugin domain */ 102 | #undef ST_TEXTDOMAIN 103 | 104 | #undef HA_HBCONF_DIR 105 | -------------------------------------------------------------------------------- /include/lrm/Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # Author: Sun Jiang Dong 3 | # Copyright (c) 2004 International Business Machines 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # as published by the Free Software Foundation; either version 2 8 | # of the License, or (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program; if not, see . 17 | # 18 | MAINTAINERCLEANFILES = Makefile.in 19 | 20 | idir=$(includedir)/heartbeat/lrm 21 | i_HEADERS = lrm_api.h lrm_msg.h racommon.h raexec.h 22 | -------------------------------------------------------------------------------- /include/lrm/racommon.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Author: Sun Jiang Dong 3 | * Copyright (c) 2004 International Business Machines 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, see 17 | */ 18 | 19 | #ifndef RACOMMON_H 20 | #define RACOMMON_H 21 | 22 | void get_ra_pathname(const char* class_path, const char* type, const char* provider, char pathname[]); 23 | gboolean filtered(char * file_name); 24 | int get_runnable_list(const char* class_path, GList ** rsc_info); 25 | int get_failed_exec_rc(void); 26 | void closefiles(void); 27 | 28 | #endif /* RACOMMON_H */ 29 | -------------------------------------------------------------------------------- /include/pils/Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # linux-ha: Linux-HA heartbeat code 3 | # 4 | # Copyright (C) 2001 Michael Moerz 5 | # This instance created by Horms 6 | # 7 | # This program is free software; you can redistribute it and/or 8 | # modify it under the terms of the GNU General Public License 9 | # as published by the Free Software Foundation; either version 2 10 | # of the License, or (at your option) any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with this program; if not, see . 19 | # 20 | MAINTAINERCLEANFILES = Makefile.in 21 | 22 | idir=$(includedir)/pils 23 | 24 | i_HEADERS = generic.h interface.h plugin.h 25 | -------------------------------------------------------------------------------- /include/replace_uuid.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This library is free software; you can redistribute it and/or 3 | * modify it under the terms of the GNU Lesser General Public 4 | * License as published by the Free Software Foundation; either 5 | * version 2.1 of the License, or (at your option) any later version. 6 | * 7 | * This library is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 | * Lesser General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU Lesser General Public 13 | * License along with this library; if not, see 14 | */ 15 | 16 | /* 17 | * uuid: wrapper declarations. 18 | * 19 | * heartbeat originally used "uuid" functionality by calling directly, 20 | * and only, onto the "e2fsprogs" implementation. 21 | * 22 | * The run-time usages in the code have since been abstracted, funnelled 23 | * through a thin, common interface layer: a Good Thing. 24 | * 25 | * Similarly, the compile-time usages of "include " are 26 | * replaced, being funnelled through a reference to this header file. 27 | * 28 | * This header file interfaces onto the actual underlying implementation. 29 | * In the case of the "e2fsprogs" implementation, it is simply a stepping 30 | * stone onto "". As other implementations are accommodated, 31 | * so their header requirements can be accommodated here. 32 | * 33 | * Copyright (C) 2004 David Lee 34 | */ 35 | 36 | #ifndef REPLACE_UUID_H 37 | #define REPLACE_UUID_H 38 | 39 | typedef unsigned char uuid_t[16]; 40 | void uuid_clear(uuid_t uu); 41 | int uuid_compare(const uuid_t uu1, const uuid_t uu2); 42 | void uuid_copy(uuid_t dst, const uuid_t src); 43 | void uuid_generate(uuid_t out); 44 | void uuid_generate_random(uuid_t out); 45 | int uuid_is_null(const uuid_t uu); 46 | int uuid_parse(const char *in, uuid_t uu); 47 | void uuid_unparse(const uuid_t uu, char *out); 48 | 49 | #endif /* REPLACE_UUID_H */ 50 | -------------------------------------------------------------------------------- /include/stonith/Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # linux-ha: Linux-HA heartbeat code 3 | # 4 | # Copyright (C) 2001 Michael Moerz 5 | # This instance created by Horms 6 | # 7 | # This program is free software; you can redistribute it and/or 8 | # modify it under the terms of the GNU General Public License 9 | # as published by the Free Software Foundation; either version 2 10 | # of the License, or (at your option) any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with this program; if not, see . 19 | # 20 | MAINTAINERCLEANFILES = Makefile.in 21 | 22 | idir=$(includedir)/stonith 23 | 24 | i_HEADERS = expect.h stonith.h stonith_plugin.h st_ttylock.h 25 | -------------------------------------------------------------------------------- /include/stonith/expect.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Expect simple tokens. Simple expect infrastructure for STONITH API 3 | * 4 | * Copyright (c) 2000 Alan Robertson 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, see 18 | * 19 | */ 20 | 21 | #ifndef __EXPECT_H 22 | # define __EXPECT_H 23 | /* 24 | * If we find any of the given tokens in the input stream, 25 | * we return it's "toktype", so we can tell which one was 26 | * found. 27 | * 28 | */ 29 | 30 | struct Etoken { 31 | const char * string; /* The token to look for */ 32 | int toktype; /* The type to return on match */ 33 | int matchto; /* Modified during matches */ 34 | }; 35 | 36 | int ExpectToken(int fd 37 | , struct Etoken * toklist /* List of tokens to match against */ 38 | /* Final token has NULL string */ 39 | , int to_secs /* Timeout value in seconds */ 40 | , char * buf /* If non-NULL, then all the text 41 | * matched/skipped over by this match */ 42 | , int maxline, 43 | , int debug); /* debug level */ 44 | 45 | 46 | /* 47 | * A handy little routine. It runs the given process 48 | * with it's standard output redirected into our *readfd, and 49 | * its standard input redirected from our *writefd 50 | * 51 | * Doing this with all the pipes, etc. required for doing this 52 | * is harder than it sounds :-) 53 | */ 54 | 55 | int StartProcess(const char * cmd, int* readfd, int* writefd); 56 | 57 | #ifndef EOS 58 | # define EOS '\0' 59 | #endif 60 | #endif /*__EXPECT_H*/ 61 | -------------------------------------------------------------------------------- /include/stonith/st_ttylock.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This library is free software; you can redistribute it and/or 3 | * modify it under the terms of the GNU Lesser General Public 4 | * License as published by the Free Software Foundation; either 5 | * version 2.1 of the License, or (at your option) any later version. 6 | * 7 | * This library is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 | * Lesser General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU Lesser General Public 13 | * License along with this library; if not, see 14 | */ 15 | 16 | #ifndef __STONITH_ST_TTYLOCK_H 17 | # define __STONITH_ST_TTYLOCK_H 18 | int st_ttylock(const char *serial_device); 19 | int st_ttyunlock(const char *serial_device); 20 | #endif /*__STONITH_ST_TTYLOCK_H*/ 21 | -------------------------------------------------------------------------------- /lib/Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2008 Andrew Beekhof 3 | # 4 | # This program is free software; you can redistribute it and/or 5 | # modify it under the terms of the GNU General Public License 6 | # as published by the Free Software Foundation; either version 2 7 | # of the License, or (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program; if not, see . 16 | # 17 | 18 | MAINTAINERCLEANFILES = Makefile.in 19 | SUBDIRS = pils clplumbing lrm stonith plugins 20 | -------------------------------------------------------------------------------- /lib/clplumbing/cl_reboot.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #ifdef HAVE_UNISTD_H 4 | # include 5 | #endif 6 | #ifdef HAVE_SYS_REBOOT_H 7 | # include 8 | #endif 9 | #ifdef HAVE_STDLIB_H 10 | # include 11 | #endif 12 | #include 13 | #include 14 | 15 | enum rebootopt { 16 | REBOOT_DEFAULT = 0, 17 | REBOOT_NOCOREDUMP = 1, 18 | REBOOT_COREDUMP = 2, 19 | }; 20 | static enum rebootopt coredump = REBOOT_DEFAULT; 21 | 22 | void 23 | cl_enable_coredump_before_reboot(gboolean yesno) 24 | { 25 | coredump = (yesno ? REBOOT_COREDUMP : REBOOT_NOCOREDUMP); 26 | } 27 | 28 | 29 | void cl_reboot(int msdelaybeforereboot, const char * reason) 30 | { 31 | int rebootflag = 0; 32 | int systemrc = 0; 33 | #ifdef RB_AUTOBOOT 34 | rebootflag = RB_AUTOBOOT; 35 | #endif 36 | #ifdef RB_NOSYNC 37 | rebootflag = RB_NOSYNC; 38 | #endif 39 | #ifdef RB_DUMP 40 | if (coredump == REBOOT_COREDUMP) { 41 | rebootflag = RB_DUMP; 42 | } 43 | #endif 44 | cl_log(LOG_EMERG, "Rebooting system. Reason: %s", reason); 45 | sync(); 46 | mssleep(msdelaybeforereboot); 47 | #if REBOOT_ARGS == 1 48 | reboot(rebootflag); 49 | #elif REBOOT_ARGS == 2 50 | reboot(rebootflag, NULL); 51 | #else 52 | #error "reboot() call needs to take one or two args" 53 | #endif 54 | /* Shouldn't ever get here, but just in case... */ 55 | systemrc=system(REBOOT " " REBOOT_OPTIONS); 56 | cl_log(LOG_EMERG, "ALL REBOOT OPTIONS FAILED: %s returned %d" 57 | , REBOOT " " REBOOT_OPTIONS, systemrc); 58 | exit(1); 59 | } 60 | -------------------------------------------------------------------------------- /lib/clplumbing/ipctransient.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 Andrew Beekhof 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, see 16 | */ 17 | #undef _GNU_SOURCE /* in case it was defined on the command line */ 18 | #define _GNU_SOURCE 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | #define MAXERRORS 1000 38 | #define MAX_IPC_FAIL 10 39 | #define FIFO_LEN 1024 40 | 41 | extern const char *procname; 42 | 43 | extern const char *commdir; 44 | 45 | void trans_getargs(int argc, char **argv); 46 | 47 | void default_ipctest_input_destroy(gpointer user_data); 48 | 49 | IPC_Message * create_simple_message(const char *text, IPC_Channel *ch); 50 | -------------------------------------------------------------------------------- /lib/clplumbing/ipctransientlib.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2004 Andrew Beekhof 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, see 16 | */ 17 | 18 | #include 19 | 20 | /* for basename() on some OSes (e.g. Solaris) */ 21 | #include 22 | 23 | #define WORKING_DIR HA_VARLIBHBDIR 24 | 25 | const char *procname = NULL; 26 | 27 | const char *commdir = WORKING_DIR; 28 | 29 | void 30 | trans_getargs(int argc, char **argv) 31 | { 32 | int argflag, argerrs; 33 | 34 | procname = basename(argv[0]); 35 | 36 | argerrs = 0; 37 | while ((argflag = getopt(argc, argv, "C:")) != EOF) { 38 | switch (argflag) { 39 | case 'C': /* directory to commpath */ 40 | commdir = optarg; 41 | break; 42 | default: 43 | argerrs++; 44 | break; 45 | } 46 | } 47 | if (argerrs) { 48 | fprintf(stderr, 49 | "Usage: %s [-C commdir]\n" 50 | "\t-C : directory to commpath (default %s)\n", 51 | procname, WORKING_DIR); 52 | exit(1); 53 | } 54 | 55 | } 56 | 57 | void 58 | default_ipctest_input_destroy(gpointer user_data) 59 | { 60 | cl_log(LOG_INFO, "default_ipctest_input_destroy:received HUP"); 61 | } 62 | 63 | IPC_Message * 64 | create_simple_message(const char *text, IPC_Channel *ch) 65 | { 66 | IPC_Message *ack_msg = NULL; 67 | char *copy_text = NULL; 68 | 69 | if(text == NULL) { 70 | cl_log(LOG_ERR, "ERROR: can't create IPC_Message with no text"); 71 | return NULL; 72 | } else if(ch == NULL) { 73 | cl_log(LOG_ERR, "ERROR: can't create IPC_Message with no channel"); 74 | return NULL; 75 | } 76 | 77 | ack_msg = (IPC_Message *)malloc(sizeof(IPC_Message)); 78 | if (ack_msg == NULL){ 79 | cl_log(LOG_ERR, "create_simple_message:" 80 | "allocating memory for IPC_Message failed"); 81 | return NULL; 82 | } 83 | 84 | memset(ack_msg, 0, sizeof(IPC_Message)); 85 | 86 | copy_text = strdup(text); 87 | 88 | ack_msg->msg_private = NULL; 89 | ack_msg->msg_done = NULL; 90 | ack_msg->msg_body = copy_text; 91 | ack_msg->msg_ch = ch; 92 | 93 | ack_msg->msg_len = strlen(text)+1; 94 | 95 | return ack_msg; 96 | } 97 | -------------------------------------------------------------------------------- /lib/clplumbing/mkstemp_mode.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This library is free software; you can redistribute it and/or 3 | * modify it under the terms of the GNU Lesser General Public 4 | * License as published by the Free Software Foundation; either 5 | * version 2.1 of the License, or (at your option) any later version. 6 | * 7 | * This library is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 | * Lesser General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU Lesser General Public 13 | * License along with this library; if not, see 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | 25 | /* 26 | * A slightly safer version of mkstemp(3) 27 | * 28 | * In this version, the file is initially created mode 0, and then chmod-ed 29 | * to the requested permissions. This guarantees that the file is never 30 | * open to others beyond the specified permissions at any time. 31 | */ 32 | int 33 | mkstemp_mode(char* template, mode_t filemode) 34 | { 35 | 36 | mode_t maskval; 37 | int fd; 38 | 39 | maskval = umask(0777); 40 | 41 | /* created file should now be mode 0000 */ 42 | fd = mkstemp(template); 43 | 44 | umask(maskval); /* cannot fail :-) */ 45 | 46 | if (fd >= 0) { 47 | if (chmod(template, filemode) < 0) { 48 | int save = errno; 49 | close(fd); 50 | errno = save; 51 | fd = -1; 52 | } 53 | } 54 | return fd; 55 | } 56 | -------------------------------------------------------------------------------- /lib/clplumbing/timers.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This library is free software; you can redistribute it and/or 3 | * modify it under the terms of the GNU Lesser General Public 4 | * License as published by the Free Software Foundation; either 5 | * version 2.1 of the License, or (at your option) any later version. 6 | * 7 | * This library is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 | * Lesser General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU Lesser General Public 13 | * License along with this library; if not, see 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | int 28 | setmsrepeattimer(long ms) 29 | { 30 | long secs = ms / 1000L; 31 | long usecs = (ms % 1000L)*1000L; 32 | struct itimerval nexttime = 33 | { {secs, usecs} /* Repeat Interval */ 34 | , {secs, usecs} /* Timer Value */ 35 | }; 36 | 37 | #if 0 38 | cl_log(LOG_DEBUG, "Setting repeating timer for %ld ms" 39 | , ms); 40 | #endif 41 | 42 | 43 | /* Is this right??? */ 44 | CL_IGNORE_SIG(SIGALRM); 45 | return setitimer(ITIMER_REAL, &nexttime, NULL); 46 | } 47 | 48 | int 49 | setmsalarm(long ms) 50 | { 51 | long secs = ms / 1000L; 52 | long usecs = (ms % 1000L)*1000L; 53 | struct itimerval nexttime = 54 | { {0L, 0L} /* Repeat Interval */ 55 | , {secs, usecs} /* Timer Value */ 56 | }; 57 | 58 | return setitimer(ITIMER_REAL, &nexttime, NULL); 59 | } 60 | 61 | int 62 | cancelmstimer(void) 63 | { 64 | struct itimerval nexttime = 65 | { {0L, 0L} /* Repeat Interval */ 66 | , {0L, 0L} /* Timer Value */ 67 | }; 68 | return setitimer(ITIMER_REAL, &nexttime, NULL); 69 | } 70 | 71 | 72 | static int alarmpopped = 0; 73 | 74 | static void 75 | st_timer_handler(int nsig) 76 | { 77 | ++alarmpopped; 78 | } 79 | 80 | /* 81 | * Pretty simple: 82 | * 1) Set up SIGALRM signal handler 83 | * 2) set alarmpopped to FALSE; 84 | * 2) Record current time 85 | * 3) Call setmsalarm(ms) 86 | * 4) Call pause(2) 87 | * 5) Call cancelmstimer() 88 | * 6) Reset signal handler 89 | * 7) See if SIGALRM happened 90 | * if so: return zero 91 | * if not: get current time, and compute milliseconds left 'til signal 92 | * should arrive, and return that... 93 | */ 94 | long 95 | mssleep(long ms) 96 | { 97 | struct sigaction saveaction; 98 | longclock_t start; 99 | longclock_t finish; 100 | unsigned long elapsedms; 101 | 102 | memset(&saveaction, 0, sizeof(saveaction)); 103 | 104 | cl_signal_set_simple_handler(SIGALRM, st_timer_handler, &saveaction); 105 | alarmpopped = 0; 106 | start = time_longclock(); 107 | setmsalarm(ms); 108 | pause(); 109 | cancelmstimer(); 110 | cl_signal_set_simple_handler(SIGALRM, saveaction.sa_handler, &saveaction); 111 | if (alarmpopped) { 112 | return 0; 113 | } 114 | 115 | finish = time_longclock(); 116 | elapsedms = longclockto_ms(sub_longclock(finish, start)); 117 | return ms - elapsedms; 118 | } 119 | -------------------------------------------------------------------------------- /lib/lrm/Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # Author: Sun Jiang Dong 3 | # Copyright (c) 2004 International Business Machines 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # as published by the Free Software Foundation; either version 2 8 | # of the License, or (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program; if not, see . 17 | # 18 | MAINTAINERCLEANFILES = Makefile.in 19 | 20 | AM_CPPFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include \ 21 | -I$(top_builddir)/libltdl -I$(top_srcdir)/libltdl 22 | 23 | lrmdir = $(localstatedir)/lib/heartbeat/lrm 24 | COMMONLIBS = $(top_builddir)/lib/clplumbing/libplumb.la \ 25 | $(GLIBLIB) 26 | 27 | lib_LTLIBRARIES = liblrm.la 28 | liblrm_la_SOURCES = lrm_msg.c clientlib.c racommon.c 29 | liblrm_la_LDFLAGS = -version-info 2:0:0 $(COMMONLIBS) 30 | liblrm_la_CFLAGS = $(INCLUDES) 31 | 32 | install-exec-local: 33 | $(mkinstalldirs) $(DESTDIR)$(lrmdir) 34 | -chgrp $(GLUE_DAEMON_GROUP) $(DESTDIR)/$(lrmdir) 35 | chmod 770 $(DESTDIR)/$(lrmdir) 36 | -------------------------------------------------------------------------------- /lib/pils/Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # pils: Linux-HA heartbeat code 3 | # 4 | # Copyright (C) 2001 Alan Robertson 5 | # 6 | # This program is free software; you can redistribute it and/or 7 | # modify it under the terms of the GNU General Public License 8 | # as published by the Free Software Foundation; either version 2 9 | # of the License, or (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, see . 18 | # 19 | MAINTAINERCLEANFILES = Makefile.in 20 | 21 | AM_CPPFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include \ 22 | -I$(top_builddir)/linux-ha -I$(top_srcdir)/linux-ha \ 23 | -I$(top_builddir)/libltdl -I$(top_srcdir)/libltdl 24 | 25 | 26 | AM_CFLAGS = @CFLAGS@ 27 | 28 | ## include files 29 | #pkginclude_HEADERS = $(top_srcdir)/include/pils/plugin.h \ 30 | # $(top_srcdir)/include/pils/interface.h 31 | 32 | ## binaries 33 | #sbin_PROGRAMS = main 34 | 35 | 36 | #main_SOURCES = main.c 37 | 38 | #main_LDADD = libpils.la @LIBLTDL@ \ 39 | # $(GLIBLIB) \ 40 | # $(top_builddir)/replace/libreplace.la 41 | #main_LDFLAGS = @LIBADD_DL@ @LIBLTDL@ -export-dynamic @DLOPEN_FORCE_FLAGS@ 42 | 43 | 44 | ## libraries 45 | 46 | lib_LTLIBRARIES = libpils.la 47 | 48 | plugindir = $(libdir)/@HB_PKG@/plugins/test 49 | plugin_LTLIBRARIES = test.la 50 | 51 | libpils_la_SOURCES = pils.c 52 | libpils_la_LDFLAGS = -version-info 2:0:0 53 | libpils_la_LIBADD = $(top_builddir)/replace/libreplace.la \ 54 | @LIBLTDL@ $(GLIBLIB) 55 | test_la_SOURCES = test.c 56 | test_la_LDFLAGS = -export-dynamic -module -avoid-version 57 | -------------------------------------------------------------------------------- /lib/pils/test.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2001 Alan Robertson 3 | * This software licensed under the GNU LGPL. 4 | * 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, see 18 | * 19 | */ 20 | /* 21 | * Sample Interface manager. 22 | */ 23 | #define PIL_PLUGINTYPE test 24 | #define PIL_PLUGINTYPENAME "test" 25 | #define PIL_PLUGIN test 26 | #define PIL_PLUGINNAME "test" 27 | #define PIL_PLUGINLICENSE LICENSE_LGPL 28 | #define PIL_PLUGINLICENSEURL URL_LGPL 29 | 30 | /* We are a interface manager... */ 31 | #define ENABLE_PLUGIN_MANAGER_PRIVATE 32 | 33 | #include 34 | 35 | PIL_PLUGIN_BOILERPLATE("1.0", DebugFlag, Ourclose) 36 | 37 | /* 38 | * Places to store information gotten during registration. 39 | */ 40 | static const PILPluginImports* OurPIImports; /* Imported plugin funs */ 41 | static PILPlugin* OurPlugin; /* Our plugin info */ 42 | static PILInterfaceImports* OurIfImports; /* Interface imported funs */ 43 | static PILInterface* OurIf; /* Pointer to interface info */ 44 | 45 | static void 46 | Ourclose (PILPlugin* us) 47 | { 48 | } 49 | 50 | /* 51 | * Our Interface Manager interfaces - exported to the universe! 52 | * 53 | * (or at least the interface management universe ;-). 54 | * 55 | */ 56 | static PILInterfaceOps OurIfOps = { 57 | /* FIXME -- put some in here !! */ 58 | }; 59 | 60 | PIL_rc PIL_PLUGIN_INIT(PILPlugin*us, PILPluginImports* imports, void*); 61 | 62 | static PIL_rc 63 | IfClose(PILInterface*intf, void* ud_interface) 64 | { 65 | OurPIImports->log(PIL_INFO, "In Ifclose (test plugin)"); 66 | return PIL_OK; 67 | } 68 | 69 | PIL_rc 70 | PIL_PLUGIN_INIT(PILPlugin*us, PILPluginImports* imports, void *user_ptr) 71 | { 72 | PIL_rc ret; 73 | /* 74 | * Force compiler to check our parameters... 75 | */ 76 | PILPluginInitFun fun = &PIL_PLUGIN_INIT; (void)fun; 77 | 78 | 79 | OurPIImports = imports; 80 | OurPlugin = us; 81 | 82 | imports->log(PIL_INFO, "Plugin %s: user_ptr = %lx" 83 | , PIL_PLUGINNAME, (unsigned long)user_ptr); 84 | 85 | imports->log(PIL_INFO, "Registering ourselves as a plugin"); 86 | 87 | /* Register as a plugin */ 88 | imports->register_plugin(us, &OurPIExports); 89 | 90 | imports->log(PIL_INFO, "Registering our interfaces"); 91 | 92 | /* Register our interfaces */ 93 | ret = imports->register_interface 94 | ( us 95 | , PIL_PLUGINTYPENAME 96 | , PIL_PLUGINNAME 97 | , &OurIfOps /* Exported interface operations */ 98 | , IfClose /* Interface Close function */ 99 | , &OurIf 100 | , (void*)&OurIfImports 101 | , NULL); 102 | imports->log(PIL_INFO, "test init function: returning %u" 103 | , ret); 104 | 105 | return ret; 106 | } 107 | -------------------------------------------------------------------------------- /lib/plugins/InterfaceMgr/Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # InterfaceMgr: Interface manager plugins for Linux-HA 3 | # 4 | # Copyright (C) 2001 Alan Robertson 5 | # 6 | # This program is free software; you can redistribute it and/or 7 | # modify it under the terms of the GNU General Public License 8 | # as published by the Free Software Foundation; either version 2 9 | # of the License, or (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, see . 18 | # 19 | MAINTAINERCLEANFILES = Makefile.in 20 | 21 | AM_CPPFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include \ 22 | -I$(top_builddir)/linux-ha -I$(top_srcdir)/linux-ha \ 23 | -I$(top_builddir)/libltdl -I$(top_srcdir)/libltdl \ 24 | -I$(top_builddir)/lib/upmls -I$(top_srcdir)/lib/upmls 25 | 26 | ## libraries 27 | 28 | plugindir = $(libdir)/@HB_PKG@/plugins/InterfaceMgr 29 | plugin_LTLIBRARIES = generic.la 30 | 31 | generic_la_SOURCES = generic.c 32 | generic_la_LDFLAGS = -export-dynamic -module -avoid-version 33 | -------------------------------------------------------------------------------- /lib/plugins/Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2008 Andrew Beekhof 3 | # 4 | # This program is free software; you can redistribute it and/or 5 | # modify it under the terms of the GNU General Public License 6 | # as published by the Free Software Foundation; either version 2 7 | # of the License, or (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program; if not, see . 16 | # 17 | 18 | MAINTAINERCLEANFILES = Makefile.in 19 | SUBDIRS = InterfaceMgr stonith lrm compress 20 | -------------------------------------------------------------------------------- /lib/plugins/compress/Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # InterfaceMgr: Interface manager plugins for Linux-HA 3 | # 4 | # Copyright (C) 2001 Alan Robertson 5 | # 6 | # This program is free software; you can redistribute it and/or 7 | # modify it under the terms of the GNU General Public License 8 | # as published by the Free Software Foundation; either version 2 9 | # of the License, or (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, see . 18 | # 19 | MAINTAINERCLEANFILES = Makefile.in 20 | 21 | if BUILD_ZLIB_COMPRESS_MODULE 22 | zlibmodule = zlib.la 23 | endif 24 | 25 | if BUILD_BZ2_COMPRESS_MODULE 26 | bz2module = bz2.la 27 | endif 28 | 29 | SUBDIRS = 30 | 31 | AM_CPPFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include \ 32 | -I$(top_builddir)/linux-ha -I$(top_srcdir)/linux-ha \ 33 | -I$(top_builddir)/libltdl -I$(top_srcdir)/libltdl \ 34 | -I$(top_builddir)/lib/upmls -I$(top_srcdir)/lib/upmls 35 | 36 | AM_CFLAGS = @CFLAGS@ 37 | 38 | ## libraries 39 | 40 | halibdir = $(libdir)/@HB_PKG@ 41 | plugindir = $(halibdir)/plugins/compress 42 | plugin_LTLIBRARIES = $(zlibmodule) $(bz2module) 43 | 44 | zlib_la_SOURCES = zlib.c 45 | zlib_la_LDFLAGS = -export-dynamic -module -avoid-version -lz 46 | zlib_la_LIBADD = $(top_builddir)/replace/libreplace.la 47 | 48 | bz2_la_SOURCES = bz2.c 49 | bz2_la_LDFLAGS = -export-dynamic -module -avoid-version -lbz2 50 | bz2_la_LIBADD = $(top_builddir)/replace/libreplace.la 51 | 52 | -------------------------------------------------------------------------------- /lib/plugins/lrm/Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # Author: Sun Jiang Dong 3 | # Copyright (c) 2004 International Business Machines 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # as published by the Free Software Foundation; either version 2 8 | # of the License, or (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program; if not, see . 17 | # 18 | MAINTAINERCLEANFILES = Makefile.in 19 | if UPSTART 20 | SUBDIRS = dbus 21 | endif 22 | 23 | LRM_DIR = lrm 24 | AM_CPPFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include \ 25 | -I$(top_builddir)/linux-ha -I$(top_srcdir)/linux-ha \ 26 | -I$(top_builddir)/libltdl -I$(top_srcdir)/libltdl 27 | if UPSTART 28 | AM_CPPFLAGS += $(DBUS_CFLAGS) 29 | endif 30 | 31 | halibdir = $(libdir)/@HB_PKG@ 32 | havarlibdir = $(localstatedir)/lib/@HB_PKG@ 33 | COMMONLIBS = $(top_builddir)/lib/clplumbing/libplumb.la \ 34 | $(top_builddir)/lib/lrm/liblrm.la \ 35 | $(GLIBLIB) 36 | 37 | plugindir = $(halibdir)/plugins/RAExec 38 | 39 | plugin_LTLIBRARIES = lsb.la ocf.la heartbeat.la 40 | if UPSTART 41 | plugin_LTLIBRARIES += upstart.la 42 | endif 43 | 44 | lsb_la_SOURCES = raexeclsb.c 45 | lsb_la_LDFLAGS = -L$(top_builddir)/lib/pils -lpils -export-dynamic -module -avoid-version 46 | 47 | ocf_la_SOURCES = raexecocf.c 48 | ocf_la_LDFLAGS = -L$(top_builddir)/lib/pils -lpils -export-dynamic -module -avoid-version 49 | 50 | heartbeat_la_SOURCES = raexechb.c 51 | heartbeat_la_LDFLAGS = -L$(top_builddir)/lib/pils -lpils -export-dynamic -module -avoid-version 52 | 53 | if UPSTART 54 | upstart_la_SOURCES = raexecupstart.c upstart-dbus.c 55 | upstart_la_LDFLAGS = -L$(top_builddir)/lib/pils -lpils -export-dynamic -module -avoid-version \ 56 | $(DBUS_LIBS) 57 | endif 58 | -------------------------------------------------------------------------------- /lib/plugins/lrm/dbus/Makefile.am: -------------------------------------------------------------------------------- 1 | if UPSTART 2 | BINDINGS=Upstart_Instance.h \ 3 | Upstart_Job.h \ 4 | Upstart.h 5 | 6 | all-local: 7 | for header in $(BINDINGS); do \ 8 | input=com.ubuntu.`echo $$header | sed 's/\.h//' | tr _ .`.xml; \ 9 | $(DBUS_BINDING_TOOL) --mode=glib-client $$input > $$header; \ 10 | done 11 | 12 | clean-local: 13 | rm -f $(BINDINGS) 14 | 15 | EXTRA_DIST = *.xml 16 | endif 17 | -------------------------------------------------------------------------------- /lib/plugins/lrm/dbus/com.ubuntu.Upstart.Instance.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 21 | 22 | 23 | 24 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /lib/plugins/lrm/dbus/com.ubuntu.Upstart.Job.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 20 | 21 | 22 | 23 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 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 | -------------------------------------------------------------------------------- /lib/plugins/lrm/dbus/com.ubuntu.Upstart.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 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 | -------------------------------------------------------------------------------- /lib/plugins/lrm/upstart-dbus.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This library is free software; you can redistribute it and/or 3 | * modify it under the terms of the GNU Lesser General Public 4 | * License as published by the Free Software Foundation; either 5 | * version 2.1 of the License, or (at your option) any later version. 6 | * 7 | * This library is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 | * Lesser General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU Lesser General Public 13 | * License along with this library; if not, see 14 | * 15 | * File: upstart-dbus.c 16 | * Copyright (C) 2010 Senko Rasic 17 | * Copyright (c) 2010 Ante Karamatic 18 | */ 19 | #ifndef _UPSTART_DBUS_H_ 20 | #define _UPSTART_DBUS_H_ 21 | 22 | #include 23 | 24 | typedef enum { 25 | UPSTART_JOB_START, 26 | UPSTART_JOB_STOP, 27 | UPSTART_JOB_RESTART 28 | } UpstartJobCommand; 29 | 30 | G_GNUC_INTERNAL gchar **upstart_get_all_jobs(void); 31 | G_GNUC_INTERNAL gboolean upstart_job_do(const gchar *name, UpstartJobCommand cmd, const int timeout); 32 | G_GNUC_INTERNAL gboolean upstart_job_is_running (const gchar *name); 33 | 34 | #endif /* _UPSTART_DBUS_H_ */ 35 | 36 | -------------------------------------------------------------------------------- /lib/plugins/stonith/apcmastersnmp.cfg.example: -------------------------------------------------------------------------------- 1 | # 2 | # this is an example config for the stonith module apcmastersnmp 3 | # 4 | # 1. what does the fields on the line mean ? 5 | # 6 | # all parameters must be given on a single line. blank lines and lines 7 | # starting with '#' are ignored. only the first not ignored line will 8 | # be processed. all subsequent lines will be ignored. the different 9 | # fields must be seperated by white-spaces (blanks and/or tabs). 10 | # 11 | # the first field is the either the hostname or the ip address. the 12 | # hostname must be resolvable. the second fields specifies the snmp port 13 | # the masterswitch is listening. for snmp the default is 161. the last 14 | # field contains the so called 'community' string. this must be the same 15 | # as the one in the masterswitch configuration. 16 | # 17 | # 18 | # 2. how must the masterswitch be configured ? 19 | # 20 | # as said above, the community string must be set to the same value entered 21 | # in this config. the different outlets must be named after the connected 22 | # hosts. that means, the outlet names must be the same as the node names 23 | # in /etc/ha.d/ha.cf. the reset values should be set to reasonable values. 24 | # 25 | # the module DON'T configure the module in any way! 26 | # 27 | # 28 | # 3. how does the module work ? 29 | # 30 | # in case of a stonith the module receives the nodename of the host, which 31 | # should be reset. the module looks up this nodename in the list of outlet 32 | # names. that's why the names must be identical (see 2.). if it finds the 33 | # name, it'll reset the appropriate outlet using the configured values 34 | # (eg. delay, duration). then the module waits for the outlet to coming 35 | # up. if it comes up, a successful stonith will be reported back. otherwise 36 | # the stonith failed and a failure code will be returned. 37 | # 38 | 39 | 192.168.1.110 161 private 40 | -------------------------------------------------------------------------------- /lib/plugins/stonith/apcsmart.cfg.example: -------------------------------------------------------------------------------- 1 | /dev/ups hostname 2 | -------------------------------------------------------------------------------- /lib/plugins/stonith/drac3_command.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Stonith module for Dell DRACIII (Dell Remote Access Card) 3 | * 4 | * Copyright (C) 2003 Alfa21 Outsourcing 5 | * Copyright (C) 2003 Roberto Moreda 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, see 19 | * 20 | */ 21 | 22 | int drac3InitCurl (CURL *curl); 23 | int drac3Login (CURL *curl, const char *host, const char *user, const char *pass); 24 | int drac3PowerCycle (CURL *curl, const char *host); 25 | int drac3GetSysInfo (CURL *curl, const char *host); 26 | int drac3Logout (CURL *curl, const char *host); 27 | int drac3VerifyLogin (CURL *curl, const char *host); 28 | 29 | -------------------------------------------------------------------------------- /lib/plugins/stonith/drac3_hash.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Stonith module for Dell DRACIII (Dell Remote Access Card) 3 | * 4 | * Copyright (C) 2003 Alfa21 Outsourcing 5 | * Copyright (C) 2003 Roberto Moreda 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, see 19 | * 20 | */ 21 | 22 | #include 23 | #include 24 | 25 | guint16 drac3Crc16(const char *str, const int l); 26 | void drac3AuthHash(const char *chall, const char *pass, char *token, int len); 27 | 28 | -------------------------------------------------------------------------------- /lib/plugins/stonith/external/Makefile.am: -------------------------------------------------------------------------------- 1 | # Makefile.am for OCF RAs 2 | # 3 | # Author: Sun Jing Dong 4 | # Copyright (C) 2004 IBM 5 | # 6 | # This program is free software; you can redistribute it and/or 7 | # modify it under the terms of the GNU General Public License 8 | # as published by the Free Software Foundation; either version 2 9 | # of the License, or (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, see . 18 | # 19 | MAINTAINERCLEANFILES = Makefile.in 20 | 21 | EXTRA_DIST = drac5 dracmc-telnet ibmrsa-telnet ipmi rackpdu vmware vcenter xen0 \ 22 | xen0-ha-dom0-stonith-helper kdumpcheck nut 23 | 24 | extdir = $(stonith_ext_plugindir) 25 | 26 | helperdir = $(stonith_plugindir) 27 | 28 | ext_SCRIPTS = drac5 dracmc-telnet ibmrsa ibmrsa-telnet ipmi riloe ssh vmware vcenter rackpdu xen0 hmchttp \ 29 | xen0-ha kdumpcheck ippower9258 nut libvirt \ 30 | hetzner ec2 31 | 32 | helper_SCRIPTS = xen0-ha-dom0-stonith-helper 33 | -------------------------------------------------------------------------------- /lib/plugins/stonith/external/drac5.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # External STONITH module for DRAC5 adapters. 4 | # 5 | # Author: Jun Wang 6 | # License: GNU General Public License (GPL) 7 | # 8 | 9 | trap 'if [ -n "$outf" ]; then ha_log.sh err "`cat $outf`"; rm -f "$outf"; fi' 0 10 | outf=`mktemp` || { 11 | ha_log.sh err "mktemp failed" 12 | exit 1 13 | } 14 | 15 | sshlogin() { 16 | if [ x = "x$ipaddr" -o x = "x$userid" ] 17 | then 18 | ha_log.sh err "ipaddr or userid missing; check configuration" 19 | return 1 20 | fi 21 | @SSH@ -q -x -n $userid@$ipaddr racadm serveraction "$1" >$outf 2>&1 22 | } 23 | 24 | drac_reset() { 25 | sshlogin hardreset 26 | } 27 | 28 | drac_on() { 29 | sshlogin poweron 30 | } 31 | 32 | drac_off() { 33 | sshlogin poweroff 34 | } 35 | 36 | drac_status() { 37 | sshlogin powerstatus 38 | } 39 | 40 | case $1 in 41 | gethosts) 42 | echo $hostname 43 | ;; 44 | on) 45 | drac_poweron 46 | ;; 47 | off) 48 | drac_poweroff 49 | ;; 50 | reset) 51 | drac_reset 52 | ;; 53 | status) 54 | drac_status 55 | ;; 56 | getconfignames) 57 | for i in hostname ipaddr userid; do 58 | echo $i 59 | done 60 | ;; 61 | getinfo-devid) 62 | echo "DRAC5 STONITH device" 63 | ;; 64 | getinfo-devname) 65 | echo "DRAC5 STONITH device" 66 | ;; 67 | getinfo-devdescr) 68 | echo "DRAC5 host reset/poweron/poweroff" 69 | ;; 70 | getinfo-devurl) 71 | echo "http://www.dell.com" 72 | ;; 73 | getinfo-xml) 74 | cat < 76 | 77 | 78 | 79 | 80 | Hostname 81 | 82 | 83 | The hostname of the host to be managed by this STONITH device 84 | 85 | 86 | 87 | 88 | 89 | 90 | IP Address 91 | 92 | 93 | The IP address of the STONITH device 94 | 95 | 96 | 97 | 98 | 99 | 100 | Login 101 | 102 | 103 | The username used for logging in to the STONITH device 104 | 105 | 106 | 107 | 108 | EOF 109 | ;; 110 | *) 111 | exit 1 112 | ;; 113 | esac 114 | -------------------------------------------------------------------------------- /lib/plugins/stonith/external/xen0-ha-dom0-stonith-helper: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Author: Lars Marowsky-Bree 3 | # 4 | # Copyright 2008 Lars Marowsky-Bree 5 | # License: GNU General Public License (GPL) 6 | 7 | # This is not an external/stonith plugin by itself, but instead a helper 8 | # script which gets installed in Dom0. 9 | 10 | # TODO: 11 | # - Error handling 12 | # - How to handle if the DomU resource doesn't exist? 13 | # - Does this truly work with split-brain? 14 | # - Is the handling of non-existent resources adequate? 15 | # ... 16 | # Basically: more testing. This is proof-of-concept and works, but deserves 17 | # validation. 18 | 19 | CMD="$1" 20 | DOMU="$2" 21 | TIMEOUT="$3" 22 | 23 | # Make sure the timeout is an integer: 24 | if [ "0$TIMEOUT" -eq 0 ]; then 25 | TIMEOUT=300 26 | fi 27 | 28 | SetTargetRole() { 29 | local new_role="$1" 30 | crm_resource -r $DOMU --meta -p target_role -v $new_role 31 | 32 | local timeout="$TIMEOUT" 33 | 34 | # We only need to wait for "stopped". 35 | if [ "$new_role" != "stopped" ]; then 36 | return 0 37 | fi 38 | 39 | while [ $timeout -gt 0 ]; do 40 | local rc 41 | crm_resource -W -r $DOMU 2>&1 | grep -q "is NOT running" 42 | rc=$? 43 | if [ $rc -eq 0 ]; then 44 | return 0 45 | fi 46 | timeout=$[timeout-1]; 47 | sleep 1 48 | done 49 | return 1 50 | } 51 | 52 | 53 | case $CMD in 54 | on) SetTargetRole started 55 | exit $? 56 | ;; 57 | off) SetTargetRole stopped 58 | exit $? 59 | ;; 60 | reset) SetTargetRole stopped || exit 1 61 | SetTargetRole started 62 | exit $? 63 | ;; 64 | status) exit 0 65 | ;; 66 | *) ha_log.sh err "Called with unknown command: $CMD" 67 | exit 1 68 | ;; 69 | esac 70 | 71 | exit 1 72 | 73 | -------------------------------------------------------------------------------- /lib/plugins/stonith/external/xen0-ha.in: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # This STONITH script integrates a cluster running within DomUs 4 | # with the CRM/Pacemaker cluster running in Dom0. 5 | # 6 | # Author: Lars Marowsky-Bree 7 | # Copyright: 2008 Lars Marowsky-Bree 8 | # License: GNU General Public License (GPL) 9 | # 10 | 11 | SSH_COMMAND="@SSH@ -q -x -n" 12 | HVM_HELPER="@stonith_plugindir@/xen0-ha-dom0-stonith-helper" 13 | 14 | # Rewrite the hostlist to accept "," as a delimeter for hostnames too. 15 | hostlist=`echo $hostlist | tr ',' ' '` 16 | 17 | # Runs a command on the host, waiting for it to return 18 | RunHVMCommand() { 19 | $SSH_COMMAND $dom0_cluster_ip "$HVM_HELPER $1 $2 $stop_timeout" 20 | } 21 | 22 | # Main code 23 | case $1 in 24 | gethosts) 25 | echo $hostlist 26 | exit 0 27 | ;; 28 | on|off|reset|status) 29 | RunHVMCommand $1 $2 30 | exit $? 31 | ;; 32 | getconfignames) 33 | echo "hostlist dom0_cluster_ip timeout" 34 | exit 0 35 | ;; 36 | getinfo-devid) 37 | echo "xen0-ha DomU/Dom0 device" 38 | exit 0 39 | ;; 40 | getinfo-devname) 41 | echo "xen0-ha DomU/Dom0 external device" 42 | exit 0 43 | ;; 44 | getinfo-devdescr) 45 | echo "Allows STONITH to control DomUs managed by a CRM/Pacemaker Dom0." 46 | echo "Requires Xen + CRM/Pacemaker at both layers." 47 | echo "Proof-of-concept code!" 48 | exit 0 49 | ;; 50 | getinfo-devurl) 51 | echo "http://linux-ha.org/wiki/DomUClusters" 52 | exit 0 53 | ;; 54 | getinfo-xml) 55 | cat << SSHXML 56 | 57 | 58 | 59 | 60 | Hostlist 61 | 62 | 63 | The list of controlled DomUs, separated by whitespace. 64 | These must be configured as Xen RA resources with a name with a matching 65 | id. 66 | For example: "xen-1 xen-2 xen-3" 67 | 68 | 69 | 70 | 71 | 72 | Dom0 cluster ip 73 | 74 | 75 | The cluster IP address associated with Dom0. 76 | Root user must be able to ssh to that node. 77 | 78 | 79 | 80 | 81 | 82 | Stop timeout 83 | 84 | 85 | The timeout, in seconds, for which to wait for Dom0 to report that the 86 | DomU has been stopped, before aborting with a failure. 87 | 88 | 89 | 90 | SSHXML 91 | exit 0 92 | ;; 93 | *) 94 | exit 1 95 | ;; 96 | esac 97 | -------------------------------------------------------------------------------- /lib/plugins/stonith/ipmilan.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Stonith module for ipmi lan Stonith device 3 | * 4 | * Copyright (c) 2003 Intel Corp. 5 | * Yixiong Zou 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, see 19 | * 20 | */ 21 | 22 | #define ST_IPMI_STATUS 4 23 | #include 24 | 25 | struct ipmilanHostInfo { 26 | char * hostname; 27 | char * ipaddr; 28 | int portnumber; 29 | int authtype; 30 | int privilege; 31 | char * username; 32 | char * password; 33 | int reset_method; 34 | 35 | struct ipmilanHostInfo * prev; 36 | struct ipmilanHostInfo * next; 37 | }; 38 | 39 | int do_ipmi_cmd(struct ipmilanHostInfo * host, int request); 40 | void ipmi_leave(void); 41 | -------------------------------------------------------------------------------- /lib/plugins/stonith/ipmilan_test.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Stonith module for ipmi lan Stonith device 3 | * 4 | * Copyright (c) 2003 Intel Corp. 5 | * Yixiong Zou 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, see 19 | * 20 | */ 21 | 22 | /* 23 | * A quick test program to verify that IPMI host is setup correctly. 24 | * 25 | * You will need to modify the values in user, pass, ip, and port. 26 | */ 27 | 28 | #include 29 | #include 30 | #include "ipmilan.h" 31 | #include 32 | 33 | int main(int argc, char * argv[]) 34 | { 35 | struct ipmilanHostInfo host; 36 | int request = 2; 37 | int rv; 38 | 39 | char user[] = "joe"; 40 | char pass[] = "blow"; 41 | char ip[] = "192.168.1.7"; 42 | 43 | host.hostname = NULL; 44 | host.portnumber = 999; 45 | host.authtype = IPMI_AUTHTYPE_NONE; 46 | host.privilege = IPMI_PRIVILEGE_ADMIN; 47 | 48 | host.ipaddr = ip; 49 | host.username = strdup(user); 50 | host.password = strdup(pass); 51 | 52 | rv = do_ipmi_cmd(&host, request); 53 | if (rv) 54 | printf("rv = %d, operation failed. \n", rv); 55 | else 56 | printf("operation succeeded. \n"); 57 | return rv; 58 | } 59 | -------------------------------------------------------------------------------- /lib/plugins/stonith/ribcl.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | 4 | # 5 | # This library is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU Lesser General Public 7 | # License as published by the Free Software Foundation; either 8 | # version 2.1 of the License, or (at your option) any later version. 9 | # 10 | # This library is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | # Lesser General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU Lesser General Public 16 | # License along with this library; if not, see 17 | # 18 | 19 | import sys 20 | import socket 21 | from http.client import * 22 | from time import sleep 23 | 24 | 25 | argv = sys.argv 26 | 27 | 28 | try: 29 | host = argv[1].split('.')[0]+'-rm' 30 | cmd = argv[2] 31 | except IndexError: 32 | print("Not enough arguments") 33 | sys.exit(1) 34 | 35 | 36 | login = [ b'', 37 | b'' ] 38 | 39 | 40 | logout = [ b'', b'' ] 41 | 42 | 43 | status = [ b'', b'', 44 | b'' ] 45 | 46 | 47 | reset = [ b'', b'', b'' ] 48 | 49 | 50 | off = [ b'', b'', 51 | b'' ] 52 | 53 | 54 | on = [ b'', b'', 55 | b'' ] 56 | 57 | 58 | todo = { 'reset':reset, 'on':on, 'off':off, 'status':status } 59 | 60 | 61 | acmds=[] 62 | try: 63 | if cmd == 'reset' and host.startswith('gfxcl'): 64 | acmds.append(login + todo['off'] + logout) 65 | acmds.append(login + todo['on'] + logout) 66 | else: 67 | acmds.append(login + todo[cmd] + logout) 68 | except KeyError: 69 | print("Invalid command: "+ cmd) 70 | sys.exit(1) 71 | 72 | 73 | try: 74 | for cmds in acmds: 75 | 76 | 77 | c=HTTPSConnection(host) 78 | c.send(b'\r\n') 79 | c.sock.recv(1024) 80 | 81 | 82 | for line in cmds: 83 | c.send(line+b'\r\n') 84 | c.sock.recv(1024) 85 | 86 | 87 | c.close() 88 | sleep(1) 89 | 90 | 91 | except socket.gaierror as msg: 92 | print(msg) 93 | sys.exit(1) 94 | except socket.error as msg: 95 | print(msg) 96 | sys.exit(1) 97 | -------------------------------------------------------------------------------- /lib/plugins/stonith/ssh.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClusterLabs/cluster-glue/5cc622b4f12f163ff29a2b77459508b662790cb6/lib/plugins/stonith/ssh.c -------------------------------------------------------------------------------- /lib/plugins/stonith/stonith_signal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * stonith_signal.h: signal handling routines to be used by stonith 3 | * plugin libraries 4 | * 5 | * Copyright (C) 2002 Horms 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, see 19 | * 20 | */ 21 | #ifndef _STONITH_SIGNAL_H 22 | #define _STONITH_SIGNAL_H 23 | 24 | #include 25 | #include 26 | 27 | int 28 | stonith_signal_set_simple_handler(int sig, void (*handler)(int) 29 | , struct sigaction *oldact); 30 | 31 | int 32 | stonith_signal_set_simple_handler(int sig, void (*handler)(int) 33 | , struct sigaction *oldact) 34 | { 35 | struct sigaction sa; 36 | sigset_t mask; 37 | 38 | (void)stonith_signal_set_simple_handler; 39 | if(sigemptyset(&mask) < 0) { 40 | return(-1); 41 | } 42 | 43 | sa.sa_handler = handler; 44 | sa.sa_mask = mask; 45 | sa.sa_flags = 0; 46 | 47 | if(sigaction(sig, &sa, oldact) < 0) { 48 | return(-1); 49 | } 50 | 51 | return(0); 52 | } 53 | 54 | #define STONITH_SIGNAL(_sig, _handler) \ 55 | stonith_signal_set_simple_handler((_sig), (_handler), NULL) 56 | #ifdef HAVE_SIGIGNORE 57 | #define STONITH_IGNORE_SIG(_sig) \ 58 | sigignore((_sig)) 59 | #else 60 | #define STONITH_IGNORE_SIG(_sig) \ 61 | STONITH_SIGNAL((_sig), SIG_IGN) 62 | #endif 63 | #define STONITH_DEFAULT_SIG(_sig) STONITH_SIGNAL((_sig), SIG_DFL) 64 | 65 | #define STONITH_KILL(_pid, _sig) kill((_pid), (_sig)) 66 | 67 | #endif /* _STONITH_SIGNAL_H */ 68 | -------------------------------------------------------------------------------- /lib/stonith/Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # Stonith: Shoot The Node In The Head 3 | # 4 | # Copyright (C) 2001 Alan Robertson 5 | # 6 | # This program is free software; you can redistribute it and/or 7 | # modify it under the terms of the GNU General Public License 8 | # as published by the Free Software Foundation; either version 2 9 | # of the License, or (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, see . 18 | # 19 | MAINTAINERCLEANFILES = Makefile.in 20 | 21 | AM_CPPFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include \ 22 | -I$(top_builddir)/linux-ha -I$(top_srcdir)/linux-ha \ 23 | -I$(top_builddir)/libltdl -I$(top_srcdir)/libltdl 24 | 25 | ## include files 26 | 27 | ## binaries 28 | sbin_PROGRAMS = stonith meatclient 29 | 30 | stonith_SOURCES = main.c 31 | 32 | stonith_LDADD = libstonith.la $(top_builddir)/lib/pils/libpils.la $(GLIBLIB) \ 33 | $(top_builddir)/lib/clplumbing/libplumb.la \ 34 | $(top_builddir)/lib/clplumbing/libplumbgpl.la 35 | stonith_LDFLAGS = @LIBADD_DL@ @LIBLTDL@ -export-dynamic @DLOPEN_FORCE_FLAGS@ @LIBADD_INTL@ 36 | 37 | meatclient_SOURCES = meatclient.c 38 | meatclient_LDADD = $(GLIBLIB) libstonith.la 39 | 40 | ## libraries 41 | 42 | lib_LTLIBRARIES = libstonith.la 43 | 44 | libstonith_la_SOURCES = expect.c stonith.c st_ttylock.c 45 | libstonith_la_LDFLAGS = -version-info 1:0:0 46 | libstonith_la_LIBADD = $(top_builddir)/lib/pils/libpils.la \ 47 | $(top_builddir)/replace/libreplace.la \ 48 | $(GLIBLIB) 49 | 50 | helperdir = $(datadir)/$(PACKAGE_NAME) 51 | helper_SCRIPTS = ha_log.sh 52 | 53 | EXTRA_DIST = $(helper_SCRIPTS) 54 | -------------------------------------------------------------------------------- /lib/stonith/README: -------------------------------------------------------------------------------- 1 | The STONITH module (a.k.a. STOMITH) provides an extensible interface 2 | for remotely powering down a node in the cluster. The idea is quite simple: 3 | When the software running on one machine wants to make sure another 4 | machine in the cluster is not using a resource, pull the plug on the other 5 | machine. It's simple and reliable, albiet admittedly brutal. 6 | 7 | Here's an example command line invocation used to power off a machine 8 | named 'nodeb'. The parameters are dependent on the type of device you 9 | are using for this capability. 10 | 11 | stonith -t rps10 -p "/dev/ttyS5 nodeb 0 " nodeb 12 | 13 | Currently supported devices: 14 | 15 | apcsmart: APCSmart (tested with 2 old 900XLI) 16 | baytech: Baytech RPC5 17 | meatware: Alerts an operator to manually turn off a device. 18 | nw_rpc100s: Micro Energetics Night/Ware RPC100S 19 | rps10: Western Telematics RPS10 20 | vacm_stonith: VA Linux Cluster Manager (see README.vacm) 21 | 22 | 23 | To see the parameter syntax for a module, run the 'stonith' command and omit the 24 | -p parameter. For example: 25 | 26 | $ /usr/sbin/stonith -t rps10 test 27 | 28 | stonith: Invalid config file for rps10 device. 29 | stonith: Config file syntax: [ [...] ] 30 | All tokens are white-space delimited. 31 | Blank lines and lines beginning with # are ignored 32 | -------------------------------------------------------------------------------- /lib/stonith/ha_log.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # 4 | # ha_log.sh for stonith external plugins 5 | # (equivalent to ocf_log in ocf-shellfuncs in resource-agents) 6 | # 7 | # Copyright (c) 2004 SUSE LINUX AG, Lars Marowsky-Brée 8 | # All Rights Reserved. 9 | # 10 | # 11 | # This library is free software; you can redistribute it and/or 12 | # modify it under the terms of the GNU Lesser General Public 13 | # License as published by the Free Software Foundation; either 14 | # version 2.1 of the License, or (at your option) any later version. 15 | # 16 | # This library is distributed in the hope that it will be useful, 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | # Lesser General Public License for more details. 20 | # 21 | # You should have received a copy of the GNU Lesser General Public 22 | # License along with this library; if not, see 23 | # 24 | 25 | # Build version: @GLUE_BUILD_VERSION@ 26 | 27 | PROG=`basename $0` 28 | 29 | : ${HA_DATEFMT=+"%b %d %T"} 30 | : ${HA_LOGD=yes} 31 | : ${HA_LOGTAG=""} 32 | : ${HA_LOGFACILITY=daemon} 33 | : ${HA_LOGFILE=""} 34 | : ${HA_DEBUGLOG=""} 35 | : ${HA_debug="0"} 36 | 37 | hadate() { 38 | date "+$HA_DATEFMT" 39 | } 40 | 41 | level_pres() { 42 | case "$1" in 43 | crit) echo "CRIT";; 44 | err|error) echo "ERROR";; 45 | warn|warning) echo "WARN";; 46 | notice) echo "notice";; 47 | info) echo "info";; 48 | debug) echo "debug";; 49 | *) 50 | ha_log err "$PROG: unrecognized loglevel: $1" 51 | exit 1 52 | ;; 53 | esac 54 | } 55 | 56 | set_logtag() { 57 | # add parent pid to the logtag 58 | if [ "$HA_LOGTAG" ]; then 59 | if [ -n "$CRM_meta_st_device_id" ]; then 60 | HA_LOGTAG="$HA_LOGTAG($CRM_meta_st_device_id)[$PPID]" 61 | else 62 | HA_LOGTAG="$HA_LOGTAG[$PPID]" 63 | fi 64 | fi 65 | } 66 | 67 | ha_log() { 68 | loglevel=$1 69 | shift 70 | prn_level=`level_pres $loglevel` 71 | msg="$prn_level: $@" 72 | 73 | if [ "x$HA_debug" = "x0" -a "x$loglevel" = xdebug ] ; then 74 | return 0 75 | fi 76 | 77 | set_logtag 78 | 79 | # if we're connected to a tty, then output to stderr 80 | if tty >/dev/null; then 81 | if [ "$HA_LOGTAG" ]; then 82 | echo "$HA_LOGTAG: $msg" 83 | else 84 | echo "$msg" 85 | fi >&2 86 | return 0 87 | fi 88 | 89 | [ "x$HA_LOGD" = "xyes" ] && 90 | cat<> $dest 101 | fi 102 | } 103 | 104 | if [ $# -lt 2 ]; then 105 | ha_log err "$PROG: not enough arguments [$#]" 106 | exit 1 107 | fi 108 | 109 | loglevel="$1" 110 | shift 1 111 | msg="$*" 112 | 113 | ha_log "$loglevel" "$msg" 114 | -------------------------------------------------------------------------------- /logd/Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # hbclient library: Linux-HA heartbeat code 3 | # 4 | # Copyright (C) 2001 Michael Moerz 5 | # Copyright (C) 2004 International Business Machines 6 | # 7 | # This program is free software; you can redistribute it and/or 8 | # modify it under the terms of the GNU General Public License 9 | # as published by the Free Software Foundation; either version 2 10 | # of the License, or (at your option) any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with this program; if not, see . 19 | # 20 | MAINTAINERCLEANFILES = Makefile.in 21 | 22 | AM_CPPFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include \ 23 | -I$(top_builddir)/linux-ha -I$(top_srcdir)/linux-ha \ 24 | -I$(top_builddir)/libltdl -I$(top_srcdir)/libltdl 25 | 26 | halibdir = $(libdir)/@HB_PKG@ 27 | ha_sbindir = $(sbindir) 28 | 29 | LIBRT = @LIBRT@ 30 | AM_CFLAGS = @CFLAGS@ 31 | 32 | initddir = @INITDIR@ 33 | 34 | ## binary progs 35 | ha_sbin_PROGRAMS = ha_logger 36 | halib_PROGRAMS = ha_logd logtest 37 | 38 | ha_logd_SOURCES = ha_logd.c 39 | ha_logd_LDADD = $(top_builddir)/lib/clplumbing/libplumb.la \ 40 | $(top_builddir)/lib/clplumbing/libplumbgpl.la 41 | 42 | # $(top_builddir)/lib/apphb/libapphb.la 43 | 44 | ha_logger_SOURCES = ha_logger.c 45 | ha_logger_LDADD = $(top_builddir)/lib/clplumbing/libplumb.la 46 | 47 | logtest_SOURCES = logtest.c 48 | logtest_LDADD = $(top_builddir)/lib/clplumbing/libplumb.la 49 | 50 | if HAVE_SYSTEMD 51 | systemdsystemunit_DATA = \ 52 | logd.service 53 | else 54 | initd_SCRIPTS = logd 55 | endif 56 | -------------------------------------------------------------------------------- /logd/ha_logger.1: -------------------------------------------------------------------------------- 1 | .TH HA_LOGGER 1 "5th Nov 2004" 2 | .SH NAME 3 | .B ha_logger 4 | \- Log a message to files/syslog through the HA Logging Daemon 5 | .SH SYNOPSIS 6 | .B ha_logger 7 | .RI "[-D ha-log/ha-debug] [-t tag] [message ...]" 8 | .P 9 | .SH DESCRIPTION 10 | .B ha_logger 11 | is used to log a message to files/syslog through the HA Logging Daemon 12 | .PP 13 | .IP "\fB-D\fP \fIha-log/ha-debug\fP" 14 | Log the message to different files. Ha-log will log the message to 15 | the log file and the debug file, while ha-debug will log the message 16 | to the debug file only. 17 | .IP "\fB-t\fP \fItag\fP" 18 | Mark every line in the log with the specified 19 | .IP \fBmessage\fP 20 | The message you want to log on. 21 | .PP 22 | .SH SEE ALSO 23 | ha_logd(8) heartbeat(8) 24 | 25 | .SH DOCUMENTATION 26 | More information may be found at 27 | .UR http://linux-ha.org/wiki 28 | http://linux-ha.org/wiki 29 | .UE 30 | 31 | .SH AUTHORS 32 | .nf 33 | Guochun Shi 34 | Alan Robertson 35 | Lars Marowsky-Bree 36 | .fi 37 | 38 | 39 | -------------------------------------------------------------------------------- /logd/logd.cf: -------------------------------------------------------------------------------- 1 | # File to write debug messages to 2 | # Default: /var/log/ha-debug 3 | #debugfile /var/log/ha-debug 4 | 5 | # 6 | # 7 | # File to write other messages to 8 | # Default: /var/log/ha-log 9 | #logfile /var/log/ha-log 10 | 11 | # 12 | # 13 | # Octal file permission to create the log files with 14 | # Default: 0644 15 | #logmode 0640 16 | 17 | 18 | # 19 | # 20 | # Facility to use for syslog()/logger 21 | # (set to 'none' to disable syslog logging) 22 | # Default: daemon 23 | #logfacility daemon 24 | 25 | 26 | # Entity to be shown at beginning of a message 27 | # generated by the logging daemon itself 28 | # Default: "logd" 29 | #entity logd 30 | 31 | 32 | # Entity to be shown at beginning of _every_ message 33 | # passed to syslog (not to log files). 34 | # 35 | # Intended for easier filtering, or safe blacklisting. 36 | # You can filter on logfacility and this prefix. 37 | # 38 | # Message format changes like this: 39 | # -Nov 18 11:30:31 soda logtest: [21366]: info: total message dropped: 0 40 | # +Nov 18 11:30:31 soda common-prefix: logtest[21366]: info: total message dropped: 0 41 | # 42 | # Default: none (disabled) 43 | #syslogprefix linux-ha 44 | 45 | 46 | # Do we register to apphbd 47 | # Default: no 48 | #useapphbd no 49 | 50 | # There are two processes running for logging daemon 51 | # 1. parent process which reads messages from all client channels 52 | # and writes them to the child process 53 | # 54 | # 2. the child process which reads messages from the parent process through IPC 55 | # and writes them to syslog/disk 56 | 57 | 58 | # set the send queue length from the parent process to the child process 59 | # 60 | #sendqlen 256 61 | 62 | # set the recv queue length in child process 63 | # 64 | #recvqlen 256 65 | 66 | 67 | -------------------------------------------------------------------------------- /logd/logd.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # 4 | # logd Start logd (non-blocking log service) 5 | # 6 | # Author: Dejan Muhamedagic 7 | # (After the heartbeat init script) 8 | # License: GNU General Public License (GPL) 9 | # 10 | # This script works correctly under SuSE, Debian, 11 | # Conectiva, Red Hat and a few others. Please let me know if it 12 | # doesn't work under your distribution, and we'll fix it. 13 | # We don't hate anyone, and like for everyone to use 14 | # our software, no matter what OS or distribution you're using. 15 | # 16 | # chkconfig: 2345 19 21 17 | # description: Startup script logd service. 18 | # processname: ha_logd 19 | # pidfile: @localstatedir@/run/logd.pid 20 | # config: @sysconfdir@/logd.cf 21 | # 22 | ### BEGIN INIT INFO 23 | # Description: ha_logd is a non-blocking logging daemon. 24 | # It can log messages either to a file or through syslog 25 | # daemon. 26 | # Short-Description: ha_logd logging daemon 27 | # Provides: ha_logd 28 | # Required-Start: $network $syslog $remote_fs 29 | # Required-Stop: $network $syslog $remote_fs 30 | # X-Start-Before: heartbeat openais corosync 31 | # Default-Start: 3 5 32 | # Default-Stop: 0 1 6 33 | ### END INIT INFO 34 | 35 | LOGD_CFG=@sysconfdir@/logd.cf 36 | LOGD_OPT="" 37 | [ -f "$LOGD_CFG" ] && LOGD_OPT="-c $LOGD_CFG" 38 | LOGD_BIN="@libdir@/@HB_PKG@/ha_logd" 39 | 40 | if [ ! -f $LOGD_BIN ]; then 41 | echo -n "ha_logd not installed." 42 | exit 5 43 | fi 44 | 45 | StartLogd() { 46 | echo -n "Starting ha_logd: " 47 | $LOGD_BIN -s >/dev/null 2>&1 48 | if [ $? -eq 0 ]; then 49 | echo "logd is already running" 50 | return 0 51 | fi 52 | 53 | $LOGD_BIN -d $LOGD_OPT >/dev/null 2>&1 54 | if [ $? -ne 0 ]; then 55 | echo "starting logd failed" 56 | exit 1 57 | fi 58 | echo "ok" 59 | exit 0 60 | } 61 | 62 | StopLogd() { 63 | echo -n "Stopping ha_logd: " 64 | 65 | $LOGD_BIN -s >/dev/null 2>&1 66 | if [ $? -ne 0 ]; then 67 | echo "logd is already stopped" 68 | return 0 69 | fi 70 | 71 | $LOGD_BIN -k >/dev/null 2>&1 72 | if [ $? -ne 0 ]; then 73 | echo "stopping logd failed" 74 | exit 1 75 | fi 76 | echo "stopped" 77 | exit 0 78 | } 79 | 80 | StatusLogd() { 81 | $LOGD_BIN -s 82 | exit $? 83 | } 84 | 85 | case "$1" in 86 | start) StartLogd ;; 87 | status) StatusLogd ;; 88 | stop) StopLogd ;; 89 | restart) 90 | sleeptime=1 91 | $0 stop && sleep $sleeptime && $0 start 92 | echo 93 | ;; 94 | try-restart) 95 | $0 status && $0 restart 96 | ;; 97 | *) 98 | echo "Usage: $0 {start|stop|status|restart}" 99 | exit 1 100 | esac 101 | 102 | -------------------------------------------------------------------------------- /logd/logd.service.in: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=ha_logd logging daemon 3 | Documentation=man:ha_logd(8) 4 | 5 | [Service] 6 | ExecStart=@libdir@/@HB_PKG@/ha_logd -c @sysconfdir@/logd.cf 7 | ExecStartPre=/bin/rm -f @HA_VARRUNDIR@/logd.pid 8 | ExecStopPost=/bin/rm -f @HA_VARRUNDIR@/logd.pid 9 | PIDFile=@HA_VARRUNDIR@/logd.pid 10 | 11 | [Install] 12 | WantedBy=multi-user.target 13 | -------------------------------------------------------------------------------- /logd/logtest.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ha_logger.c utility to log a message to the logging daemon 3 | * 4 | * Copyright (C) 2004 Guochun Shi 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, see 18 | * 19 | */ 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #define EXIT_OK 0 37 | #define EXIT_FAIL 1 38 | #define MAXMSGSIZE (1048*4) 39 | 40 | int LogToDaemon(int priority, const char * buf, int bstrlen, gboolean use_pri_str); 41 | extern IPC_Channel * get_log_chan(void); 42 | 43 | static GMainLoop* loop; 44 | 45 | static gboolean 46 | send_log_msg(gpointer data) 47 | { 48 | static int count = 0; 49 | char msgstring[MAXMSGSIZE]; 50 | int priority; 51 | static int dropmsg = 0; 52 | long maxcount = (long) data; 53 | IPC_Channel* chan = get_log_chan(); 54 | 55 | 56 | if (chan == NULL){ 57 | cl_log(LOG_ERR, "logging channel is NULL"); 58 | g_main_loop_quit(loop); 59 | return FALSE; 60 | 61 | } 62 | if (count >= maxcount){ 63 | cl_log(LOG_INFO, "total message dropped: %d", dropmsg); 64 | g_main_loop_quit(loop); 65 | return FALSE; 66 | } 67 | 68 | if (chan->send_queue->current_qlen 69 | == chan->send_queue->max_qlen){ 70 | return TRUE; 71 | } 72 | 73 | 74 | priority = LOG_INFO; 75 | msgstring[0]=0; 76 | 77 | snprintf(msgstring, sizeof(msgstring),"Message %d", count++); 78 | fprintf(stderr, "sending %s\n", msgstring); 79 | if (LogToDaemon(priority, msgstring,MAXMSGSIZE, FALSE) != HA_OK){ 80 | printf("sending out message %d failed\n", count); 81 | dropmsg++; 82 | } 83 | 84 | 85 | 86 | return TRUE; 87 | } 88 | 89 | 90 | static void 91 | usage(char* prog) 92 | { 93 | printf("Usage:%s \n", prog); 94 | return; 95 | } 96 | 97 | int 98 | main(int argc, char** argv) 99 | { 100 | 101 | long maxcount; 102 | 103 | if (argc < 2){ 104 | usage(argv[0]); 105 | return 1; 106 | } 107 | 108 | maxcount = atoi(argv[1]); 109 | 110 | cl_log_set_entity("logtest"); 111 | cl_log_set_facility(HA_LOG_FACILITY); 112 | cl_log_set_uselogd(TRUE); 113 | 114 | if(!cl_log_test_logd()){ 115 | return EXIT_FAIL; 116 | } 117 | 118 | cl_log_set_logd_channel_source(NULL, NULL); 119 | 120 | g_idle_add(send_log_msg, (gpointer)maxcount); 121 | 122 | 123 | loop = g_main_loop_new(NULL, FALSE); 124 | g_main_loop_run(loop); 125 | return(1); 126 | 127 | } 128 | 129 | -------------------------------------------------------------------------------- /lrm/Makefile.am: -------------------------------------------------------------------------------- 1 | # Author: Sun Jiang Dong 2 | # Copyright (c) 2004 International Business Machines 3 | # 4 | # This program is free software; you can redistribute it and/or 5 | # modify it under the terms of the GNU General Public License 6 | # as published by the Free Software Foundation; either version 2 7 | # of the License, or (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program; if not, see . 16 | # 17 | MAINTAINERCLEANFILES = Makefile.in 18 | 19 | SUBDIRS = lrmd admin test 20 | -------------------------------------------------------------------------------- /lrm/admin/Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # Author: Sun Jiang Dong 3 | # Copyright (c) 2004 International Business Machines 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # as published by the Free Software Foundation; either version 2 8 | # of the License, or (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program; if not, see . 17 | # 18 | MAINTAINERCLEANFILES = Makefile.in 19 | 20 | AM_CPPFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include \ 21 | -I$(top_builddir)/libltdl -I$(top_srcdir)/libltdl 22 | 23 | halibdir = $(libdir)/@HB_PKG@ 24 | COMMONLIBS = $(top_builddir)/lib/clplumbing/libplumb.la $(GLIBLIB) 25 | LRM_DIR = lrm 26 | sbin_PROGRAMS = lrmadmin 27 | sbin_SCRIPTS = cibsecret 28 | lrmadmin_SOURCES = lrmadmin.c 29 | lrmadmin_LDFLAGS = $(COMMONLIBS) 30 | lrmadmin_LDADD = $(top_builddir)/lib/$(LRM_DIR)/liblrm.la 31 | lrmadmin_DEPENDENCIES = $(top_builddir)/lib/$(LRM_DIR)/liblrm.la 32 | 33 | if BUILD_HELP 34 | man8_MANS = $(sbin_PROGRAMS:%=%.8) 35 | %.8: % 36 | echo Creating $@ 37 | chmod a+x $< 38 | help2man --output $@ --no-info --section 8 --name "Part of the Linux-HA project" $(top_builddir)/lrm/admin/$< 39 | endif 40 | -------------------------------------------------------------------------------- /lrm/admin/lrmadmin.txt: -------------------------------------------------------------------------------- 1 | # LRM Admin Command-line Interface 2 | # It's a draft 3 | NAME 4 | lrmadmin - Local Resource Manager Commander-line Daministrator Tools 5 | 6 | SYNOPSIS 7 | lrmadmin {-d|--daemon} 8 | {-A|--add} [] 9 | {-D|--delete} 10 | {-F|--flush} 11 | {-E|--execute} [] 12 | {-M|--monitor} -s 13 | [] 14 | {-M|--monitor} {-g|-c} 15 | {-S|--status} 16 | {-L|--listall} 17 | {-I|--information} 18 | {-R|--rasupported} 19 | {-h|--help} 20 | 21 | Detailed Explanation for Options 22 | 23 | Lrmd daemon options 24 | {-d|--daemon} 25 | # -s The status of lrmd: running or not running 26 | # -r Reset lrmd (?) 27 | 28 | Resource options 29 | {-A|--add} [] 30 | Add a resource. 31 | 32 | {-D|--delete} 33 | Delete a resource 34 | 35 | {-E|--execute} [] 36 | Let resource agent to performance the operation 37 | 38 | {-F|--flush} 39 | Clear all pending operation on the resource agnency 40 | 41 | {-M|--monitor} {-s|-g} 42 | -s rscname Set a monitors on the resource agent 43 | -g Get the information about the monitors on the 44 | resource agent 45 | 46 | {-S|--status} 47 | Get the status of current resource agent 48 | 49 | {-L|--listall} 50 | List all available resource agent 51 | 52 | {-I|--information} 53 | List the information about a resource 54 | 55 | {-R|--rasupported} 56 | List the support types of resource agent such as OCF and etc. 57 | 58 | Other options 59 | {-h|--help} 60 | Display the help screen 61 | -------------------------------------------------------------------------------- /lrm/lrmd/Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # Author: Sun Jiang Dong 3 | # Copyright (c) 2002 International Business Machines 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # as published by the Free Software Foundation; either version 2 8 | # of the License, or (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program; if not, see . 17 | # 18 | MAINTAINERCLEANFILES = Makefile.in 19 | 20 | AM_CPPFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include \ 21 | -I$(top_builddir)/libltdl -I$(top_srcdir)/libltdl \ 22 | -I$(top_builddir)/linux-ha -I$(top_srcdir)/linux-ha \ 23 | -I$(top_builddir) -I$(top_srcdir) 24 | 25 | halibdir = $(libdir)/@HB_PKG@ 26 | 27 | COMMONLIBS = $(top_builddir)/lib/clplumbing/libplumb.la \ 28 | $(GLIBLIB) 29 | # $(top_builddir)/lib/apphb/libapphb.la 30 | 31 | halib_PROGRAMS = lrmd 32 | 33 | lrmd_SOURCES = lrmd.c audit.c cib_secrets.c lrmd_fdecl.h lrmd.h 34 | 35 | lrmd_LDFLAGS = $(top_builddir)/lib/lrm/liblrm.la \ 36 | $(COMMONLIBS) @LIBLTDL@ \ 37 | $(top_builddir)/lib/pils/libpils.la 38 | 39 | noinst_HEADERS = lrmd_fdecl.h lrmd.h 40 | 41 | # make lrmd's owner as hacluster:haclient? 42 | -------------------------------------------------------------------------------- /lrm/test/LRMBasicSanityCheck.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Copyright (c) 2004 International Business Machines 4 | # Author: Huang Zhen 5 | # 6 | # This program is free software; you can redistribute it and/or 7 | # modify it under the terms of the GNU General Public License 8 | # as published by the Free Software Foundation; either version 2 9 | # of the License, or (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this library; if not, see 18 | # 19 | HBLIB=@libdir@/heartbeat 20 | LRMD=$HBLIB/lrmd 21 | LRMADMIN=@sbindir@/lrmadmin 22 | export LRMD LRMADMIN 23 | 24 | if [ $# -gt 0 ]; then 25 | LRMD=$1/lrmd 26 | fi 27 | 28 | if [ ! -f $LRMD ]; then 29 | echo $LRMD does not exist 30 | exit 1 31 | fi 32 | 33 | if [ ! -f $LRMADMIN ]; then 34 | echo $LRMADMIN does not exist 35 | exit 1 36 | fi 37 | 38 | OUTDIR=/tmp/LRM_BSC_$$ 39 | export OUTDIR 40 | [ -d $OUTDIR ] && { 41 | echo $OUTDIR exists, please cleanup 42 | exit 1 43 | } 44 | 45 | `dirname $0`/regression.sh -q set:BSC 46 | rc=$? 47 | if [ $rc -eq 0 ]; then 48 | echo "LRM tests PASSED" 49 | rm -rf $OUTDIR 50 | else 51 | echo "LRM tests FAILED" 52 | echo "Please check $OUTDIR for results" 53 | fi 54 | exit $rc 55 | -------------------------------------------------------------------------------- /lrm/test/Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # Author: Sun Jiang Dong 3 | # Copyright (c) 2004 International Business Machines 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # as published by the Free Software Foundation; either version 2 8 | # of the License, or (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program; if not, see . 17 | # 18 | MAINTAINERCLEANFILES = Makefile.in 19 | 20 | SUBDIRS = testcases 21 | 22 | AM_CPPFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include \ 23 | -I$(top_builddir)/libltdl -I$(top_srcdir)/libltdl 24 | 25 | COMMONLIBS = $(top_builddir)/lib/clplumbing/libplumb.la $(GLIBLIB) 26 | 27 | noinst_PROGRAMS = apitest plugintest callbacktest 28 | 29 | apitest_SOURCES = apitest.c 30 | apitest_LDFLAGS = $(COMMONLIBS) 31 | apitest_LDADD = $(top_builddir)/lib/$(LRM_DIR)/liblrm.la 32 | apitest_DEPENDENCIES = $(top_builddir)/lib/$(LRM_DIR)/liblrm.la 33 | 34 | plugintest_SOURCES = plugintest.c 35 | plugintest_LDADD = $(COMMONLIBS) 36 | plugintest_LDFLAGS = -L$(top_builddir)/lib/pils -lpils @LIBLTDL@ 37 | 38 | callbacktest_SOURCES = callbacktest.c 39 | callbacktest_LDFLAGS = $(COMMONLIBS) 40 | callbacktest_LDADD = $(top_builddir)/lib/$(LRM_DIR)/liblrm.la 41 | callbacktest_DEPENDENCIES = $(top_builddir)/lib/$(LRM_DIR)/liblrm.la 42 | 43 | testdir = $(datadir)/$(PACKAGE_NAME)/lrmtest 44 | test_SCRIPTS = LRMBasicSanityCheck regression.sh evaltest.sh lrmregtest lrmregtest-lsb 45 | test_DATA = README.regression defaults descriptions lrmadmin-interface language 46 | # shouldn't need this, but we do for some versions of autofoo tools 47 | EXTRA_DIST = $(test_SCRIPTS) $(test_DATA) 48 | -------------------------------------------------------------------------------- /lrm/test/apitest.exp: -------------------------------------------------------------------------------- 1 | sigon... 2 | add_rsc... 3 | get_rsc... 4 | print resource 5 | resource of id:ip248 6 | type:IPv6addr 7 | class:heartbeat 8 | params: 9 | 1=3ffe:ffff:0:f101::3 10 | print end 11 | perform_op(start)... 12 | print op 13 | op_type:start 14 | params: 15 | 1=3ffe:ffff:0:f101::3 16 | timeout:0 17 | user_data:It is a start op! 18 | op_status:0 19 | app_name:null 20 | output:null 21 | rc:0 22 | print end 23 | perform_op(status)... 24 | print op 25 | op_type:status 26 | params: 27 | 1=3ffe:ffff:0:f101::3 28 | timeout:0 29 | user_data:It is a status op! 30 | op_status:0 31 | app_name:null 32 | output:null 33 | rc:0 34 | print end 35 | perform_op(stop)... 36 | print op 37 | op_type:stop 38 | params: 39 | 1=3ffe:ffff:0:f101::3 40 | timeout:0 41 | user_data:It is a stop op! 42 | op_status:0 43 | app_name:null 44 | output:null 45 | rc:0 46 | print end 47 | get_cur_state... 48 | current state:Busy 49 | print op 50 | op_type:start 51 | params: 52 | 1=3ffe:ffff:0:f101::3 53 | timeout:0 54 | user_data:It is a start op! 55 | op_status:-1 56 | app_name:apitest 57 | output:null 58 | rc:0 59 | print end 60 | print op 61 | op_type:status 62 | params: 63 | 1=3ffe:ffff:0:f101::3 64 | timeout:0 65 | user_data:It is a status op! 66 | op_status:-1 67 | app_name:apitest 68 | output:null 69 | rc:0 70 | print end 71 | print op 72 | op_type:stop 73 | params: 74 | 1=3ffe:ffff:0:f101::3 75 | timeout:0 76 | user_data:It is a stop op! 77 | op_status:-1 78 | app_name:apitest 79 | output:null 80 | rc:0 81 | print end 82 | stop_op... 83 | get_cur_state... 84 | current state:Busy 85 | print op 86 | op_type:start 87 | params: 88 | 1=3ffe:ffff:0:f101::3 89 | timeout:0 90 | user_data:null 91 | op_status:-1 92 | app_name:apitest 93 | output:null 94 | rc:0 95 | print end 96 | print op 97 | op_type:stop 98 | params: 99 | 1=3ffe:ffff:0:f101::3 100 | timeout:0 101 | user_data:null 102 | op_status:-1 103 | app_name:apitest 104 | output:null 105 | rc:0 106 | print end 107 | sleep a while... 108 | get_cur_state... 109 | current state:Idel 110 | print op 111 | op_type:stop 112 | params: 113 | 1=3ffe:ffff:0:f101::3 114 | timeout:0 115 | user_data:null 116 | op_status:0 117 | app_name:apitest 118 | output:null 119 | rc:0 120 | print end 121 | delete_rsc... 122 | signoff... 123 | -------------------------------------------------------------------------------- /lrm/test/defaults: -------------------------------------------------------------------------------- 1 | # defaults 2 | : ${dflt_rsc:=r1} 3 | : ${dflt_type:=lrmregtest} 4 | : ${dflt_class:=ocf} 5 | : ${dflt_provider:=heartbeat} 6 | : ${dflt_timeout:=1000} 7 | : ${dflt_interval:=0} 8 | : ${dflt_targetrc:=EVERYTIME} 9 | dflt_args="" 10 | -------------------------------------------------------------------------------- /lrm/test/descriptions: -------------------------------------------------------------------------------- 1 | lead=".TRY" 2 | describe_list() { 3 | echo $lead List resources 4 | } 5 | describe_add() { 6 | echo $lead Add resource \ 7 | ${rsc:-$dflt_rsc} \ 8 | class=${class:-$dflt_class} type=${type:-$dflt_type} \ 9 | provider=${provider:-$dflt_provider} \ 10 | args=$args 11 | } 12 | describe_del() { 13 | echo $lead Delete resource \ 14 | ${rsc:-$dflt_rsc} 15 | } 16 | describe_flush() { 17 | echo $lead Flush resource \ 18 | ${rsc:-$dflt_rsc} 19 | } 20 | describe_state() { 21 | echo $lead Show state \ 22 | ${rsc:-$dflt_rsc} 23 | } 24 | describe_info() { 25 | echo $lead Show info \ 26 | ${rsc:-$dflt_rsc} 27 | } 28 | describe_exec() { 29 | echo $lead Exec \ 30 | ${rsc:-$dflt_rsc} \ 31 | op=${operation:-$dflt_operation} \ 32 | timeout=${timeout:-$dflt_timeout} interval=${interval:-$dflt_interval} \ 33 | target=${targetrc:-$dflt_targetrc} args=$args 34 | } 35 | 36 | describe_classes() { 37 | echo $lead List classes 38 | } 39 | describe_types() { 40 | echo $lead List types \ 41 | class=${class:-$dflt_class} 42 | } 43 | describe_classmeta() { 44 | echo $lead Meta-data \ 45 | class=${class:-$dflt_class} 46 | } 47 | describe_meta() { 48 | echo $lead Show meta-data \ 49 | class=${class:-$dflt_class} \ 50 | type=${type:-$dflt_type} provider=${provider:-$dflt_provider} 51 | } 52 | describe_provider() { 53 | echo $lead Show provider \ 54 | class=${class:-$dflt_class} type=${type:-$dflt_type} 55 | } 56 | -------------------------------------------------------------------------------- /lrm/test/language: -------------------------------------------------------------------------------- 1 | The meta language and how it translates to the lrmadmin options: 2 | 3 | list:-L 4 | add:-A %r %C %T %P 5 | del:-D %r 6 | flush:-F %r 7 | state:-S %r 8 | info:-I %r 9 | exec:-E %r %o %t %i %e 10 | 11 | classes:-C 12 | types:-T %C 13 | classmeta:-O %C 14 | meta:-M %C %T %P 15 | provider:-P %C %T 16 | 17 | -------------------------------------------------------------------------------- /lrm/test/lrmadmin-interface: -------------------------------------------------------------------------------- 1 | lrm_list() { 2 | $LRMADMIN -L 3 | } 4 | lrm_add() { 5 | $LRMADMIN -A ${rsc:-$dflt_rsc} \ 6 | ${class:-$dflt_class} ${type:-$dflt_type} \ 7 | ${provider:-$dflt_provider} \ 8 | $args 9 | } 10 | lrm_del() { 11 | $LRMADMIN -D ${rsc:-$dflt_rsc} 12 | } 13 | lrm_flush() { 14 | $LRMADMIN -F ${rsc:-$dflt_rsc} 15 | } 16 | lrm_state() { 17 | $LRMADMIN -S ${rsc:-$dflt_rsc} 18 | } 19 | lrm_info() { 20 | $LRMADMIN -I ${rsc:-$dflt_rsc} 21 | } 22 | lrm_exec() { 23 | $LRMADMIN -E ${rsc:-$dflt_rsc} \ 24 | ${operation:-$dflt_operation} \ 25 | ${timeout:-$dflt_timeout} ${interval:-$dflt_interval} \ 26 | ${targetrc:-$dflt_targetrc} $args 27 | } 28 | 29 | lrm_classes() { 30 | $LRMADMIN -C 31 | } 32 | lrm_types() { 33 | $LRMADMIN -T ${class:-$dflt_class} 34 | } 35 | lrm_classmeta() { 36 | $LRMADMIN -O ${class:-$dflt_class} 37 | } 38 | lrm_meta() { 39 | $LRMADMIN -M ${class:-$dflt_class} ${type:-$dflt_type} ${provider:-$dflt_provider} 40 | } 41 | lrm_provider() { 42 | $LRMADMIN -P ${class:-$dflt_class} ${type:-$dflt_type} 43 | } 44 | -------------------------------------------------------------------------------- /lrm/test/lrmregtest-lsb: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # WARNING: This script is for LRM regressions tests only 4 | # 5 | ### BEGIN INIT INFO 6 | # Provides: lrmregtest 7 | # Required-Start: 8 | # Should-Start: 9 | # Required-Stop: 10 | # Should-Stop: 11 | # Default-Start: 12 | # Default-Stop: 13 | # Short-Description: LRM regression tests LSB RA 14 | # Description: LRM regression tests LSB RA 15 | ### END INIT INFO 16 | 17 | TYPE=lrmregtest 18 | # depends on resource-agents and the OCF 19 | : ${OCF_ROOT:=/usr/lib/ocf} 20 | . ${OCF_ROOT}/lib/heartbeat/ocf-shellfuncs 21 | 22 | case "$1" in 23 | start) 24 | echo -n "Starting $TYPE" 25 | ha_pseudo_resource lrmregtest_lsb start 26 | ;; 27 | stop) 28 | echo -n "Shutting down $TYPE" 29 | ha_pseudo_resource lrmregtest_lsb stop 30 | ;; 31 | status) 32 | echo -n "Checking for $TYPE" 33 | ha_pseudo_resource lrmregtest_lsb monitor 34 | if [ $? -eq 0 ]; then 35 | echo " running" 36 | exit 0 37 | else 38 | echo " stopped" 39 | exit 3 40 | fi 41 | ;; 42 | *) 43 | echo "Usage: $0 {start|stop|status}" 44 | exit 1 45 | ;; 46 | esac 47 | 48 | if [ $? -eq 0 ]; then 49 | echo " OK" 50 | exit 0 51 | else 52 | echo " failed" 53 | exit 1 54 | fi 55 | -------------------------------------------------------------------------------- /lrm/test/lrmregtest.in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClusterLabs/cluster-glue/5cc622b4f12f163ff29a2b77459508b662790cb6/lrm/test/lrmregtest.in -------------------------------------------------------------------------------- /lrm/test/plugintest.c: -------------------------------------------------------------------------------- 1 | /* File: plugintest.c 2 | * Description: A small,simple tool to test RA execution plugin 3 | * 4 | * Author: Sun Jiang Dong 5 | * Copyright (c) 2004 International Business Machines 6 | * 7 | * Todo: security verification 8 | * 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 2 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, see 21 | */ 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | static void 32 | g_print_item(gpointer data, gpointer user_data) 33 | { 34 | printf("%s\n", (char*)data); 35 | } 36 | 37 | 38 | int main(void) 39 | { 40 | PILPluginUniv * PluginLoadingSystem = NULL; 41 | GHashTable * RAExecFuncs = NULL; 42 | GList * ratype_list; 43 | struct RAExecOps * RAExec; 44 | /* 45 | GHashTable * cmd_params; 46 | */ 47 | int ret; 48 | 49 | PILGenericIfMgmtRqst RegisterRqsts[]= { 50 | {"RAExec", &RAExecFuncs, NULL, NULL, NULL}, 51 | { NULL, NULL, NULL, NULL, NULL} }; 52 | 53 | PluginLoadingSystem = NewPILPluginUniv ("/usr/lib/heartbeat/plugins"); 54 | 55 | PILLoadPlugin(PluginLoadingSystem , "InterfaceMgr", "generic" , &RegisterRqsts); 56 | 57 | PILLoadPlugin(PluginLoadingSystem , "RAExec", "ocf", NULL); 58 | RAExec = g_hash_table_lookup(RAExecFuncs,"ocf"); 59 | ret = RAExec->get_resource_list(&ratype_list); 60 | printf("length=%d\n", g_list_length(ratype_list)); 61 | if (ret >= 0) { 62 | g_list_foreach(ratype_list, g_print_item, NULL); 63 | } 64 | 65 | /* 66 | PILLoadPlugin(PluginLoadingSystem , "RAExec", "lsb", NULL); 67 | RAExec = g_hash_table_lookup(RAExecFuncs,"lsb"); 68 | cmd_params = g_hash_table_new(g_str_hash, g_str_equal); 69 | g_hash_table_insert(cmd_params, g_strdup("1"), g_strdup("par1")); 70 | g_hash_table_insert(cmd_params, g_strdup("2"), g_strdup("par2")); 71 | ret = RAExec->execra("/tmp/test.sh", "start", cmd_params,NULL); 72 | */ 73 | 74 | /* For test the dealing with directory appended to RA */ 75 | /* 76 | PILLoadPlugin(PluginLoadingSystem , "RAExec", "ocf", NULL); 77 | RAExec = g_hash_table_lookup(RAExecFuncs,"ocf"); 78 | if (0>RAExec->execra("/root/linux-ha-checkout/linux-ha/lrm/test.sh", 79 | "stop",NULL,NULL, TRUE, &key)) 80 | */ 81 | printf("execra result: ret = %d\n", ret); 82 | return -1; 83 | } 84 | -------------------------------------------------------------------------------- /lrm/test/testcases/BSC: -------------------------------------------------------------------------------- 1 | rscmgmt 2 | metadata 3 | rscexec 4 | stonith 5 | -------------------------------------------------------------------------------- /lrm/test/testcases/Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # Author: Sun Jiang Dong 3 | # Copyright (c) 2004 International Business Machines 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # as published by the Free Software Foundation; either version 2 8 | # of the License, or (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program; if not, see . 17 | # 18 | MAINTAINERCLEANFILES = Makefile.in 19 | 20 | testcasesdir = $(datadir)/$(PACKAGE_NAME)/lrmtest/testcases 21 | testcases_SCRIPTS = common.filter ra-list.sh rscmgmt.log_filter xmllint.sh 22 | testcases_DATA = BSC basicset metadata metadata.exp rscexec \ 23 | rscexec.exp rscmgmt rscmgmt.exp \ 24 | stonith stonith.exp 25 | # shouldn't need this next line... 26 | EXTRA_DIST = $(testcases_SCRIPTS) $(testcases_DATA) 27 | -------------------------------------------------------------------------------- /lrm/test/testcases/basicset: -------------------------------------------------------------------------------- 1 | rscmgmt 2 | metadata 3 | rscexec 4 | stonith 5 | serialize 6 | flood 7 | -------------------------------------------------------------------------------- /lrm/test/testcases/common.filter: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | sed ' 4 | /^lrmadmin/s/([0-9][0-9]*)/()/ 5 | /^lrmadmin/s/^lrmadmin[^:]*: [^ ]* // 6 | s/call_id=[0-9][0-9]*/call_id=(removed)/ 7 | /run at:/d 8 | /last rc change at:/d 9 | /queue time:/d 10 | ' | 11 | awk ' 12 | /Waiting for lrmd to callback.../ { n=1; next; } 13 | n==1 && /----------------operation--------------/ { n++; next; } 14 | n==2 && /type:/ { op=$0; sub("type:","",op); next } 15 | n==2 && /operation status:/ { desc=$0; sub("operation status:","",desc); next } 16 | n==2 && /op_status:/ { stat=$0; sub("op_status: *","",stat); next } 17 | n==2 && /return code:/ { rc=$0; sub("return code: *","",rc); next } 18 | n==2 && /output data:/ { n++; next; } 19 | n==3 && /---------------------------------------/ { 20 | printf("> %s %s (status=%s,rc=%s): %s\n",op,desc,stat,rc,substr(output,2)); 21 | n=0; 22 | output=""; 23 | next; 24 | } 25 | n==3 && $1!="" { output=output"/"$0; next; } 26 | { print } 27 | ' 28 | -------------------------------------------------------------------------------- /lrm/test/testcases/flood: -------------------------------------------------------------------------------- 1 | # 30 secs should be enough even on slow machines 2 | list 3 | %setenv dflt_timeout=30000 4 | # add 64 resources 5 | %repeat 64 6 | add rsc=r%i args="delay=0" 7 | # start all in background 8 | %bgrepeat 64 9 | exec rsc=r%i operation=start 10 | %sleep 1 11 | # and run a monitor on all in background 12 | %bgrepeat 64 13 | exec rsc=r%i operation=monitor 14 | %sleep 1 15 | # finally, stop all 16 | %repeat 64 17 | exec rsc=r%i operation=stop 18 | %repeat 64 19 | del rsc=r%i 20 | -------------------------------------------------------------------------------- /lrm/test/testcases/metadata: -------------------------------------------------------------------------------- 1 | # list various meta-data 2 | %setenv LANG=POSIX 3 | %extcheck sort 4 | classes 5 | %extcheck ra-list.sh 6 | types class=ocf 7 | %extcheck ra-list.sh 8 | types class=lsb 9 | %extcheck ra-list.sh 10 | types class=heartbeat 11 | #%extcheck ra-list.sh 12 | #types class=stonith 13 | %extcheck xmllint.sh many 14 | classmeta class=ocf 15 | %extcheck xmllint.sh many 16 | classmeta class=lsb 17 | %extcheck xmllint.sh many 18 | classmeta class=heartbeat 19 | #%extcheck xmllint.sh many 20 | #classmeta class=stonith 21 | %extcheck xmllint.sh 22 | meta class=ocf type=Dummy 23 | %extcheck xmllint.sh 24 | meta class=lsb type=lrmregtest 25 | %extcheck xmllint.sh 26 | meta class=heartbeat type=Dummy 27 | #%extcheck xmllint.sh 28 | #meta class=stonith type=ssh 29 | provider class=ocf type=IPaddr 30 | -------------------------------------------------------------------------------- /lrm/test/testcases/metadata.exp: -------------------------------------------------------------------------------- 1 | .SETENV LANG=POSIX 2 | .EXTCHECK sort 3 | .TRY List classes 4 | There are 4 RA classes supported: 5 | heartbeat 6 | lsb 7 | ocf 8 | stonith 9 | .EXTCHECK ra-list.sh 10 | .TRY List types class=ocf 11 | Cool. RA list passed. 12 | .EXTCHECK ra-list.sh 13 | .TRY List types class=lsb 14 | Cool. RA list passed. 15 | .EXTCHECK ra-list.sh 16 | .TRY List types class=heartbeat 17 | Cool. RA list passed. 18 | .EXTCHECK xmllint.sh many 19 | .TRY Meta-data class=ocf 20 | .EXTCHECK xmllint.sh many 21 | .TRY Meta-data class=lsb 22 | .EXTCHECK xmllint.sh many 23 | .TRY Meta-data class=heartbeat 24 | .EXTCHECK xmllint.sh 25 | .TRY Show meta-data class=ocf type=Dummy provider=heartbeat 26 | .EXTCHECK xmllint.sh 27 | .TRY Show meta-data class=lsb type=lrmregtest provider=heartbeat 28 | .EXTCHECK xmllint.sh 29 | .TRY Show meta-data class=heartbeat type=Dummy provider=heartbeat 30 | .TRY Show provider class=ocf type=IPaddr 31 | heartbeat 32 | -------------------------------------------------------------------------------- /lrm/test/testcases/ra-list.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | awk ' 4 | NR==1 {num=$3;next} 5 | {in_num++} 6 | END{ 7 | if( num!=in_num ) 8 | print "ERROR: A mismatch in number of reported RAs!"; 9 | else 10 | print "Cool. RA list passed."; 11 | } 12 | ' 13 | -------------------------------------------------------------------------------- /lrm/test/testcases/rscexec: -------------------------------------------------------------------------------- 1 | list 2 | # ocf 3 | %setenv dflt_rsc=rscexec_rsc_r1 4 | add rsc=rscexec_rsc_r1 args="delay=0" 5 | list 6 | exec operation=start 7 | state 8 | exec operation=monitor 9 | exec operation=start 10 | exec operation=monitor 11 | exec operation=stop 12 | state 13 | exec operation=monitor 14 | exec operation=stop 15 | exec operation=monitor 16 | exec operation=meta-data 17 | del 18 | # lsb 19 | %setenv dflt_class=lsb dftl_rsc=rscexec_rsc_r1-lsb 20 | add 21 | exec operation=start 22 | state 23 | exec operation=monitor 24 | exec operation=start 25 | exec operation=monitor 26 | exec operation=stop 27 | state 28 | exec operation=monitor 29 | exec operation=stop 30 | exec operation=monitor 31 | exec operation=meta-data 32 | del 33 | %stop 34 | # stonith 35 | %setenv dflt_class=stonith dftl_rsc=rscexec_rsc_r1-stonith 36 | add type=null args="hostlist=node1" 37 | exec operation=start 38 | state 39 | exec operation=monitor 40 | exec operation=start 41 | exec operation=monitor 42 | exec operation=stop 43 | state 44 | exec operation=monitor 45 | exec operation=stop 46 | exec operation=monitor 47 | exec operation=meta-data 48 | del 49 | -------------------------------------------------------------------------------- /lrm/test/testcases/rscmgmt: -------------------------------------------------------------------------------- 1 | list 2 | # add/remove resources 3 | # 4 | add rsc=r1 5 | info rsc=r1 6 | list 7 | del rsc=r1 8 | %setenv dflt_class=lsb dflt_type=lrmregtest 9 | list 10 | add rsc=r1 11 | list 12 | del rsc=r1 13 | list 14 | # 15 | # a bit of mix 16 | # 17 | %setenv dflt_class=ocf 18 | add rsc=r1 19 | add rsc=r1 class=lsb type=lrmregtest 20 | add rsc=r1 21 | del rsc=r1 22 | add rsc=r1 class=lsb type=lrmregtest 23 | list 24 | add rsc=r2 25 | list 26 | del rsc=r1 27 | del rsc=r2 28 | list 29 | del rsc=r1 30 | -------------------------------------------------------------------------------- /lrm/test/testcases/rscmgmt.exp: -------------------------------------------------------------------------------- 1 | .TRY List resources 2 | Currently no resources are managed by LRM. 3 | .TRY Add resource r1 class=ocf type=lrmregtest provider=heartbeat args= 4 | Succeeded in adding this resource. 5 | .TRY Show info r1 6 | 7 | Resource ID:r1 8 | Resource agent class:ocf 9 | Resource agent type:lrmregtest 10 | Resource agent provider:heartbeat 11 | .TRY List resources 12 | 13 | Resource ID:r1 14 | Resource agent class:ocf 15 | Resource agent type:lrmregtest 16 | Resource agent provider:heartbeat 17 | .TRY Delete resource r1 18 | Succeeded in deleting this resource. 19 | .SETENV dflt_class=lsb dflt_type=lrmregtest 20 | .TRY List resources 21 | Currently no resources are managed by LRM. 22 | .TRY Add resource r1 class=lsb type=lrmregtest provider=heartbeat args= 23 | Succeeded in adding this resource. 24 | .TRY List resources 25 | 26 | Resource ID:r1 27 | Resource agent class:lsb 28 | Resource agent type:lrmregtest 29 | Resource agent provider:heartbeat 30 | .TRY Delete resource r1 31 | Succeeded in deleting this resource. 32 | .TRY List resources 33 | Currently no resources are managed by LRM. 34 | .SETENV dflt_class=ocf 35 | .TRY Add resource r1 class=ocf type=lrmregtest provider=heartbeat args= 36 | Succeeded in adding this resource. 37 | .TRY Add resource r1 class=lsb type=lrmregtest provider=heartbeat args= 38 | ERROR: lrm_add_rsc(): got a return code HA_FAIL from a reply message of addrsc with function get_ret_from_msg. 39 | Failed to add this resource. 40 | .TRY Add resource r1 class=ocf type=lrmregtest provider=heartbeat args= 41 | ERROR: lrm_add_rsc(): got a return code HA_FAIL from a reply message of addrsc with function get_ret_from_msg. 42 | Failed to add this resource. 43 | .TRY Delete resource r1 44 | Succeeded in deleting this resource. 45 | .TRY Add resource r1 class=lsb type=lrmregtest provider=heartbeat args= 46 | Succeeded in adding this resource. 47 | .TRY List resources 48 | 49 | Resource ID:r1 50 | Resource agent class:lsb 51 | Resource agent type:lrmregtest 52 | Resource agent provider:heartbeat 53 | .TRY Add resource r2 class=ocf type=lrmregtest provider=heartbeat args= 54 | Succeeded in adding this resource. 55 | .TRY List resources 56 | 57 | Resource ID:r2 58 | Resource agent class:ocf 59 | Resource agent type:lrmregtest 60 | Resource agent provider:heartbeat 61 | 62 | Resource ID:r1 63 | Resource agent class:lsb 64 | Resource agent type:lrmregtest 65 | Resource agent provider:heartbeat 66 | .TRY Delete resource r1 67 | Succeeded in deleting this resource. 68 | .TRY Delete resource r2 69 | Succeeded in deleting this resource. 70 | .TRY List resources 71 | Currently no resources are managed by LRM. 72 | .TRY Delete resource r1 73 | ERROR: lrm_delete_rsc(): got a return code HA_FAIL from a reply message of delrsc with function get_ret_from_msg. 74 | Failed to delete this resource. 75 | -------------------------------------------------------------------------------- /lrm/test/testcases/rscmgmt.log_filter: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | awk ' 4 | n<2 && /ERROR: on_msg_add_rsc: same id resource exists./ {n++; next} 5 | m<1 && /ERROR: on_msg_del_rsc: no rsc with id/ {m++; next} 6 | {print} 7 | END{ 8 | if( n!=2 ) 9 | print "ERROR: missed on_msg_add_rsc errors"; 10 | if( m!=1 ) 11 | print "ERROR: missed on_msg_del_rsc errors"; 12 | } 13 | ' 14 | -------------------------------------------------------------------------------- /lrm/test/testcases/serialize: -------------------------------------------------------------------------------- 1 | list 2 | # allow for a delay of 2 seconds 3 | %setenv dflt_timeout=2500 4 | add rsc=r1 args="delay=2" 5 | # 6 | # we run the next three ops in the background 7 | # in case ops are not serialized, the lrmregtest RA should complain 8 | # 9 | %bg 2 10 | exec operation=start 11 | # insert sleeps to make sure that the operations are started in 12 | # the order given here 13 | %sleep 1 14 | # set timeouts high enough so that no op fails 15 | exec operation=start timeout=3000 16 | %sleep 1 17 | %bgrepeat 4 18 | exec operation=monitor timeout=11000 19 | %sleep 11 20 | state 21 | exec operation=stop 22 | state 23 | del rsc=r1 24 | # 25 | # 26 | # 27 | %setenv dflt_rsc=r2 dflt_timeout=10500 28 | add rsc=r2 args="ignore_TERM=1 delay=9" 29 | exec operation=start 30 | %bg 31 | exec operation=monitor timeout=500 32 | exec operation=monitor 33 | del rsc=r2 34 | -------------------------------------------------------------------------------- /lrm/test/testcases/stonith: -------------------------------------------------------------------------------- 1 | %extcheck xmllint.sh many 2 | %shell stonith -L | while read p; do echo $p:heartbeat; stonith -m -t $p; done 3 | -------------------------------------------------------------------------------- /lrm/test/testcases/stonith.exp: -------------------------------------------------------------------------------- 1 | .EXTCHECK xmllint.sh many 2 | .SHELL stonith -L | while read p; do echo $p:heartbeat; stonith -m -t $p; done 3 | -------------------------------------------------------------------------------- /lrm/test/testcases/xmllint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | gawk -v many="$1" ' 4 | BEGIN{XMLLINT="xmllint --noout -";} 5 | function chkoutput(ra) { 6 | if( ra=="" ) return; 7 | if( close(XMLLINT) ) # we need gawk for this 8 | print "xmllint reported error in RA:",ra; 9 | } 10 | many=="many" && /^[a-zA-Z][^:]*:[a-zA-Z0-9]+$/ { 11 | chkoutput(ra); 12 | ra=$0; 13 | next; 14 | } 15 | { print | XMLLINT } 16 | END{ 17 | if( many!="many" ) 18 | chkoutput("noname"); 19 | } 20 | ' 21 | -------------------------------------------------------------------------------- /replace/Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # 3 | # This program is free software; you can redistribute it and/or 4 | # modify it under the terms of the GNU General Public License 5 | # as published by the Free Software Foundation; either version 2 6 | # of the License, or (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program; if not, see . 15 | # 16 | 17 | MAINTAINERCLEANFILES = Makefile.in 18 | 19 | AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include \ 20 | -I$(top_srcdir)/linux-ha -I$(top_builddir)/linux-ha 21 | 22 | QUIET_LIBTOOL_OPTS = @QUIET_LIBTOOL_OPTS@ 23 | LIBTOOL = @LIBTOOL@ @QUIET_LIBTOOL_OPTS@ 24 | 25 | 26 | noinst_LTLIBRARIES = libreplace.la 27 | libreplace_la_SOURCES = 28 | libreplace_la_LIBADD = @LTLIBOBJS@ 29 | -------------------------------------------------------------------------------- /replace/NoSuchFunctionName.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002 Alan Robertson 3 | * This software licensed under the GNU LGPL. 4 | * 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, see 18 | * 19 | */ 20 | void nosuchfunctionname(void); 21 | 22 | /* 23 | * This is a completely useless function put here only to make OpenBSD make 24 | * procedures happy. I hope no one ever makes such a function ;-) 25 | */ 26 | void 27 | nosuchfunctionname(void) 28 | { 29 | return; 30 | } 31 | -------------------------------------------------------------------------------- /replace/alphasort.c: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * alphasort - replacement for alphasort functions. 4 | * 5 | * Matt Soffen 6 | 7 | * Copyright (C) 2001 Matt Soffen 8 | * 9 | * Taken from the FreeBSD file (with copyright notice) 10 | * /usr/src/gnu/lib/libdialog/dir.c 11 | *************************************************************************** 12 | * Program: dir.c 13 | * Author: Marc van Kempen 14 | * desc: Directory routines, sorting and reading 15 | * 16 | * Copyright (c) 1995, Marc van Kempen 17 | * 18 | * All rights reserved. 19 | * 20 | * This software may be used, modified, copied, distributed, and 21 | * sold, in both source and binary form provided that the above 22 | * copyright and these terms are retained, verbatim, as the first 23 | * lines of this file. Under no circumstances is the author 24 | * responsible for the proper functioning of this software, nor does 25 | * the author assume any responsibility for damages incurred with 26 | * its use. 27 | * 28 | *************************************************************************** 29 | */ 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | #include /* XXX for _POSIX_VERSION ifdefs */ 36 | 37 | #if HAVE_STRINGS_H 38 | #include 39 | #endif 40 | 41 | #if !defined sgi && !defined _POSIX_VERSION 42 | #include 43 | #endif 44 | 45 | #include 46 | #include 47 | #include 48 | #include 49 | 50 | int alphasort(const void *dirent1, const void *dirent2) { 51 | return(strcmp((*(const struct dirent **)dirent1)->d_name, 52 | (*(const struct dirent **)dirent2)->d_name)); 53 | } 54 | -------------------------------------------------------------------------------- /replace/daemon.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * 3 | * daemon - replacement for daemon function. 4 | * 5 | * Matt Soffen 6 | * Copyright (C) 2004 Matt Soffen 7 | * 8 | * Taken from the FreeBSD file (with copyright notice) 9 | * ------------------------------------------------------------ 10 | * Copyright (c) 1990, 1993 11 | * The Regents of the University of California. All rights reserved. 12 | * 13 | * Redistribution and use in source and binary forms, with or without 14 | * modification, are permitted provided that the following conditions 15 | * are met: 16 | * 1. Redistributions of source code must retain the above copyright 17 | * notice, this list of conditions and the following disclaimer. 18 | * 2. Redistributions in binary form must reproduce the above copyright 19 | * notice, this list of conditions and the following disclaimer in the 20 | * documentation and/or other materials provided with the distribution. 21 | * 3. All advertising materials mentioning features or use of this software 22 | * must display the following acknowledgement: 23 | * This product includes software developed by the University of 24 | * California, Berkeley and its contributors. 25 | * 4. Neither the name of the University nor the names of its contributors 26 | * may be used to endorse or promote products derived from this software 27 | * without specific prior written permission. 28 | * 29 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 30 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 31 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 32 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 33 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 34 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 35 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 36 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 37 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 38 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 39 | * SUCH DAMAGE. 40 | * 41 | * $FreeBSD: src/lib/libc/gen/daemon.c,v 1.3 2000/01/27 23:06:14 jasone Exp $ 42 | * 43 | */ 44 | 45 | #if defined(LIBC_SCCS) && !defined(lint) 46 | static char sccsid[] = "@(#)daemon.c 8.1 (Berkeley) 6/4/93"; 47 | #endif /* LIBC_SCCS and not lint */ 48 | 49 | #include 50 | 51 | #include 52 | #include 53 | 54 | int 55 | daemon(nochdir, noclose) 56 | int nochdir, noclose; 57 | { 58 | int fd; 59 | 60 | switch (fork()) { 61 | case -1: 62 | return (-1); 63 | case 0: 64 | break; 65 | default: 66 | exit(0); 67 | } 68 | 69 | if (setsid() == -1) 70 | return (-1); 71 | 72 | if (!nochdir) 73 | (void)chdir("/"); 74 | 75 | if (!noclose && (fd = open("/dev/null", O_RDWR, 0)) != -1) { 76 | (void)dup2(fd, STDIN_FILENO); 77 | (void)dup2(fd, STDOUT_FILENO); 78 | (void)dup2(fd, STDERR_FILENO); 79 | if (fd > 2) 80 | (void)close(fd); 81 | } 82 | return (0); 83 | } 84 | -------------------------------------------------------------------------------- /replace/scandir.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClusterLabs/cluster-glue/5cc622b4f12f163ff29a2b77459508b662790cb6/replace/scandir.c -------------------------------------------------------------------------------- /replace/setenv.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2001 Alan Robertson 3 | * This software licensed under the GNU LGPL. 4 | * 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, see 18 | * 19 | */ 20 | #include 21 | #include 22 | #include 23 | 24 | /* 25 | * Small replacement function for setenv() 26 | */ 27 | int 28 | setenv(const char *name, const char * value, int why) 29 | { 30 | int rc = -1; 31 | 32 | if ( name && value ) { 33 | char * envp = NULL; 34 | envp = malloc(strlen(name)+strlen(value)+2); 35 | if (envp) { 36 | /* 37 | * Unfortunately, the putenv API guarantees memory leaks when 38 | * changing environment variables repeatedly... :-( 39 | */ 40 | 41 | sprintf(envp, "%s=%s", name, value); 42 | 43 | /* Cannot free envp (!) */ 44 | rc = putenv(envp); 45 | } 46 | 47 | } 48 | return(rc); 49 | } 50 | -------------------------------------------------------------------------------- /replace/strerror.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002 Alan Robertson 3 | * This software licensed under the GNU LGPL. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of version 2.1 of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, see 16 | * 17 | */ 18 | #include 19 | #include 20 | #include 21 | extern const char * sys_err[]; 22 | extern int sys_nerr; 23 | char * 24 | strerror(int errnum) 25 | { 26 | static char whaterr[32]; 27 | 28 | if (errnum < 0) { 29 | return "negative errno"; 30 | } 31 | if (errnum >= sys_nerr) { 32 | snprintf(whaterr, sizeof(whaterr),"error %d", errnum); 33 | return whaterr; 34 | } 35 | return sys_err[sys_nerr]; 36 | } 37 | -------------------------------------------------------------------------------- /replace/strlcat.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | /* 4 | * Copyright (C) 2007 Alan Robertson 5 | * This software licensed under the GNU LGPL. 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, see 19 | * 20 | */ 21 | 22 | size_t 23 | strlcat(char *dest, const char * src, size_t maxlen) 24 | { 25 | size_t curlen = strlen(dest); 26 | size_t addlen = strlen(src); 27 | size_t appendlen = (maxlen-1) - curlen; 28 | if (appendlen > 0) { 29 | strlcpy(dest+curlen, src, maxlen-curlen); 30 | } 31 | return curlen + addlen; 32 | } 33 | -------------------------------------------------------------------------------- /replace/strlcpy.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | /* 4 | * Copyright (C) 2007 Alan Robertson 5 | * This software licensed under the GNU LGPL. 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, see 19 | * 20 | */ 21 | 22 | size_t 23 | strlcpy(char *dest, const char * src, size_t maxlen) 24 | { 25 | size_t srclen = strlen(src); 26 | if (maxlen > 0) { 27 | strncpy(dest, src, maxlen); 28 | dest[maxlen-1]=EOS; 29 | } 30 | return srclen; 31 | } 32 | -------------------------------------------------------------------------------- /replace/strndup.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | /* 5 | * Copyright (C) 2004 Matt Soffen 6 | * This software licensed under the GNU LGPL. 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this library; if not, see 20 | * 21 | */ 22 | 23 | /* Taken from the GlibC implementation of strndup */ 24 | 25 | char *strndup(const char *str, size_t len) 26 | { 27 | size_t n = strnlen(str,len); 28 | char *new = (char *) malloc (len+1); 29 | 30 | if (NULL == new) { 31 | return NULL; 32 | } 33 | 34 | new[n] = '\0'; 35 | return (char *)memcpy (new, str, len); 36 | } 37 | 38 | -------------------------------------------------------------------------------- /replace/strnlen.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | /* 4 | * Copyright (C) 2003 Alan Robertson 5 | * This software licensed under the GNU LGPL. 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, see 19 | * 20 | */ 21 | 22 | size_t 23 | strnlen(const char *s, size_t maxlen) 24 | { 25 | const char * eospos; 26 | 27 | eospos = memchr(s, (int)'\0', maxlen); 28 | 29 | return (eospos == NULL ? maxlen : (size_t)(eospos-s)); 30 | } 31 | -------------------------------------------------------------------------------- /replace/unsetenv.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2001 Alan Robertson 3 | * This software licensed under the GNU LGPL. 4 | * 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, see 18 | * 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #define __environ environ 28 | #ifndef HAVE_ENVIRON_DECL 29 | extern char **environ; 30 | #endif 31 | 32 | int 33 | unsetenv (const char *name) 34 | { 35 | const size_t len = strlen (name); 36 | char **ep; 37 | 38 | for (ep = __environ; *ep; ++ep) { 39 | if (!strncmp (*ep, name, len) && (*ep)[len] == '=') { 40 | /* Found it. */ 41 | /* Remove this pointer by moving later ones back. */ 42 | char **dp = ep; 43 | do 44 | dp[0] = dp[1]; 45 | while (*dp++); 46 | /* Continue the loop in case NAME appears again. */ 47 | } 48 | } 49 | return 0; 50 | } 51 | --------------------------------------------------------------------------------