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

« back to all changes in this revision

Viewing changes to src/ftp.cc

  • Committer: Bazaar Package Importer
  • Author(s): Luigi Gangitano
  • Date: 2011-01-21 18:43:56 UTC
  • mfrom: (1.4.5 upstream)
  • mto: This revision was merged to the branch mainline in revision 26.
  • Revision ID: james.westby@ubuntu.com-20110121184356-4zn7gwuzws6lpnuc
Tags: 3.1.10-1
* New upstream release (Closes: #609881)
  - Removed patches integrated upstream
    + 16-CVE-2010-3072
    + 17-CVE-2010-2951
  - Fixes TCP DNS lookups failure on IPv6-disabled systems (Closes: #607379)
  - Fixes HTTPS not working if IPv6 is disabled (Closes: #594713)

* debian/rules
  - Enable ZPH feature (Closes: #597687)

* debian/squid3.ufw.profile
  - Added UFW profile, thanks to Alessio Treglia (Closes: #605088)

* debian/control
  - Added versioned dependency on squid-langpack

Show diffs side-by-side

added added

removed removed

Lines of Context:
461
461
    flags.rest_supported = 1;
462
462
 
463
463
    typedef CommCbMemFunT<FtpStateData, CommCloseCbParams> Dialer;
464
 
    AsyncCall::Pointer closer = asyncCall(9, 5, "FtpStateData::ctrlClosed",
465
 
                                          Dialer(this, &FtpStateData::ctrlClosed));
 
464
    AsyncCall::Pointer closer = JobCallback(9, 5,
 
465
                                            Dialer, this, FtpStateData::ctrlClosed);
466
466
    ctrl.opened(theFwdState->server_fd, closer);
467
467
 
468
468
    if (request->method == METHOD_PUT)
1311
1311
    data.read_pending = true;
1312
1312
 
1313
1313
    typedef CommCbMemFunT<FtpStateData, CommTimeoutCbParams> TimeoutDialer;
1314
 
    AsyncCall::Pointer timeoutCall =  asyncCall(9, 5, "FtpStateData::ftpTimeout",
1315
 
                                      TimeoutDialer(this,&FtpStateData::ftpTimeout));
 
1314
    AsyncCall::Pointer timeoutCall =  JobCallback(9, 5,
 
1315
                                      TimeoutDialer, this, FtpStateData::ftpTimeout);
1316
1316
    commSetTimeout(data.fd, Config.Timeout.read, timeoutCall);
1317
1317
 
1318
1318
    debugs(9,5,HERE << "queueing read on FD " << data.fd);
1319
1319
 
1320
1320
    typedef CommCbMemFunT<FtpStateData, CommIoCbParams> Dialer;
1321
1321
    entry->delayAwareRead(data.fd, data.readBuf->space(), read_sz,
1322
 
                          asyncCall(9, 5, "FtpStateData::dataRead",
1323
 
                                    Dialer(this, &FtpStateData::dataRead)));
 
1322
                          JobCallback(9, 5, Dialer, this, FtpStateData::dataRead));
1324
1323
}
1325
1324
 
1326
1325
void
1369
1368
 
1370
1369
        if (ignoreErrno(io.xerrno)) {
1371
1370
            typedef CommCbMemFunT<FtpStateData, CommTimeoutCbParams> TimeoutDialer;
1372
 
            AsyncCall::Pointer timeoutCall =  asyncCall(9, 5, "FtpStateData::ftpTimeout",
1373
 
                                              TimeoutDialer(this,&FtpStateData::ftpTimeout));
 
1371
            AsyncCall::Pointer timeoutCall = JobCallback(9, 5,
 
1372
                                             TimeoutDialer, this, FtpStateData::ftpTimeout);
1374
1373
            commSetTimeout(io.fd, Config.Timeout.read, timeoutCall);
1375
1374
 
1376
1375
            maybeReadVirginBody();
1678
1677
    }
1679
1678
 
1680
1679
    typedef CommCbMemFunT<FtpStateData, CommIoCbParams> Dialer;
1681
 
    AsyncCall::Pointer call = asyncCall(9, 5, "FtpStateData::ftpWriteCommandCallback",
1682
 
                                        Dialer(this, &FtpStateData::ftpWriteCommandCallback));
 
1680
    AsyncCall::Pointer call = JobCallback(9, 5,
 
1681
                                          Dialer, this, FtpStateData::ftpWriteCommandCallback);
1683
1682
    comm_write(ctrl.fd,
1684
1683
               ctrl.last_command,
1685
1684
               strlen(ctrl.last_command),
1816
1815
    } else {
1817
1816
        /* XXX What about Config.Timeout.read? */
1818
1817
        typedef CommCbMemFunT<FtpStateData, CommIoCbParams> Dialer;
1819
 
        AsyncCall::Pointer reader=asyncCall(9, 5, "FtpStateData::ftpReadControlReply",
1820
 
                                            Dialer(this, &FtpStateData::ftpReadControlReply));
 
1818
        AsyncCall::Pointer reader = JobCallback(9, 5,
 
1819
                                                Dialer, this, FtpStateData::ftpReadControlReply);
1821
1820
        comm_read(ctrl.fd, ctrl.buf + ctrl.offset, ctrl.size - ctrl.offset, reader);
1822
1821
        /*
1823
1822
         * Cancel the timeout on the Data socket (if any) and
1830
1829
        }
1831
1830
 
1832
1831
        typedef CommCbMemFunT<FtpStateData, CommTimeoutCbParams> TimeoutDialer;
1833
 
        AsyncCall::Pointer timeoutCall =  asyncCall(9, 5, "FtpStateData::ftpTimeout",
1834
 
                                          TimeoutDialer(this,&FtpStateData::ftpTimeout));
 
1832
        AsyncCall::Pointer timeoutCall = JobCallback(9, 5,
 
1833
                                         TimeoutDialer, this, FtpStateData::ftpTimeout);
1835
1834
 
1836
1835
        commSetTimeout(ctrl.fd, Config.Timeout.read, timeoutCall);
1837
1836
    }
1983
1982
    ErrorState *err = NULL;
1984
1983
    const char *command, *reply;
1985
1984
 
1986
 
    if (state == SENT_USER || state == SENT_PASS) {
1987
 
        if (ctrl.replycode > 500) {
1988
 
            if (password_url)
 
1985
    if ((state == SENT_USER || state == SENT_PASS) && ctrl.replycode >= 400) {
 
1986
        if (ctrl.replycode == 421 || ctrl.replycode == 426) {
 
1987
            // 421/426 - Service Overload - retry permitted.
 
1988
            err = errorCon(ERR_FTP_UNAVAILABLE, HTTP_SERVICE_UNAVAILABLE, fwd->request);
 
1989
        } else if (ctrl.replycode >= 430 && ctrl.replycode <= 439) {
 
1990
            // 43x - Invalid or Credential Error - retry challenge required.
 
1991
            err = errorCon(ERR_FTP_FORBIDDEN, HTTP_UNAUTHORIZED, fwd->request);
 
1992
        } else if (ctrl.replycode >= 530 && ctrl.replycode <= 539) {
 
1993
            // 53x - Credentials Missing - retry challenge required
 
1994
            if (password_url) // but they were in the URI! major fail.
1989
1995
                err = errorCon(ERR_FTP_FORBIDDEN, HTTP_FORBIDDEN, fwd->request);
1990
1996
            else
1991
1997
                err = errorCon(ERR_FTP_FORBIDDEN, HTTP_UNAUTHORIZED, fwd->request);
1992
 
        } else if (ctrl.replycode == 421) {
1993
 
            err = errorCon(ERR_FTP_UNAVAILABLE, HTTP_SERVICE_UNAVAILABLE, fwd->request);
1994
1998
        }
1995
 
    } else {
 
1999
    }
 
2000
 
 
2001
    // any other problems are general falures.
 
2002
    if (!err) {
1996
2003
        ftpFail(this);
1997
2004
        return;
1998
2005
    }
2709
2716
     * dont acknowledge PASV commands.
2710
2717
     */
2711
2718
    typedef CommCbMemFunT<FtpStateData, CommTimeoutCbParams> TimeoutDialer;
2712
 
    AsyncCall::Pointer timeoutCall =  asyncCall(9, 5, "FtpStateData::ftpTimeout",
2713
 
                                      TimeoutDialer(ftpState,&FtpStateData::ftpTimeout));
 
2719
    AsyncCall::Pointer timeoutCall =  JobCallback(9, 5,
 
2720
                                      TimeoutDialer, ftpState, FtpStateData::ftpTimeout);
2714
2721
 
2715
2722
    commSetTimeout(ftpState->data.fd, 15, timeoutCall);
2716
2723
}
3085
3092
 
3086
3093
            comm_close(io.nfd);
3087
3094
            typedef CommCbMemFunT<FtpStateData, CommAcceptCbParams> acceptDialer;
3088
 
            AsyncCall::Pointer acceptCall = asyncCall(11, 5, "FtpStateData::ftpAcceptDataConnection",
3089
 
                                            acceptDialer(this, &FtpStateData::ftpAcceptDataConnection));
 
3095
            AsyncCall::Pointer acceptCall = JobCallback(11, 5,
 
3096
                                            acceptDialer, this, FtpStateData::ftpAcceptDataConnection);
3090
3097
            comm_accept(data.fd, acceptCall);
3091
3098
            return;
3092
3099
        }
3116
3123
    commSetTimeout(ctrl.fd, -1, nullCall);
3117
3124
 
3118
3125
    typedef CommCbMemFunT<FtpStateData, CommTimeoutCbParams> TimeoutDialer;
3119
 
    AsyncCall::Pointer timeoutCall =  asyncCall(9, 5, "FtpStateData::ftpTimeout",
3120
 
                                      TimeoutDialer(this,&FtpStateData::ftpTimeout));
 
3126
    AsyncCall::Pointer timeoutCall =  JobCallback(9, 5,
 
3127
                                      TimeoutDialer, this, FtpStateData::ftpTimeout);
3121
3128
    commSetTimeout(data.fd, Config.Timeout.read, timeoutCall);
3122
3129
 
3123
3130
    /*\todo XXX We should have a flag to track connect state...
3209
3216
        commSetTimeout(ctrl.fd, -1, nullCall);
3210
3217
 
3211
3218
        typedef CommCbMemFunT<FtpStateData, CommTimeoutCbParams> TimeoutDialer;
3212
 
        AsyncCall::Pointer timeoutCall =  asyncCall(9, 5, "FtpStateData::ftpTimeout",
3213
 
                                          TimeoutDialer(this,&FtpStateData::ftpTimeout));
 
3219
        AsyncCall::Pointer timeoutCall =  JobCallback(9, 5,
 
3220
                                          TimeoutDialer, this, FtpStateData::ftpTimeout);
3214
3221
 
3215
3222
        commSetTimeout(data.fd, Config.Timeout.read, timeoutCall);
3216
3223
 
3221
3228
         * When client code is 150 with a hostname, Accept data channel. */
3222
3229
        debugs(9, 3, "ftpReadStor: accepting data channel");
3223
3230
        typedef CommCbMemFunT<FtpStateData, CommAcceptCbParams> acceptDialer;
3224
 
        AsyncCall::Pointer acceptCall = asyncCall(11, 5, "FtpStateData::ftpAcceptDataConnection",
3225
 
                                        acceptDialer(this, &FtpStateData::ftpAcceptDataConnection));
 
3231
        AsyncCall::Pointer acceptCall = JobCallback(11, 5,
 
3232
                                        acceptDialer, this, FtpStateData::ftpAcceptDataConnection);
3226
3233
 
3227
3234
        comm_accept(data.fd, acceptCall);
3228
3235
    } else {
3357
3364
    } else if (code == 150) {
3358
3365
        /* Accept data channel */
3359
3366
        typedef CommCbMemFunT<FtpStateData, CommAcceptCbParams> acceptDialer;
3360
 
        AsyncCall::Pointer acceptCall = asyncCall(11, 5, "FtpStateData::ftpAcceptDataConnection",
3361
 
                                        acceptDialer(ftpState, &FtpStateData::ftpAcceptDataConnection));
 
3367
        AsyncCall::Pointer acceptCall = JobCallback(11, 5,
 
3368
                                        acceptDialer, ftpState, FtpStateData::ftpAcceptDataConnection);
3362
3369
 
3363
3370
        comm_accept(ftpState->data.fd, acceptCall);
3364
3371
        /*
3369
3376
        commSetTimeout(ftpState->ctrl.fd, -1, nullCall);
3370
3377
 
3371
3378
        typedef CommCbMemFunT<FtpStateData, CommTimeoutCbParams> TimeoutDialer;
3372
 
        AsyncCall::Pointer timeoutCall =  asyncCall(9, 5, "FtpStateData::ftpTimeout",
3373
 
                                          TimeoutDialer(ftpState,&FtpStateData::ftpTimeout));
 
3379
        AsyncCall::Pointer timeoutCall =  JobCallback(9, 5,
 
3380
                                          TimeoutDialer, ftpState,FtpStateData::ftpTimeout);
3374
3381
        commSetTimeout(ftpState->data.fd, Config.Timeout.read, timeoutCall);
3375
3382
        return;
3376
3383
    } else if (!ftpState->flags.tried_nlst && code > 300) {
3419
3426
    } else if (code == 150) {
3420
3427
        /* Accept data channel */
3421
3428
        typedef CommCbMemFunT<FtpStateData, CommAcceptCbParams> acceptDialer;
3422
 
        AsyncCall::Pointer acceptCall = asyncCall(11, 5, "FtpStateData::ftpAcceptDataConnection",
3423
 
                                        acceptDialer(ftpState, &FtpStateData::ftpAcceptDataConnection));
 
3429
        AsyncCall::Pointer acceptCall = JobCallback(11, 5,
 
3430
                                        acceptDialer, ftpState, FtpStateData::ftpAcceptDataConnection);
3424
3431
        comm_accept(ftpState->data.fd, acceptCall);
3425
3432
        /*
3426
3433
         * Cancel the timeout on the Control socket and establish one
3430
3437
        commSetTimeout(ftpState->ctrl.fd, -1, nullCall);
3431
3438
 
3432
3439
        typedef CommCbMemFunT<FtpStateData, CommTimeoutCbParams> TimeoutDialer;
3433
 
        AsyncCall::Pointer timeoutCall =  asyncCall(9, 5, "FtpStateData::ftpTimeout",
3434
 
                                          TimeoutDialer(ftpState,&FtpStateData::ftpTimeout));
 
3440
        AsyncCall::Pointer timeoutCall =  JobCallback(9, 5,
 
3441
                                          TimeoutDialer, ftpState,FtpStateData::ftpTimeout);
3435
3442
        commSetTimeout(ftpState->data.fd, Config.Timeout.read, timeoutCall);
3436
3443
    } else if (code >= 300) {
3437
3444
        if (!ftpState->flags.try_slash_hack) {
4041
4048
FtpStateData::dataCloser()
4042
4049
{
4043
4050
    typedef CommCbMemFunT<FtpStateData, CommCloseCbParams> Dialer;
4044
 
    return asyncCall(9, 5, "FtpStateData::dataClosed",
4045
 
                     Dialer(this, &FtpStateData::dataClosed));
 
4051
    return JobCallback(9, 5, Dialer, this, FtpStateData::dataClosed);
4046
4052
}
4047
4053
 
4048
4054
/// configures the channel with a descriptor and registers a close handler