[PATCH] DBus support won't fail by default.
by Radek Novacek
Now WITH-DBUS has 3 states - ON, OFF and TRY:
ON means fail when DBus requirements aren't met,
OFF means that DBus is disabled completely,
TRY (default) builds DBus agent when requirement are met.
Signed-off-by: Radek Novacek <rnovacek(a)redhat.com>
---
src/CMakeLists.txt | 31 +++++++++++++++++++++++++++++--
1 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index b55f339..ed379c0 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -11,7 +11,12 @@ if(WIN32)
else(WIN32)
set(VARIANT "linux")
# DBus makes sense only on linux
- option(WITH-DBUS "Build the DBus daemon" ON)
+ # WITH-DBUS == OFF means no DBus,
+ # TRY means autodetection
+ # ON means explicit support
+ if(NOT DEFINED WITH-DBUS)
+ set(WITH-DBUS "TRY" CACHE STRING "Build the DBus daemons (ON|TRY|OFF)")
+ endif(NOT DEFINED WITH-DBUS)
endif(WIN32)
option(WITH-QMF "Build the QMF daemon" ON)
@@ -78,7 +83,8 @@ include_directories(${glib_INCLUDE_DIRS})
include(MatahariMacros)
## dbus
-if(WITH-DBUS)
+if(WITH-DBUS STREQUAL "ON")
+ # Explicitly turned ON => fail when not found
pkg_check_modules(dbus-glib REQUIRED dbus-glib-1)
pkg_check_modules(polkit REQUIRED polkit-gobject-1)
@@ -89,9 +95,30 @@ if(WITH-DBUS)
if(NOT polkit_FOUND)
message(FATAL_ERROR "polkit headers/libraries not found.")
endif(NOT polkit_FOUND)
+elseif(WITH-DBUS STREQUAL "OFF")
+ # Explicitly turned OFF => no action
+else(WITH-DBUS STREQUAL "ON")
+ # All other options means TRY
+ pkg_check_modules(dbus-glib dbus-glib-1)
+ pkg_check_modules(polkit polkit-gobject-1)
+
+ if(NOT dbus-glib_FOUND)
+ message(STATUS "dbus-glib headers/libraries not found => DBus
disabled")
+ set(WITH-DBUS "OFF")
+ endif(NOT dbus-glib_FOUND)
+
+ if(NOT polkit_FOUND)
+ message(STATUS "polkit headers/libraries not found => DBus disabled")
+ set(WITH-DBUS "OFF")
+ endif(NOT polkit_FOUND)
+endif(WITH-DBUS STREQUAL "ON")
+if(WITH-DBUS)
+ message(STATUS "DBus is enabled")
# Create src/dbus directory and generate DBus XML definition files into
it
generate_dbus_interface(${SCHEMAS})
+else(WITH-DBUS)
+ message(STATUS "DBus is disabled")
endif(WITH-DBUS)
## qpid
--
1.7.5
13 years
[PATCH 0/2] Services agent improvements
by russell@russellbryant.net
I started working on some Services agent improvements. This first patch is
just an optimization:
[PATCH 1/2] service-qmf: Cache the result of event.getArguments().
The second patch is for recurring action support. This same code for doing
async request processing can be used for a lot more stuff in the Services
agent, but before I went and did that, I figured I'd post this much up for
feedback.
[PATCH 2/2] service-qmf: Complete recurring action support.
My testing of this has been pretty basic. I used qmf-tool to initiate a
recurring status request. I verified that it still returned the result I
expected to qmf-tool. I also verified that the Services agent properly
detected a change in the result by watching its log output. That leads
me to a question: what's a good way for monitoring for QMF events on the
bus, like what is being fired off on a result change?
Thanks,
--
Russell Bryant
13 years
[PATCH] Add macros for simplify generation of DBus and QMF agents.
by Radek Novacek
* MatahariDBusMacros.cmake was renamed to MatahariMacros.cmake.
* generate_dbus_interface macro added for xsl transformation from
QMF schema to DBus interface XML
* generate_qmf_schemas macro for generating QMF files using qmfgen.
Signed-off-by: Radek Novacek <rnovacek(a)redhat.com>
---
src/CMakeLists.txt | 43 +++------------
src/cmake/modules/MatahariDBusMacros.cmake | 28 ----------
src/cmake/modules/MatahariMacros.cmake | 82
++++++++++++++++++++++++++++
src/host/CMakeLists.txt | 1 -
src/network/CMakeLists.txt | 1 -
src/service/CMakeLists.txt | 1 -
6 files changed, 89 insertions(+), 67 deletions(-)
delete mode 100644 src/cmake/modules/MatahariDBusMacros.cmake
create mode 100644 src/cmake/modules/MatahariMacros.cmake
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d3b49a7..18bc6df 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -72,11 +72,14 @@ if(NOT glib_FOUND)
endif(NOT glib_FOUND)
include_directories(${glib_INCLUDE_DIRS})
+# Include QMF and DBus generation macros
+include(MatahariMacros)
+
## dbus
if(WITH-DBUS)
pkg_check_modules(dbus-glib REQUIRED dbus-glib-1)
pkg_check_modules(polkit REQUIRED polkit-gobject-1)
-
+
if(NOT dbus-glib_FOUND)
message(FATAL_ERROR "dbus-glib headers/libraries not found.")
endif(NOT dbus-glib_FOUND)
@@ -86,12 +89,7 @@ if(WITH-DBUS)
endif(NOT polkit_FOUND)
# Create src/dbus directory and generate DBus XML definition files into
it
- execute_process(COMMAND mkdir -p src/dbus)
- find_file(XSLTPROC xsltproc)
- execute_process(
- COMMAND ${XSLTPROC} ${CMAKE_CURRENT_SOURCE_DIR}/schema-to-dbus.xsl
${CMAKE_CURRENT_SOURCE_DIR}/schema.xml
- WORKING_DIRECTORY src/dbus
- )
+ generate_dbus_interface(${SCHEMAS})
endif(WITH-DBUS)
## qpid
@@ -108,34 +106,7 @@ if(WITH-QMF)
message(FATAL_ERROR "QPID library not found.")
endif(QPID-NOTFOUND)
- # string(REGEX REPLACE "\\." "" QPID_VERSION ${QPID_VERSION})
-
- # message("Building against: ${QPID_VERSION_LONG} (${QPID_VERSION} )")
- # add_definitions(-DQPID_VERSION=${QPID_VERSION})
-
- set(regen_schema OFF)
- message(STATUS "Regenerating QMF schemas: ${SCHEMAS}")
- foreach (schema_file ${SCHEMAS} ${QMFGEN})
- foreach (file ${SCHEMA_SOURCES})
- if (EXISTS ${file})
- if (${schema_file} IS_NEWER_THAN ${file})
- set(regen_schema ON)
- message("${schema_file} is newer than ${file}")
- endif (${schema_file} IS_NEWER_THAN ${file})
- else (EXISTS ${file})
- set(regen_schema ON)
- endif (EXISTS ${file})
- endforeach (file ${SCHEMA_SOURCES})
- endforeach (schema_file ${SCHEMAS})
-
- if (regen_schema)
- # Regenerate everything
- execute_process(COMMAND rm -f ${SCHEMA_SOURCES})
- execute_process(COMMAND ${QMFGEN} -2 -o ./qmf ${SCHEMAS}
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
- else (regen_schema)
- message(STATUS "No need to generate QMF schema")
- endif (regen_schema)
+ generate_qmf_schemas(${SCHEMAS} ${SCHEMA_SOURCES})
endif(WITH-QMF)
@@ -149,6 +120,7 @@ add_subdirectory(service)
install(FILES ${SCHEMAS} DESTINATION share/matahari)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/include/matahari.h DESTINATION
include)
install(FILES cmake/modules/FindMatahari.cmake DESTINATION
share/cmake/Modules)
+install(FILES cmake/modules/MatahariMacros.cmake DESTINATION
share/cmake/Modules)
if(WITH-QMF)
install(FILES cmake/modules/FindQPID.cmake DESTINATION
share/cmake/Modules)
@@ -159,5 +131,4 @@ if(WITH-DBUS)
install(FILES schema-to-dbus.xsl DESTINATION share/matahari)
install(FILES include/matahari/mh_dbus_common.h DESTINATION
include/matahari)
install(FILES include/matahari/mh_gobject_class.h DESTINATION
include/matahari)
- install(FILES cmake/modules/MatahariDBusMacros.cmake DESTINATION
share/cmake/Modules)
endif(WITH-DBUS)
diff --git a/src/cmake/modules/MatahariDBusMacros.cmake
b/src/cmake/modules/MatahariDBusMacros.cmake
deleted file mode 100644
index a9e16f7..0000000
--- a/src/cmake/modules/MatahariDBusMacros.cmake
+++ /dev/null
@@ -1,28 +0,0 @@
-# Generator for files specific to DBus interface
-
-# This macro takes name of the API and then creates two files
-# matahari-${API}-dbus-glue.h and matahari-${API}-dbus-properties.h
-# First one contains gobject definition generated by dbus-binding-tool
-# Second one is definition of properties of the object
-
-macro(generate_dbus_headers API XML)
- find_file(XSLTPROC xsltproc)
- find_file(BIND_TOOL dbus-binding-tool)
-
- # Convert dbus interface to glue and properties files
- add_custom_command(
- OUTPUT ${API}-dbus-glue.h
- COMMAND ${BIND_TOOL} --prefix=matahari --mode=glib-server
- --output=${API}-dbus-glue.h
- ${XML}
- COMMENT "Generating ${API}-dbus-glue.h"
- )
-
- add_custom_command(
- OUTPUT ${API}-dbus-properties.h
- COMMAND ${XSLTPROC} --output ${API}-dbus-properties.h
- ${CMAKE_CURRENT_SOURCE_DIR}/../dbus-to-c.xsl
- ${XML}
- COMMENT "Generating ${API}-dbus-properties.h"
- )
-endmacro(generate_dbus_headers)
diff --git a/src/cmake/modules/MatahariMacros.cmake
b/src/cmake/modules/MatahariMacros.cmake
new file mode 100644
index 0000000..3c5a428
--- /dev/null
+++ b/src/cmake/modules/MatahariMacros.cmake
@@ -0,0 +1,82 @@
+# Generator for files specific to DBus interface
+
+# This macro takes name of the API and then creates two files
+# matahari-${API}-dbus-glue.h and matahari-${API}-dbus-properties.h
+# First one contains gobject definition generated by dbus-binding-tool
+# Second one is definition of properties of the object
+macro(generate_dbus_headers API XML)
+ find_file(XSLTPROC xsltproc)
+ find_file(BIND_TOOL dbus-binding-tool)
+
+ # Convert dbus interface to glue and properties files
+ add_custom_command(
+ OUTPUT ${API}-dbus-glue.h
+ COMMAND ${BIND_TOOL} --prefix=matahari --mode=glib-server
+ --output=${API}-dbus-glue.h
+ ${XML}
+ COMMENT "Generating ${API}-dbus-glue.h"
+ )
+
+ add_custom_command(
+ OUTPUT ${API}-dbus-properties.h
+ COMMAND ${XSLTPROC} --output ${API}-dbus-properties.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/../dbus-to-c.xsl
+ ${XML}
+ COMMENT "Generating ${API}-dbus-properties.h"
+ )
+endmacro(generate_dbus_headers)
+
+# This macro will transform QMF interface XML to DBus interface XML file
+# Arguments SCHEMAS - paths to XML schema files
+macro(generate_dbus_interface SCHEMAS)
+ find_file(SCHEMA_TO_DBUS schema-to-dbus.xsl
+ ${CMAKE_CURRENT_SOURCE_DIR} /usr/share/matahari)
+ find_file(XSLTPROC xsltproc)
+ # Create dbus subdirectory
+ execute_process(COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/dbus)
+ foreach(SCHEMA ${SCHEMAS})
+ # Generate files for each schema
+ execute_process(
+ COMMAND ${XSLTPROC} ${SCHEMA_TO_DBUS} ${SCHEMA}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/dbus
+ )
+ endforeach(SCHEMA ${SCHEMAS})
+endmacro(generate_dbus_interface)
+
+# This macro will generate QMF definition files from QMF schema
+# Argument SCHEMAS - paths to XML schema files
+# Variable SCHEMA_SOURCES - list of generated cpp files (it can be added
+# to add_executable command for proper compliation)
+macro(generate_qmf_schemas SCHEMAS SCHEMA_SOURCES)
+ message(STATUS "Regenerating QMF schemas: ${SCHEMAS}")
+ set(regen_schema OFF)
+
+ if (SCHEMA_SOURCES)
+ # There are some already generated files, check if they
+ # need to be regenerated
+ foreach (schema_file ${SCHEMAS})
+ foreach (file ${SCHEMA_SOURCES})
+ if (EXISTS ${file})
+ if (${schema_file} IS_NEWER_THAN ${file})
+ set(regen_schema ON)
+ message("${schema_file} is newer than ${file}")
+ endif (${schema_file} IS_NEWER_THAN ${file})
+ else (EXISTS ${file})
+ set(regen_schema ON)
+ endif (EXISTS ${file})
+ endforeach (file ${SCHEMA_SOURCES})
+ endforeach (schema_file ${SCHEMAS})
+ else (SCHEMA_SOURCES)
+ # No already generated files => generate them
+ set(regen_schema ON)
+ endif (SCHEMA_SOURCES)
+
+ if (regen_schema)
+ # Regenerate everything
+ execute_process(COMMAND rm -f ${SCHEMA_SOURCES})
+ execute_process(COMMAND ${QMFGEN} -2 -o ./qmf ${SCHEMAS}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
+ else (regen_schema)
+ message(STATUS "No need to generate QMF schema")
+ endif (regen_schema)
+endmacro(generate_qmf_schemas)
diff --git a/src/host/CMakeLists.txt b/src/host/CMakeLists.txt
index 30c3b15..d9b5513 100644
--- a/src/host/CMakeLists.txt
+++ b/src/host/CMakeLists.txt
@@ -24,7 +24,6 @@ endif(WITH-QMF)
# DBus daemon
if(WITH-DBUS)
# Auto-generated stuff
- include(MatahariDBusMacros)
generate_dbus_headers(${BASE}
${CMAKE_BINARY_DIR}/src/dbus/org.matahariproject.Host.xml)
# Must be included to find matahari-API-dbus-properties.h
include_directories(${CMAKE_CURRENT_BINARY_DIR})
diff --git a/src/network/CMakeLists.txt b/src/network/CMakeLists.txt
index a26eac1..020358f 100644
--- a/src/network/CMakeLists.txt
+++ b/src/network/CMakeLists.txt
@@ -24,7 +24,6 @@ endif(WITH-QMF)
# DBus daemon
if(WITH-DBUS)
# Auto-generated stuff
- include(MatahariDBusMacros)
generate_dbus_headers(${BASE}
${CMAKE_BINARY_DIR}/src/dbus/org.matahariproject.Network.xml)
# Must be included to find API-dbus-properties.h
include_directories(${CMAKE_CURRENT_BINARY_DIR})
diff --git a/src/service/CMakeLists.txt b/src/service/CMakeLists.txt
index 44d70cd..c61b7c8 100644
--- a/src/service/CMakeLists.txt
+++ b/src/service/CMakeLists.txt
@@ -24,7 +24,6 @@ endif(WITH-QMF)
# DBus daemon
if(WITH-DBUS)
# Auto-generated stuff
- include(MatahariDBusMacros)
generate_dbus_headers(${BASE}
${CMAKE_BINARY_DIR}/src/dbus/org.matahariproject.Services.xml)
# Must be included to find matahari-API-dbus-properties.h
include_directories(${CMAKE_CURRENT_BINARY_DIR})
--
1.7.4.4
13 years
[PATCH] Tweak a bit an init script
by Roman Rakus
Use nested command substitution.
Use pattern substitution instead of ugly echo and pipeline.
Signed-off-by: Roman Rakus <rrakus(a)redhat.com>
---
matahari.init.in | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/matahari.init.in b/matahari.init.in
index ed34c4b..0d80d67 100644
--- a/matahari.init.in
+++ b/matahari.init.in
@@ -21,9 +21,8 @@
# Source function library.
. @sysconfdir(a)/rc.d/init.d/functions
-SERVICE=`readlink -f "$0"`
-SERVICE=`basename "$SERVICE"`
-PROCESS=`echo "$SERVICE" | cut -f1 -d'-'`-qmf-`echo "$SERVICE" | cut -f2 -d'-'`d
+SERVICE=$(basename $(readlink -f "$0"))
+PROCESS=${SERVICE/-/-qmf-}d
RETVAL=0
--
1.7.4.4
13 years
[PATCH] Fix $PROCESS in init script after name change.
by russell@russellbryant.net
I haven't tested this script fully yet. I've been running things manually
and now I'm trying to build RPMs and start everything as services but
I'm having some problems. I noticed this while debugging it.
I still need to figure out why /var/lib/matahari and /var/run/matahari
don't seem to be created properly when installing the RPMs though.
I'm using Fedora 15.
-----
matahari-serviced is now matahari-qmf-serviced, so tweak the init script
to match that naming scheme.
Signed-off-by: Russell Bryant <russell(a)russellbryant.net>
---
matahari.init.in | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/matahari.init.in b/matahari.init.in
index c967b8d..ed34c4b 100644
--- a/matahari.init.in
+++ b/matahari.init.in
@@ -23,7 +23,7 @@
SERVICE=`readlink -f "$0"`
SERVICE=`basename "$SERVICE"`
-PROCESS=`echo "$SERVICE"d`
+PROCESS=`echo "$SERVICE" | cut -f1 -d'-'`-qmf-`echo "$SERVICE" | cut -f2 -d'-'`d
RETVAL=0
--
1.7.4.4
13 years
[PATCH] remove custom asprintf(), use g_strdup_printf().
by russell@russellbryant.net
Instead of implementing a custom version of asprintf(), use an
equivalent function provided by glib.
Signed-off-by: Russell Bryant <russell(a)russellbryant.net>
---
src/CMakeLists.txt | 2 --
src/include/config.h.in | 1 -
src/include/matahari/services.h | 2 +-
src/include/matahari/utilities.h | 11 -----------
src/lib/services.c | 10 +++++-----
src/lib/services_linux.c | 6 +++---
src/lib/services_private.h | 2 +-
src/lib/utilities.c | 32 --------------------------------
8 files changed, 10 insertions(+), 56 deletions(-)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index b55f339..18bc6df 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -33,8 +33,6 @@ file(GLOB SCHEMAS "${CMAKE_CURRENT_SOURCE_DIR}/*.xml")
include (CheckIncludeFiles)
check_include_files (string.h HAVE_STRING_H)
check_include_files (sys/ioctl.h HAVE_SYS_IOCTL_H)
-include (CheckFunctionExists)
-check_function_exists (asprintf HAVE_ASPRINTF)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/include/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/include/matahari.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/matahari.h)
diff --git a/src/include/config.h.in b/src/include/config.h.in
index 9f2989c..e67866b 100644
--- a/src/include/config.h.in
+++ b/src/include/config.h.in
@@ -1,3 +1,2 @@
#cmakedefine HAVE_STRING_H 1
#cmakedefine HAVE_SYS_IOCTL_H 1
-#cmakedefine HAVE_ASPRINTF 1
diff --git a/src/include/matahari/services.h b/src/include/matahari/services.h
index 0a48bb8..edfd716 100644
--- a/src/include/matahari/services.h
+++ b/src/include/matahari/services.h
@@ -85,7 +85,7 @@ enum op_status {
typedef struct svc_action_private_s svc_action_private_t;
typedef struct svc_action_s
{
- char *id;
+ gchar *id;
char *rsc;
char *action;
int interval;
diff --git a/src/include/matahari/utilities.h b/src/include/matahari/utilities.h
index e48be25..545d274 100644
--- a/src/include/matahari/utilities.h
+++ b/src/include/matahari/utilities.h
@@ -36,17 +36,6 @@ extern const char *mh_hostname(void);
extern void mh_abort(const char *file, const char *function, int line,
const char *assert_condition, int do_core, int do_fork);
-#ifndef HAVE_ASPRINTF
-/**
- * Custom implementation of asprintf()
- *
- * This version of asprintf() is only used when the build system doesn't find
- * asprintf() on the system. For more information on how to use asprintf(),
- * see its man page.
- */
-extern int asprintf(char **ret, const char *fmt, ...);
-#endif
-
#define DIMOF(a) ((int) (sizeof(a) / sizeof(0[a])))
#ifndef __GNUC__
diff --git a/src/lib/services.c b/src/lib/services.c
index fc20165..87a40c7 100644
--- a/src/lib/services.c
+++ b/src/lib/services.c
@@ -47,7 +47,7 @@ svc_action_t *services_action_create(
op->timeout = timeout;
op->rclass = strdup("lsb");
op->agent = strdup(name);
- asprintf(&op->id, "%s_%s_%d", name, action, interval);
+ op->id = g_strdup_printf("%s_%s_%d", name, action, interval);
services_os_set_exec(op);
@@ -70,8 +70,8 @@ svc_action_t *resources_action_create(
op->agent = strdup(agent);
op->provider = strdup(provider);
op->params = params;
- asprintf(&op->id, "%s_%s_%d", name, action, interval);
- asprintf(&op->opaque->exec, "%s/resource.d/%s/%s", OCF_ROOT,
+ op->id = g_strdup_printf("%s_%s_%d", name, action, interval);
+ op->opaque->exec = g_strdup_printf("%s/resource.d/%s/%s", OCF_ROOT,
provider, agent);
op->opaque->args[0] = strdup(op->opaque->exec);
op->opaque->args[1] = strdup(action);
@@ -85,8 +85,8 @@ void services_action_free(svc_action_t *op)
return;
}
- free(op->id);
- free(op->opaque->exec);
+ g_free(op->id);
+ g_free(op->opaque->exec);
free(op->opaque->args[0]);
free(op->opaque->args[1]);
diff --git a/src/lib/services_linux.c b/src/lib/services_linux.c
index 3a54386..84c4cb8 100644
--- a/src/lib/services_linux.c
+++ b/src/lib/services_linux.c
@@ -433,21 +433,21 @@ void
services_os_set_exec(svc_action_t* op)
{
if(strcmp("enable", op->action) == 0) {
- op->opaque->exec = strdup("/sbin/chkconfig");
+ op->opaque->exec = g_strdup("/sbin/chkconfig");
op->opaque->args[0] = strdup(op->opaque->exec);
op->opaque->args[1] = strdup(op->agent);
op->opaque->args[2] = strdup("on");
op->opaque->args[3] = NULL;
} else if(strcmp("disable", op->action) == 0) {
- op->opaque->exec = strdup("/sbin/chkconfig");
+ op->opaque->exec = g_strdup("/sbin/chkconfig");
op->opaque->args[0] = strdup(op->opaque->exec);
op->opaque->args[1] = strdup(op->agent);
op->opaque->args[2] = strdup("off");
op->opaque->args[3] = NULL;
} else {
- asprintf(&op->opaque->exec, "%s/%s", LSB_ROOT, op->agent);
+ op->opaque->exec = g_strdup_printf("%s/%s", LSB_ROOT, op->agent);
op->opaque->args[0] = strdup(op->opaque->exec);
op->opaque->args[1] = strdup(op->action);
op->opaque->args[2] = NULL;
diff --git a/src/lib/services_private.h b/src/lib/services_private.h
index 2b30228..68bd5f5 100644
--- a/src/lib/services_private.h
+++ b/src/lib/services_private.h
@@ -1,6 +1,6 @@
struct svc_action_private_s
{
- char *exec;
+ gchar *exec;
char *args[4];
gboolean cancel;
diff --git a/src/lib/utilities.c b/src/lib/utilities.c
index 1151c00..973bba4 100644
--- a/src/lib/utilities.c
+++ b/src/lib/utilities.c
@@ -394,35 +394,3 @@ mh_uuid(void)
mh_trace("Got uuid: %s", uuid);
return uuid;
}
-
-#ifndef HAVE_ASPRINTF
-int
-asprintf(char **ret, const char *fmt, ...)
-{
- va_list ap;
- int len;
- char buf[1];
-
- /*
- * Ask vsnprintf() how many characters it would write if the buffer
- * were big enough.
- */
- va_start(ap, fmt);
- len = vsnprintf(buf, sizeof(buf), fmt, ap);
- va_end(ap);
-
- /*
- * Now go allocate a buffer that is big enough.
- */
- *ret = malloc(len + 1);
-
- /*
- * Now vsnprintf() the string into the final result buffer.
- */
- va_start(ap, fmt);
- vsnprintf(*ret, len + 1, fmt, ap);
- va_end(ap);
-
- return len;
-}
-#endif /* HAVE_ASPRINTF */
--
1.7.4.4
13 years
[PATCH] utilities.c: Resolve compiler warning.
by russell@russellbryant.net
hostname is not const, but mh_uuid() returns a const char *. Just cast
away the const to silence the warning.
Signed-off-by: Russell Bryant <russell(a)russellbryant.net>
---
src/lib/utilities.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/lib/utilities.c b/src/lib/utilities.c
index cad41eb..b1fcc67 100644
--- a/src/lib/utilities.c
+++ b/src/lib/utilities.c
@@ -348,7 +348,7 @@ mh_hostname(void)
if(hostname != NULL && strcmp(hostname, "localhost") == 0) {
free(hostname);
- hostname = mh_uuid();
+ hostname = (char *) mh_uuid();
}
mh_trace("Got hostname: %s", hostname);
--
1.7.4.4
13 years
[PATCH] Add custom implementation of asprintf().
by russell@russellbryant.net
I don't have the cross compilation environment set up yet, but it does build
with and without HAVE_ASPRINTF defined. I also tested the asprintf() code
in a test application to make sure it did what I thought it did.
------------
Andrew pointed out that adding the use of asprintf() broke the build for
Windows. Instead of reverting the uses back to how they were, this
patch adds a custom implementation of asprintf() that will only be
included when the build system doesn't find asprintf() on the system.
Signed-off-by: Russell Bryant <russell(a)russellbryant.net>
---
src/CMakeLists.txt | 2 ++
src/include/config.h.in | 1 +
src/include/matahari/utilities.h | 13 +++++++++++++
src/lib/utilities.c | 35 +++++++++++++++++++++++++++++++++++
4 files changed, 51 insertions(+), 0 deletions(-)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d3b49a7..16d3403 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -33,6 +33,8 @@ file(GLOB SCHEMAS "${CMAKE_CURRENT_SOURCE_DIR}/*.xml")
include (CheckIncludeFiles)
check_include_files (string.h HAVE_STRING_H)
check_include_files (sys/ioctl.h HAVE_SYS_IOCTL_H)
+include (CheckFunctionExists)
+check_function_exists (asprintf HAVE_ASPRINTF)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/include/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/include/matahari.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/matahari.h)
diff --git a/src/include/config.h.in b/src/include/config.h.in
index e67866b..9f2989c 100644
--- a/src/include/config.h.in
+++ b/src/include/config.h.in
@@ -1,2 +1,3 @@
#cmakedefine HAVE_STRING_H 1
#cmakedefine HAVE_SYS_IOCTL_H 1
+#cmakedefine HAVE_ASPRINTF 1
diff --git a/src/include/matahari/utilities.h b/src/include/matahari/utilities.h
index 0c9fb94..e48be25 100644
--- a/src/include/matahari/utilities.h
+++ b/src/include/matahari/utilities.h
@@ -25,6 +25,8 @@
#ifndef __MH_UTILITIES__
#define __MH_UTILITIES__
+#include "config.h"
+
#include <stdlib.h>
#include <sys/types.h>
#include <string.h>
@@ -34,6 +36,17 @@ extern const char *mh_hostname(void);
extern void mh_abort(const char *file, const char *function, int line,
const char *assert_condition, int do_core, int do_fork);
+#ifndef HAVE_ASPRINTF
+/**
+ * Custom implementation of asprintf()
+ *
+ * This version of asprintf() is only used when the build system doesn't find
+ * asprintf() on the system. For more information on how to use asprintf(),
+ * see its man page.
+ */
+extern int asprintf(char **ret, const char *fmt, ...);
+#endif
+
#define DIMOF(a) ((int) (sizeof(a) / sizeof(0[a])))
#ifndef __GNUC__
diff --git a/src/lib/utilities.c b/src/lib/utilities.c
index 645a81c..cad41eb 100644
--- a/src/lib/utilities.c
+++ b/src/lib/utilities.c
@@ -16,9 +16,12 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include "config.h"
+
#define _GNU_SOURCE
#include <stdlib.h>
#include <stdio.h>
+#include <stdarg.h>
#include <stdio.h>
#include <errno.h>
@@ -391,3 +394,35 @@ mh_uuid(void)
mh_trace("Got uuid: %s", uuid);
return uuid;
}
+
+#ifndef HAVE_ASPRINTF
+int
+asprintf(char **ret, const char *fmt, ...)
+{
+ va_list ap;
+ int len;
+ char buf[1];
+
+ /*
+ * Ask vsnprintf() how many characters it would write if the buffer
+ * were big enough.
+ */
+ va_start(ap, fmt);
+ len = vsnprintf(buf, sizeof(buf), fmt, ap);
+ va_end(ap);
+
+ /*
+ * Now go allocate a buffer that is big enough.
+ */
+ *ret = malloc(len + 1);
+
+ /*
+ * Now vsnprintf() the string into the final result buffer.
+ */
+ va_start(ap, fmt);
+ vsnprintf(*ret, len + 1, fmt, ap);
+ va_end(ap);
+
+ return len;
+}
+#endif /* HAVE_ASPRINTF */
--
1.7.4.4
13 years
Fwd: qpid ssl environment var's
by Andrew Beekhof
Forgot reply-all
---------- Forwarded message ----------
From: Andrew Beekhof <andrew(a)beekhof.net>
Date: Mon, May 2, 2011 at 9:48 AM
Subject: Re: [Matahari] qpid ssl environment var's
To: Ted Ross <tross(a)redhat.com>
On Fri, Apr 29, 2011 at 10:46 PM, Ted Ross <tross(a)redhat.com> wrote:
> On 04/29/2011 04:16 PM, Adam Stokes wrote:
>> little history..
>>
>> QPID_SSL_CERT_DB and QPID_SSL_CERT_PASSWORD_FILE need to be set in order to make the broker load the sslconnector library and provide us with SSL capabilities during communication. Unfortunately, there is no command level way to set these options and so we are looking at alternatives.
>
> There are three ways to get options into the broker process: 1) command
> line options, 2) env variables, 3) the config file. That list is in
> priority order. If a setting is in the config file, it can be
> overridden by an env variable. Either can be overridden by a command
> line option.
>
> When running as a Linux daemon/service, env variables are not an option
> because there is no way to set the environment for a daemon process.
>
> This leaves the two options. The easiest way is to put the options in
> the /etc/qpidd.conf file. You can also override these options by
> setting command line options in /etc/sysconfig/qpidd. This file is of
> the form:
>
> OPTIONS="--ssl-sert-db=xyz --ssl-cert-password-file=qrs"
>
>> So far:
>> 1) setting the variables QPID_SSL_CERT_DB and QPID_SSL_CERT_PASSWORD_FILE with setenv() prior to making the amqp connection. The broker failed to see variables
>
> This is confusing to me...
It would have been for me too :-)
s/broker/agent's connection to the broker/
Getting the broker configured is fine, its the agent we're more concerned with.
A series of recursive greps have found the answer though...
Grepping for ssl-cert-password-file turns up:
./cpp/src/qpid/sys/ssl/util.cpp:59: ("ssl-cert-password-file",
optValue(certPasswordFile, "PATH"), "File containing password to use
for accessing certificate database")
Grepping for certPasswordFile turns up:
./cpp/src/qpid/sys/ssl/util.cpp:84: const std::string& passwordFile
= SslOptions::global.certPasswordFile;
and the SslOptions class in ./cpp/src/qpid/sys/ssl/util.h
Ted: correct me if I'm wrong, but it looks like we should be creating
an instance of SslOptions and (after setting the contents based on the
command line) passing it to:
void initNSS(const SslOptions& options, bool server);
Yes? Or must we be populating QPIDC_CONF_FILE with our ssl options?
Adam: highly suggest you add the following function to your repertoire:
# Eg. rgrep ssl-cert-password-file .cpp
function rgrep() {
context=3
directory=.
options="-n --color"
patterns=""
file_pattern=""
done=0
while test "$done" = "0"; do
case "$1" in
-f) options="$options --include=$2"; shift; shift;;
-C) context="$2"; shift; shift;;
-d) directory="$2"; shift; shift;;
-e) patterns="$patterns -e `echo $2 | sed 's/ /\\\W/g'`";
shift; shift;;
"") done=1;;
\.*) options="$options --include=*$1"; shift;;
-*) options="$options $1"; shift;;
*) patterns="$patterns -e `echo $1 | sed 's/ /\\\W/g'`"; shift;;
esac
done
if [ $context != 0 ]; then
options="$options -C $context"
fi
grep -r $options $patterns $directory
}
> Are you setting the variables on the client
> process prior to starting it up? If so, this has nothing to do with the
> broker process. Or are you setting the variables on the broker system
> prior to starting the client? If so, the broker wouldn't pick up new
> variables unless it was restarted (see above about daemon processes).
>
>> 2) Placing them in /etc/qpid/qpidc.conf, I thought this may work but did not have luck. There is code for checking at least the cert database in qpid.
>
> That configuration file only applies to client processes.
> /etc/qpidd.conf is used for the broker.
Agents is what we want though.
>> 3) Prior to running any agents, brokers, prepend QPID_SSL_CERT_DB and QPID_SSL_CERT_PASSWORD_FILE on the commandline. works.
>
> Yes, because the variables are passed into the processes (won't work for
> daemons). Using config files or /etc/sysconfig will work better.
>
>> Other options may be to set them in an initscript or maybe some configuration items in our own matahari.conf
>>
>> thoughts?
>>
>
> _______________________________________________
> Matahari mailing list
> Matahari(a)lists.fedorahosted.org
> https://fedorahosted.org/mailman/listinfo/matahari
>
13 years
[PATCH 0/11] Current patch queue
by russell@russellbryant.net
These are the patches currently queued up in my tree. Nothing groundbreaking
here, but ...
Posted this one already, not sure if it's right, though:
[PATCH 05/11] Fix $PROCESS in init script after name change.
I posted this one already, too. This was my proposed fix for the asprintf()
build problem for Windows:
[PATCH 11/11] Add custom implementation of asprintf().
Other cleanups, bug fixes:
[PATCH 01/11] Add "mh_" prefix to network API.
[PATCH 02/11] Change matahari_hostname() and matahari_uuid() to have
[PATCH 03/11] matahari-srv.cpp: Fix mixed tab/space indentation.
[PATCH 04/11] matahari-srv.cpp: call methodSuccess when event type
[PATCH 06/11] services_linux.c: Formatting tweaks.
[PATCH 07/11] services_linux.c: Fix off by one error, other
[PATCH 08/11] services_linux.c: Convert a macro to an inline
[PATCH 09/11] services.h: fix formatting issues.
[PATCH 10/11] service-qmf: Don't declare the SrvAgent globally.
Thanks,
--
Russell Bryant
13 years