~ubuntu-branches/ubuntu/natty/freeradius/natty-updates

« back to all changes in this revision

Viewing changes to src/modules/rlm_eap/libeap/tls.c

  • Committer: Bazaar Package Importer
  • Author(s): Josip Rodin
  • Date: 2009-11-23 03:57:37 UTC
  • mfrom: (1.2.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 28.
  • Revision ID: james.westby@ubuntu.com-20091123035737-zsgtzhfych8hir68
Tags: 2.1.7+dfsg-1
* Adopting the package, closes: #536623.
* New upstream version, closes: #513484.
  + Fixes the blooper in unlang evaluation logic, closes: #526175.
* Used quilt (and added README.source), and moved upstream file patching
  into debian/patches/. The source is no longer in collab-maint git
  (to make it simpler for me to finally get this out the door), but
  kept the .gitignore should we need that again.
* Dropped the dialup_admin/bin/backup_radacct patch (integrated upstream).
* Dropped the raddb/Makefile patch (problem no longer exists upstream).
* Dropped the lib/packet.c lib/radius.c main/listen.c patches (was from
  upstream 2.0.5 anyway).
* Dropped references to otp.conf, it no longer exists upstream.
  Keep removing the conffile statoverride in prerm.
* Dropped references to snmp.conf, it no longer exists upstream.
  Keep removing the conffile statoverride in prerm.
* Ship /etc/freeradius/modules/* in the freeradius package.
* Stop shipping sites-enabled symlinks in the package and instead create
  them only on initial install, thanks to Matej Vela, closes: #533396.
* Add export PATH="${PATH:+$PATH:}/usr/sbin:/sbin" to the init script
  at the request of John Morrissey, closes: #550143.
* Stop installing /var/run/freeradius in the package to silence Lintian.
  The init script already recreates it at will.
* Remove executable bit from example.pl to silence Lintian.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * tls.c
3
3
 *
4
 
 * Version:     $Id: tls.c,v 1.15 2007/12/15 14:56:10 aland Exp $
 
4
 * Version:     $Id$
5
5
 *
6
6
 *   This program is free software; you can redistribute it and/or modify
7
7
 *   it under the terms of the GNU General Public License as published by
23
23
 */
24
24
 
25
25
#include <freeradius-devel/ident.h>
26
 
RCSID("$Id: tls.c,v 1.15 2007/12/15 14:56:10 aland Exp $")
 
26
RCSID("$Id$")
27
27
 
28
28
#include "eap_tls.h"
29
29
 
43
43
        client_cert = client_cert; /* -Wunused.  See bug #350 */
44
44
 
45
45
        if ((new_tls = SSL_new(ssl_ctx)) == NULL) {
46
 
                radlog(L_ERR, "rlm_eap_tls: Error creating new SSL");
47
 
                radlog(L_ERR, "rlm_eap: SSL error %s", ERR_error_string(ERR_get_error(), NULL));
 
46
                radlog(L_ERR, "SSL: Error creating new SSL: %s",
 
47
                       ERR_error_string(ERR_get_error(), NULL));
48
48
                return NULL;
49
49
        }
50
50
 
54
54
        state = (tls_session_t *)malloc(sizeof(*state));
55
55
        memset(state, 0, sizeof(*state));
56
56
        session_init(state);
 
57
 
 
58
        state->ctx = ssl_ctx;
57
59
        state->ssl = new_tls;
58
60
 
59
61
        /*
134
136
                 *      being regarded as "dead".
135
137
                 */
136
138
        case SSL_ERROR_SYSCALL:
137
 
                radlog(L_ERR, "rlm_eap_tls: %s failed in a system call (%d), TLS session fails.",
 
139
                radlog(L_ERR, "SSL: %s failed in a system call (%d), TLS session fails.",
138
140
                       text, ret);
139
141
                return 0;
140
142
 
141
143
        case SSL_ERROR_SSL:
142
 
                radlog(L_ERR, "rlm_eap_tls: %s failed inside of TLS (%d), TLS session fails.",
 
144
                radlog(L_ERR, "SSL: %s failed inside of TLS (%d), TLS session fails.",
143
145
                       text, ret);
144
146
                return 0;
145
147
 
150
152
                 *      them - so "politely inform" the caller that
151
153
                 *      the code needs updating here.
152
154
                 */
153
 
                radlog(L_ERR, "rlm_eap_tls: FATAL SSL error ..... %d\n", e);
 
155
                radlog(L_ERR, "SSL: FATAL SSL error ..... %d\n", e);
154
156
                return 0;
155
157
        }
156
158
 
205
207
                DEBUG2("In SSL Connect mode \n");
206
208
        }
207
209
 
208
 
        /*
209
 
         *      If we're finished the setup, and doing session
210
 
         *      resumption, (CCS and Finish received, parsed,
211
 
         *      and validated), wind up handshake.
212
 
         */
213
 
#if 0
214
 
        if (SSL_is_init_finished(ssn->ssl) && (ssn->ssl->hit == 1)) {
215
 
                record_init(&ssn->dirty_in);
216
 
 
217
 
                /*
218
 
                 *      Magic value. See eaptls_operation().
219
 
                 */
220
 
                return 0xea; 
221
 
 
222
 
        }
223
 
#endif
224
 
 
225
210
        err = BIO_ctrl_pending(ssn->from_ssl);
226
211
        if (err > 0) {
227
212
                err = BIO_read(ssn->from_ssl, ssn->dirty_out.data,
240
225
                        return 0;
241
226
                }
242
227
        } else {
243
 
                DEBUG2("rlm_eap_tls: Application Data");
 
228
                DEBUG2("SSL Application Data");
244
229
                /* Its clean application data, do whatever we want */
245
230
                record_init(&ssn->clean_out);
246
231
        }
273
258
                written = SSL_write(ssn->ssl, ssn->clean_in.data, ssn->clean_in.used);
274
259
                record_minus(&ssn->clean_in, NULL, written);
275
260
 
276
 
 
277
261
                /* Get the dirty data from Bio to send it */
278
262
                err = BIO_read(ssn->from_ssl, ssn->dirty_out.data,
279
263
                               sizeof(ssn->dirty_out.data));
307
291
}
308
292
 
309
293
void session_close(tls_session_t *ssn)
310
 
{
 
294
{       
 
295
        SSL_set_quiet_shutdown(ssn->ssl, 1);
 
296
        SSL_shutdown(ssn->ssl);
 
297
 
311
298
        if(ssn->ssl)
312
299
                SSL_free(ssn->ssl);
313
300
#if 0
403
390
{
404
391
        const char *str_write_p, *str_version, *str_content_type = "";
405
392
        const char *str_details1 = "", *str_details2= "";
 
393
        EAP_HANDLER *handler;
 
394
        REQUEST *request;
406
395
 
407
396
        /*
408
397
         *      Don't print this out in the normal course of
585
574
                 str_write_p, str_version, str_content_type,
586
575
                 (unsigned long)tls_session->info.record_len,
587
576
                 str_details1, str_details2);
588
 
        DEBUG2("  rlm_eap_tls: %s\n", tls_session->info.info_description);
 
577
 
 
578
        handler = (EAP_HANDLER *)SSL_get_ex_data(tls_session->ssl, 0);
 
579
        if (handler) {
 
580
                request = handler->request;
 
581
        } else {
 
582
                request = NULL;
 
583
        }
 
584
 
 
585
        RDEBUG2("%s\n", tls_session->info.info_description);
589
586
}