~ubuntu-branches/ubuntu/trusty/serf/trusty-security

« back to all changes in this revision

Viewing changes to ssltunnel.c

  • Committer: Package Import Robot
  • Author(s): James McCoy
  • Date: 2013-12-31 13:17:16 UTC
  • mfrom: (1.1.8) (3.3.2 sid)
  • Revision ID: package-import@ubuntu.com-20131231131716-s862wc4uwdzxmrr1
Tags: 1.3.3-1
* Add myself to Uploaders.
* Change the watch file to better handle code.google.com.
* New upstream release.  (Closes: #716793)
  + Refresh patches/libtool
  + Update symbols
* Adapt packaging for the upstream switch to SCons.
  + control: + scons, - autotools-dev, autoconf
  + rules: Change configure/make calls to scons
* Rename libserf1 to libserf-1-1, following standard naming conventions.
* Enable hardening flags.
* Strip unnecessary RPATH from libserf.
* Honor DEB_BUILD_OPTIONS=parallel=X

Show diffs side-by-side

added added

removed removed

Lines of Context:
91
91
        return status;
92
92
    }
93
93
 
94
 
    /* Body is supposed to be empty. */
95
 
    if (sl.code == 200) {
 
94
    /* RFC 2817:  Any successful (2xx) response to a CONNECT request indicates
 
95
       that the proxy has established a connection to the requested host and
 
96
       port, and has switched to tunneling the current connection to that server
 
97
       connection.
 
98
    */
 
99
    if (sl.code >= 200 && sl.code < 300) {
96
100
        request->conn->state = SERF_CONN_CONNECTED;
97
101
 
 
102
        /* Body is supposed to be empty. */
98
103
        apr_pool_destroy(ctx->pool);
99
104
        serf_bucket_destroy(request->conn->ssltunnel_ostream);
100
105
        request->conn->stream = NULL;
101
106
        ctx = NULL;
102
107
 
 
108
        serf__log(CONN_VERBOSE, __FILE__,
 
109
                  "successfully set up ssl tunnel on connection 0x%x\n",
 
110
                  request->conn);
 
111
 
103
112
        return APR_EOF;
104
113
    }
105
114
 
106
 
    /* Authentication failure and 200 Ok are handled at this point,
 
115
    /* Authentication failure and 2xx Ok are handled at this point,
107
116
       the rest are errors. */
108
 
    return APR_EGENERAL; /* TODO: better error code */
 
117
    return SERF_ERROR_SSLTUNNEL_SETUP_FAILED;
109
118
}
110
119
 
111
120
/* Prepare the CONNECT request. */
150
159
 
151
160
    ctx = apr_palloc(ssltunnel_pool, sizeof(*ctx));
152
161
    ctx->pool = ssltunnel_pool;
153
 
    ctx->uri = apr_psprintf(ctx->pool, "%s:%d", conn->host_info.hostinfo,
 
162
    ctx->uri = apr_psprintf(ctx->pool, "%s:%d", conn->host_info.hostname,
154
163
                            conn->host_info.port);
155
164
 
156
165
    conn->ssltunnel_ostream = serf__bucket_stream_create(conn->allocator,
157
166
                                                         detect_eof,
158
167
                                                         conn);
159
168
 
160
 
    /* TODO: should be the first request on the connection. */
161
 
    serf_connection_priority_request_create(conn,
162
 
                                            setup_request,
163
 
                                            ctx);
 
169
    serf__ssltunnel_request_create(conn,
 
170
                                   setup_request,
 
171
                                   ctx);
164
172
 
165
173
    conn->state = SERF_CONN_SETUP_SSLTUNNEL;
 
174
    serf__log(CONN_VERBOSE, __FILE__,
 
175
              "setting up ssl tunnel on connection 0x%x\n", conn);
166
176
 
167
177
    return APR_SUCCESS;
168
178
}