diff options
author | Michael R Sweet <michael.r.sweet@gmail.com> | 2018-06-18 21:28:04 -0400 |
---|---|---|
committer | Michael R Sweet <michael.r.sweet@gmail.com> | 2018-06-18 21:28:04 -0400 |
commit | 997b67343f7489183db0319c9f4eac82e1472794 (patch) | |
tree | e2a0d1f30a31b98f99d81a18a1188e47826a65a7 /systemv | |
parent | 9fc5c8d42ef127c72ecdbed976b514face5e173c (diff) | |
download | cups-997b67343f7489183db0319c9f4eac82e1472794.tar.gz |
Use Enable-Printer and Resume-Printer operations so we don't create a bogus printer (Issue #5305)
Diffstat (limited to 'systemv')
-rw-r--r-- | systemv/lpadmin.c | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/systemv/lpadmin.c b/systemv/lpadmin.c index 5841d866c..d7d02591a 100644 --- a/systemv/lpadmin.c +++ b/systemv/lpadmin.c @@ -1125,33 +1125,33 @@ enable_printer(http_t *http, /* I - Server connection */ DEBUG_printf(("enable_printer(%p, \"%s\")\n", http, printer)); /* - * Build a IPP_OP_CUPS_ADD_MODIFY_PRINTER or IPP_OP_CUPS_ADD_MODIFY_CLASS request, which + * Send IPP_OP_ENABLE_PRINTER and IPP_OP_RESUME_PRINTER requests, which * require the following attributes: * * attributes-charset * attributes-natural-language * printer-uri * requesting-user-name - * printer-state - * printer-is-accepting-jobs */ - if (get_printer_type(http, printer, uri, sizeof(uri)) & CUPS_PRINTER_CLASS) - request = ippNewRequest(IPP_OP_CUPS_ADD_MODIFY_CLASS); - else - request = ippNewRequest(IPP_OP_CUPS_ADD_MODIFY_PRINTER); + request = ippNewRequest(IPP_OP_ENABLE_PRINTER); - ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, - "printer-uri", NULL, uri); - ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, - "requesting-user-name", NULL, cupsUser()); - ippAddInteger(request, IPP_TAG_PRINTER, IPP_TAG_ENUM, "printer-state", - IPP_PSTATE_IDLE); - ippAddBoolean(request, IPP_TAG_PRINTER, "printer-is-accepting-jobs", 1); + ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, uri); + ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, cupsUser()); - /* - * Do the request and get back a response... - */ + ippDelete(cupsDoRequest(http, request, "/admin/")); + + if (cupsLastError() > IPP_STATUS_OK_CONFLICTING) + { + _cupsLangPrintf(stderr, _("%s: %s"), "lpadmin", cupsLastErrorString()); + + return (1); + } + + request = ippNewRequest(IPP_OP_RESUME_PRINTER); + + ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, uri); + ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, cupsUser()); ippDelete(cupsDoRequest(http, request, "/admin/")); @@ -1161,8 +1161,8 @@ enable_printer(http_t *http, /* I - Server connection */ return (1); } - else - return (0); + + return (0); } |