Hello,
Learning to create modules, I want to read configuration directives. I used the
following example out of “The Apache Modules Book” (Nick Kew). It compiles
fine, however, when I restart apache, I get segmentation fault:
sudo service apache2 restart
Segmentation fault (core dumped)
Action 'configtest' failed.
The Apache error log may have more information.
…fail!
log shows this:
[Sun Dec 08 03:58:04 2013] [notice] child pid 30080 exit signal Segmentation
fault (11), possible coredump in /etc/apache2
The fault seems to be a result of this line of code (no error results if it is
removed):
((txt_cfg*)cfg)->header = val ;
Here is my code (reduced to minimal test case):
#include "httpd.h"
#include "http_config.h"
#include "http_protocol.h"
typedef struct txt_cfg {
const char* header ;
const char* footer ;
} txt_cfg;
static const char* get_form_path(cmd_parms* cmd, void* cfg,
const char* val) {
((txt_cfg*)cfg)->header = val ;
return NULL ;
}
static const command_rec mod_cmds[] = {
AP_INIT_TAKE1("CustomAuthFormPath", get_form_path, NULL, OR_ALL,
"Path to custom authorization form"),
{ NULL }
};
static void register_hooks(apr_pool_t *pool)
{
}
module AP_MODULE_DECLARE_DATA customauthform_module =
{
STANDARD20_MODULE_STUFF,
NULL,
NULL,
NULL,
NULL,
mod_cmds,
register_hooks,
};
If anyone knows the reason for this I would surely appreciate understanding.
Thank you kindly,
Allasso