~ubuntu-branches/ubuntu/natty/cups/natty

« back to all changes in this revision

Viewing changes to backend/ipp.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-09-15 11:30:07 UTC
  • mto: (12.1.3 sid) (14.1.1 sid) (25.1.2 lucid)
  • mto: This revision was merged to the branch mainline in revision 13.
  • Revision ID: james.westby@ubuntu.com-20090915113007-1gngzbskotfxronq
Tags: upstream-1.4.1
ImportĀ upstreamĀ versionĀ 1.4.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * "$Id: ipp.c 8731 2009-06-26 18:26:36Z mike $"
 
2
 * "$Id: ipp.c 8805 2009-08-31 16:34:06Z mike $"
3
3
 *
4
4
 *   IPP backend for the Common UNIX Printing System (CUPS).
5
5
 *
45
45
 
46
46
static char     *password = NULL;       /* Password for device URI */
47
47
static int      password_tries = 0;     /* Password tries */
 
48
static const char *auth_info_required = "none";
 
49
                                        /* New auth-info-required value */
48
50
#ifdef __APPLE__
49
51
static char     pstmpname[1024] = "";   /* Temporary PostScript file name */
50
52
#endif /* __APPLE__ */
1049
1051
        _cupsLangPrintf(stderr, _("ERROR: Print file was not accepted (%s)!\n"),
1050
1052
                        cupsLastErrorString());
1051
1053
 
1052
 
        if (ipp_status == IPP_NOT_AUTHORIZED)
 
1054
        if (ipp_status == IPP_NOT_AUTHORIZED || ipp_status == IPP_FORBIDDEN)
1053
1055
        {
1054
1056
          fprintf(stderr, "DEBUG: WWW-Authenticate=\"%s\"\n",
1055
1057
                  httpGetField(http, HTTP_FIELD_WWW_AUTHENTICATE));
1056
1058
 
 
1059
         /*
 
1060
          * Normal authentication goes through the password callback, which sets
 
1061
          * auth_info_required to "username,password".  Kerberos goes directly
 
1062
          * through GSSAPI, so look for Negotiate in the WWW-Authenticate header
 
1063
          * here and set auth_info_required as needed...
 
1064
          */
 
1065
 
1057
1066
          if (!strncmp(httpGetField(http, HTTP_FIELD_WWW_AUTHENTICATE),
1058
1067
                       "Negotiate", 9))
1059
 
            fputs("ATTR: auth-info-required=negotiate\n", stderr);
1060
 
          else
1061
 
            fputs("ATTR: auth-info-required=username,password\n", stderr);
 
1068
            auth_info_required = "negotiate";
1062
1069
        }
1063
1070
      }
1064
1071
    }
1239
1246
            break;
1240
1247
          }
1241
1248
        }
 
1249
        else
 
1250
        {
 
1251
         /*
 
1252
          * If the printer does not return a job-state attribute, it does not
 
1253
          * conform to the IPP specification - break out immediately and fail
 
1254
          * the job...
 
1255
          */
 
1256
 
 
1257
          fputs("DEBUG: No job-state available from printer - stopping queue.\n",
 
1258
                stderr);
 
1259
          ipp_status = IPP_INTERNAL_ERROR;
 
1260
          break;
 
1261
        }
1242
1262
      }
1243
1263
 
1244
1264
      ippDelete(response);
1283
1303
      page_count > start_count)
1284
1304
    fprintf(stderr, "PAGE: total %d\n", page_count - start_count);
1285
1305
 
 
1306
#ifdef HAVE_GSSAPI
 
1307
 /*
 
1308
  * See if we used Kerberos at all...
 
1309
  */
 
1310
 
 
1311
  if (http->gssctx)
 
1312
    auth_info_required = "negotiate";
 
1313
#endif /* HAVE_GSSAPI */
 
1314
 
1286
1315
 /*
1287
1316
  * Free memory...
1288
1317
  */
1315
1344
  * Return the queue status...
1316
1345
  */
1317
1346
 
1318
 
  if (ipp_status == IPP_NOT_AUTHORIZED)
 
1347
  fprintf(stderr, "ATTR: auth-info-required=%s\n", auth_info_required);
 
1348
 
 
1349
  if (ipp_status == IPP_NOT_AUTHORIZED || ipp_status == IPP_FORBIDDEN)
1319
1350
    return (CUPS_BACKEND_AUTH_REQUIRED);
 
1351
  else if (ipp_status == IPP_INTERNAL_ERROR)
 
1352
    return (CUPS_BACKEND_STOP);
1320
1353
  else if (ipp_status > IPP_OK_CONFLICT)
1321
1354
    return (CUPS_BACKEND_FAILED);
1322
1355
  else
1517
1550
{
1518
1551
  (void)prompt;
1519
1552
 
 
1553
 /*
 
1554
  * Remember that we need to authenticate...
 
1555
  */
 
1556
 
 
1557
  auth_info_required = "username,password";
 
1558
 
1520
1559
  if (password && *password && password_tries < 3)
1521
1560
  {
1522
1561
    password_tries ++;
1526
1565
  else
1527
1566
  {
1528
1567
   /*
1529
 
    * If there is no password set in the device URI, return the
1530
 
    * "authentication required" exit code...
 
1568
    * Give up after 3 tries or if we don't have a password to begin with...
1531
1569
    */
1532
1570
 
1533
 
    if (tmpfilename[0])
1534
 
      unlink(tmpfilename);
1535
 
 
1536
 
#ifdef __APPLE__
1537
 
    if (pstmpname[0])
1538
 
      unlink(pstmpname);
1539
 
#endif /* __APPLE__ */
1540
 
 
1541
 
    fputs("ATTR: auth-info-required=username,password\n", stderr);
1542
 
 
1543
 
    exit(CUPS_BACKEND_AUTH_REQUIRED);
1544
 
 
1545
 
    return (NULL);                      /* Eliminate compiler warning */
 
1571
    return (NULL);
1546
1572
  }
1547
1573
}
1548
1574
 
1908
1934
 
1909
1935
 
1910
1936
/*
1911
 
 * End of "$Id: ipp.c 8731 2009-06-26 18:26:36Z mike $".
 
1937
 * End of "$Id: ipp.c 8805 2009-08-31 16:34:06Z mike $".
1912
1938
 */