~ubuntu-branches/ubuntu/utopic/cups/utopic

« back to all changes in this revision

Viewing changes to cups/auth.c

  • Committer: Package Import Robot
  • Author(s): Didier Raboud, Till Kamppeter, Steve Langasek, Didier Raboud
  • Date: 2014-01-03 18:42:39 UTC
  • mfrom: (1.3.2)
  • mto: This revision was merged to the branch mainline in revision 142.
  • Revision ID: package-import@ubuntu.com-20140103184239-juzq32ckr7ra49b3
* New 1.7.0 upstream release

[ Till Kamppeter ]
* Refresh most patches with quilt
* Removed usb-backend-do-not-crash-if-usb-disabled-in-bios and
  cupsd-no-crash-on-avahi-threaded-poll-shutdown patches as they got
  applied upstream
* Removed drop-arch-specifics-from-doc patch as it is not needed
  anymore
* Updated drop_unnecessary_dependencies, manpage-hyphen-minus,
  manpage-translations and ppd-poll-with-client-conf patches manually
  to apply to the new CUPS version
* Added error counting exception from
  usb-backend-do-not-crash-if-usb-disabled-in-bios to
  tests-ignore-warnings
* Install the newly added ippfind utility and its manpage in
  cups-client
* Added pwg.h to libcups2-dev package
* Call dh_auto_clean only if the file Makedefs is present, to avoid a
  FTBFS
* Added color management extensions from Joe Simon's GSoC 2013
  project.
* Patch cups-files.conf to activate CUPS daemon syncing of files when
  closing, so that config files (like printers.conf) do not
  mysteriously disappear (LP: #1157972)
* In the AppArmor profile, allow execution of programs in
  /etc/cups/interfaces/, needed to make CUPS working with queues based
  on System V interface scripts, especially PPD-less queues
  auto-generated by cups-browsed from cups-filters 1.0.41 on.
* Silenced AppArmor noise from udev.conf in syslog (LP: #1229766)

[ Steve Langasek ]
* Add cups-filters (>= 1.0.42) as alternative to foomatic-filters
  (which is deprecated) in package relationships

[ Didier Raboud ]
* Remove Roger Leigh from uploaders on his request with thanks for his
  past work!
* Switch avahi LSB Should-Start dependency to be avahi-daemon; also
  bump package relationship to >= 0.6.31-3~ (Closes: #731608)
* Refresh the manpage translation files
* Move the USB backend quirk rules file to cups-server-common
* Add 38 new 1.7.0 libcups2 symbols
* Mark one C++ libcupsppdc1 symbol as optional as it isn't exported in
  1.7.0 anymore
* Import Fedora patches:
  - to avoid sign-extending CRCs in gz decompression
  - to build with full read-only relocations
  - to fix job history logging (upstream patch)
  - to set the internal default for SyncOnClose to Yes, instead of
    only configuring it to Yes
  - to fix a stringpool corruption issue
  - to prevent USB timeouts causing incorrect print output
* Import Fedora patch updates:
  - to dont-use-dbus-from-two-threads patch so it removes a call to
    avahi_threaded_poll_stop()
  - to avoid_stale_lockfile_in_dbus_notifier patch to call _exit when
    handling SIGTERM
* Move manpage-translations patch at the very end of the patch series
  to have it include all our patches

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * "$Id: auth.c 11173 2013-07-23 12:31:34Z msweet $"
 
2
 * "$Id: auth.c 10996 2013-05-29 11:51:34Z msweet $"
3
3
 *
4
4
 *   Authentication functions for CUPS.
5
5
 *
112
112
/*
113
113
 * 'cupsDoAuthentication()' - Authenticate a request.
114
114
 *
115
 
 * This function should be called in response to a @code HTTP_UNAUTHORIZED@
 
115
 * This function should be called in response to a @code HTTP_STATUS_UNAUTHORIZED@
116
116
 * status, prior to resubmitting your request.
117
117
 *
118
118
 * @since CUPS 1.1.20/OS X 10.4@
164
164
      DEBUG_printf(("2cupsDoAuthentication: authstring=\"%s\"",
165
165
                    http->authstring));
166
166
 
167
 
      if (http->status == HTTP_UNAUTHORIZED)
 
167
      if (http->status == HTTP_STATUS_UNAUTHORIZED)
168
168
        http->digest_tries ++;
169
169
 
170
170
      return (0);
171
171
    }
172
172
    else if (localauth == -1)
173
173
    {
174
 
      http->status = HTTP_AUTHORIZATION_CANCELED;
 
174
      http->status = HTTP_STATUS_CUPS_AUTHORIZATION_CANCELED;
175
175
      return (-1);                      /* Error or canceled */
176
176
    }
177
177
  }
190
190
    * Nope - get a new password from the user...
191
191
    */
192
192
 
 
193
    char default_username[HTTP_MAX_VALUE];
 
194
                                        /* Default username */
 
195
 
193
196
    cg = _cupsGlobals();
194
197
 
195
198
    if (!cg->lang_default)
196
199
      cg->lang_default = cupsLangDefault();
197
200
 
 
201
    if (httpGetSubField(http, HTTP_FIELD_WWW_AUTHENTICATE, "username",
 
202
                        default_username))
 
203
      cupsSetUser(default_username);
 
204
 
198
205
    snprintf(prompt, sizeof(prompt),
199
206
             _cupsLangString(cg->lang_default, _("Password for %s on %s? ")),
200
207
             cupsUser(),
205
212
 
206
213
    if ((password = cupsGetPassword2(prompt, http, method, resource)) == NULL)
207
214
    {
208
 
      http->status = HTTP_AUTHORIZATION_CANCELED;
 
215
      http->status = HTTP_STATUS_CUPS_AUTHORIZATION_CANCELED;
209
216
      return (-1);
210
217
    }
211
218
 
212
219
    snprintf(http->userpass, sizeof(http->userpass), "%s:%s", cupsUser(),
213
220
             password);
214
221
  }
215
 
  else if (http->status == HTTP_UNAUTHORIZED)
 
222
  else if (http->status == HTTP_STATUS_UNAUTHORIZED)
216
223
    http->digest_tries ++;
217
224
 
218
 
  if (http->status == HTTP_UNAUTHORIZED && http->digest_tries >= 3)
 
225
  if (http->status == HTTP_STATUS_UNAUTHORIZED && http->digest_tries >= 3)
219
226
  {
220
227
    DEBUG_printf(("1cupsDoAuthentication: Too many authentication tries (%d)",
221
228
                  http->digest_tries));
222
229
 
223
 
    http->status = HTTP_AUTHORIZATION_CANCELED;
 
230
    http->status = HTTP_STATUS_CUPS_AUTHORIZATION_CANCELED;
224
231
    return (-1);
225
232
  }
226
233
 
237
244
 
238
245
    if (_cupsSetNegotiateAuthString(http, method, resource))
239
246
    {
240
 
      http->status = HTTP_AUTHORIZATION_CANCELED;
 
247
      http->status = HTTP_STATUS_CUPS_AUTHORIZATION_CANCELED;
241
248
      return (-1);
242
249
    }
243
250
  }
280
287
  {
281
288
    DEBUG_printf(("1cupsDoAuthentication: Unknown auth type: \"%s\"",
282
289
                  www_auth));
283
 
    http->status = HTTP_AUTHORIZATION_CANCELED;
 
290
    http->status = HTTP_STATUS_CUPS_AUTHORIZATION_CANCELED;
284
291
    return (-1);
285
292
  }
286
293
 
458
465
      authsize         = sizeof(http->_authstring);
459
466
    }
460
467
 
461
 
    strcpy(http->authstring, "Negotiate ");
 
468
    strlcpy(http->authstring, "Negotiate ", authsize);
462
469
    httpEncode64_2(http->authstring + 10, authsize - 10, output_token.value,
463
470
                   output_token.length);
464
471
 
881
888
 
882
889
 
883
890
/*
884
 
 * End of "$Id: auth.c 11173 2013-07-23 12:31:34Z msweet $".
 
891
 * End of "$Id: auth.c 10996 2013-05-29 11:51:34Z msweet $".
885
892
 */