~clint-fewbar/ubuntu/precise/squid3/ignore-sighup-early

« back to all changes in this revision

Viewing changes to helpers/basic_auth/squid_radius_auth/squid_rad_auth.c

  • Committer: Bazaar Package Importer
  • Author(s): Luigi Gangitano
  • Date: 2008-07-21 09:20:31 UTC
  • mfrom: (1.1.7 upstream) (3.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080721092031-bj8vog645lw6487u
Tags: 3.0.STABLE8-1
* Urgency high to meet freeze deadline

* New upstream release

* debian/patches/10-mgr_active_requests
  - Added upstream patch fixing delay_pool reporting in cachemgr.cgi

Show diffs side-by-side

added added

removed removed

Lines of Context:
65
65
#if HAVE_FCNTL_H
66
66
#include        <fcntl.h>
67
67
#endif
 
68
#ifdef _SQUID_WIN32_
 
69
#include <io.h>
 
70
#endif
68
71
 
69
72
#if HAVE_CTYPE_H
70
73
#include        <ctype.h>
90
93
#if HAVE_STRING_H
91
94
#include        <string.h>
92
95
#endif
 
96
#if HAVE_GETOPT_H
 
97
#include <getopt.h>
 
98
#endif
 
99
#if HAVE_ERRNO_H
 
100
#include <errno.h>
 
101
#endif
93
102
 
94
103
#include        "md5.h"
95
104
#include        "radius.h"
120
129
char *progname = "squid_rad_auth";
121
130
int debug_flag = 0;
122
131
 
 
132
#ifdef _SQUID_MSWIN_
 
133
void
 
134
Win32SockCleanup(void)
 
135
{
 
136
    WSACleanup();
 
137
    return;
 
138
}
 
139
#endif /* ifdef _SQUID_MSWIN_ */
 
140
 
123
141
/*
124
142
 *    Diff two timeval, b - a
125
143
 */
174
192
            totallen, length);
175
193
        return -1;
176
194
    }
177
 
 
178
195
    if (auth->id != request_id) {
179
196
        /* Duplicate response of an earlier query, ignore */
180
197
        return -1;
181
198
    }
182
 
 
183
199
    /* Verify the reply digest */
184
200
    memcpy(reply_digest, auth->vector, AUTH_VECTOR_LEN);
185
201
    memcpy(auth->vector, vector, AUTH_VECTOR_LEN);
191
207
        fprintf(stderr, "Warning: Received invalid reply digest from server\n");
192
208
        return -1;
193
209
    }
194
 
 
195
210
    if (auth->code != PW_AUTHENTICATION_ACK)
196
211
        return 1;
197
212
 
242
257
            crt = sscanf(line, "secret %s", secretkey);
243
258
        if (!memcmp(line, "identifier", 10))
244
259
            sscanf(line, "identifier %s", identifier);
245
 
       if (!memcmp(line, "service", 7))
 
260
        if (!memcmp(line, "service", 7))
246
261
            sscanf(line, "service %s", svc_name);
247
 
       if (!memcmp(line, "port", 4))
 
262
        if (!memcmp(line, "port", 4))
248
263
            sscanf(line, "port %s", svc_name);
249
264
    }
250
265
    if (srv && crt)
338
353
    memcpy(cbc, auth->vector, AUTH_VECTOR_LEN);
339
354
    for (j = 0; j < length; j += AUTH_VECTOR_LEN) {
340
355
        /* Calculate the MD5 Digest */
341
 
        strcpy((char *)md5buf, secretkey);
 
356
        strcpy((char *) md5buf, secretkey);
342
357
        memcpy(md5buf + secretlen, cbc, AUTH_VECTOR_LEN);
343
358
        md5_calc(cbc, md5buf, secretlen + AUTH_VECTOR_LEN);
344
359
 
391
406
     */
392
407
    auth->length = htons(total_length);
393
408
 
394
 
    while(retry--) {
 
409
    while (retry--) {
395
410
        int time_spent;
396
411
        struct timeval sent;
397
412
        /*
424
439
            if (rc == 0)
425
440
                return 1;
426
441
            if (rc == 1)
427
 
                return 0;
 
442
                return 0;
428
443
        }
429
444
    }
430
445
 
450
465
    int c;
451
466
 
452
467
    while ((c = getopt(argc, argv, "h:p:f:w:i:t:")) != -1) {
453
 
        switch(c) {
 
468
        switch (c) {
454
469
        case 'f':
455
470
            cfname = optarg;
456
471
            break;
481
496
            exit(1);
482
497
        }
483
498
    }
484
 
 
485
499
    if (!*server) {
486
500
        fprintf(stderr, "%s: Server not specified\n", argv[0]);
487
501
        exit(1);
488
502
    }
489
 
 
490
503
    if (!*secretkey) {
491
504
        fprintf(stderr, "%s: Shared secret not specified\n", argv[0]);
492
505
        exit(1);
493
506
    }
494
 
 
 
507
#ifdef _SQUID_MSWIN_
 
508
    {
 
509
        WSADATA wsaData;
 
510
        WSAStartup(2, &wsaData);
 
511
        atexit(Win32SockCleanup);
 
512
    }
 
513
#endif
495
514
    /*
496
515
     *    Open a connection to the server.
497
516
     */