Override the session.xsd path with an ENV. variable
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 14 Apr 2014 16:10:44 +0000 (12:10 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Mon, 14 Apr 2014 19:21:59 +0000 (15:21 -0400)
The LTTNG_SESSION_CONFIG_XSD_PATH environment variable can be used to
specify a path which contains the session configuration schema. This
will allow save-load tests to be ran without installing the XSD on the
system.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
doc/man/lttng-sessiond.8
src/common/config/config.c
src/common/defaults.h

index 488bf3d298ed5bf6fdbdce996ed62ebd8d426ba9..633cf81f15d73e2918b6b453f6966a09a467184a 100644 (file)
@@ -148,6 +148,8 @@ value is 5 seconds.
 Control timeout of socket connection, receive and send. Takes an integer
 parameter: the timeout value, in milliseconds. A value of 0 or -1 uses
 the timeout of the operating system (this is the default).
+.IP "LTTNG_SESSION_CONFIG_XSD_PATH"
+Specify the path that contains the XML session configuration schema (xsd).
 .SH "SEE ALSO"
 
 .PP
index e61791b7d03b01eafad109b66f319421bb1f7e16..8b34d02f1d54500a339f4cb190d58bba1bf6d4b1 100644 (file)
@@ -568,13 +568,50 @@ void fini_session_config_validation_ctx(
        memset(ctx, 0, sizeof(struct session_config_validation_ctx));
 }
 
+static
+char *get_session_config_xsd_path()
+{
+       char *xsd_path;
+       const char *base_path = getenv(DEFAULT_SESSION_CONFIG_XSD_PATH_ENV);
+       size_t base_path_len;
+       size_t max_path_len;
+
+       if (!base_path) {
+               base_path = DEFAULT_SESSION_CONFIG_XSD_PATH;
+       }
+
+       base_path_len = strlen(base_path);
+       max_path_len = base_path_len +
+               sizeof(DEFAULT_SESSION_CONFIG_XSD_FILENAME) + 1;
+       xsd_path = zmalloc(max_path_len);
+       if (!xsd_path) {
+               goto end;
+       }
+
+       strncpy(xsd_path, base_path, max_path_len);
+       if (xsd_path[base_path_len - 1] != '/') {
+               xsd_path[base_path_len++] = '/';
+       }
+
+       strncpy(xsd_path + base_path_len, DEFAULT_SESSION_CONFIG_XSD_FILENAME,
+               max_path_len - base_path_len);
+end:
+       return xsd_path;
+}
+
 static
 int init_session_config_validation_ctx(
        struct session_config_validation_ctx *ctx)
 {
        int ret;
+       char *xsd_path = get_session_config_xsd_path();
+
+       if (!xsd_path) {
+               ret = -LTTNG_ERR_NOMEM;
+               goto end;
+       }
 
-       ctx->parser_ctx = xmlSchemaNewParserCtxt(DEFAULT_SESSION_CONFIG_XSD_PATH);
+       ctx->parser_ctx = xmlSchemaNewParserCtxt(xsd_path);
        if (!ctx->parser_ctx) {
                ERR("XSD parser context creation failed");
                ret = -LTTNG_ERR_LOAD_INVALID_CONFIG;
@@ -606,6 +643,7 @@ end:
                fini_session_config_validation_ctx(ctx);
        }
 
+       free(xsd_path);
        return ret;
 }
 
index 7acabf181ef92ca2fefbaafa45730ac4818d12e0..de610644cea5cc807cbfa246e8ffacc583aa9a37 100644 (file)
 #define DEFAULT_SESSION_SYSTEM_CONFIGPATH       DEFAULT_SYSTEM_CONFIGPATH "/" \
        DEFAULT_SESSION_PATH
 #define DEFAULT_SESSION_CONFIG_FILE_EXTENSION   ".lttng"
-#define DEFAULT_SESSION_CONFIG_XSD_PATH         CONFIG_LTTNG_SYSTEM_DATADIR \
-       "/xml/lttng/session.xsd"
-
+#define DEFAULT_SESSION_CONFIG_XSD_FILENAME     "session.xsd"
+#define DEFAULT_SESSION_CONFIG_XSD_PATH         CONFIG_LTTNG_SYSTEM_DATADIR "/xml/lttng/"
+#define DEFAULT_SESSION_CONFIG_XSD_PATH_ENV     "LTTNG_SESSION_CONFIG_XSD_PATH"
 
 #define DEFAULT_GLOBAL_APPS_UNIX_SOCK \
        DEFAULT_LTTNG_RUNDIR "/" LTTNG_UST_SOCK_FILENAME
This page took 0.02832 seconds and 4 git commands to generate.