~ubuntu-branches/ubuntu/natty/apache2/natty

« back to all changes in this revision

Viewing changes to modules/aaa/mod_authnz_ldap.c

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2009-11-06 00:29:03 UTC
  • mfrom: (14.3.5 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091106002903-a7zl7sh2z1z3uxqb
Tags: 2.2.14-1ubuntu1
* Merge from debian testing, remaining changes:
  - debian/{control, rules}: Enable PIE hardening.
  - debian/{control, rules, pache2.2-common.ufw.profile}: Add ufw profiles.
  - debian/conrol: Add bzr tag and point it to our tree.
  - Dropped debian/patches/203_fix_legacy_ap_rputs_segfaults.dpatch: 
    Already applied upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
527
527
        return DECLINED;
528
528
    }
529
529
 
 
530
    /* pre-scan for ldap-* requirements so we can get out of the way early */
 
531
    for(x=0; x < reqs_arr->nelts; x++) {
 
532
        if (! (reqs[x].method_mask & (AP_METHOD_BIT << m))) {
 
533
            continue;
 
534
        }
 
535
 
 
536
        t = reqs[x].requirement;
 
537
        w = ap_getword_white(r->pool, &t);
 
538
 
 
539
        if (strncmp(w, "ldap-",5) == 0) {
 
540
            required_ldap = 1;
 
541
            break;
 
542
        }
 
543
    }
 
544
 
 
545
    if (!required_ldap) {
 
546
        ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
 
547
                      "[%" APR_PID_T_FMT "] auth_ldap authorise: declining to authorise (no ldap requirements)", getpid());
 
548
        return DECLINED;
 
549
    }
 
550
 
 
551
 
 
552
 
530
553
    if (sec->host) {
531
554
        ldc = util_ldap_connection_find(r, sec->host, sec->port,
532
555
                                       sec->binddn, sec->bindpw, sec->deref,
559
582
#endif
560
583
    }
561
584
 
562
 
    if (!reqs_arr) {
563
 
        ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
564
 
                      "[%" APR_PID_T_FMT "] auth_ldap authorise: no requirements array", getpid());
565
 
        return sec->auth_authoritative? HTTP_UNAUTHORIZED : DECLINED;
566
 
    }
567
 
 
568
585
    /*
569
586
     * If we have been authenticated by some other module than mod_auth_ldap,
570
587
     * the req structure needed for authorization needs to be created
615
632
        w = ap_getword_white(r->pool, &t);
616
633
 
617
634
        if (strcmp(w, "ldap-user") == 0) {
618
 
            required_ldap = 1;
619
635
            if (req->dn == NULL || strlen(req->dn) == 0) {
620
636
                ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
621
637
                              "[%" APR_PID_T_FMT "] auth_ldap authorise: "
665
681
            }
666
682
        }
667
683
        else if (strcmp(w, "ldap-dn") == 0) {
668
 
            required_ldap = 1;
669
684
            if (req->dn == NULL || strlen(req->dn) == 0) {
670
685
                ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
671
686
                              "[%" APR_PID_T_FMT "] auth_ldap authorise: "
693
708
        else if (strcmp(w, "ldap-group") == 0) {
694
709
            struct mod_auth_ldap_groupattr_entry_t *ent = (struct mod_auth_ldap_groupattr_entry_t *) sec->groupattr->elts;
695
710
            int i;
696
 
            required_ldap = 1;
697
711
 
698
712
            if (sec->group_attrib_is_dn) {
699
713
                if (req->dn == NULL || strlen(req->dn) == 0) {
743
757
            }
744
758
        }
745
759
        else if (strcmp(w, "ldap-attribute") == 0) {
746
 
            required_ldap = 1;
747
760
            if (req->dn == NULL || strlen(req->dn) == 0) {
748
761
                ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
749
762
                              "[%" APR_PID_T_FMT "] auth_ldap authorise: "
779
792
            }
780
793
        }
781
794
        else if (strcmp(w, "ldap-filter") == 0) {
782
 
            required_ldap = 1;
783
795
            if (req->dn == NULL || strlen(req->dn) == 0) {
784
796
                ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
785
797
                              "[%" APR_PID_T_FMT "] auth_ldap authorise: "
843
855
        return OK;
844
856
    }
845
857
 
846
 
    if (!required_ldap || !sec->auth_authoritative) {
 
858
    if (!sec->auth_authoritative) {
847
859
        ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
848
 
                      "[%" APR_PID_T_FMT "] auth_ldap authorise: declining to authorise", getpid());
 
860
                      "[%" APR_PID_T_FMT "] auth_ldap authorise: declining to authorise (not authoritative)", getpid());
849
861
        return DECLINED;
850
862
    }
851
863