summaryrefslogtreecommitdiff
path: root/usr/src/cmd/print/bsd-sysv-commands/cancel.c
diff options
context:
space:
mode:
authorsonam gupta - Sun Microsystems - Bangalore India <Sonam.Gupta@Sun.COM>2009-04-09 23:37:50 -0700
committersonam gupta - Sun Microsystems - Bangalore India <Sonam.Gupta@Sun.COM>2009-04-09 23:37:50 -0700
commitf0b87b902adb4cdfe4ad24ea596a7311ddbb2953 (patch)
treedf5d3435e267baa0cf0483c2ca43b499f51514b8 /usr/src/cmd/print/bsd-sysv-commands/cancel.c
parent40e7ce05bde825a43b0db32ded62db8cc5b6ec9c (diff)
downloadillumos-joyent-f0b87b902adb4cdfe4ad24ea596a7311ddbb2953.tar.gz
6815222 lpstat -o reports incorrect job# for general user
Diffstat (limited to 'usr/src/cmd/print/bsd-sysv-commands/cancel.c')
-rw-r--r--usr/src/cmd/print/bsd-sysv-commands/cancel.c38
1 files changed, 34 insertions, 4 deletions
diff --git a/usr/src/cmd/print/bsd-sysv-commands/cancel.c b/usr/src/cmd/print/bsd-sysv-commands/cancel.c
index 7fbdbb8db3..6efd95bda4 100644
--- a/usr/src/cmd/print/bsd-sysv-commands/cancel.c
+++ b/usr/src/cmd/print/bsd-sysv-commands/cancel.c
@@ -51,6 +51,17 @@ usage(char *program)
exit(1);
}
+static int32_t
+get_job_id_requested(papi_job_t job) {
+ int32_t rid = -1;
+
+ papi_attribute_t **list = papiJobGetAttributeList(job);
+ papiAttributeListGetInteger(list, NULL,
+ "job-id-requested", &rid);
+
+ return (rid);
+}
+
int
cancel_jobs_for_user(char *user, papi_encryption_t encryption, char *pname) {
@@ -101,6 +112,7 @@ main(int ac, char *av[])
char *user = NULL;
papi_encryption_t encryption = PAPI_ENCRYPT_NEVER;
int c;
+ int32_t rid = 0;
(void) setlocale(LC_ALL, "");
(void) textdomain("SUNW_OST_OSCMD");
@@ -143,7 +155,17 @@ main(int ac, char *av[])
if (id != -1) { /* it's a job */
char *mesg = "cancelled";
- status = papiJobCancel(svc, printer, id);
+ /*
+ * Check if the job-id is job-id-requested
+ * or job-id. If it is job-id-requested then find
+ * corresponding job-id and send it to cancel
+ */
+ rid = job_to_be_queried(svc, printer, id);
+ if (rid > 0)
+ status = papiJobCancel(svc, printer, rid);
+ else
+ status = papiJobCancel(svc, printer, id);
+
if (status == PAPI_NOT_AUTHORIZED) {
mesg = papiStatusString(status);
exit_code = 1;
@@ -183,9 +205,17 @@ main(int ac, char *av[])
svc, status);
exit_code = 1;
}
- fprintf(OUT, "%s-%d: %s\n", printer,
- id, mesg);
-
+ /*
+ * If job-id-requested exists for this
+ * job-id then that should be displayed
+ */
+ rid = get_job_id_requested(*jobs);
+ if (rid > 0)
+ fprintf(OUT, "%s-%d: %s\n",
+ printer, rid, mesg);
+ else
+ fprintf(OUT, "%s-%d: %s\n",
+ printer, id, mesg);
}
papiJobListFree(jobs);