Changeset 481 for server/common


Ignore:
Timestamp:
Oct 15, 2007, 6:46:21 AM (17 years ago)
Author:
andersk
Message:
Hard-code ~username for LDAP vhosts.
File:
1 edited

Legend:

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

    r479 r481  
    5050#define MIN_UID 100
    5151#define MIN_GID 100
     52const char USERDIR[] = "web_scripts";
    5253
    5354module AP_MODULE_DECLARE_DATA vhost_ldap_module;
     
    560561    cgi = NULL;
    561562 
     563#if 0
    562564    if (reqc->cgiroot) {
    563565        cgi = strstr(r->uri, "cgi-bin/");
     
    570572        r->handler = "cgi-script";
    571573        apr_table_setn(r->notes, "alias-forced-type", r->handler);
     574#endif
     575    /* This is a quick, dirty hack. I should be shot for taking 6.170
     576     * this term and being willing to write a quick, dirty hack. */
     577   
     578    if (strncmp(r->uri, "/~", 2) == 0) {
     579        char *username;
     580        uid_t uid = (uid_t)atoll(reqc->uid);
     581        if (apr_uid_name_get(&username, uid, r->pool) != APR_SUCCESS) {
     582            ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, 0, r,
     583                          "could not get username for uid %d", uid);
     584            return DECLINED;
     585        }
     586        if (strncmp(r->uri + 2, username, strlen(username)) == 0 &&
     587            r->uri[2 + strlen(username)] == '/') {
     588            char *homedir;
     589            if (apr_uid_homepath_get(&homedir, username, r->pool) != APR_SUCCESS) {
     590                ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, 0, r,
     591                              "could not get home directory for user %s", username);
     592                return DECLINED;
     593            }
     594            r->filename = apr_pstrcat(r->pool, homedir, "/", USERDIR, r->uri + 2 + strlen(username), NULL);
     595        }
    572596    } else if (r->uri[0] == '/') {
    573597        r->filename = apr_pstrcat (r->pool, reqc->docroot, r->uri, NULL);
Note: See TracChangeset for help on using the changeset viewer.