|
1 | 1 | /* |
2 | 2 | * Administration CGI for CUPS. |
3 | 3 | * |
4 | | - * Copyright © 2021-2023 by OpenPrinting |
| 4 | + * Copyright © 2021-2024 by OpenPrinting |
5 | 5 | * Copyright © 2007-2021 by Apple Inc. |
6 | 6 | * Copyright © 1997-2007 by Easy Software Products. |
7 | 7 | * |
8 | 8 | * Licensed under Apache License v2.0. See the file "LICENSE" for more |
9 | 9 | * information. |
10 | 10 | */ |
11 | 11 |
|
12 | | -/* |
13 | | - * Include necessary headers... |
14 | | - */ |
15 | | - |
16 | 12 | #include "cgi-private.h" |
17 | 13 | #include <cups/http-private.h> |
18 | 14 | #include <cups/ppd-private.h> |
@@ -47,7 +43,6 @@ static void do_menu(http_t *http); |
47 | 43 | static void do_set_allowed_users(http_t *http); |
48 | 44 | static void do_set_default(http_t *http); |
49 | 45 | static void do_set_options(http_t *http, int is_class); |
50 | | -static void do_set_sharing(http_t *http); |
51 | 46 | static char *get_option_value(ppd_file_t *ppd, const char *name, |
52 | 47 | char *buffer, size_t bufsize); |
53 | 48 | static double get_points(double number, const char *uval); |
@@ -140,8 +135,6 @@ main(void) |
140 | 135 | do_set_allowed_users(http); |
141 | 136 | else if (!strcmp(op, "set-as-default")) |
142 | 137 | do_set_default(http); |
143 | | - else if (!strcmp(op, "set-sharing")) |
144 | | - do_set_sharing(http); |
145 | 138 | else if (!strcmp(op, "find-new-printers") || |
146 | 139 | !strcmp(op, "list-available-printers")) |
147 | 140 | do_list_printers(http); |
@@ -916,10 +909,10 @@ do_am_printer(http_t *http, /* I - HTTP connection */ |
916 | 909 |
|
917 | 910 | #ifdef __APPLE__ |
918 | 911 | if (!strncmp(var, "usb:", 4)) |
919 | | - cgiSetVariable("printer_is_shared", "1"); |
| 912 | + cgiSetVariable("PRINTER_IS_SHARED", "1"); |
920 | 913 | else |
921 | 914 | #endif /* __APPLE__ */ |
922 | | - cgiSetVariable("printer_is_shared", "0"); |
| 915 | + cgiSetVariable("PRINTER_IS_SHARED", "0"); |
923 | 916 |
|
924 | 917 | cgiCopyTemplateLang("add-printer.tmpl"); |
925 | 918 | } |
@@ -1166,9 +1159,7 @@ do_am_printer(http_t *http, /* I - HTTP connection */ |
1166 | 1159 |
|
1167 | 1160 | ippAddBoolean(request, IPP_TAG_PRINTER, "printer-is-accepting-jobs", 1); |
1168 | 1161 |
|
1169 | | - var = cgiGetCheckbox("printer_is_shared"); |
1170 | | - ippAddBoolean(request, IPP_TAG_PRINTER, "printer-is-shared", |
1171 | | - var && (!strcmp(var, "1") || !strcmp(var, "on"))); |
| 1162 | + ippAddBoolean(request, IPP_TAG_PRINTER, "printer-is-shared", cgiGetCheckbox("PRINTER_IS_SHARED")); |
1172 | 1163 |
|
1173 | 1164 | ippAddInteger(request, IPP_TAG_PRINTER, IPP_TAG_ENUM, "printer-state", |
1174 | 1165 | IPP_PRINTER_IDLE); |
@@ -1313,7 +1304,7 @@ do_config_server(http_t *http) /* I - HTTP connection */ |
1313 | 1304 | share_printers = cgiGetCheckbox("SHARE_PRINTERS") ? "1" : "0"; |
1314 | 1305 | user_cancel_any = cgiGetCheckbox("USER_CANCEL_ANY") ? "1" : "0"; |
1315 | 1306 |
|
1316 | | - advanced = cgiGetCheckbox("ADVANCEDSETTINGS") != NULL; |
| 1307 | + advanced = cgiGetCheckbox("ADVANCEDSETTINGS"); |
1317 | 1308 | if (advanced) |
1318 | 1309 | { |
1319 | 1310 | /* |
@@ -1375,7 +1366,9 @@ do_config_server(http_t *http) /* I - HTTP connection */ |
1375 | 1366 | */ |
1376 | 1367 |
|
1377 | 1368 | if (cgiGetCheckbox("KERBEROS")) |
| 1369 | + { |
1378 | 1370 | strlcpy(default_auth_type, "Negotiate", sizeof(default_auth_type)); |
| 1371 | + } |
1379 | 1372 | else |
1380 | 1373 | { |
1381 | 1374 | val = cupsGetOption("DefaultAuthType", num_settings, settings); |
@@ -3361,99 +3354,6 @@ do_set_options(http_t *http, /* I - HTTP connection */ |
3361 | 3354 | } |
3362 | 3355 |
|
3363 | 3356 |
|
3364 | | -/* |
3365 | | - * 'do_set_sharing()' - Set printer-is-shared value. |
3366 | | - */ |
3367 | | - |
3368 | | -static void |
3369 | | -do_set_sharing(http_t *http) /* I - HTTP connection */ |
3370 | | -{ |
3371 | | - ipp_t *request, /* IPP request */ |
3372 | | - *response; /* IPP response */ |
3373 | | - char uri[HTTP_MAX_URI]; /* Printer URI */ |
3374 | | - const char *printer, /* Printer name */ |
3375 | | - *is_class, /* Is a class? */ |
3376 | | - *shared; /* Sharing value */ |
3377 | | - |
3378 | | - |
3379 | | - is_class = cgiGetVariable("IS_CLASS"); |
3380 | | - printer = cgiGetTextfield("PRINTER_NAME"); |
3381 | | - shared = cgiGetCheckbox("SHARED"); |
3382 | | - |
3383 | | - if (!printer || !shared) |
3384 | | - { |
3385 | | - cgiSetVariable("ERROR", cgiText(_("Missing form variable"))); |
3386 | | - cgiStartHTML(cgiText(_("Set Publishing"))); |
3387 | | - cgiCopyTemplateLang("error.tmpl"); |
3388 | | - cgiEndHTML(); |
3389 | | - return; |
3390 | | - } |
3391 | | - |
3392 | | - /* |
3393 | | - * Build a CUPS-Add-Printer/CUPS-Add-Class request, which requires the |
3394 | | - * following attributes: |
3395 | | - * |
3396 | | - * attributes-charset |
3397 | | - * attributes-natural-language |
3398 | | - * printer-uri |
3399 | | - * printer-is-shared |
3400 | | - */ |
3401 | | - |
3402 | | - request = ippNewRequest(is_class ? CUPS_ADD_CLASS : CUPS_ADD_PRINTER); |
3403 | | - |
3404 | | - httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL, |
3405 | | - "localhost", 0, is_class ? "/classes/%s" : "/printers/%s", |
3406 | | - printer); |
3407 | | - ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", |
3408 | | - NULL, uri); |
3409 | | - |
3410 | | - ippAddBoolean(request, IPP_TAG_OPERATION, "printer-is-shared", (char)atoi(shared)); |
3411 | | - |
3412 | | - /* |
3413 | | - * Do the request and get back a response... |
3414 | | - */ |
3415 | | - |
3416 | | - if ((response = cupsDoRequest(http, request, "/admin/")) != NULL) |
3417 | | - { |
3418 | | - cgiSetIPPVars(response, NULL, NULL, NULL, 0); |
3419 | | - |
3420 | | - ippDelete(response); |
3421 | | - } |
3422 | | - |
3423 | | - if (cupsLastError() == IPP_NOT_AUTHORIZED) |
3424 | | - { |
3425 | | - puts("Status: 401\n"); |
3426 | | - exit(0); |
3427 | | - } |
3428 | | - else if (cupsLastError() > IPP_OK_CONFLICT) |
3429 | | - { |
3430 | | - cgiStartHTML(cgiText(_("Set Publishing"))); |
3431 | | - cgiShowIPPError(_("Unable to change printer-is-shared attribute")); |
3432 | | - } |
3433 | | - else |
3434 | | - { |
3435 | | - /* |
3436 | | - * Redirect successful updates back to the printer page... |
3437 | | - */ |
3438 | | - |
3439 | | - char url[1024], /* Printer/class URL */ |
3440 | | - refresh[1024]; /* Refresh URL */ |
3441 | | - |
3442 | | - |
3443 | | - cgiRewriteURL(uri, url, sizeof(url), NULL); |
3444 | | - cgiFormEncode(uri, url, sizeof(uri)); |
3445 | | - snprintf(refresh, sizeof(refresh), "5;URL=/admin/?OP=redirect&URL=%s", uri); |
3446 | | - cgiSetVariable("refresh_page", refresh); |
3447 | | - |
3448 | | - cgiStartHTML(cgiText(_("Set Publishing"))); |
3449 | | - cgiCopyTemplateLang(is_class ? "class-modified.tmpl" : |
3450 | | - "printer-modified.tmpl"); |
3451 | | - } |
3452 | | - |
3453 | | - cgiEndHTML(); |
3454 | | -} |
3455 | | - |
3456 | | - |
3457 | 3357 | /* |
3458 | 3358 | * 'get_option_value()' - Return the value of an option. |
3459 | 3359 | * |
|
0 commit comments