You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modules-dev@httpd.apache.org by Jos Ewert <fl...@flami.net> on 2008/11/16 00:51:44 UTC

config is not read correctly

Hi,

Im trying to modify mod_fcgid to suit my needs, but I have a problem with 
reading my newly added config directive.
For some reason it sets the config in my setter right but in the getter it 
always reads the default value.

Whats even stranger is that I used this with mod_fcgid 1.10 too and it works.

e.g. 
set :
&config : 7092232, &config->homedir : 7101472 
get:
&config : 7100440, &config->homedir : 7845640

to set the value I use:

##########
 const char *set_homedir(cmd_parms *cmd, void *dirconfig, 
                                   const char *uid, const char *gid) 
 { 
       
       server_rec *s = cmd->server; 
       fcgid_server_conf *config =  
                         ap_get_module_config(s->module_config, &fcgid_module); 
         
       struct passwd *pw; 
       if((pw = getpwuid(ap_uname2id(uid))) == NULL){ 
	fprintf(stderr, 
              "Critical Error: You have specified an invalid user in 
SuexecUserGroup.\n"); 
	exit(1); 
       } else { 
       config->homedir = strdup(pw->pw_dir);
       return NULL; 
       } 
 }  
#########

To get the config:
###########

char *get_homedir(request_rec * r) 
 { 
       server_rec *s = r->server; 	
       fcgid_server_conf *config = 
			 ap_get_module_config(s->module_config, &fcgid_module); 
       return config->homedir;
 }  

###########
I removed all the debugging stuff I added to make it more readable.

if you want to take a look at the whole file + the other 2 I modified:
http://pastebin.com/f4c834a94


Any ideas what could have gone wrong? 

Greetings,
Josi

Re: config is not read correctly

Posted by Jos Ewert <fl...@flami.net>.
Ahhh found out what went wrong, I made a wrong merge. the "local" server config 
contained the right config , where the one that actually made it into the final 
config was the "base" config.



Re: config is not read correctly

Posted by Sorin Manolache <so...@gmail.com>.
On Sun, Nov 16, 2008 at 00:51, Jos Ewert <fl...@flami.net> wrote:
> Hi,
>
> Im trying to modify mod_fcgid to suit my needs, but I have a problem with
> reading my newly added config directive.
> For some reason it sets the config in my setter right but in the getter it
> always reads the default value.
>
> Whats even stranger is that I used this with mod_fcgid 1.10 too and it works.
>
> e.g.
> set :
> &config : 7092232, &config->homedir : 7101472
> get:
> &config : 7100440, &config->homedir : 7845640
>
> to set the value I use:
>
> ##########
>  const char *set_homedir(cmd_parms *cmd, void *dirconfig,
>                                   const char *uid, const char *gid)
>  {
>
>       server_rec *s = cmd->server;
>       fcgid_server_conf *config =
>                         ap_get_module_config(s->module_config, &fcgid_module);
>
>       struct passwd *pw;
>       if((pw = getpwuid(ap_uname2id(uid))) == NULL){
>        fprintf(stderr,
>              "Critical Error: You have specified an invalid user in
> SuexecUserGroup.\n");
>        exit(1);
>       } else {
>       config->homedir = strdup(pw->pw_dir);
>       return NULL;
>       }
>  }
> #########
>
> To get the config:
> ###########
>
> char *get_homedir(request_rec * r)
>  {
>       server_rec *s = r->server;
>       fcgid_server_conf *config =
>                         ap_get_module_config(s->module_config, &fcgid_module);
>       return config->homedir;
>  }
>
> ###########
> I removed all the debugging stuff I added to make it more readable.
>
> if you want to take a look at the whole file + the other 2 I modified:
> http://pastebin.com/f4c834a94
>
>
> Any ideas what could have gone wrong?

r->server in get_homedir points to the server object corresponding to
the virtual host of the request. I _guess_ it is different from the
global server object. So, the ap_get_module_config in set_* and the
ap_get_module_config in get_* could give you two distinct config
objects.

S