Ejemplo n.º 1
0
static const char *
SVNSpecialURI_cmd(cmd_parms *cmd, void *config, const char *arg1)
{
  server_conf_t *conf;
  char *uri;
  apr_size_t len;

  uri = apr_pstrdup(cmd->pool, arg1);

  /* apply a bit of processing to the thing:
     - eliminate .. and . components
     - eliminate double slashes
     - eliminate leading and trailing slashes
     */
  ap_getparents(uri);
  ap_no2slash(uri);
  if (*uri == '/')
    ++uri;
  len = strlen(uri);
  if (len > 0 && uri[len - 1] == '/')
    uri[--len] = '\0';
  if (len == 0)
    return "The special URI path must have at least one component.";

  conf = ap_get_module_config(cmd->server->module_config,
                              &dav_svn_module);
  conf->special_uri = uri;

  return NULL;
}
Ejemplo n.º 2
0
/*******************************************************************************
 * Find a FastCGI server with a matching fs_path, and if fcgi_wrapper is
 * enabled with matching uid and gid.
 */
fcgi_server *
fcgi_util_fs_get_by_id(const char *ePath, uid_t uid, gid_t gid)
{
    char path[FCGI_MAXPATH];
    fcgi_server *s;

    /* @@@ This should now be done in the loop below */
    ap_cpystrn(path, ePath, FCGI_MAXPATH);
    ap_no2slash(path);

    for (s = fcgi_servers; s != NULL; s = s->next) {
        int i;
        const char *fs_path = s->fs_path;
        for (i = 0; fs_path[i] && path[i]; ++i) {
            if (fs_path[i] != path[i]) {
                break;
            }
        }
        if (fs_path[i]) {
            continue;
        }
        if (path[i] == '\0' || path[i] == '/') {
        if (fcgi_wrapper == NULL || (uid == s->uid && gid == s->gid))
            return s;
        }
    }
    return NULL;
}
Ejemplo n.º 3
0
/*******************************************************************************
 * Find a FastCGI server with a matching fs_path, and if fcgi_wrapper is
 * enabled with matching user and group.
 */
fcgi_server *
fcgi_util_fs_get(const char *ePath, const char *user, const char *group)
{
    char path[FCGI_MAXPATH];
    fcgi_server *s;

    ap_cpystrn(path, ePath, FCGI_MAXPATH);
    ap_no2slash(path);
    
    for (s = fcgi_servers; s != NULL; s = s->next) {
        if (strcmp(s->fs_path, path) == 0) {
            if (fcgi_wrapper == NULL)
                return s;

            if (strcmp(user, s->user) == 0 
                && (user[0] == '~' || strcmp(group, s->group) == 0))
            {
                return s;
            }
        }
    }
    return NULL;
}
Ejemplo n.º 4
0
/*
 * Send the right path to the end user upon a request.
 */
static int vhx_translate_name(request_rec * r)
{
	vhx_config_rec     	*vhr  = (vhx_config_rec *)     ap_get_module_config(r->server->module_config, &vhostx_module);
	core_server_config 	*conf = (core_server_config *) ap_get_module_config(r->server->module_config, &core_module);

	vhx_request_t *reqc;
	int vhost_found_by_request = DECLINED;

	VH_AP_LOG_RERROR(APLOG_MARK, APLOG_DEBUG, 0, r, "vhx_translate_name: BEGIN ***,pid=%d",getpid());
	VH_AP_LOG_RERROR(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r, "vhx_translate_name: request URI '%s'", r->unparsed_uri);

	/* If VHS is not enabled, then don't process request */
	if (!vhr->enable) {
		VH_AP_LOG_RERROR(APLOG_MARK, APLOG_DEBUG, 0, r, "vhx_translate_name: VHS Disabled ");
		return DECLINED;
	}

	if(r->hostname == NULL) {
		VH_AP_LOG_RERROR(APLOG_MARK, APLOG_DEBUG, 0, r, "vhx_translate_name: no 'Host:' header found");
		return vhx_redirect_stuff(r, vhr);
	}

	vhx_conn_cfg_t *conn_cfg =
		(vhx_conn_cfg_t*) ap_get_module_config(r->connection->conn_config,
				&vhostx_module);
	if (conn_cfg != NULL) {
		if(conn_cfg->last_vhost != NULL) {
			if ((apr_strnatcasecmp(r->hostname, conn_cfg->last_vhost) == 0) && (conn_cfg->last_vhost_status == VH_VHOST_INFOS_NOT_FOUND)) {
				VH_AP_LOG_RERROR(APLOG_MARK, APLOG_DEBUG, 0, r, "vhx_translate_name: VH_VHOST_INFOS_NOT_FOUND already set");
				return DECLINED;
			}
		}
	}

	reqc = ap_get_module_config(r->request_config, &vhostx_module);	
	if (!reqc) {
		reqc = (vhx_request_t *)apr_pcalloc(r->pool, sizeof(vhx_request_t));
		reqc->vhost_found = VH_VHOST_INFOS_NOT_YET_REQUESTED;
		VH_AP_LOG_RERROR(APLOG_MARK, APLOG_DEBUG, 0, r, "vhx_translate_name: set VH_VHOST_INFOS_NOT_YET_REQUESTED");
		ap_set_module_config(r->request_config, &vhostx_module, reqc);
	}
	/* If we don't have LDAP Url module is disabled */
	if (!vhr->ldap_have_url) {
		VH_AP_LOG_RERROR(APLOG_MARK, APLOG_ERR, 0, r, "vhx_translate_name: VHS Disabled - No LDAP URL ");
		return DECLINED;
	}
	VH_AP_LOG_RERROR(APLOG_MARK, APLOG_DEBUG, 0, r, "vhx_translate_name: VHS Enabled.");

	/* Avoid handling request that don't start with '/' */
	if (r->uri[0] != '/' && r->uri[0] != '\0') {
		VH_AP_LOG_RERROR(APLOG_MARK, APLOG_WARNING, 0, r, "%s: (vhx_translate_name) declined URI '%s' no leading `/'", VH_NAME, r->uri);
		return DECLINED;
	}
	//if ((ptr = ap_strchr(host, ':'))) {
	//	*ptr = '\0';
	//}

	if (reqc->vhost_found == VH_VHOST_INFOS_NOT_YET_REQUESTED) {
		VH_AP_LOG_RERROR(APLOG_MARK, APLOG_DEBUG, 0, r, "vhx_translate_name: looking for %s", r->hostname);
		/*
		 * Trying to get vhost information
		 */
		vhost_found_by_request = getldaphome(r, vhr, (char *) r->hostname, reqc);

		if (vhost_found_by_request != OK) { 
			/*
			 * The vhost has not been found
			 * Trying to get lamer mode or not
			 */
			if (vhr->lamer_mode) {
				if ((strncasecmp(r->hostname, "www.",4) == 0) && (strlen(r->hostname) > 4)) {
					VH_AP_LOG_RERROR(APLOG_MARK, APLOG_DEBUG, 0, r, "vhx_translate_name: Lamer friendly mode engaged");
					char           *lhost;
					lhost = apr_pstrdup(r->pool, r->hostname + 4);
					VH_AP_LOG_RERROR(APLOG_MARK, APLOG_DEBUG, 0, r, "vhx_translate_name: Found a lamer for %s -> %s", r->hostname, lhost);

					vhost_found_by_request = getldaphome(r, vhr, lhost, reqc);
					if (vhost_found_by_request != OK) {
						if (vhr->log_notfound) {
							VH_AP_LOG_RERROR(APLOG_MARK, APLOG_NOTICE, 0, r, "%s: (vhx_translate_name) no host found in database for %s or %s", VH_NAME, r->hostname, lhost);
						}
						return vhx_redirect_stuff(r, vhr);
					}
				}
			} else {
				if (vhr->log_notfound) {
					VH_AP_LOG_RERROR(APLOG_MARK, APLOG_NOTICE, 0, r, "%s: (vhx_translate_name) no host found in database for %s (WWW mode not enabled)", VH_NAME, r->hostname);
				}
				return vhx_redirect_stuff(r, vhr);
			}
		}
	}
	else {
		VH_AP_LOG_RERROR(APLOG_MARK, APLOG_DEBUG, 0, r, "vhx_translate_name: Request to backend has already been done (vhx_itk_post_read()) !");
		if (reqc->vhost_found == VH_VHOST_INFOS_NOT_FOUND)
			vhost_found_by_request = DECLINED; /* the request has already be done and vhost was not found */
		else
			vhost_found_by_request = OK; /* the request has already be done and vhost was found */
	}

	if (vhost_found_by_request == OK)
		VH_AP_LOG_RERROR(APLOG_MARK, APLOG_DEBUG, 0, r, "vhx_translate_name: path found in database for %s is %s", r->hostname, reqc->docroot);
	else {
		if (vhr->log_notfound) {
			VH_AP_LOG_RERROR(APLOG_MARK, APLOG_NOTICE|APLOG_NOERRNO, 0, r, "%s: (vhx_translate_name) no path found found in database for %s", VH_NAME, r->hostname);
		}
		return vhx_redirect_stuff(r, vhr);
	}

	// Set VH_GECOS env variable - used for logging
	apr_table_set(r->subprocess_env, "VH_GECOS", reqc->name ? reqc->name : "");

	/* Do we have handle vhr_Path_Prefix here ? */
	if (vhr->path_prefix) {
		apr_table_set(r->subprocess_env, "VH_PATH", apr_pstrcat(r->pool, vhr->path_prefix, reqc->docroot, NULL));
		apr_table_set(r->subprocess_env, "SERVER_ROOT", apr_pstrcat(r->pool, vhr->path_prefix, reqc->docroot, NULL));
	} else {
		apr_table_set(r->subprocess_env, "VH_PATH", reqc->docroot);
		apr_table_set(r->subprocess_env, "SERVER_ROOT", reqc->docroot);
	}

	if (reqc->admin) {
		r->server->server_admin = apr_pstrcat(r->pool, reqc->admin, NULL);
	} else {
		r->server->server_admin = apr_pstrcat(r->pool, "webmaster@", r->hostname, NULL);
	}
	r->server->server_hostname = apr_pstrcat(r->connection->pool, r->hostname, NULL);
	r->parsed_uri.path = apr_pstrcat(r->pool, vhr->path_prefix ? vhr->path_prefix : "", reqc->docroot, r->parsed_uri.path, NULL);
	r->parsed_uri.hostname = r->server->server_hostname;
	r->parsed_uri.hostinfo = r->server->server_hostname;

	/* document_root */
	if (vhr->path_prefix) {
		conf->ap_document_root = apr_pstrcat(r->pool, vhr->path_prefix, reqc->docroot, NULL);
	} else {
		conf->ap_document_root = apr_pstrcat(r->pool, reqc->docroot, NULL);
	}

	/* if directory exist */
	if (!ap_is_directory(r->pool, reqc->docroot)) {
		VH_AP_LOG_RERROR(APLOG_MARK, APLOG_ERR, 0, r,
				"%s: (vhx_translate_name) homedir '%s' is not dir at all", VH_NAME, reqc->docroot);
		return DECLINED;
	}
	r->filename = apr_psprintf(r->pool, "%s%s%s", vhr->path_prefix ? vhr->path_prefix : "", reqc->docroot, r->uri);

	/* Avoid getting // in filename */
	ap_no2slash(r->filename);

	VH_AP_LOG_RERROR(APLOG_MARK, APLOG_DEBUG, 0, r, "vhx_translate_name: translated http[s]://%s%s to file %s", r->hostname, r->uri, r->filename);

#ifdef HAVE_MOD_PHP_SUPPORT
	if(reqc->homedirectory != NULL)
		vhx_php_config(r, vhr, reqc->homedirectory, reqc->phpoptions);
	else
		vhx_php_config(r, vhr, reqc->docroot, reqc->phpoptions);
#endif /* HAVE_MOD_PHP_SUPPORT */

	VH_AP_LOG_RERROR(APLOG_MARK, APLOG_DEBUG, 0, r, "vhx_translate_name: END ***, pid=%d",getpid());
	return OK;
}
Ejemplo n.º 5
0
/*******************************************************************************
 * Configure a static FastCGI server that is started/managed elsewhere.
 */
const char *fcgi_config_new_external_server(cmd_parms *cmd, void *dummy, const char *arg)
{
    fcgi_server *s;
    pool * const p = cmd->pool, *tp = cmd->temp_pool;
    const char * const name = cmd->cmd->name;
    char *fs_path = ap_getword_conf(p, &arg);
    const char *option, *err;

    err = ap_check_cmd_context(cmd, NOT_IN_LIMIT|NOT_IN_DIR_LOC_FILE);
    if (err) {
        return err;
    }

    if (!*fs_path) {
        return ap_pstrcat(tp, name, " requires a path and either a -socket or -host option", NULL);
    }

#ifdef APACHE2
    if (apr_filepath_merge(&fs_path, "", fs_path, 0, p))
        return ap_psprintf(tp, "%s %s: invalid filepath", name, fs_path);
#else
    fs_path = ap_os_canonical_filename(p, fs_path);
#endif

    fs_path = ap_server_root_relative(p, fs_path);

    ap_getparents(fs_path);
    ap_no2slash(fs_path);

    /* See if we've already got one of these bettys configured */
    s = fcgi_util_fs_get_by_id(fs_path, fcgi_util_get_server_uid(cmd->server),
                               fcgi_util_get_server_gid(cmd->server));
    if (s != NULL) {
        if (fcgi_wrapper) {
            return ap_psprintf(tp,
                "%s: redefinition of a previously defined class \"%s\" "
                "with uid=%ld and gid=%ld",
                name, fs_path, (long) fcgi_util_get_server_uid(cmd->server),
                (long) fcgi_util_get_server_gid(cmd->server));
        }
        else 
        {
            return ap_psprintf(tp,
                "%s: redefinition of previously defined class \"%s\"", name, fs_path);
        }
    }

    s = fcgi_util_fs_new(p);
    s->fs_path = fs_path;
    s->directive = APP_CLASS_EXTERNAL;

    /*  Parse directive arguments */
    while (*arg != '\0') {
        option = ap_getword_conf(tp, &arg);

        if (strcasecmp(option, "-host") == 0) {
            if ((err = get_host_n_port(p, &arg, &s->host, &s->port)))
                return invalid_value(tp, name, fs_path, option, err);
        }
        else if (strcasecmp(option, "-socket") == 0) {
            s->socket_path = ap_getword_conf(tp, &arg);
            if (*s->socket_path == '\0')
                return invalid_value(tp, name, fs_path, option, "\"\"");
        }
        else if (strcasecmp(option, "-appConnTimeout") == 0) {
            if ((err = get_u_int(tp, &arg, &s->appConnectTimeout, 0)))
                return invalid_value(tp, name, fs_path, option, err);
        }
        else if (strcasecmp(option, "-idle-timeout") == 0) {
            if ((err = get_u_int(tp, &arg, &s->idle_timeout, 1)))
                return invalid_value(tp, name, fs_path, option, err);
        }
        else if (strcasecmp(option, "-nph") == 0) {
            s->nph = 1;
        }
        else if (strcasecmp(option, "-pass-header") == 0) {
            if ((err = get_pass_header(p, &arg, &s->pass_headers)))
                return invalid_value(tp, name, fs_path, option, err);
        }
        else if (strcasecmp(option, "-flush") == 0) {
            s->flush = 1;
        }
        else if (strcasecmp(option, "-user") == 0) {
#ifdef WIN32
            return ap_psprintf(tp, 
                "%s %s: the -user option isn't supported on WIN", name, fs_path);
#else
            s->user = ap_getword_conf(tp, &arg);
            if (*s->user == '\0')
                return invalid_value(tp, name, fs_path, option, "\"\"");
#endif
        }
        else if (strcasecmp(option, "-group") == 0) {
#ifdef WIN32
            return ap_psprintf(tp, 
                "%s %s: the -group option isn't supported on WIN", name, fs_path);
#else
            s->group = ap_getword_conf(tp, &arg);
            if (*s->group == '\0')
                return invalid_value(tp, name, fs_path, option, "\"\"");
#endif
        }
        else if (strcasecmp(option, "-fixPaths") == 0) {
            s->fixPaths = 1;
        }
        else {
            return ap_psprintf(tp, "%s %s: invalid option: %s", name, fs_path, option);
        }
    } /* while */


#ifndef WIN32
    if (fcgi_wrapper)
    {
        if (s->group == NULL)
        {
            s->group = ap_psprintf(tp, "#%ld", (long)fcgi_util_get_server_gid(cmd->server));
        }

        if (s->user == NULL)
        {
            s->user = ap_psprintf(p, "#%ld", (long)fcgi_util_get_server_uid(cmd->server));
        }

        s->uid = ap_uname2id(s->user);
        s->gid = ap_gname2id(s->group);
    }
    else if (s->user || s->group)
    {
        ap_log_error(FCGI_LOG_WARN, cmd->server, "FastCGI: there is no "
                     "fastcgi wrapper set, user/group options are ignored");
    }

    if ((err = fcgi_util_fs_set_uid_n_gid(p, s, s->uid, s->gid)))
    {
        return ap_psprintf(tp,
            "%s %s: invalid user or group: %s", name, fs_path, err);
    }
#endif /* !WIN32 */

    /* Require one of -socket or -host, but not both */
    if (s->socket_path != NULL && s->port != 0) {
        return ap_psprintf(tp,
            "%s %s: -host and -socket are mutually exclusive options",
            name, fs_path);
    }
    if (s->socket_path == NULL && s->port == 0) {
        return ap_psprintf(tp,
            "%s %s: -socket or -host option missing", name, fs_path);
    }

    /* Build the appropriate sockaddr structure */
    if (s->port != 0) {
        err = fcgi_util_socket_make_inet_addr(p, (struct sockaddr_in **)&s->socket_addr,
            &s->socket_addr_len, s->host, s->port);
        if (err != NULL)
            return ap_psprintf(tp, "%s %s: %s", name, fs_path, err);
    } else {

        if (fcgi_socket_dir == NULL)
        {
#ifdef WIN32
            fcgi_socket_dir = DEFAULT_SOCK_DIR;
#else
            fcgi_socket_dir = ap_server_root_relative(p, DEFAULT_SOCK_DIR);
#endif
        }

        s->socket_path = fcgi_util_socket_make_path_absolute(p, s->socket_path, 0);
#ifndef WIN32
        err = fcgi_util_socket_make_domain_addr(p, (struct sockaddr_un **)&s->socket_addr,
                                  &s->socket_addr_len, s->socket_path);
        if (err != NULL)
            return ap_psprintf(tp, "%s %s: %s", name, fs_path, err);
#endif
    }

    /* Add it to the list of FastCGI servers */
    fcgi_util_fs_add(s);

    return NULL;
}
Ejemplo n.º 6
0
/*******************************************************************************
 * Configure a static FastCGI server.
 */
const char *fcgi_config_new_static_server(cmd_parms *cmd, void *dummy, const char *arg)
{
    fcgi_server *s;
    pool *p = cmd->pool, *tp = cmd->temp_pool;
    const char *name = cmd->cmd->name;
    char *fs_path = ap_getword_conf(p, &arg);
    const char *option, *err;

    /* Allocate temp storage for the array of initial environment variables */
    char **envp = ap_pcalloc(tp, sizeof(char *) * (MAX_INIT_ENV_VARS + 3));
    unsigned int envc = 0;

#ifdef WIN32
    HANDLE mutex;
#endif

    err = ap_check_cmd_context(cmd, NOT_IN_LIMIT|NOT_IN_DIR_LOC_FILE);
    if (err)
    {
        return err;
    }

    if (*fs_path == '\0')
        return "AppClass requires a pathname!?";

    if ((err = fcgi_config_set_fcgi_uid_n_gid(1)) != NULL)
        return ap_psprintf(tp, "%s %s: %s", name, fs_path, err);

#ifdef APACHE2
    if (apr_filepath_merge(&fs_path, "", fs_path, 0, p))
        return ap_psprintf(tp, "%s %s: invalid filepath", name, fs_path);
#else
    fs_path = ap_os_canonical_filename(p, fs_path);
#endif
    fs_path = ap_server_root_relative(p, fs_path);

    ap_getparents(fs_path);
    ap_no2slash(fs_path);

    /* See if we've already got one of these configured */
    s = fcgi_util_fs_get_by_id(fs_path, fcgi_util_get_server_uid(cmd->server),
                               fcgi_util_get_server_gid(cmd->server));
    if (s != NULL) {
        if (fcgi_wrapper) {
            return ap_psprintf(tp,
                "%s: redefinition of a previously defined FastCGI "
                "server \"%s\" with uid=%ld and gid=%ld",
                name, fs_path, (long) fcgi_util_get_server_uid(cmd->server),
                (long) fcgi_util_get_server_gid(cmd->server));
        }
        else {
            return ap_psprintf(tp,
                "%s: redefinition of a previously defined FastCGI server \"%s\"",
                name, fs_path);
        }
    }

    err = fcgi_util_fs_is_path_ok(tp, fs_path, NULL);
    if (err != NULL) {
        return ap_psprintf(tp, "%s: \"%s\" %s", name, fs_path, err);
    }

    s = fcgi_util_fs_new(p);
    s->fs_path = fs_path;
    s->directive = APP_CLASS_STANDARD;
    s->restartOnExit = TRUE;
    s->numProcesses = 1;

#ifdef WIN32

    /* TCP FastCGI applications require SystemRoot be present in the environment
     * Put it in both for consistency to the application */
    fcgi_config_set_env_var(p, envp, &envc, "SystemRoot");

    mutex = CreateMutex(NULL, FALSE, fs_path);
    
    if (mutex == NULL)
    {
        ap_log_error(FCGI_LOG_ALERT, fcgi_apache_main_server,
            "FastCGI: CreateMutex() failed");
        return "failed to create FastCGI application accept mutex";
    }
    
    SetHandleInformation(mutex, HANDLE_FLAG_INHERIT, TRUE);

    s->mutex_env_string = ap_psprintf(p, "_FCGI_MUTEX_=%ld", mutex);

#endif

    /*  Parse directive arguments */
    while (*arg) {
        option = ap_getword_conf(tp, &arg);

        if (strcasecmp(option, "-processes") == 0) {
            if ((err = get_u_int(tp, &arg, &s->numProcesses, 1)))
                return invalid_value(tp, name, fs_path, option, err);
        }
        else if (strcasecmp(option, "-restart-delay") == 0) {
            if ((err = get_u_int(tp, &arg, &s->restartDelay, 0)))
                return invalid_value(tp, name, fs_path, option, err);
        }
        else if (strcasecmp(option, "-init-start-delay") == 0) {
            if ((err = get_int(tp, &arg, &s->initStartDelay, 0)))
                return invalid_value(tp, name, fs_path, option, err);
        }
        else if (strcasecmp(option, "-min-server-life") == 0) {
            if ((err = get_u_int(tp, &arg, &s->minServerLife, 0)))
                return invalid_value(tp, name, NULL, option, err);
        }
        else if (strcasecmp(option, "-priority") == 0) {
            if ((err = get_u_int(tp, &arg, &s->processPriority, 0)))
                return invalid_value(tp, name, fs_path, option, err);
        }
        else if (strcasecmp(option, "-listen-queue-depth") == 0) {
            if ((err = get_u_int(tp, &arg, &s->listenQueueDepth, 1)))
                return invalid_value(tp, name, fs_path, option, err);
        }
        else if (strcasecmp(option, "-appConnTimeout") == 0) {
            if ((err = get_u_int(tp, &arg, &s->appConnectTimeout, 0)))
                return invalid_value(tp, name, fs_path, option, err);
        }
        else if (strcasecmp(option, "-idle-timeout") == 0) {
            if ((err = get_u_int(tp, &arg, &s->idle_timeout, 1)))
                return invalid_value(tp, name, fs_path, option, err);
        }
        else if (strcasecmp(option, "-port") == 0) {
            if ((err = get_u_short(tp, &arg, &s->port, 1)))
                return invalid_value(tp, name, fs_path, option, err);
        }
        else if (strcasecmp(option, "-socket") == 0) {
            s->socket_path = ap_getword_conf(tp, &arg);
            if (*s->socket_path == '\0')
                return invalid_value(tp, name, fs_path, option, "\"\"");
        }
        else if (strcasecmp(option, "-initial-env") == 0) {
            if ((err = get_env_var(p, &arg, envp, &envc)))
                return invalid_value(tp, name, fs_path, option, err);
        }
        else if (strcasecmp(option, "-pass-header") == 0) {
            if ((err = get_pass_header(p, &arg, &s->pass_headers)))
                return invalid_value(tp, name, fs_path, option, err);
        }
        else if (strcasecmp(option, "-flush") == 0) {
            s->flush = 1;
        }
        else if (strcasecmp(option, "-nph") == 0) {
            s->nph = 1;
        }
        else if (strcasecmp(option, "-user") == 0) {
#ifdef WIN32
            return ap_psprintf(tp, 
                "%s %s: the -user option isn't supported on WIN", name, fs_path);
#else
            s->user = ap_getword_conf(tp, &arg);
            if (*s->user == '\0')
                return invalid_value(tp, name, fs_path, option, "\"\"");
#endif
        }
        else if (strcasecmp(option, "-group") == 0) {
#ifdef WIN32
            return ap_psprintf(tp, 
                "%s %s: the -group option isn't supported on WIN", name, fs_path);
#else
            s->group = ap_getword_conf(tp, &arg);
            if (*s->group == '\0')
                return invalid_value(tp, name, fs_path, option, "\"\"");
#endif
        }
        else {
            return ap_psprintf(tp, "%s %s: invalid option: %s", name, fs_path, option);
        }
    } /* while */

#ifndef WIN32
    if (fcgi_wrapper)
    {
        if (s->group == NULL)
        {
            s->group = ap_psprintf(tp, "#%ld", (long)fcgi_util_get_server_gid(cmd->server));
        }

        if (s->user == NULL)
        {
            s->user = ap_psprintf(p, "#%ld", (long)fcgi_util_get_server_uid(cmd->server)); 
        }

        s->uid = ap_uname2id(s->user);
        s->gid = ap_gname2id(s->group);
    }
    else if (s->user || s->group)
    {
        ap_log_error(FCGI_LOG_WARN, cmd->server, "FastCGI: there is no "
                     "fastcgi wrapper set, user/group options are ignored");
    }

    if ((err = fcgi_util_fs_set_uid_n_gid(p, s, s->uid, s->gid)))
    {
        return ap_psprintf(tp, 
            "%s %s: invalid user or group: %s", name, fs_path, err);
    }
#endif /* !WIN32 */

    if (s->socket_path != NULL && s->port != 0) {
        return ap_psprintf(tp,
                "%s %s: -port and -socket are mutually exclusive options",
                name, fs_path);
    }

    /* Move env array to a surviving pool */
    s->envp = (char **)ap_pcalloc(p, sizeof(char *) * (envc + 4));
    memcpy(s->envp, envp, sizeof(char *) * envc);

    /* Initialize process structs */
    s->procs = fcgi_util_fs_create_procs(p, s->numProcesses);

    /* Build the appropriate sockaddr structure */
    if (s->port != 0) {
        err = fcgi_util_socket_make_inet_addr(p, (struct sockaddr_in **)&s->socket_addr,
                                &s->socket_addr_len, NULL, s->port);
        if (err != NULL)
            return ap_psprintf(tp, "%s %s: %s", name, fs_path, err);
#ifdef WIN32
        err = fcgi_util_socket_make_inet_addr(p, (struct sockaddr_in **)&s->dest_addr,
                                          &s->socket_addr_len, "localhost", s->port);
        if (err != NULL)
            return ap_psprintf(tp, "%s %s: %s", name, fs_path, err);
#endif
    } else {
        if (s->socket_path == NULL)
             s->socket_path = fcgi_util_socket_hash_filename(tp, fs_path, s->user, s->group);

        if (fcgi_socket_dir == NULL)
        {
#ifdef WIN32
            fcgi_socket_dir = DEFAULT_SOCK_DIR;
#else
            fcgi_socket_dir = ap_server_root_relative(p, DEFAULT_SOCK_DIR);
#endif
        }

        s->socket_path = fcgi_util_socket_make_path_absolute(p, s->socket_path, 0);
#ifndef WIN32
        err = fcgi_util_socket_make_domain_addr(p, (struct sockaddr_un **)&s->socket_addr,
                                  &s->socket_addr_len, s->socket_path);
        if (err != NULL)
            return ap_psprintf(tp, "%s %s: %s", name, fs_path, err);
#endif
    }

    /* Add it to the list of FastCGI servers */
    fcgi_util_fs_add(s);

    return NULL;
}