Changeset 2755 for trunk/server/common


Ignore:
Timestamp:
Feb 26, 2016, 2:06:58 AM (6 years ago)
Author:
andersk
Message:
mod_vhost_ldap: Use scriptsVhost records rather than apacheConfig records

This will let us kill off the redundant apacheConfig records.  It
relies on the following CoS template in LDAP to make the
homeDirectory, uidNumber, and gidNumber fields available as generated
attributes in the scriptsVhost records.

dn: cn=vhostOwnerCoS,ou=VirtualHosts,dc=scripts,dc=mit,dc=edu
cn: vhostOwnerCoS
objectClass: top
objectClass: ldapSubEntry
objectClass: cosSuperDefinition
objectClass: cosIndirectDefinition
cosIndirectSpecifier: scriptsVhostAccount
cosAttribute: homeDirectory operational
cosAttribute: uid operational
cosAttribute: uidNumber operational
cosAttribute: gidNumber operational
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/server/common/oursrc/httpdmods/mod_vhost_ldap.c

    r1608 r2755  
    9090    char *dn;                           /* The saved dn from a successful search */
    9191    char *name;                         /* ServerName */
    92     char *admin;                        /* ServerAdmin */
    93     char *docroot;                      /* DocumentRoot */
    94     char *cgiroot;                      /* ScriptAlias */
     92    char *home;                         /* HOME */
     93    char *directory;                    /* DocumentRoot relative to HOME/web_scripts */
    9594    char *uid;                          /* Suexec Uid */
    9695    char *gid;                          /* Suexec Gid */
     
    9897
    9998char *attributes[] =
    100   { "apacheServerName", "apacheDocumentRoot", "apacheScriptAlias", "apacheSuexecUid", "apacheSuexecGid", "apacheServerAdmin", 0 };
     99  { "scriptsVhostName", "homeDirectory", "scriptsVhostDirectory", "uidNumber", "gidNumber", 0 };
    101100
    102101static int total_modules;
     
    304303    }
    305304    else {
    306         conf->filter = "objectClass=apacheConfig";
     305        conf->filter = "objectClass=scriptsVhost";
    307306    }
    308307
     
    509508    if (ldap_bv2escaped_filter_value(&hostnamebv, &shostnamebv) != 0)
    510509        goto null;
    511     apr_snprintf(filtbuf, FILTER_LENGTH, "(&(%s)(|(apacheServerName=%s)(apacheServerAlias=%s)))", conf->filter, shostnamebv.bv_val, shostnamebv.bv_val);
     510    apr_snprintf(filtbuf, FILTER_LENGTH, "(&(%s)(|(scriptsVhostName=%s)(scriptsVhostAlias=%s)))", conf->filter, shostnamebv.bv_val, shostnamebv.bv_val);
    512511    ber_memfree(shostnamebv.bv_val);
    513512
     
    587586            char *val = apr_pstrdup (r->pool, vals[i]);
    588587            /* These do not correspond to any real directives */
    589             if (strcasecmp (attributes[i], "apacheSuexecUid") == 0) {
     588            if (strcasecmp (attributes[i], "uidNumber") == 0) {
    590589                reqc->uid = val;
    591590                continue;
    592591            }
    593             else if (strcasecmp (attributes[i], "apacheSuexecGid") == 0) {
     592            else if (strcasecmp (attributes[i], "gidNumber") == 0) {
    594593                reqc->gid = val;
    595594                continue;
    596595            }
    597 
    598             if (strcasecmp (attributes[i], "apacheServerName") == 0) {
     596            else if (strcasecmp (attributes[i], "homeDirectory") == 0) {
     597                reqc->home = val;
     598                continue;
     599            }
     600            else if (strcasecmp (attributes[i], "scriptsVhostDirectory") == 0) {
     601                reqc->directory = val;
     602                continue;
     603            }
     604
     605            if (strcasecmp (attributes[i], "scriptsVhostName") == 0) {
    599606                reqc->name = val;
    600607                directive = "ServerName";
    601             }
    602             else if (strcasecmp (attributes[i], "apacheServerAdmin") == 0) {
    603                 reqc->admin = val;
    604                 directive = "ServerAdmin";
    605             }
    606             else if (strcasecmp (attributes[i], "apacheDocumentRoot") == 0) {
    607                 reqc->docroot = val;
    608                 directive = "DocumentRoot";
    609             }
    610             else if (strcasecmp (attributes[i], "apacheScriptAlias") == 0) {
    611                 if (val != NULL) {
    612                     /* Hack to deal with current apacheScriptAlias lagout */
    613                     if (strlen(val) > 0 && val[strlen(val) - 1] == '/')
    614                         val = apr_pstrcat(r->pool, "/cgi-bin/ ", val, (const char *)NULL);
    615                     else
    616                         val = apr_pstrcat(r->pool, "/cgi-bin/ ", val, "/", (const char *)NULL);
    617                     directive = "ScriptAlias";
    618                 }
    619                 reqc->cgiroot = val;
    620608            }
    621609            else {
     
    637625    ap_log_rerror(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r,
    638626                  "[mod_vhost_ldap.c]: loaded from ldap: "
    639                   "apacheServerName: %s, "
    640                   "apacheServerAdmin: %s, "
    641                   "apacheDocumentRoot: %s, "
    642                   "apacheScriptAlias: %s, "
    643                   "apacheSuexecUid: %s, "
    644                   "apacheSuexecGid: %s",
    645                   reqc->name, reqc->admin, reqc->docroot, reqc->cgiroot, reqc->uid, reqc->gid);
    646 
    647     if ((reqc->name == NULL)||(reqc->docroot == NULL)) {
     627                  "scriptsVhostName: %s, "
     628                  "homeDirectory: %s, "
     629                  "scriptsVhostDirectory: %s, "
     630                  "uidNumber: %s, "
     631                  "gidNumber: %s",
     632                  reqc->name, reqc->home, reqc->directory, reqc->uid, reqc->gid);
     633
     634    if (reqc->name == NULL || reqc->home == NULL || reqc->directory == NULL) {
    648635        ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, 0, r,
    649636                      "[mod_vhost_ldap.c] translate: "
     
    651638        return HTTP_INTERNAL_SERVER_ERROR;
    652639    }
     640
     641    char *docroot =
     642        strcmp(reqc->directory, ".") == 0 ?
     643        apr_pstrcat(r->pool, reqc->home, "/web_scripts", (const char *)NULL) :
     644        apr_pstrcat(r->pool, reqc->home, "/web_scripts/", reqc->directory, (const char *)NULL);
     645    if ((code = reconfigure_directive(r->pool, server, "DocumentRoot", docroot)) != 0)
     646        return code;
    653647
    654648    if (reqc->uid != NULL) {
Note: See TracChangeset for help on using the changeset viewer.