~hartmans/ubuntu/trusty/krb5/gss-infinite-loop

« back to all changes in this revision

Viewing changes to src/lib/krb5/krb/gic_pwd.c

  • Committer: Package Import Robot
  • Author(s): Dmitrijs Ledkovs
  • Date: 2013-11-10 02:20:12 UTC
  • mfrom: (53.1.3 trusty-proposed)
  • Revision ID: package-import@ubuntu.com-20131110022012-b8ojkqhcxos55kln
Tags: 1.11.3+dfsg-3ubuntu2
Add alternate dependency on libverto-libevent1 as that's the package
ABI name in ubuntu.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
#include "k5-int.h"
3
3
#include "com_err.h"
4
4
#include "init_creds_ctx.h"
 
5
#include "int-proto.h"
5
6
 
6
7
krb5_error_code
7
8
krb5_get_as_key_password(krb5_context context,
12
13
                         krb5_data *salt,
13
14
                         krb5_data *params,
14
15
                         krb5_keyblock *as_key,
15
 
                         void *gak_data)
 
16
                         void *gak_data,
 
17
                         k5_response_items *ritems)
16
18
{
17
19
    krb5_data *password;
18
20
    krb5_error_code ret;
21
23
    char promptstr[1024];
22
24
    krb5_prompt prompt;
23
25
    krb5_prompt_type prompt_type;
 
26
    const char *rpass;
24
27
 
25
28
    password = (krb5_data *) gak_data;
 
29
    assert(password->length > 0);
 
30
 
 
31
    /* If we need to get the AS key via the responder, ask for it. */
 
32
    if (as_key == NULL) {
 
33
        /* However, if we already have a password, don't ask. */
 
34
        if (password->data[0] != '\0')
 
35
            return 0;
 
36
 
 
37
        return k5_response_items_ask_question(ritems,
 
38
                                              KRB5_RESPONDER_QUESTION_PASSWORD,
 
39
                                              "");
 
40
    }
26
41
 
27
42
    /* If there's already a key of the correct etype, we're done.
28
43
       If the etype is wrong, free the existing key, and make
39
54
        }
40
55
    }
41
56
 
42
 
    if (password->length == 0 || password->data[0] == '\0') {
 
57
    if (password->data[0] == '\0') {
 
58
        /* Check the responder for the password. */
 
59
        rpass = k5_response_items_get_answer(ritems,
 
60
                                             KRB5_RESPONDER_QUESTION_PASSWORD);
 
61
        if (rpass != NULL) {
 
62
            strlcpy(password->data, rpass, password->length);
 
63
            password->length = strlen(password->data);
 
64
        }
 
65
    }
 
66
 
 
67
    if (password->data[0] == '\0') {
43
68
        if (prompter == NULL)
44
69
            return(EIO);
45
70
 
63
88
            return(ret);
64
89
    }
65
90
 
66
 
    if (salt->length == SALT_TYPE_AFS_LENGTH && salt->data == NULL) {
 
91
    if (salt == NULL) {
67
92
        if ((ret = krb5_principal2salt(context, client, &defsalt)))
68
93
            return(ret);
69
94
 
218
243
krb5_get_init_creds_password(krb5_context context,
219
244
                             krb5_creds *creds,
220
245
                             krb5_principal client,
221
 
                             char *password,
 
246
                             const char *password,
222
247
                             krb5_prompter_fct prompter,
223
248
                             void *data,
224
249
                             krb5_deltat start_time,
225
 
                             char *in_tkt_service,
 
250
                             const char *in_tkt_service,
226
251
                             krb5_get_init_creds_opt *options)
227
252
{
228
253
    krb5_error_code ret, ret2;
235
260
    char banner[1024], pw0array[1024], pw1array[1024];
236
261
    krb5_prompt prompt[2];
237
262
    krb5_prompt_type prompt_types[sizeof(prompt)/sizeof(prompt[0])];
 
263
    char *message;
238
264
 
239
265
    use_master = 0;
240
266
    as_reply = NULL;
309
335
            use_master = 0;
310
336
    }
311
337
 
312
 
#ifdef USE_KIM
313
 
    if (ret == KRB5KDC_ERR_KEY_EXP)
314
 
        goto cleanup;   /* Login library will deal appropriately with this error */
315
 
#endif
316
 
 
317
338
    /* at this point, we have an error from the master.  if the error
318
339
       is not password expired, or if it is but there's no prompter,
319
340
       return this error */
413
434
 
414
435
            /* the error was soft, so try again */
415
436
 
 
437
            if (krb5_chpw_message(context, &result_string, &message) != 0)
 
438
                message = NULL;
 
439
 
416
440
            /* 100 is I happen to know that no code_string will be longer
417
441
               than 100 chars */
418
442
 
419
 
            if (result_string.length > (sizeof(banner)-100))
420
 
                result_string.length = sizeof(banner)-100;
 
443
            if (message != NULL && strlen(message) > (sizeof(banner) - 100))
 
444
                message[sizeof(banner) - 100] = '\0';
421
445
 
422
446
            snprintf(banner, sizeof(banner),
423
 
                     _("%.*s%s%.*s.  Please try again.\n"),
 
447
                     _("%.*s%s%s.  Please try again.\n"),
424
448
                     (int) code_string.length, code_string.data,
425
 
                     result_string.length ? ": " : "",
426
 
                     (int) result_string.length,
427
 
                     result_string.data ? result_string.data : "");
 
449
                     message ? ": " : "", message ? message : "");
428
450
 
 
451
            free(message);
429
452
            free(code_string.data);
430
453
            free(result_string.data);
431
454
        }