This is a bug in qstat. It uses JSON_NONE for a value type (i.e., let JSON encoder decide), where it should use JSON_STRING for values that must be strings.
The following patch works in limited testing, but needs more soak time before I submit it. Compile with -DNASXXX to enable the patch.
There are more attributes that might cause trouble, but only if the admin picks bad names for users, groups, etc.
diff --git a/src/cmds/qstat.c b/src/cmds/qstat.c
index 79d7a67a..6b0f08a4 100644
--- a/src/cmds/qstat.c
+++ b/src/cmds/qstat.c
@@ -411,6 +411,25 @@ prt_attr(char *name, char *resource, char *value, int one_line) {
return;
switch (output_format) {
case FORMAT_JSON:
+#ifdef NASXXX /* localmod XXX23 */
+ /* Terminate any active resource list */
+ if (prev_resc_name && resource == NULL) {
+ if (add_json_node(JSON_OBJECT_END, JSON_NULL, JSON_NOVALUE, NULL, NULL)
+ == NULL)
+ exit_qstat("out of memory");
+ prev_resc_name = NULL;
+ }
+ /* Handle attributes whose values must be strings, but might be
+ * confused for numbers, etc.
+ */
+ if (strcmp(name, ATTR_name) == 0 ||
+ strcmp(name, ATTR_M) == 0 ||
+ strcmp(name, ATTR_project) == 0 ||
+ strcmp(name, ATTR_comment) == 0 ) {
+ if (add_json_node(JSON_VALUE, JSON_STRING, JSON_ESCAPE, name, value) == NULL)
+ exit_qstat("out of memory");
+ } else
+#endif /* localmod XXX23 */
if (strcmp(name, ATTR_v) == 0) {
if (add_json_node(JSON_OBJECT, JSON_NULL, JSON_NOVALUE, name, NULL) == NULL)
exit_qstat("out of memory");
@@ -435,7 +454,11 @@ prt_attr(char *name, char *resource, char *value, int one_line) {
*buf++ = *value++;
}
*buf = '\0';
+#ifdef NASXXX /* localmod XXX22 */
+ if (add_json_node(JSON_VALUE, JSON_STRING, JSON_ESCAPE, key, val) == NULL)
+#else
if (add_json_node(JSON_VALUE, JSON_NULL, JSON_ESCAPE, key, val) == NULL)
+#endif /* localmod XXX22 */
exit_qstat("out of memory");
if (*value != '\0')
value++;
@@ -461,12 +484,14 @@ prt_attr(char *name, char *resource, char *value, int one_line) {
== NULL)
exit_qstat("out of memory");
} else {
+#ifndef NASXXX /* localmod XXX23 */
if (prev_resc_name) {
if (add_json_node(JSON_OBJECT_END, JSON_NULL, JSON_NOVALUE, NULL, NULL)
== NULL)
exit_qstat("out of memory");
prev_resc_name = NULL;
}
+#endif /* localmod XXX23 */
if (add_json_node(JSON_VALUE, JSON_NULL, JSON_ESCAPE, name, value) == NULL)
exit_qstat("out of memory");
}