config: accept "0" and "1" as XML boolean values
[lttng-tools.git] / src / common / config / session-config.c
index 37c5ce383962e1b278e150a9dfac0a063998fd4e..b08f40a2e319155074b39d39ddcdf427eb333442 100644 (file)
@@ -712,7 +712,7 @@ void fini_session_config_validation_ctx(
 }
 
 static
-char *get_session_config_xsd_path()
+char *get_session_config_xsd_path(void)
 {
        char *xsd_path;
        const char *base_path = lttng_secure_getenv(DEFAULT_SESSION_CONFIG_XSD_PATH_ENV);
@@ -843,12 +843,14 @@ int parse_bool(xmlChar *str, int *val)
                goto end;
        }
 
-       if (!strcmp((const char *) str, config_xml_true)) {
+       if (!strcmp((const char *) str, config_xml_true) ||
+                       !strcmp((const char *) str, "1")) {
                *val = 1;
-       } else if (!strcmp((const char *) str, config_xml_false)) {
+       } else if (!strcmp((const char *) str, config_xml_false) ||
+                       !strcmp((const char *) str, "0")) {
                *val = 0;
        } else {
-               WARN("Invalid boolean value encoutered (%s).",
+               WARN("Invalid boolean value encountered (%s).",
                        (const char *) str);
                ret = -1;
        }
@@ -4017,16 +4019,17 @@ int config_load_session(const char *path, const char *session_name,
                /* Try home path */
                home_path = utils_get_home_dir();
                if (home_path) {
-                       char path[PATH_MAX];
+                       char path_buf[PATH_MAX];
 
                        /*
                         * Try user session configuration path. Ignore error here so we can
                         * continue loading the system wide sessions.
                         */
                        if (autoload) {
-                               ret = snprintf(path, sizeof(path),
-                                               DEFAULT_SESSION_HOME_CONFIGPATH "/"
-                                               DEFAULT_SESSION_CONFIG_AUTOLOAD, home_path);
+                               ret = snprintf(path_buf, sizeof(path_buf),
+                                               DEFAULT_SESSION_HOME_CONFIGPATH
+                                               "/" DEFAULT_SESSION_CONFIG_AUTOLOAD,
+                                               home_path);
                                if (ret < 0) {
                                        PERROR("snprintf session autoload home config path");
                                        ret = -LTTNG_ERR_INVALID;
@@ -4038,19 +4041,20 @@ int config_load_session(const char *path, const char *session_name,
                                 * avoid any user session daemon to try to load kernel sessions
                                 * automatically and failing all the times.
                                 */
-                               ret = validate_path_creds(path);
+                               ret = validate_path_creds(path_buf);
                                if (ret) {
-                                       path_ptr = path;
+                                       path_ptr = path_buf;
                                }
                        } else {
-                               ret = snprintf(path, sizeof(path),
-                                               DEFAULT_SESSION_HOME_CONFIGPATH, home_path);
+                               ret = snprintf(path_buf, sizeof(path_buf),
+                                               DEFAULT_SESSION_HOME_CONFIGPATH,
+                                               home_path);
                                if (ret < 0) {
                                        PERROR("snprintf session home config path");
                                        ret = -LTTNG_ERR_INVALID;
                                        goto end;
                                }
-                               path_ptr = path;
+                               path_ptr = path_buf;
                        }
                        if (path_ptr) {
                                ret = load_session_from_path(path_ptr, session_name,
This page took 0.025149 seconds and 4 git commands to generate.