commit afb38684344e077b73ad7d355c0bf3599bd24763
parent 87e5b0d77a92ccb7b96afd8b9c04cea0ad8cd5e2
Author: Bharatvaj Hemanth <bharatvaj@yahoo.com>
Date: Sat, 12 Sep 2026 21:53:13 +0530
parent 87e5b0d77a92ccb7b96afd8b9c04cea0ad8cd5e2
Author: Bharatvaj Hemanth <bharatvaj@yahoo.com>
Date: Sat, 12 Sep 2026 21:53:13 +0530
Redirect cancelled jobs to report pages
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/main.c b/main.c @@ -1655,7 +1655,7 @@ static void post_cancel(struct kreq *r) { struct kpair *kpi, *kpn, *kpjn; - char *path = NULL, *url = NULL; + char *dir = NULL, *path = NULL, *url = NULL; int fd; kpi = r->fieldmap[VALID_JOB_ID]; @@ -1672,8 +1672,12 @@ post_cancel(struct kreq *r) http_open(r, KHTTP_403, KMIME__MAX, 0); goto out; } - kasprintf(&path, DATADIR "/run/%s/%s.stop", - kpn->parsed.s, kpjn->parsed.s); + mkdir(DATADIR "/run", 01777); + chmod(DATADIR "/run", 01777); + kasprintf(&dir, DATADIR "/run/%s", kpn->parsed.s); + mkdir(dir, 01777); + chmod(dir, 01777); + kasprintf(&path, "%s/%s.stop", dir, kpjn->parsed.s); fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0666); if (fd == -1) { kutil_warn(r, NULL, "%s", path); @@ -1682,12 +1686,13 @@ post_cancel(struct kreq *r) } close(fd); url = khttp_urlpartx(r->pname, ksuffixes[KMIME_TEXT_HTML], - pages[PAGE_INDEX], valid_keys[VALID_JOB_ID].name, + pages[PAGE_INDEX], valid_keys[VALID_REPORT_ID].name, KATTRX_INT, kpi->parsed.i, NULL); khttp_head(r, kresps[KRESP_STATUS], "%s", khttps[KHTTP_303]); khttp_head(r, kresps[KRESP_LOCATION], "%s", url); khttp_body(r); out: + free(dir); free(path); free(url); }
: nply/minci