Skip to content
Snippets Groups Projects
Commit d75ec381 authored by Tim Wickberg's avatar Tim Wickberg
Browse files

Remove slurm_add_slash_to_quotes calls to avoid double-escaping.

This is the 17.11 version.

Bug 4792.
parent 2384d2a8
No related branches found
No related tags found
No related merge requests found
...@@ -1382,9 +1382,9 @@ extern int as_mysql_node_down(mysql_conn_t *mysql_conn, ...@@ -1382,9 +1382,9 @@ extern int as_mysql_node_down(mysql_conn_t *mysql_conn,
return SLURM_ERROR; return SLURM_ERROR;
if (reason) if (reason)
my_reason = slurm_add_slash_to_quotes(reason); my_reason = reason;
else else
my_reason = slurm_add_slash_to_quotes(node_ptr->reason); my_reason = node_ptr->reason;
row = mysql_fetch_row(result); row = mysql_fetch_row(result);
if (row && (node_ptr->node_state == slurm_atoul(row[0])) && if (row && (node_ptr->node_state == slurm_atoul(row[0])) &&
...@@ -1396,7 +1396,6 @@ extern int as_mysql_node_down(mysql_conn_t *mysql_conn, ...@@ -1396,7 +1396,6 @@ extern int as_mysql_node_down(mysql_conn_t *mysql_conn,
node_ptr->name, mysql_conn->cluster_name, node_ptr->name, mysql_conn->cluster_name,
node_ptr->node_state, row[0], node_ptr->node_state, row[0],
my_reason, row[1]); my_reason, row[1]);
xfree(my_reason);
mysql_free_result(result); mysql_free_result(result);
return SLURM_SUCCESS; return SLURM_SUCCESS;
} }
...@@ -1434,7 +1433,7 @@ extern int as_mysql_node_down(mysql_conn_t *mysql_conn, ...@@ -1434,7 +1433,7 @@ extern int as_mysql_node_down(mysql_conn_t *mysql_conn,
DB_DEBUG(mysql_conn->conn, "query\n%s", query); DB_DEBUG(mysql_conn->conn, "query\n%s", query);
rc = mysql_db_query(mysql_conn, query); rc = mysql_db_query(mysql_conn, query);
xfree(query); xfree(query);
xfree(my_reason);
return rc; return rc;
} }
......
...@@ -306,8 +306,7 @@ extern int as_mysql_job_start(mysql_conn_t *mysql_conn, ...@@ -306,8 +306,7 @@ extern int as_mysql_job_start(mysql_conn_t *mysql_conn,
int rc = SLURM_SUCCESS; int rc = SLURM_SUCCESS;
char *nodes = NULL, *jname = NULL, *node_inx = NULL; char *nodes = NULL, *jname = NULL, *node_inx = NULL;
int track_steps = 0; int track_steps = 0;
char *block_id = NULL, *partition = NULL, *work_dir = NULL; char *block_id = NULL, *partition = NULL;
char *gres_req = NULL, *gres_alloc = NULL, *mcs_label = NULL;
char temp_bit[BUF_SIZE]; char temp_bit[BUF_SIZE];
char *query = NULL; char *query = NULL;
int reinit = 0; int reinit = 0;
...@@ -466,9 +465,9 @@ extern int as_mysql_job_start(mysql_conn_t *mysql_conn, ...@@ -466,9 +465,9 @@ extern int as_mysql_job_start(mysql_conn_t *mysql_conn,
no_rollup_change: no_rollup_change:
if (job_ptr->name && job_ptr->name[0]) if (job_ptr->name && job_ptr->name[0])
jname = slurm_add_slash_to_quotes(job_ptr->name); jname = job_ptr->name;
else { else {
jname = xstrdup("allocation"); jname = "allocation";
track_steps = 1; track_steps = 1;
} }
...@@ -509,20 +508,9 @@ no_rollup_change: ...@@ -509,20 +508,9 @@ no_rollup_change:
job_ptr->assoc_id); job_ptr->assoc_id);
if (!IS_JOB_PENDING(job_ptr) && job_ptr->part_ptr) if (!IS_JOB_PENDING(job_ptr) && job_ptr->part_ptr)
partition = slurm_add_slash_to_quotes(job_ptr->part_ptr->name); partition = job_ptr->part_ptr->name;
else if (job_ptr->partition) else if (job_ptr->partition)
partition = slurm_add_slash_to_quotes(job_ptr->partition); partition = job_ptr->partition;
if (job_ptr->gres_req)
gres_req = slurm_add_slash_to_quotes(job_ptr->gres_req);
if (job_ptr->gres_alloc)
gres_alloc = slurm_add_slash_to_quotes(job_ptr->gres_alloc);
if (job_ptr->mcs_label)
mcs_label = slurm_add_slash_to_quotes(job_ptr->mcs_label);
if (job_ptr->details->work_dir)
work_dir = slurm_add_slash_to_quotes(
job_ptr->details->work_dir);
if (!job_ptr->db_index) { if (!job_ptr->db_index) {
if (start_time && (job_state >= JOB_COMPLETE) && if (start_time && (job_state >= JOB_COMPLETE) &&
...@@ -568,9 +556,9 @@ no_rollup_change: ...@@ -568,9 +556,9 @@ no_rollup_change:
xstrcat(query, ", wckey"); xstrcat(query, ", wckey");
if (node_inx) if (node_inx)
xstrcat(query, ", node_inx"); xstrcat(query, ", node_inx");
if (gres_req) if (job_ptr->gres_req)
xstrcat(query, ", gres_req"); xstrcat(query, ", gres_req");
if (gres_alloc) if (job_ptr->gres_alloc)
xstrcat(query, ", gres_alloc"); xstrcat(query, ", gres_alloc");
if (array_recs && array_recs->task_id_str) if (array_recs && array_recs->task_id_str)
xstrcat(query, ", array_task_str, array_max_tasks, " xstrcat(query, ", array_task_str, array_max_tasks, "
...@@ -582,7 +570,7 @@ no_rollup_change: ...@@ -582,7 +570,7 @@ no_rollup_change:
xstrcat(query, ", tres_alloc"); xstrcat(query, ", tres_alloc");
if (job_ptr->tres_req_str) if (job_ptr->tres_req_str)
xstrcat(query, ", tres_req"); xstrcat(query, ", tres_req");
if (work_dir) if (job_ptr->details->work_dir)
xstrcat(query, ", work_dir"); xstrcat(query, ", work_dir");
xstrfmtcat(query, xstrfmtcat(query,
...@@ -604,8 +592,8 @@ no_rollup_change: ...@@ -604,8 +592,8 @@ no_rollup_change:
if (wckeyid) if (wckeyid)
xstrfmtcat(query, ", %u", wckeyid); xstrfmtcat(query, ", %u", wckeyid);
if (mcs_label) if (job_ptr->mcs_label)
xstrfmtcat(query, ", '%s'", mcs_label); xstrfmtcat(query, ", '%s'", job_ptr->mcs_label);
if (job_ptr->account) if (job_ptr->account)
xstrfmtcat(query, ", '%s'", job_ptr->account); xstrfmtcat(query, ", '%s'", job_ptr->account);
if (partition) if (partition)
...@@ -616,10 +604,10 @@ no_rollup_change: ...@@ -616,10 +604,10 @@ no_rollup_change:
xstrfmtcat(query, ", '%s'", job_ptr->wckey); xstrfmtcat(query, ", '%s'", job_ptr->wckey);
if (node_inx) if (node_inx)
xstrfmtcat(query, ", '%s'", node_inx); xstrfmtcat(query, ", '%s'", node_inx);
if (gres_req) if (job_ptr->gres_req)
xstrfmtcat(query, ", '%s'", gres_req); xstrfmtcat(query, ", '%s'", job_ptr->gres_req);
if (gres_alloc) if (job_ptr->gres_alloc)
xstrfmtcat(query, ", '%s'", gres_alloc); xstrfmtcat(query, ", '%s'", job_ptr->gres_alloc);
if (array_recs && array_recs->task_id_str) if (array_recs && array_recs->task_id_str)
xstrfmtcat(query, ", '%s', %u, %u", xstrfmtcat(query, ", '%s', %u, %u",
array_recs->task_id_str, array_recs->task_id_str,
...@@ -634,8 +622,9 @@ no_rollup_change: ...@@ -634,8 +622,9 @@ no_rollup_change:
xstrfmtcat(query, ", '%s'", job_ptr->tres_alloc_str); xstrfmtcat(query, ", '%s'", job_ptr->tres_alloc_str);
if (job_ptr->tres_req_str) if (job_ptr->tres_req_str)
xstrfmtcat(query, ", '%s'", job_ptr->tres_req_str); xstrfmtcat(query, ", '%s'", job_ptr->tres_req_str);
if (work_dir) if (job_ptr->details->work_dir)
xstrfmtcat(query, ", '%s'", work_dir); xstrfmtcat(query, ", '%s'",
job_ptr->details->work_dir);
xstrfmtcat(query, xstrfmtcat(query,
") on duplicate key update " ") on duplicate key update "
...@@ -663,7 +652,8 @@ no_rollup_change: ...@@ -663,7 +652,8 @@ no_rollup_change:
if (wckeyid) if (wckeyid)
xstrfmtcat(query, ", id_wckey=%u", wckeyid); xstrfmtcat(query, ", id_wckey=%u", wckeyid);
if (job_ptr->mcs_label) if (job_ptr->mcs_label)
xstrfmtcat(query, ", mcs_label='%s'", mcs_label); xstrfmtcat(query, ", mcs_label='%s'",
job_ptr->mcs_label);
if (job_ptr->account) if (job_ptr->account)
xstrfmtcat(query, ", account='%s'", job_ptr->account); xstrfmtcat(query, ", account='%s'", job_ptr->account);
if (partition) if (partition)
...@@ -674,10 +664,11 @@ no_rollup_change: ...@@ -674,10 +664,11 @@ no_rollup_change:
xstrfmtcat(query, ", wckey='%s'", job_ptr->wckey); xstrfmtcat(query, ", wckey='%s'", job_ptr->wckey);
if (node_inx) if (node_inx)
xstrfmtcat(query, ", node_inx='%s'", node_inx); xstrfmtcat(query, ", node_inx='%s'", node_inx);
if (gres_req) if (job_ptr->gres_req)
xstrfmtcat(query, ", gres_req='%s'", gres_req); xstrfmtcat(query, ", gres_req='%s'", job_ptr->gres_req);
if (gres_alloc) if (job_ptr->gres_alloc)
xstrfmtcat(query, ", gres_alloc='%s'", gres_alloc); xstrfmtcat(query, ", gres_alloc='%s'",
job_ptr->gres_alloc);
if (array_recs && array_recs->task_id_str) if (array_recs && array_recs->task_id_str)
xstrfmtcat(query, ", array_task_str='%s', " xstrfmtcat(query, ", array_task_str='%s', "
"array_max_tasks=%u, array_task_pending=%u", "array_max_tasks=%u, array_task_pending=%u",
...@@ -696,8 +687,9 @@ no_rollup_change: ...@@ -696,8 +687,9 @@ no_rollup_change:
if (job_ptr->tres_req_str) if (job_ptr->tres_req_str)
xstrfmtcat(query, ", tres_req='%s'", xstrfmtcat(query, ", tres_req='%s'",
job_ptr->tres_req_str); job_ptr->tres_req_str);
if (work_dir) if (job_ptr->details->work_dir)
xstrfmtcat(query, ", work_dir='%s'", work_dir); xstrfmtcat(query, ", work_dir='%s'",
job_ptr->details->work_dir);
if (debug_flags & DEBUG_FLAG_DB_JOB) if (debug_flags & DEBUG_FLAG_DB_JOB)
DB_DEBUG(mysql_conn->conn, "query\n%s", query); DB_DEBUG(mysql_conn->conn, "query\n%s", query);
...@@ -722,7 +714,8 @@ no_rollup_change: ...@@ -722,7 +714,8 @@ no_rollup_change:
if (wckeyid) if (wckeyid)
xstrfmtcat(query, "id_wckey=%u, ", wckeyid); xstrfmtcat(query, "id_wckey=%u, ", wckeyid);
if (job_ptr->mcs_label) if (job_ptr->mcs_label)
xstrfmtcat(query, "mcs_label='%s', ", mcs_label); xstrfmtcat(query, "mcs_label='%s', ",
job_ptr->mcs_label);
if (job_ptr->account) if (job_ptr->account)
xstrfmtcat(query, "account='%s', ", job_ptr->account); xstrfmtcat(query, "account='%s', ", job_ptr->account);
if (partition) if (partition)
...@@ -733,10 +726,12 @@ no_rollup_change: ...@@ -733,10 +726,12 @@ no_rollup_change:
xstrfmtcat(query, "wckey='%s', ", job_ptr->wckey); xstrfmtcat(query, "wckey='%s', ", job_ptr->wckey);
if (node_inx) if (node_inx)
xstrfmtcat(query, "node_inx='%s', ", node_inx); xstrfmtcat(query, "node_inx='%s', ", node_inx);
if (gres_req) if (job_ptr->gres_req)
xstrfmtcat(query, "gres_req='%s', ", gres_req); xstrfmtcat(query, "gres_req='%s', ",
if (gres_alloc) job_ptr->gres_req);
xstrfmtcat(query, "gres_alloc='%s', ", gres_alloc); if (job_ptr->gres_alloc)
xstrfmtcat(query, "gres_alloc='%s', ",
job_ptr->gres_alloc);
if (array_recs && array_recs->task_id_str) if (array_recs && array_recs->task_id_str)
xstrfmtcat(query, "array_task_str='%s', " xstrfmtcat(query, "array_task_str='%s', "
"array_max_tasks=%u, " "array_max_tasks=%u, "
...@@ -756,8 +751,9 @@ no_rollup_change: ...@@ -756,8 +751,9 @@ no_rollup_change:
if (job_ptr->tres_req_str) if (job_ptr->tres_req_str)
xstrfmtcat(query, "tres_req='%s', ", xstrfmtcat(query, "tres_req='%s', ",
job_ptr->tres_req_str); job_ptr->tres_req_str);
if (work_dir) if (job_ptr->details->work_dir)
xstrfmtcat(query, "work_dir='%s', ", work_dir); xstrfmtcat(query, "work_dir='%s', ",
job_ptr->details->work_dir);
xstrfmtcat(query, "time_start=%ld, job_name='%s', " xstrfmtcat(query, "time_start=%ld, job_name='%s', "
"state=greatest(state, %u), " "state=greatest(state, %u), "
...@@ -791,13 +787,7 @@ no_rollup_change: ...@@ -791,13 +787,7 @@ no_rollup_change:
end_it: end_it:
xfree(tres_alloc_str); xfree(tres_alloc_str);
xfree(block_id); xfree(block_id);
xfree(partition);
xfree(gres_req);
xfree(gres_alloc);
xfree(jname);
xfree(query); xfree(query);
xfree(mcs_label);
xfree(work_dir);
return rc; return rc;
} }
...@@ -832,11 +822,9 @@ extern List as_mysql_modify_job(mysql_conn_t *mysql_conn, uint32_t uid, ...@@ -832,11 +822,9 @@ extern List as_mysql_modify_job(mysql_conn_t *mysql_conn, uint32_t uid,
if (job->derived_ec != NO_VAL) if (job->derived_ec != NO_VAL)
xstrfmtcat(vals, ", derived_ec=%u", job->derived_ec); xstrfmtcat(vals, ", derived_ec=%u", job->derived_ec);
if (job->derived_es) { if (job->derived_es)
char *derived_es = slurm_add_slash_to_quotes(job->derived_es); xstrfmtcat(vals, ", derived_es='%s'", job->derived_es);
xstrfmtcat(vals, ", derived_es='%s'", derived_es);
xfree(derived_es);
}
if (!vals) { if (!vals) {
errno = SLURM_NO_CHANGE_IN_DATA; errno = SLURM_NO_CHANGE_IN_DATA;
error("No change specified for job modification"); error("No change specified for job modification");
...@@ -1040,18 +1028,12 @@ extern int as_mysql_job_complete(mysql_conn_t *mysql_conn, ...@@ -1040,18 +1028,12 @@ extern int as_mysql_job_complete(mysql_conn_t *mysql_conn,
else if (job_ptr->tres_alloc_str) else if (job_ptr->tres_alloc_str)
xstrfmtcat(query, ", tres_alloc='%s'", job_ptr->tres_alloc_str); xstrfmtcat(query, ", tres_alloc='%s'", job_ptr->tres_alloc_str);
if (job_ptr->comment) { if (job_ptr->comment)
char *comment = slurm_add_slash_to_quotes(job_ptr->comment); xstrfmtcat(query, ", derived_es='%s'", job_ptr->comment);
xstrfmtcat(query, ", derived_es='%s'", comment);
xfree(comment);
}
if (job_ptr->admin_comment) { if (job_ptr->admin_comment)
char *comment = slurm_add_slash_to_quotes( xstrfmtcat(query, ", admin_comment='%s'",
job_ptr->admin_comment); job_ptr->admin_comment);
xstrfmtcat(query, ", admin_comment='%s'", comment);
xfree(comment);
}
exit_code = job_ptr->exit_code; exit_code = job_ptr->exit_code;
if (exit_code == 1) { if (exit_code == 1) {
...@@ -1082,7 +1064,7 @@ extern int as_mysql_step_start(mysql_conn_t *mysql_conn, ...@@ -1082,7 +1064,7 @@ extern int as_mysql_step_start(mysql_conn_t *mysql_conn,
int rc = SLURM_SUCCESS; int rc = SLURM_SUCCESS;
char temp_bit[BUF_SIZE]; char temp_bit[BUF_SIZE];
char node_list[BUFFER_SIZE]; char node_list[BUFFER_SIZE];
char *node_inx = NULL, *step_name = NULL; char *node_inx = NULL;
time_t start_time, submit_time; time_t start_time, submit_time;
char *query = NULL; char *query = NULL;
...@@ -1201,8 +1183,6 @@ extern int as_mysql_step_start(mysql_conn_t *mysql_conn, ...@@ -1201,8 +1183,6 @@ extern int as_mysql_step_start(mysql_conn_t *mysql_conn,
} }
} }
step_name = slurm_add_slash_to_quotes(step_ptr->name);
/* we want to print a -1 for the requid so leave it a /* we want to print a -1 for the requid so leave it a
%d */ %d */
/* The stepid could be -2 so use %d not %u */ /* The stepid could be -2 so use %d not %u */
...@@ -1221,7 +1201,7 @@ extern int as_mysql_step_start(mysql_conn_t *mysql_conn, ...@@ -1221,7 +1201,7 @@ extern int as_mysql_step_start(mysql_conn_t *mysql_conn,
mysql_conn->cluster_name, step_table, mysql_conn->cluster_name, step_table,
step_ptr->job_ptr->db_index, step_ptr->job_ptr->db_index,
step_ptr->step_id, step_ptr->step_id,
(int)start_time, step_name, (int)start_time, step_ptr->name,
JOB_RUNNING, step_ptr->tres_alloc_str, JOB_RUNNING, step_ptr->tres_alloc_str,
nodes, tasks, node_list, node_inx, task_dist, nodes, tasks, node_list, node_inx, task_dist,
step_ptr->cpu_freq_max, step_ptr->cpu_freq_min, step_ptr->cpu_freq_max, step_ptr->cpu_freq_min,
...@@ -1233,7 +1213,6 @@ extern int as_mysql_step_start(mysql_conn_t *mysql_conn, ...@@ -1233,7 +1213,6 @@ extern int as_mysql_step_start(mysql_conn_t *mysql_conn,
DB_DEBUG(mysql_conn->conn, "query\n%s", query); DB_DEBUG(mysql_conn->conn, "query\n%s", query);
rc = mysql_db_query(mysql_conn, query); rc = mysql_db_query(mysql_conn, query);
xfree(query); xfree(query);
xfree(step_name);
return rc; return rc;
} }
......
...@@ -98,11 +98,9 @@ static int _setup_resv_limits(slurmdb_reservation_rec_t *resv, ...@@ -98,11 +98,9 @@ static int _setup_resv_limits(slurmdb_reservation_rec_t *resv,
} }
if (resv->name) { if (resv->name) {
char *tmp_char = slurm_add_slash_to_quotes(resv->name);
xstrcat(*cols, ", resv_name"); xstrcat(*cols, ", resv_name");
xstrfmtcat(*vals, ", '%s'", tmp_char); xstrfmtcat(*vals, ", '%s'", resv->name);
xstrfmtcat(*extra, ", resv_name='%s'", tmp_char); xstrfmtcat(*extra, ", resv_name='%s'", resv->name);
xfree(tmp_char);
} }
if (resv->nodes) { if (resv->nodes) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment