[PATCH] Spec: Don't use chkconfig --del with systemd
by Zane Bitter
Since the SysV init scripts are no longer installed when systemd is in use,
we shouldn't do chkconfig --del to clean up /etc/rc.d when uninstalling
either. At the moment uninstall is failing because this command returns an
error.
Signed-off-by: Zane Bitter <zbitter(a)redhat.com>
---
matahari.spec.in | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/matahari.spec.in b/matahari.spec.in
index 85dae66..ae43f1e 100644
--- a/matahari.spec.in
+++ b/matahari.spec.in
@@ -219,7 +219,9 @@ rm -f $RPM_BUILD_ROOT/%{_sysconfdir}/rc.d/init.d/matahari-broker
%preun host
if [ $1 = 0 ]; then
/sbin/service matahari-host stop >/dev/null 2>&1 || :
+%if %{undefined _unitdir}
chkconfig --del matahari-host
+%endif
fi
%postun host
@@ -235,7 +237,9 @@ fi
%preun network
if [ $1 = 0 ]; then
/sbin/service matahari-network stop >/dev/null 2>&1 || :
+%if %{undefined _unitdir}
chkconfig --del matahari-network
+%endif
fi
%postun network
@@ -251,7 +255,9 @@ fi
%preun service
if [ $1 = 0 ]; then
/sbin/service matahari-service stop >/dev/null 2>&1 || :
+%if %{undefined _unitdir}
chkconfig --del matahari-service
+%endif
fi
%postun service
@@ -267,7 +273,9 @@ fi
%preun sysconfig
if [ $1 = 0 ]; then
/sbin/service matahari-sysconfig stop >/dev/null 2>&1 || :
+%if %{undefined _unitdir}
chkconfig --del matahari-sysconfig
+%endif
fi
%postun sysconfig
@@ -283,7 +291,9 @@ fi
%preun broker
if [ $1 = 0 ]; then
/sbin/service matahari-broker stop >/dev/null 2>&1 || :
+%if %{undefined _unitdir}
chkconfig --del matahari-broker
+%endif
fi
%postun broker
12 years, 7 months
[PATCH] Various manual updates.
by Russell Bryant
1) Add a project introduction chapter.
2) Add some notes on installation and running agents on Windows.
3) Add some more items to the outline of the getting started chapter.
- a section for initial configuration of a broker and agents
- a section for testing agents using qmf-tool
Signed-off-by: Russell Bryant <rbryant(a)redhat.com>
---
en-US/GettingStarted.xml | 84 ++++++++++++++++++++---
en-US/Intro.xml | 167 ++++++++++++++++++++++++++++++++++++++++++++++
en-US/Matahari.xml | 1 +
matahari | 2 +-
4 files changed, 242 insertions(+), 12 deletions(-)
create mode 100644 en-US/Intro.xml
diff --git a/en-US/GettingStarted.xml b/en-US/GettingStarted.xml
index 52afe8f..47d4dcc 100644
--- a/en-US/GettingStarted.xml
+++ b/en-US/GettingStarted.xml
@@ -19,7 +19,7 @@
packaged in various Linux distributions to make installation as easy as
possible. If Matahari is not packaged in your Linux distribution, you can
fall back to installation from source. For source installation
- instructures, please see the <ulink
+ instructions, please see the <ulink
url="https://github.com/matahari/matahari/blob/master/README.mkd">README</ulink>
included in the Matahari source.</para>
@@ -35,9 +35,63 @@
<section>
<title>Windows</title>
- <warning>
- <para>TODO: Document how to install on Windows.</para>
- </warning>
+ <para>The Matahari project produces a Windows installer. However, it is
+ not current available to be downloaded directly. While it may seem odd,
+ you can get it via a package on some Linux distributions. This is
+ primarily just because it's very easy for the Matahari developers to
+ distribute the installer this way since it just goes along with the rest
+ of the Matahari Linux packages. On Fedora, install the
+ <literal>mingw32-matahari</literal> package:</para>
+
+ <screen><prompt>#</prompt> <userinput>yum install mingw32-matahari</userinput></screen>
+
+ <para>Once this package has been installed, there will be an ISO that
+ can be found at
+ <filename>/usr/i686-pc-mingw32/sys-root/mingw/share/matahari/matahari-0.4.6-win32.iso</filename>.
+ This ISO contains a Windows installer. There are various ways to get the
+ Windows installer to a Windows machine. A few options include:</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>Mount the ISO locally on Linux and copy the installer.</para>
+ </listitem>
+
+ <listitem>
+ <para>Mount the ISO to the CD drive of a Windows guest virtual
+ machine.</para>
+ </listitem>
+
+ <listitem>
+ <para>Burn the ISO to a CD.</para>
+ </listitem>
+ </itemizedlist>
+
+ <para>Once the Windows installer is on the Windows system, run it and it
+ will proceed like many other common Windows installers. Once the
+ installation has been completed, Matahari agents will have been
+ installed as system services that can be started and stopped like any
+ other Windows service.</para>
+ </section>
+ </section>
+
+ <section>
+ <title>Initial Configuration</title>
+
+ <para><remark>TODO: Complete the initial config section. Document basic
+ configuraiton options that apply in fairly common cases here. Include a
+ link to the security chapter or wherever else is appropriate for some of
+ the more advanced configuration topics.</remark></para>
+
+ <section>
+ <title>Broker Configuration</title>
+
+ <para></para>
+ </section>
+
+ <section>
+ <title>Agent Configuration</title>
+
+ <para></para>
</section>
</section>
@@ -46,8 +100,8 @@
<para>At this time, the <command>qpidd</command> broker is only supported
on Linux. Matahari comes with a <command>matahari-brokerd</command>
- wrapper around <command>qpidd</command>. To start the <literal>matahari-broker</literal>
- service:</para>
+ wrapper around <command>qpidd</command>. To start the
+ <literal>matahari-broker</literal> service:</para>
<screen><prompt>#</prompt> <userinput>service matahari-broker start</userinput></screen>
@@ -65,8 +119,8 @@
<section>
<title>Linux</title>
- <para>Each Matahari agent can be started via a system service.
- For example, to start the <literal>Host</literal> agent:</para>
+ <para>Each Matahari agent can be started via a system service. For
+ example, to start the <literal>Host</literal> agent:</para>
<screen><prompt>#</prompt> <userinput>service <replaceable>matahari-host</replaceable> start</userinput></screen>
@@ -103,9 +157,9 @@
<section>
<title>Windows</title>
- <warning>
- <para>TODO: Document how to run agents on Windows.</para>
- </warning>
+ <para>Matahari agents are installed as system services on Windows. Start
+ and stop them using the method appropriate method for the version of
+ Windows you are using.</para>
<section>
<title>Logging</title>
@@ -118,4 +172,12 @@
</section>
</section>
</section>
+
+ <section>
+ <title>Testing Agent Connectivity</title>
+
+ <para><remark>TODO: Show how to use qmf-tool to verify that an agent is up
+ and running. Once the Matahari shell is available, using that here would
+ be good too.</remark></para>
+ </section>
</chapter>
diff --git a/en-US/Intro.xml b/en-US/Intro.xml
new file mode 100644
index 0000000..6cc6c6f
--- /dev/null
+++ b/en-US/Intro.xml
@@ -0,0 +1,167 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+<!ENTITY % BOOK_ENTITIES SYSTEM "Matahari.ent">
+%BOOK_ENTITIES;
+]>
+<chapter id="Matahari-Introduction">
+ <title>Introduction</title>
+
+ <para>Matahari is a cross-platform (Linux and Windows so far) collection of
+ APIs accessible over local and remote interfaces for systems management and
+ monitoring. What the heck does that mean? Read on, dear friends.</para>
+
+ <section>
+ <title>Architecture Overview</title>
+
+ <para>Matahari APIs are accessible via a few different methods. The core
+ of the functionality that is implemented is done as C libraries. These can
+ be used directly. However, it is expected and intended for most users to
+ access the functionality via one of the agents we provide. A Matahari
+ Agent is an application that provides access to the features implemented
+ in a Matahari Library via some transport. We are currently providing
+ agents for <ulink
+ url="http://www.freedesktop.org/wiki/Software/dbus">D-Bus</ulink> and
+ <ulink url="http://qpid.apache.org/">QMF</ulink>.</para>
+
+ <para>D-Bus is used quite heavily as a communications mechanism between
+ applications on a single system. QMF, or the Qpid Management Framework, is
+ used as a remote interface. QMF is a framework for building remote APIs on
+ top of AMQP, an open protocol for messaging.</para>
+
+ <para>The agents are generally thin wrappers around a core library, so
+ other transports could be added in the future if the need presents
+ itself.</para>
+ </section>
+
+ <section>
+ <title>Current Features</title>
+
+ <para>So, what can you do with Matahari? </para>
+
+ <para>Matahari is still under heavy development, but there is already a
+ decent amount of usable functionality. The current set of agents
+ includes:</para>
+
+ <itemizedlist>
+ <listitem>
+ <para><emphasis>Host</emphasis> - An agent for viewing and controlling
+ hosts.</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>View basic host information such as OS, hostname, CPU, RAM,
+ load average, and more.</para>
+ </listitem>
+
+ <listitem>
+ <para>Host control (shutdown, reboot)</para>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ </itemizedlist>
+
+ <itemizedlist>
+ <listitem>
+ <para><emphasis>Networking</emphasis> – An agent for viewing and
+ controlling network devices</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>Get a list of available network interfaces and information
+ about them, such as IP and MAC addresses</para>
+ </listitem>
+
+ <listitem>
+ <para>Start and stop network interfaces</para>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ </itemizedlist>
+
+ <itemizedlist>
+ <listitem>
+ <para><emphasis>Services</emphasis> – An agent for viewing and
+ controlling system services</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>List configured services</para>
+ </listitem>
+
+ <listitem>
+ <para>Start and stop services</para>
+ </listitem>
+
+ <listitem>
+ <para>Monitor the status of services</para>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ </itemizedlist>
+
+ <itemizedlist>
+ <listitem>
+ <para><emphasis>Sysconfig</emphasis> – Modify system
+ configuration</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>Modify system configuration files (Linux)</para>
+ </listitem>
+
+ <listitem>
+ <para>Modify system registry (Windows)</para>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ </itemizedlist>
+
+ <para>More things that are in the works can be found on the project <ulink
+ url="https://github.com/matahari/matahari/wiki/Backlog">backlog</ulink>.</para>
+ </section>
+
+ <section>
+ <title>Use Cases</title>
+
+ <para>An example of a project that already utilizes Matahari is <ulink
+ url="http://pacemaker-cloud.org/">Pacemaker-cloud</ulink>, which is also
+ under heavy development. Pacemaker-cloud utilizes both the Host and
+ Services agents of Matahari. Being able to actively monitor and control
+ services on remote hosts is a key element of being able to provide HA in a
+ cloud deployment.</para>
+
+ <para>In addition to providing ready-to-use agents, we also provide some
+ code that makes it easier to write a QMF agent so that third-parties can
+ write their own Matahari agents. One example of this that already exists
+ is <ulink url="http://libvirt.org/">libvirt-qmf</ulink>, which is a
+ Matahari agent that exposes libvirt functionality over QMF.</para>
+ </section>
+
+ <section>
+ <title>More Information</title>
+
+ <para>The rest of this manual goes into more detail about how to install
+ and use Matahari. Here is a list of other places you can go to get more
+ information and participate in the project.</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>The project home page is <ulink
+ url="http://www.matahariproject.org">http://www.matahariproject.org/</ulink>.</para>
+ </listitem>
+
+ <listitem>
+ <para>You can find the code on <ulink
+ url="https://github.com/matahari/matahari">github</ulink>.</para>
+ </listitem>
+
+ <listitem>
+ <para>You can follow patches and project related discussion on the
+ <ulink
+ url="https://fedorahosted.org/mailman/listinfo/matahari">mailing
+ list</ulink>.</para>
+ </listitem>
+ </itemizedlist>
+ </section>
+</chapter>
diff --git a/en-US/Matahari.xml b/en-US/Matahari.xml
index 2b7d0c7..f048a10 100644
--- a/en-US/Matahari.xml
+++ b/en-US/Matahari.xml
@@ -6,6 +6,7 @@
<book>
<xi:include href="Book_Info.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href="Preface.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <xi:include href="Intro.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href="GettingStarted.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href="Agents.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href="CreatingYourOwnAgent.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
diff --git a/matahari b/matahari
index f828cb4..ed997fd 160000
--- a/matahari
+++ b/matahari
@@ -1 +1 @@
-Subproject commit f828cb4a07c0ed28c227b480c99b0d065265bb80
+Subproject commit ed997fd88eac6df4b32214000bf12d9eded6a03f
--
1.7.6
12 years, 8 months
[PATCH] sysconfig: Fix file:// support in run_uri.
by Russell Bryant
A recent change to add more error checking on a curl request broke
file:// support. Now the check for the result code is only dont if the
URI was HTTP or FTP, since those are the only URI types that this check
is applicable to.
Signed-off-by: Russell Bryant <rbryant(a)redhat.com>
---
src/lib/sysconfig_linux.c | 22 ++++++++++++----------
1 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/src/lib/sysconfig_linux.c b/src/lib/sysconfig_linux.c
index df4e071..c46ac1e 100644
--- a/src/lib/sysconfig_linux.c
+++ b/src/lib/sysconfig_linux.c
@@ -58,7 +58,7 @@ sysconfig_os_download(const char *uri, FILE *fp)
{
CURL *curl;
CURLcode curl_res;
- long http_code = 0;
+ long response = 0;
int res = 0;
static int curl_init = 0;
@@ -98,15 +98,17 @@ sysconfig_os_download(const char *uri, FILE *fp)
goto return_cleanup;
}
- curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &http_code);
- if (curl_res != CURLE_OK) {
- mh_warn("curl_easy_getinfo for RESPONSE_CODE failed. (%d)", curl_res);
- res = -1;
- goto return_cleanup;
- }
- if (http_code < 200 || http_code > 299) {
- mh_warn("curl request for URI '%s' got response %ld", uri, http_code);
- res = -1;
+ if (!strncasecmp(uri, "http", 4) || !strncasecmp(uri, "ftp", 3)) {
+ curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response);
+ if (curl_res != CURLE_OK) {
+ mh_warn("curl_easy_getinfo for RESPONSE_CODE failed. (%d)", curl_res);
+ res = -1;
+ goto return_cleanup;
+ }
+ if (response < 200 || response > 299) {
+ mh_warn("curl request for URI '%s' got response %ld", uri, response);
+ res = -1;
+ }
}
return_cleanup:
--
1.7.6
12 years, 8 months
[PATCH] core: convert strncpy() usage to mh_string_copy().
by russell@russellbryant.net
From: Russell Bryant <rbryant(a)redhat.com>
Signed-off-by: Russell Bryant <rbryant(a)redhat.com>
---
src/broker/broker_federation.c | 3 +--
src/lib/dnssrv.c | 3 +--
src/lib/host_linux.c | 3 +--
src/lib/network.c | 3 +--
src/lib/sysconfig.c | 6 ++----
src/lib/utilities_windows.c | 3 +--
6 files changed, 7 insertions(+), 14 deletions(-)
diff --git a/src/broker/broker_federation.c b/src/broker/broker_federation.c
index 4e8249d..f4d09bb 100644
--- a/src/broker/broker_federation.c
+++ b/src/broker/broker_federation.c
@@ -99,8 +99,7 @@ void broker_federation_configure(void)
snprintf(local, sizeof(local), "localhost:%hu", broker_get_port());
- strncpy(peers, brokers, sizeof(peers) - 1);
- peers[sizeof(peers) - 1] = '\0';
+ mh_string_copy(peers, brokers, sizeof(peers));
while ((peer = strtok_r(p ? NULL : peers, ",; ", &p)) != NULL) {
if (strncmp(peer, DNS_SRV_PREFIX, strlen(DNS_SRV_PREFIX)) == 0) {
diff --git a/src/lib/dnssrv.c b/src/lib/dnssrv.c
index 4f346cb..351da76 100644
--- a/src/lib/dnssrv.c
+++ b/src/lib/dnssrv.c
@@ -184,8 +184,7 @@ mh_dnssrv_lookup_single(const char *query, char *host, size_t host_len, uint16_t
record = g_list_nth_data(records, 0);
if (record) {
- strncpy(host, record->host, host_len);
- host[host_len - 1] = '\0';
+ mh_string_copy(host, record->host, host_len);
*port = record->port;
}
diff --git a/src/lib/host_linux.c b/src/lib/host_linux.c
index fd748c1..dedd249 100644
--- a/src/lib/host_linux.c
+++ b/src/lib/host_linux.c
@@ -103,8 +103,7 @@ host_os_get_cpu_flags(void)
if (!(flags = malloc(len))) {
goto done;
}
- strncpy(flags, cur + found[4], len);
- flags[len - 1] = '\0';
+ mh_string_copy(flags, cur + found[4], len);
break;
}
diff --git a/src/lib/network.c b/src/lib/network.c
index 0df4dc5..e57e027 100644
--- a/src/lib/network.c
+++ b/src/lib/network.c
@@ -160,8 +160,7 @@ mh_network_get_ip_address(const char *iface, char *buf, size_t len)
if ((g_str_equal(mh_network_interface_get_name(mh_iface), iface)) == TRUE) {
sigar_net_address_to_string(NULL, &mh_iface->ifconfig.address, addr_str);
- strncpy(buf, addr_str, len - 1);
- buf[len - 1] = '\0';
+ mh_string_copy(buf, addr_str, len);
break;
}
}
diff --git a/src/lib/sysconfig.c b/src/lib/sysconfig.c
index c5800b0..4e32737 100644
--- a/src/lib/sysconfig.c
+++ b/src/lib/sysconfig.c
@@ -52,8 +52,7 @@ static const char *
keys_dir_get(void)
{
if (!*_keys_dir) {
- strncpy(_keys_dir, DEFAULT_KEYS_DIR, sizeof(_keys_dir) - 1);
- _keys_dir[sizeof(_keys_dir) - 1] = '\0';
+ mh_string_copy(_keys_dir, DEFAULT_KEYS_DIR, sizeof(_keys_dir));
}
return _keys_dir;
@@ -62,8 +61,7 @@ keys_dir_get(void)
void
mh_sysconfig_keys_dir_set(const char *path)
{
- strncpy(_keys_dir, path, sizeof(_keys_dir) - 1);
- _keys_dir[sizeof(_keys_dir) - 1] = '\0';
+ mh_string_copy(_keys_dir, path, sizeof(_keys_dir));
}
static gboolean
diff --git a/src/lib/utilities_windows.c b/src/lib/utilities_windows.c
index 4a9eb39..74cecbf 100644
--- a/src/lib/utilities_windows.c
+++ b/src/lib/utilities_windows.c
@@ -70,8 +70,7 @@ mh_os_uuid(void)
UuidCreate(&uuid);
if (UuidToStringA(&uuid, &rs) == RPC_S_OK) {
- strncpy(uuid_str, (char *) rs, sizeof(uuid_str));
- uuid_str[sizeof(uuid_str) - 1] = '\0';
+ mh_string_copy(uuid_str, (char *) rs, sizeof(uuid_str));
RpcStringFreeA(&rs);
mh_trace("Got uuid: %s", uuid_str);
res = RegSetValueExA(key, UUID_REGISTRY_KEY, 0, REG_SZ,
--
1.7.6
12 years, 8 months
[PATCH] core: Add mh_string_copy().
by russell@russellbryant.net
From: Russell Bryant <rbryant(a)redhat.com>
This simple string helper is like strncpy(), but sucks less.
Signed-off-by: Russell Bryant <rbryant(a)redhat.com>
---
src/include/matahari/utilities.h | 10 ++++++++
src/lib/utilities.c | 21 ++++++++++++++++++
src/tests/CMakeLists.txt | 2 +
src/tests/mh_api_utilities.h | 44 ++++++++++++++++++++++++++++++++++++++
4 files changed, 77 insertions(+), 0 deletions(-)
create mode 100644 src/tests/mh_api_utilities.h
diff --git a/src/include/matahari/utilities.h b/src/include/matahari/utilities.h
index cea0c3b..b6cce84 100644
--- a/src/include/matahari/utilities.h
+++ b/src/include/matahari/utilities.h
@@ -118,4 +118,14 @@ mh_strlen_zero(const char *s)
return !s || *s == '\0';
}
+/**
+ * Like strncpy(), but with less suck.
+ *
+ * Use like strncpy(). The differences are that it guarantees to terminate
+ * the output string and that it doesn't wastefully zero out the entire output
+ * buffer after the end of the string.
+ */
+char *
+mh_string_copy(char *dst, const char *src, size_t dst_len);
+
#endif
diff --git a/src/lib/utilities.c b/src/lib/utilities.c
index 68c6582..93f44a4 100644
--- a/src/lib/utilities.c
+++ b/src/lib/utilities.c
@@ -497,3 +497,24 @@ g_list_free_full (GList *list, GDestroyNotify free_func)
g_list_free (list);
}
#endif /* HAVE_G_LIST_FREE_FULL */
+
+char *
+mh_string_copy(char *dst, const char *src, size_t dst_len)
+{
+ char *ret = dst;
+ size_t orig_dst_len = dst_len;
+
+ while (*src && dst_len) {
+ *dst++ = *src++;
+ dst_len--;
+ }
+
+ if (orig_dst_len) {
+ if (!dst_len) {
+ dst--;
+ }
+ *dst = '\0';
+ }
+
+ return ret;
+}
diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt
index 8fe81f2..331481b 100644
--- a/src/tests/CMakeLists.txt
+++ b/src/tests/CMakeLists.txt
@@ -6,12 +6,14 @@ if(CXXTEST_FOUND)
CXXTEST_ADD_TEST(mh_api_network_unittest network_unittest.cpp ${CMAKE_CURRENT_SOURCE_DIR}/mh_api_network.h)
CXXTEST_ADD_TEST(mh_api_host_unittest host_unittest.cpp ${CMAKE_CURRENT_SOURCE_DIR}/mh_api_host.h)
CXXTEST_ADD_TEST(mh_api_sysconfig_unittest sysconfig_unittest.cpp ${CMAKE_CURRENT_SOURCE_DIR}/mh_api_sysconfig.h)
+ CXXTEST_ADD_TEST(mh_api_utilities_unittest utilities_unittest.cpp ${CMAKE_CURRENT_SOURCE_DIR}/mh_api_utilities.h)
CXXTEST_ADD_TEST(mh_hsa_unittest hsa_unittest.cpp ${CMAKE_CURRENT_SOURCE_DIR}/mh_hsa_${VARIANT}.h)
add_library(mh_tester SHARED test_utilities.c)
target_link_libraries(mh_tester ${pcre_LIBRARIES} mcommon mnetwork mhost msysconfig)
target_link_libraries(mh_api_network_unittest mh_tester)
target_link_libraries(mh_api_host_unittest mh_tester)
target_link_libraries(mh_api_sysconfig_unittest mh_tester)
+ target_link_libraries(mh_api_utilities_unittest mh_tester)
target_link_libraries(mh_hsa_unittest mh_tester)
endif(CXXTEST_FOUND)
diff --git a/src/tests/mh_api_utilities.h b/src/tests/mh_api_utilities.h
new file mode 100644
index 0000000..c7e5b97
--- /dev/null
+++ b/src/tests/mh_api_utilities.h
@@ -0,0 +1,44 @@
+#ifndef __MH_API_UTILITIES_UNITTEST_H
+#define __MH_API_UTILITIES_UNITTEST_H
+
+#include <cstring>
+#include <cxxtest/TestSuite.h>
+
+extern "C" {
+#include "matahari/utilities.h"
+};
+
+using namespace std;
+
+class MhApiUtilitiesSuite : public CxxTest::TestSuite
+{
+public:
+ void testStrlenZero(void)
+ {
+ TS_ASSERT(mh_strlen_zero("foo") == 0);
+ TS_ASSERT(mh_strlen_zero("") != 0);
+ TS_ASSERT(mh_strlen_zero(NULL) != 0);
+ }
+
+ void testCopyString(void)
+ {
+ char out[8] = "abc";
+
+ mh_string_copy(out, "x", 0);
+ TS_ASSERT(strcmp(out, "abc") == 0);
+
+ mh_string_copy(out, "", sizeof(out));
+ TS_ASSERT(out[0] == '\0');
+ TS_ASSERT(out[1] == 'b');
+
+ mh_string_copy(out, "z", sizeof(out));
+ TS_ASSERT(out[0] == 'z');
+ TS_ASSERT(out[1] == '\0');
+ TS_ASSERT(out[2] == 'c');
+
+ mh_string_copy(out, "1234567890", sizeof(out));
+ TS_ASSERT(strcmp(out, "1234567") == 0);
+ }
+};
+
+#endif
--
1.7.6
12 years, 8 months
[PATCH] A bit of header file nit-picking.
by russell@russellbryant.net
From: Russell Bryant <rbryant(a)redhat.com>
Remove unnecessary extern from a bunch of function prototypes. Tweak
formatting of function prototypes to match coding guidelines.
Signed-off-by: Russell Bryant <rbryant(a)redhat.com>
---
src/include/matahari/agent.h | 32 ++++++++------
src/include/matahari/host.h | 66 ++++++++++++++++++++--------
src/include/matahari/logging.h | 12 ++++-
src/include/matahari/mainloop.h | 51 ++++++++++++----------
src/include/matahari/network.h | 23 ++++++----
src/include/matahari/services.h | 43 ++++++++++++-------
src/include/matahari/sysconfig.h | 10 ++--
src/include/matahari/sysconfig_internal.h | 2 +-
src/include/matahari/utilities.h | 31 +++++++++----
src/lib/host_private.h | 26 +++++++----
src/lib/network_private.h | 12 ++++-
src/lib/services_private.h | 50 ++++++++++++++++++----
src/lib/sysconfig_private.h | 12 +++--
src/tests/mh_test_utilities.h | 3 +-
14 files changed, 248 insertions(+), 125 deletions(-)
diff --git a/src/include/matahari/agent.h b/src/include/matahari/agent.h
index 8345841..4175809 100644
--- a/src/include/matahari/agent.h
+++ b/src/include/matahari/agent.h
@@ -74,25 +74,31 @@ typedef struct mainloop_qmf_s {
* retval[1] failed to daemonize
* retval[0] successfully daemonize
*/
-extern int
+int
mh_should_daemonize(int code, const char *name, const char *arg, void *userdata);
-extern int mh_add_option(
- int code, int has_arg, const char *name, const char *description,
- void *userdata, int(*callback)(int code, const char *name, const char *arg, void *userdata));
+int
+mh_add_option(int code, int has_arg, const char *name, const char *description,
+ void *userdata, int(*callback)(int code, const char *name,
+ const char *arg, void *userdata));
-extern qpid::types::Variant::Map mh_parse_options(
- const char *proc_name, int argc, char **argv, qpid::types::Variant::Map &options);
+qpid::types::Variant::Map
+mh_parse_options(const char *proc_name, int argc, char **argv,
+ qpid::types::Variant::Map &options);
-extern qpid::messaging::Connection mh_connect(
- qpid::types::Variant::Map mh_options, qpid::types::Variant::Map amqp_options, int retry);
+qpid::messaging::Connection
+mh_connect(qpid::types::Variant::Map mh_options,
+ qpid::types::Variant::Map amqp_options, int retry);
-extern mainloop_qmf_t *mainloop_add_qmf(int priority, qmf::AgentSession session,
- gboolean (*dispatch)(qmf::AgentSession session, qmf::AgentEvent event,
- gpointer userdata),
- GDestroyNotify notify, gpointer userdata);
+mainloop_qmf_t *
+mainloop_add_qmf(int priority, qmf::AgentSession session,
+ gboolean (*dispatch)(qmf::AgentSession session,
+ qmf::AgentEvent event,
+ gpointer userdata),
+ GDestroyNotify notify, gpointer userdata);
-extern gboolean mainloop_destroy_qmf(mainloop_qmf_t *source);
+gboolean
+mainloop_destroy_qmf(mainloop_qmf_t *source);
struct MatahariAgentImpl;
diff --git a/src/include/matahari/host.h b/src/include/matahari/host.h
index ba540f7..1da756a 100644
--- a/src/include/matahari/host.h
+++ b/src/include/matahari/host.h
@@ -43,7 +43,7 @@
*
* \return the UUID
*/
-extern const char *
+const char *
mh_host_get_uuid(const char *lifetime);
/**
@@ -56,24 +56,44 @@ mh_host_get_uuid(const char *lifetime);
* \retval 0 success
* \retval non-zero failure
*/
-extern int
+int
mh_host_set_uuid(const char *lifetime, const char *uuid);
-extern const char *mh_host_get_hostname(void);
-extern const char *mh_host_get_operating_system(void);
+const char *
+mh_host_get_hostname(void);
-extern const char *mh_host_get_architecture(void);
-extern const char *mh_host_get_cpu_model(void);
-extern const char *mh_host_get_cpu_flags(void);
+const char *
+mh_host_get_operating_system(void);
-extern uint64_t mh_host_get_memory(void);
-extern uint64_t mh_host_get_mem_free(void);
-extern uint64_t mh_host_get_swap(void);
-extern uint64_t mh_host_get_swap_free(void);
+const char *
+mh_host_get_architecture(void);
-extern int mh_host_get_cpu_count(void);
-extern int mh_host_get_cpu_number_of_cores(void);
-extern int mh_host_get_cpu_wordsize(void);
+const char *
+mh_host_get_cpu_model(void);
+
+const char *
+mh_host_get_cpu_flags(void);
+
+uint64_t
+mh_host_get_memory(void);
+
+uint64_t
+mh_host_get_mem_free(void);
+
+uint64_t
+mh_host_get_swap(void);
+
+uint64_t
+mh_host_get_swap_free(void);
+
+int
+mh_host_get_cpu_count(void);
+
+int
+mh_host_get_cpu_number_of_cores(void);
+
+int
+mh_host_get_cpu_wordsize(void);
/**
* Identify a host.
@@ -83,11 +103,19 @@ extern int mh_host_get_cpu_wordsize(void);
* \retval 0 success
* \retval non-zero failure
*/
-extern int mh_host_identify(void);
+int
+mh_host_identify(void);
+
+void
+mh_host_reboot(void);
+
+void
+mh_host_shutdown(void);
+
+void
+mh_host_get_load_averages(sigar_loadavg_t *avg);
-extern void mh_host_reboot(void);
-extern void mh_host_shutdown(void);
-extern void mh_host_get_load_averages(sigar_loadavg_t *avg);
-extern void mh_host_get_processes(sigar_proc_stat_t *procs);
+void
+mh_host_get_processes(sigar_proc_stat_t *procs);
#endif // __MH_HOST_H__
diff --git a/src/include/matahari/logging.h b/src/include/matahari/logging.h
index 7d152a9..260eccc 100644
--- a/src/include/matahari/logging.h
+++ b/src/include/matahari/logging.h
@@ -46,9 +46,15 @@
#define LOG_TRACE 8
extern int mh_log_level;
-extern void mh_log_fn(int priority, const char * fmt, ...) G_GNUC_PRINTF(2,3);
-extern void mh_log_init(const char *ident, int level, gboolean to_stderr);
-extern void mh_enable_stderr(gboolean to_stderr);
+
+void
+mh_log_fn(int priority, const char * fmt, ...) G_GNUC_PRINTF(2,3);
+
+void
+mh_log_init(const char *ident, int level, gboolean to_stderr);
+
+void
+mh_enable_stderr(gboolean to_stderr);
#if SUPPORT_TRACING
diff --git a/src/include/matahari/mainloop.h b/src/include/matahari/mainloop.h
index 43a7a20..74adce8 100644
--- a/src/include/matahari/mainloop.h
+++ b/src/include/matahari/mainloop.h
@@ -28,48 +28,52 @@
#include <glib.h>
#include <sys/types.h>
-extern gboolean mainloop_signal(int sig, void (*dispatch)(int sig));
+gboolean
+mainloop_signal(int sig, void (*dispatch)(int sig));
-extern gboolean mainloop_add_signal(int sig, void (*dispatch)(int sig));
+gboolean
+mainloop_add_signal(int sig, void (*dispatch)(int sig));
-extern gboolean mainloop_destroy_signal(int sig);
+gboolean
+mainloop_destroy_signal(int sig);
-typedef struct trigger_s
-{
+typedef struct trigger_s {
GSource source;
GDestroyNotify dnotify;
gboolean trigger;
void *user_data;
guint id;
-
} mainloop_trigger_t;
-extern mainloop_trigger_t *mainloop_add_trigger(
- int priority, gboolean (*dispatch)(gpointer user_data), gpointer userdata);
+mainloop_trigger_t *
+mainloop_add_trigger(int priority, gboolean (*dispatch)(gpointer user_data),
+ gpointer userdata);
-extern void mainloop_set_trigger(mainloop_trigger_t *source);
+void
+mainloop_set_trigger(mainloop_trigger_t *source);
-extern gboolean mainloop_destroy_trigger(mainloop_trigger_t *source);
+gboolean
+mainloop_destroy_trigger(mainloop_trigger_t *source);
-typedef struct mainloop_fd_s
-{
+typedef struct mainloop_fd_s {
GSource source;
GPollFD gpoll;
guint id;
void *user_data;
GDestroyNotify dnotify;
gboolean (*dispatch)(int fd, gpointer user_data);
-
} mainloop_fd_t;
-extern mainloop_fd_t *mainloop_add_fd(int priority, int fd,
- gboolean (*dispatch)(int fd, gpointer userdata),
- GDestroyNotify notify, gpointer userdata);
+mainloop_fd_t *
+mainloop_add_fd(int priority, int fd,
+ gboolean (*dispatch)(int fd, gpointer userdata),
+ GDestroyNotify notify, gpointer userdata);
-extern gboolean mainloop_destroy_fd(mainloop_fd_t* source);
+gboolean
+mainloop_destroy_fd(mainloop_fd_t* source);
@@ -83,19 +87,18 @@ struct mainloop_child_s {
/* Called when a process dies */
void (*callback)(mainloop_child_t* p, int status, int signo, int exitcode);
-
};
-extern void mainloop_track_children(int priority);
+void
+mainloop_track_children(int priority);
/*
* Create a new tracked process
* To track a process group, use -pid
*/
-extern void mainloop_add_child(pid_t pid, int timeout, const char *desc,
- void *privatedata,
- void (*callback)(mainloop_child_t* p,
- int status, int signo,
- int exitcode));
+void
+mainloop_add_child(pid_t pid, int timeout, const char *desc, void *privatedata,
+ void (*callback)(mainloop_child_t* p, int status, int signo,
+ int exitcode));
#endif
diff --git a/src/include/matahari/network.h b/src/include/matahari/network.h
index 89effe4..1249bfd 100644
--- a/src/include/matahari/network.h
+++ b/src/include/matahari/network.h
@@ -48,7 +48,7 @@ enum mh_network_interface_flags {
*
* \return the name for the provided network interface
*/
-extern const char *
+const char *
mh_network_interface_get_name(const struct mh_network_interface *iface);
/**
@@ -76,7 +76,7 @@ mh_network_interface_get_flags(const struct mh_network_interface *iface);
* g_list_free_full(iface_list, mh_network_interface_destroy);
* \endcode
*/
-extern void
+void
mh_network_interface_destroy(gpointer data);
/**
@@ -88,7 +88,7 @@ mh_network_interface_destroy(gpointer data);
* \return A list of network interfaces. The data for each list item is a
* struct mh_network_interface.
*/
-extern GList *
+GList *
mh_network_get_interfaces(void);
/**
@@ -100,7 +100,7 @@ mh_network_get_interfaces(void);
*
* \return buf, for convenience
*/
-extern const char *
+const char *
mh_network_get_ip_address(const char *iface, char *buf, size_t len);
/**
@@ -112,12 +112,17 @@ mh_network_get_ip_address(const char *iface, char *buf, size_t len);
*
* \return buf, for convenience
*/
-extern const char *
+const char *
mh_network_get_mac_address(const char *iface, char *buf, size_t len);
-extern void mh_network_stop(const char *iface);
-extern void mh_network_start(const char *iface);
-extern void mh_network_restart(const char *iface);
+void
+mh_network_stop(const char *iface);
+
+void
+mh_network_start(const char *iface);
+
+void
+mh_network_restart(const char *iface);
/**
* Get the status of a network interface
@@ -131,7 +136,7 @@ extern void mh_network_restart(const char *iface);
* \retval non-zero network interface was not found and the value of flags
* is undefined.
*/
-extern int
+int
mh_network_status(const char *iface, uint64_t *flags);
#endif /* __NETWORK_H */
diff --git a/src/include/matahari/services.h b/src/include/matahari/services.h
index e48da77..82d0aa9 100644
--- a/src/include/matahari/services.h
+++ b/src/include/matahari/services.h
@@ -145,7 +145,7 @@ typedef struct svc_action_s
* \return a list of what was found. The list items are gchar *. This list _must_
* be destroyed using g_list_free_full(list, free).
*/
-extern GList *
+GList *
get_directory_list(const char *root, gboolean files);
/**
@@ -154,7 +154,7 @@ get_directory_list(const char *root, gboolean files);
* \return a list of services. The list items are gchar *. This list _must_
* be destroyed using g_list_free_full(list, free).
*/
-extern GList *
+GList *
services_list(void);
/**
@@ -165,7 +165,7 @@ services_list(void);
* \return a list of providers. The list items are gchar *. This list _must_
* be destroyed using g_list_free_full(list, free).
*/
-extern GList *
+GList *
resources_list_providers(const char *standard);
/**
@@ -177,16 +177,27 @@ resources_list_providers(const char *standard);
* \return a list of resource agents. The list items are gchar *. This list _must_
* be destroyed using g_list_free_full(list, free).
*/
-extern GList *
+GList *
resources_list_agents(const char *standard, const char *provider);
-extern svc_action_t *services_action_create(
- const char *name, const char *action, int interval /* ms */, int timeout /* ms */);
+svc_action_t *
+services_action_create(const char *name, const char *action,
+ int interval /* ms */, int timeout /* ms */);
-/* After the call, 'params' is owned, and later free'd by the svc_action_t result */
-extern svc_action_t *resources_action_create(
- const char *name, const char *standard, const char *provider, const char *agent,
- const char *action, int interval /* ms */, int timeout /* ms */, GHashTable *params);
+/**
+ * Create a resources action.
+ *
+ * \param[in] timeout the timeout in milliseconds
+ * \param[in] interval how often to repeat this action, in milliseconds.
+ * If this value is 0, only execute this action one time.
+ *
+ * \post After the call, 'params' is owned, and later free'd by the svc_action_t result
+ */
+svc_action_t *
+resources_action_create(const char *name, const char *standard,
+ const char *provider, const char *agent,
+ const char *action, int interval /* ms */,
+ int timeout /* ms */, GHashTable *params);
/**
* Utilize services API to execute an arbitrary command.
@@ -204,9 +215,11 @@ extern svc_action_t *resources_action_create(
svc_action_t *
mh_services_action_create_generic(const char *exec, const char *args[]);
-extern void services_action_free(svc_action_t *op);
+void
+services_action_free(svc_action_t *op);
-extern gboolean services_action_sync(svc_action_t *op);
+gboolean
+services_action_sync(svc_action_t *op);
/**
* Run an action asynchronously.
@@ -217,11 +230,11 @@ extern gboolean services_action_sync(svc_action_t *op);
* \retval TRUE succesfully started execution
* \retval FALSE failed to start execution, no callback will be received
*/
-extern gboolean
+gboolean
services_action_async(svc_action_t *op, void (*action_callback)(svc_action_t *));
-extern gboolean services_action_cancel(const char *name, const char *action,
- int interval);
+gboolean
+services_action_cancel(const char *name, const char *action, int interval);
static inline enum ocf_exitcode
services_get_ocf_exitcode(char *action, int lsb_exitcode)
diff --git a/src/include/matahari/sysconfig.h b/src/include/matahari/sysconfig.h
index a5bfd04..21a59eb 100644
--- a/src/include/matahari/sysconfig.h
+++ b/src/include/matahari/sysconfig.h
@@ -56,7 +56,7 @@ typedef void (*mh_sysconfig_result_cb)(void *data, int res);
* \retval 0 for success
* \retval -1 for failure
*/
-extern int
+int
mh_sysconfig_run_uri(const char *uri, uint32_t flags, const char *scheme, const char *key,
mh_sysconfig_result_cb result_cb, void *cb_data);
@@ -76,7 +76,7 @@ mh_sysconfig_run_uri(const char *uri, uint32_t flags, const char *scheme, const
* \retval 0 for success
* \retval -1 for failure
*/
-extern int
+int
mh_sysconfig_run_string(const char *string, uint32_t flags, const char *scheme,
const char *key, mh_sysconfig_result_cb result_cb,
void *cb_data);
@@ -90,7 +90,7 @@ mh_sysconfig_run_string(const char *string, uint32_t flags, const char *scheme,
*
* \return DATA of returned query result
*/
-extern const char *
+const char *
mh_sysconfig_query(const char *query, uint32_t flags, const char *scheme);
/**
@@ -102,7 +102,7 @@ mh_sysconfig_query(const char *query, uint32_t flags, const char *scheme);
* \retval 1 if writing to file suceeds
* \retval 0 failed to write to file
*/
-extern gboolean
+gboolean
mh_sysconfig_set_configured(const char *key, const char *contents);
/**
@@ -114,7 +114,7 @@ mh_sysconfig_set_configured(const char *key, const char *contents);
*
* \return STATUS of key
*/
-extern char *
+char *
mh_sysconfig_is_configured(const char *key);
#endif // __MH_SYSCONFIG_H__
diff --git a/src/include/matahari/sysconfig_internal.h b/src/include/matahari/sysconfig_internal.h
index 48879ad..1495737 100644
--- a/src/include/matahari/sysconfig_internal.h
+++ b/src/include/matahari/sysconfig_internal.h
@@ -41,7 +41,7 @@
*
* \return nothing
*/
-extern void
+void
mh_sysconfig_keys_dir_set(const char *path);
#endif /* __MH_SYSCONFIG_INTERNAL_H__ */
diff --git a/src/include/matahari/utilities.h b/src/include/matahari/utilities.h
index 4f73b08..cea0c3b 100644
--- a/src/include/matahari/utilities.h
+++ b/src/include/matahari/utilities.h
@@ -32,22 +32,31 @@
#include <string.h>
#include <glib.h>
-extern const char *mh_uuid(void);
-extern const char *mh_hostname(void);
-extern const char *mh_domainname(void);
+const char *
+mh_uuid(void);
+
+const char *
+mh_hostname(void);
+
+const char *
+mh_domainname(void);
/**
* Get the local dnsdomainname.
*/
-extern const char *
+const char *
mh_dnsdomainname(void);
-extern char *mh_file_first_line(const char *file);
-extern void mh_abort(const char *file, const char *function, int line,
- const char *assert_condition, int do_core, int do_fork);
+char *
+mh_file_first_line(const char *file);
+
+void
+mh_abort(const char *file, const char *function, int line,
+ const char *assert_condition, int do_core, int do_fork);
#ifdef WIN32
-extern wchar_t *char2wide(const char *str);
+wchar_t *
+char2wide(const char *str);
#endif
#ifndef HAVE_ASPRINTF
@@ -58,7 +67,8 @@ extern wchar_t *char2wide(const char *str);
* asprintf() on the system. For more information on how to use asprintf(),
* see its man page.
*/
-extern int asprintf(char **ret, const char *fmt, ...);
+int
+asprintf(char **ret, const char *fmt, ...);
#endif
#ifndef HAVE_G_LIST_FREE_FULL
@@ -68,7 +78,8 @@ extern int asprintf(char **ret, const char *fmt, ...);
* This version of g_list_free_full() is only used when the build system
* doesn't find g_list_free_full() on the system.
*/
-extern void g_list_free_full(GList *list, GDestroyNotify free_func);
+void
+g_list_free_full(GList *list, GDestroyNotify free_func);
#endif
#define DIMOF(a) ((int) (sizeof(a) / sizeof(0[a])))
diff --git a/src/lib/host_private.h b/src/lib/host_private.h
index 1ddc241..009dda6 100644
--- a/src/lib/host_private.h
+++ b/src/lib/host_private.h
@@ -31,13 +31,13 @@
#include <glib.h>
-extern const char *
+const char *
host_os_get_cpu_flags(void);
-extern void
+void
host_os_reboot(void);
-extern void
+void
host_os_shutdown(void);
/**
@@ -46,14 +46,22 @@ host_os_shutdown(void);
* \retval 0 success
* \retval non-zero failure
*/
-extern int
+int
host_os_identify(void);
-extern char *host_os_machine_uuid(void);
-extern char *host_os_custom_uuid(void);
-extern char *host_os_reboot_uuid(void);
-extern const char *host_os_agent_uuid(void);
+char *
+host_os_machine_uuid(void);
-extern int host_os_set_custom_uuid(const char *uuid);
+char *
+host_os_custom_uuid(void);
+
+char *
+host_os_reboot_uuid(void);
+
+const char *
+host_os_agent_uuid(void);
+
+int
+host_os_set_custom_uuid(const char *uuid);
#endif /* __MH_HOST_PRIVATE_H__ */
diff --git a/src/lib/network_private.h b/src/lib/network_private.h
index 859e63d..60b1b71 100644
--- a/src/lib/network_private.h
+++ b/src/lib/network_private.h
@@ -16,7 +16,15 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#ifndef __MH_NETWORK_PRIVATE_H__
+#define __MH_NETWORK_PRIVATE_H__
+
#include <glib.h>
-extern void network_os_stop(const char *iface);
-extern void network_os_start(const char *iface);
+void
+network_os_stop(const char *iface);
+
+void
+network_os_start(const char *iface);
+
+#endif /* __MH_NETWORK_PRIVATE_H__ */
diff --git a/src/lib/services_private.h b/src/lib/services_private.h
index 5a147ef..d7931dc 100644
--- a/src/lib/services_private.h
+++ b/src/lib/services_private.h
@@ -1,5 +1,25 @@
-struct svc_action_private_s
-{
+/*
+ * Copyright (C) 2010 - 2011, Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef __MH_SERVICES_PRIVATE_H__
+#define __MH_SERVICES_PRIVATE_H__
+
+struct svc_action_private_s {
char *exec;
char *args[4];
@@ -13,10 +33,22 @@ struct svc_action_private_s
mainloop_fd_t *stdout_gsource;
};
-extern GList *services_os_get_directory_list(const char *root, gboolean files);
-extern gboolean services_os_action_execute(svc_action_t* op,
- gboolean synchronous);
-extern void services_os_set_exec(svc_action_t* op);
-extern GList *services_os_list(void);
-extern GList *resources_os_list_ocf_providers(void);
-extern GList *resources_os_list_ocf_agents(const char *provider);
+GList *
+services_os_get_directory_list(const char *root, gboolean files);
+
+gboolean
+services_os_action_execute(svc_action_t *op, gboolean synchronous);
+
+void
+services_os_set_exec(svc_action_t *op);
+
+GList *
+services_os_list(void);
+
+GList *
+resources_os_list_ocf_providers(void);
+
+GList *
+resources_os_list_ocf_agents(const char *provider);
+
+#endif /* __MH_SERVICES_PRIVATE_H__ */
diff --git a/src/lib/sysconfig_private.h b/src/lib/sysconfig_private.h
index 36dc554..fb49905 100644
--- a/src/lib/sysconfig_private.h
+++ b/src/lib/sysconfig_private.h
@@ -19,15 +19,17 @@
#ifndef __MH_SYSCONFIG_PRIVATE_H_
#define __MH_SYSCONFIG_PRIVATE_H_
-extern int
+int
sysconfig_os_run_uri(const char *uri, uint32_t flags, const char *scheme,
- const char *key, mh_sysconfig_result_cb result_cb, void *cb_data);
+ const char *key, mh_sysconfig_result_cb result_cb,
+ void *cb_data);
-extern int
+int
sysconfig_os_run_string(const char *string, uint32_t flags, const char *scheme,
- const char *key, mh_sysconfig_result_cb result_cb, void *cb_data);
+ const char *key, mh_sysconfig_result_cb result_cb,
+ void *cb_data);
-extern const char *
+const char *
sysconfig_os_query(const char *query, uint32_t flags, const char *scheme);
#endif /* __MH_SYSCONFIG_PRIVATE_H_ */
diff --git a/src/tests/mh_test_utilities.h b/src/tests/mh_test_utilities.h
index 4b1b4a4..8ea66ff 100644
--- a/src/tests/mh_test_utilities.h
+++ b/src/tests/mh_test_utilities.h
@@ -31,6 +31,7 @@
*
* \return 0 or greater for successful match
*/
-extern int mh_test_is_match(const char *pattern, const char *subject);
+int
+mh_test_is_match(const char *pattern, const char *subject);
#endif /* __MH_TEST_UTILITIES */
--
1.7.6
12 years, 8 months
[PATCH] Spec: Fix inverted broker dependencies
by Zane Bitter
The broker should not Require the main matahari package. That is now empty
and files that are required by both the broker and QMF agents are installed
by a subpackage (matahari-core) that provides them.
A large part of the %install stanza is no longer required, since make
install handles it correctly.
Also fixed some rpmlint warnings.
Signed-off-by: Zane Bitter <zbitter(a)redhat.com>
---
matahari.spec.in | 52 +++++++++++++++++++++++++++-------------------------
1 files changed, 27 insertions(+), 25 deletions(-)
diff --git a/matahari.spec.in b/matahari.spec.in
index 16df4fa..85dae66 100644
--- a/matahari.spec.in
+++ b/matahari.spec.in
@@ -32,6 +32,7 @@ Requires: dbus
Requires: qmf > 0.7
Requires: pcre
+Requires: %{name}-core = %{version}-%{release}
Requires: %{name}-consoles = %{version}-%{release}
Requires: %{name}-broker = %{version}-%{release}
Requires: %{name}-host = %{version}-%{release}
@@ -71,12 +72,20 @@ AMQP). This interface allows you to manage a host and its various components
as a set of objects with properties and methods.
+%package core
+License: GPLv2+
+Summary: Core files for Matahari
+Group: Applications/System
+
+%description core
+Core files for Matahari
+
%if %{with qmf}
%package broker
License: GPLv2+
Summary: Optional AMQP Broker for Matahari
Group: Applications/System
-Requires: %{name} = %{version}-%{release}
+Requires: %{name}-core = %{version}-%{release}
Requires: qpid-cpp-server > 0.7
Requires: qpid-cpp-server-ssl > 0.7
Requires: qmf > 0.7
@@ -89,6 +98,7 @@ Optional AMQP Broker for Matahari
License: GPLv2+
Summary: C libraries used by Matahari agents
Group: Applications/System
+Requires: %{name}-core = %{version}-%{release}
%description lib
C libraries used by Matahari agents
@@ -139,7 +149,7 @@ QMF agent for viewing and controlling system services
%package sysconfig
License: GPLv2+
-Summary: QMF agent for post boot configuration services.
+Summary: QMF agent for post boot configuration services
Group: Applications/System
Requires: %{name}-lib = %{version}-%{release}
Requires: %{name}-agent-lib = %{version}-%{release}
@@ -192,21 +202,6 @@ rm -f $RPM_BUILD_ROOT/%{_sysconfdir}/rc.d/init.d/matahari-sysconfig-console
rm -f $RPM_BUILD_ROOT/%{_sysconfdir}/rc.d/init.d/matahari-broker
%endif
-%{__install} -d $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/
-%{__install} matahari.sysconf $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/matahari
-
-%if %{with qmf}
-%if %{undefined _unitdir}
-%{__install} -d $RPM_BUILD_ROOT/%{_sysconfdir}/rc.d/init.d
-%{__install} matahari-broker $RPM_BUILD_ROOT/%{_sysconfdir}/rc.d/init.d/matahari-broker
-%endif
-
-%{__install} matahari-broker.sysconf $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/matahari-broker
-
-%{__install} -d -m0770 $RPM_BUILD_ROOT/%{_localstatedir}/lib/%{name}
-%{__install} -d -m0775 $RPM_BUILD_ROOT/%{_localstatedir}/run/%{name}
-%endif
-
%post -n matahari-lib -p /sbin/ldconfig
%postun -n matahari-lib -p /sbin/ldconfig
@@ -296,9 +291,9 @@ if [ "$1" -ge "1" ]; then
/sbin/service matahari-broker condrestart >/dev/null 2>&1 || :
fi
-#== Agent Lib
+#== Core
-%pre agent-lib
+%pre core
getent group qpidd >/dev/null || groupadd -r qpidd
exit 0
@@ -314,13 +309,10 @@ test "x%{buildroot}" != "x" && rm -rf %{buildroot}
%files agent-lib
%defattr(644, root, root)
%attr(755, -, -) %dir %{_datadir}/matahari/
-%config(noreplace) %{_sysconfdir}/sysconfig/matahari
%doc AUTHORS COPYING
%if %{with qmf}
%{_libdir}/libmcommon_qmf.so.*
-%dir %attr(0770, root, qpidd) %{_localstatedir}/lib/%{name}
-%ghost %dir %attr(0775, root, qpidd) %{_localstatedir}/run/%{name}
%endif
%if %{with dbus}
@@ -336,6 +328,14 @@ test "x%{buildroot}" != "x" && rm -rf %{buildroot}
%{_libdir}/libmsysconfig.so.*
%doc AUTHORS COPYING
+%files core
+%defattr(644, root, root, 755)
+%doc AUTHORS COPYING
+%config(noreplace) %{_sysconfdir}/sysconfig/matahari
+%if %{with qmf}
+%dir %attr(0770, root, qpidd) %{_localstatedir}/lib/%{name}
+%endif
+
%files network
%defattr(644, root, root, 755)
%doc AUTHORS COPYING
@@ -354,7 +354,7 @@ test "x%{buildroot}" != "x" && rm -rf %{buildroot}
%if %{with dbus}
%attr(755, root, root) %{_sbindir}/matahari-dbus-networkd
-%{_sysconfdir}/dbus-1/system.d/org.matahariproject.Network.conf
+%config %{_sysconfdir}/dbus-1/system.d/org.matahariproject.Network.conf
%{_datadir}/dbus-1/interfaces/org.matahariproject.Network.xml
%{_datadir}/dbus-1/system-services/org.matahariproject.Network.service
%{_datadir}/polkit-1/actions/org.matahariproject.Network.policy
@@ -378,7 +378,7 @@ test "x%{buildroot}" != "x" && rm -rf %{buildroot}
%if %{with dbus}
%attr(755, root, root) %{_sbindir}/matahari-dbus-hostd
-%{_sysconfdir}/dbus-1/system.d/org.matahariproject.Host.conf
+%config %{_sysconfdir}/dbus-1/system.d/org.matahariproject.Host.conf
%{_datadir}/polkit-1/actions/org.matahariproject.Host.policy
%{_datadir}/dbus-1/interfaces/org.matahariproject.Host.xml
%{_datadir}/dbus-1/system-services/org.matahariproject.Host.service
@@ -402,7 +402,7 @@ test "x%{buildroot}" != "x" && rm -rf %{buildroot}
%if %{with dbus}
%attr(755, root, root) %{_sbindir}/matahari-dbus-serviced
-%{_sysconfdir}/dbus-1/system.d/org.matahariproject.Services.conf
+%config %{_sysconfdir}/dbus-1/system.d/org.matahariproject.Services.conf
%{_datadir}/dbus-1/interfaces/org.matahariproject.Services.xml
%{_datadir}/dbus-1/system-services/org.matahariproject.Services.service
%{_datadir}/polkit-1/actions/org.matahariproject.Services.policy
@@ -457,6 +457,8 @@ test "x%{buildroot}" != "x" && rm -rf %{buildroot}
%if %{defined _unitdir}
%{_unitdir}/matahari-broker.service
+%else
+%ghost %dir %attr(0775, root, qpidd) %{_localstatedir}/run/%{name}
%endif
%else
12 years, 8 months
[PATCH] - Use mh_strlen_zero helper routine for read_environment
by Adam Stokes
Signed-off-by: Adam Stokes <astokes(a)fedoraproject.org>
---
src/lib/mh_agent.cpp | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/lib/mh_agent.cpp b/src/lib/mh_agent.cpp
index 4a7cbf1..47f7550 100644
--- a/src/lib/mh_agent.cpp
+++ b/src/lib/mh_agent.cpp
@@ -377,23 +377,23 @@ read_environment(OptionsMap& options)
const char *data;
data = getenv("MATAHARI_BROKER");
- if (data && strlen(data)) {
+ if (!mh_strlen_zero(data)) {
options["servername"] = data;
}
data = getenv("MATAHARI_PORT");
- if (data && strlen(data)) {
+ if (!mh_strlen_zero(data)) {
options["serverport"] = data;
}
data = getenv("KRB5_KEYTAB");
- if (data && strlen(data)) {
+ if (!mh_strlen_zero(data)) {
options["krb5_keytab"] = data;
} else {
options["krb5_keytab"] = "/etc/krb5.keytab";
}
data = getenv("KRB5_INTERVAL");
- if (data && strlen(data)) {
+ if (!mh_strlen_zero(data)) {
options["krb5_interval"] = data;
} else {
options["krb5_interval"] = "10";
--
1.7.6.2
12 years, 8 months
[PATCH] Check/run k5start within agent code v5
by Adam Stokes
- Verify k5start exists
- Run k5start and check the top most principal (without
this we would need to probably do some regexing through the
klist to attempt to find which principal we want)
- This will re-initialization *existing* kerberos tickets without
need for password.
- Actually show none connection options as a result of more kerberos
work
- Uses environment variables and has general defaults as a fallback
Signed-off-by: Adam Stokes <astokes(a)fedoraproject.org>
---
matahari.init.in | 4 ---
matahari.sysconf.in | 12 ----------
src/lib/mh_agent.cpp | 60 ++++++++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 58 insertions(+), 18 deletions(-)
diff --git a/matahari.init.in b/matahari.init.in
index e9588f9..323ad89 100644
--- a/matahari.init.in
+++ b/matahari.init.in
@@ -46,10 +46,6 @@ start() {
MATAHARI_ARGS="--broker $MATAHARI_BROKER $MATAHARI_ARGS"
fi
- # Setup kerberos ticket renewal
- if [ -n "$KRB_RENEW" ]; then
- k5start $KRB_RENEW_ARGS $KRB_REALM
- fi
daemon $PROCESS $MATAHARI_ARGS --daemon
RETVAL=$?
diff --git a/matahari.sysconf.in b/matahari.sysconf.in
index bc25e73..edd0065 100644
--- a/matahari.sysconf.in
+++ b/matahari.sysconf.in
@@ -18,15 +18,3 @@ MATAHARI_AGENT_ARGS="--reconnect=yes"
# Per console options
# sysconfig_CONSOLE_ARGS=...
-
-# Security
-# Kerberos
-
-# Uncomment to enable auto-renew credentials
-# KRB_RENEW=yes
-
-# Set custom application and arguments for renew process
-# KRB_RENEW_ARGS="-f /etc/krb5.keytab -K 10 -l 10h"
-
-# Kerberos REALM
-# KRB_REALM="qpidd/EXAMPLE.COM"
diff --git a/src/lib/mh_agent.cpp b/src/lib/mh_agent.cpp
index 61f32bf..4a7cbf1 100644
--- a/src/lib/mh_agent.cpp
+++ b/src/lib/mh_agent.cpp
@@ -234,8 +234,7 @@ int print_help(int code, const char *name, const char *arg, void *userdata)
printf("\nOptions:\n");
printf("\t-h | --help print this help message.\n");
for (lpc = 0; lpc < DIMOF(matahari_options); lpc++) {
- if (matahari_options[lpc].callback
- && matahari_options[lpc].callback != connection_option) {
+ if (matahari_options[lpc].callback) {
printf("\t-%c | --%-10s\t%s\n", matahari_options[lpc].code,
matahari_options[lpc].long_name, matahari_options[lpc].description);
}
@@ -251,6 +250,50 @@ mh_connect(OptionsMap mh_options, OptionsMap amqp_options, int retry)
int backoff = 0;
GList *srv_records = NULL, *cur_srv_record = NULL;
struct mh_dnssrv_record *record;
+ GError *error = NULL;
+ int status;
+ std::string krb5_keytab(mh_options["krb5_keytab"].asString());
+ std::string krb5_interval(mh_options["krb5_interval"].asString());
+ const gchar *k5start_bin[] = {
+ "/usr/bin/k5start",
+ "-U",
+ "-f",
+ krb5_keytab.c_str(),
+ "-K",
+ krb5_interval.c_str(),
+ NULL,
+ };
+
+ mh_trace("kerberos: %s %s %s %s %s %s",
+ k5start_bin[0],
+ k5start_bin[1],
+ k5start_bin[2],
+ k5start_bin[3],
+ k5start_bin[4],
+ k5start_bin[5]);
+
+ /* Attempt to initiate k5start for credential renewal's without
+ * prompting for a password each time an agent is run
+ */
+ if (strcmp(amqp_options["sasl-mechanism"].asString().c_str(),"GSSAPI") == 0) {
+ if (g_file_test(k5start_bin[0], G_FILE_TEST_IS_EXECUTABLE)) {
+ mh_trace("Running k5start");
+ if (!g_spawn_sync(
+ NULL,
+ (gchar **) k5start_bin,
+ NULL,
+ G_SPAWN_SEARCH_PATH,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ &status,
+ &error)) {
+ mh_warn("k5start failure: %s", error->message);
+ g_error_free(error);
+ }
+ }
+ }
if (!mh_options.count("servername") || mh_options.count("dns-srv")) {
/*
@@ -342,6 +385,19 @@ read_environment(OptionsMap& options)
if (data && strlen(data)) {
options["serverport"] = data;
}
+ data = getenv("KRB5_KEYTAB");
+ if (data && strlen(data)) {
+ options["krb5_keytab"] = data;
+ } else {
+ options["krb5_keytab"] = "/etc/krb5.keytab";
+ }
+
+ data = getenv("KRB5_INTERVAL");
+ if (data && strlen(data)) {
+ options["krb5_interval"] = data;
+ } else {
+ options["krb5_interval"] = "10";
+ }
}
static void
--
1.7.6.2
12 years, 8 months
[PATCH] build: Add dependency install helper script.
by Russell Bryant
I wanted something to make getting a matahari development environment up
quicker so I threw in this little helper script. While I was at it I
also updated the README with some more build dependencies.
Signed-off-by: Russell Bryant <rbryant(a)redhat.com>
---
README.mkd | 11 +++++++++--
contrib/scripts/install_deps.sh | 11 +++++++++++
2 files changed, 20 insertions(+), 2 deletions(-)
create mode 100755 contrib/scripts/install_deps.sh
diff --git a/README.mkd b/README.mkd
index e56c076..ab2a86a 100644
--- a/README.mkd
+++ b/README.mkd
@@ -12,14 +12,21 @@ Matahari has build dependencies on the following packages:
1. pcre-devel
2. glib2-devel
-3. qmf
-4. qmf-devel
+3. qpid-qmf
+4. qpid-qmf-devel
5. qpid-cpp-client
6. qpid-cpp-server
7. qpid-cpp-client-devel
8. qpid-cpp-server-devel
9. sigar
10. sigar-devel
+11. libcurl
+12. libcurl-devel
+13. dbus-glib
+14. dbus-glib-devel
+15. polkit
+16. polkit-devel
+17. cmake
Matahari requires that the following packages are installed at runtime
for certain pieces of functionality to work:
diff --git a/contrib/scripts/install_deps.sh b/contrib/scripts/install_deps.sh
new file mode 100755
index 0000000..62b1c0c
--- /dev/null
+++ b/contrib/scripts/install_deps.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+FEDORA_PACKAGES="cmake pcre-devel glib2-devel qpid-qmf qpid-qmf-devel qpid-cpp-client qpid-cpp-client-devel qpid-cpp-server qpid-cpp-server-devel sigar sigar-devel libcurl libcurl-devel puppet cxxtest help2man dbus-glib dbus-glib-devel polkit polkit-devel"
+
+if [ ! -f /etc/fedora-release ] ; then
+ echo "This script only supports Fedora so far."
+ exit 1
+fi
+
+yum groupinstall "Development Tools"
+yum install ${FEDORA_PACKAGES}
--
1.7.6
12 years, 8 months