Apache HTTPD
mod_netware.c
Go to the documentation of this file.
1/* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements. See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "apr_strings.h"
18#include "apr_portable.h"
19#include "apr_buckets.h"
20#include "ap_config.h"
21#include "httpd.h"
22#include "http_config.h"
23#include "http_core.h"
24#include "http_protocol.h"
25#include "http_request.h"
26#include "http_log.h"
27#include "util_script.h"
28#include "mod_core.h"
29#include "apr_optional.h"
30#include "apr_lib.h"
31#include "mod_cgi.h"
32#include "mpm_common.h"
33
34#ifdef NETWARE
35
36
37module AP_MODULE_DECLARE_DATA netware_module;
38
39typedef struct {
40 apr_table_t *file_type_handlers; /* CGI map from file types to CGI modules */
41 apr_table_t *file_handler_mode; /* CGI module mode (spawn in same address space or not) */
42 apr_table_t *extra_env_vars; /* Environment variables to be added to the CGI environment */
44
45
46static void *create_netware_dir_config(apr_pool_t *p, char *dir)
47{
49
50 new->file_type_handlers = apr_table_make(p, 10);
51 new->file_handler_mode = apr_table_make(p, 10);
52 new->extra_env_vars = apr_table_make(p, 10);
53
54 apr_table_setn(new->file_type_handlers, "NLM", "OS");
55
56 return new;
57}
58
59static void *merge_netware_dir_configs(apr_pool_t *p, void *basev, void *addv)
60{
64
65 new->file_type_handlers = apr_table_overlay(p, add->file_type_handlers, base->file_type_handlers);
66 new->file_handler_mode = apr_table_overlay(p, add->file_handler_mode, base->file_handler_mode);
67 new->extra_env_vars = apr_table_overlay(p, add->extra_env_vars, base->extra_env_vars);
68
69 return new;
70}
71
73 char *CGIhdlr, char *ext, char *detach)
74{
75 int i, len;
76
77 if (*ext == '.')
78 ++ext;
79
80 if (CGIhdlr != NULL) {
81 len = strlen(CGIhdlr);
82 for (i=0; i<len; i++) {
83 if (CGIhdlr[i] == '\\') {
84 CGIhdlr[i] = '/';
85 }
86 }
87 }
88
89 apr_table_set(m->file_type_handlers, ext, CGIhdlr);
90 if (detach) {
91 apr_table_set(m->file_handler_mode, ext, "y");
92 }
93
94 return NULL;
95}
96
97static apr_status_t ap_cgi_build_command(const char **cmd, const char ***argv,
100{
101 char *ext = NULL;
102 char *cmd_only, *ptr;
103 const char *new_cmd;
105 const char *args = "";
106
109
110 if (e_info->process_cgi) {
111 /* Handle the complete file name, we DON'T want to follow suexec, since
112 * an unrooted command is as predictable as shooting craps in Win32.
113 *
114 * Notice that unlike most mime extension parsing, we have to use the
115 * win32 parsing here, therefore the final extension is the only one
116 * we will consider
117 */
118 *cmd = r->filename;
119 if (r->args && r->args[0] && !ap_strchr_c(r->args, '=')) {
120 args = r->args;
121 }
122 }
123
125 e_info->cmd_type = APR_PROGRAM;
126
127 /* truncate any arguments from the cmd */
128 for (ptr = cmd_only; *ptr && (*ptr != ' '); ptr++);
129 *ptr = '\0';
130
131 /* Figure out what the extension is so that we can match it. */
133
134 /* If there isn't an extension then give it an empty string */
135 if (!ext) {
136 ext = "";
137 }
138
139 /* eliminate the '.' if there is one */
140 if (*ext == '.') {
141 ++ext;
142 }
143
144 /* check if we have a registered command for the extension*/
145 new_cmd = apr_table_get(d->file_type_handlers, ext);
146 e_info->detached = 1;
147 if (new_cmd == NULL) {
149 "Could not find a command associated with the %s extension", ext);
150 return APR_EBADF;
151 }
152 if (stricmp(new_cmd, "OS")) {
153 /* If we have a registered command then add the file that was passed in as a
154 parameter to the registered command. */
155 *cmd = apr_pstrcat (p, new_cmd, " ", cmd_only, NULL);
156
157 /* Run in its own address space if specified */
158 if (apr_table_get(d->file_handler_mode, ext)) {
159 e_info->addrspace = 1;
160 }
161 }
162
163 /* Tokenize the full command string into its arguments */
164 apr_tokenize_to_argv(*cmd, (char***)argv, p);
165
166 /* The first argument should be the executible */
168
169 return APR_SUCCESS;
170}
171
172static int
174 apr_pool_t *ptemp)
175{
177 return OK;
178}
179
180static void register_hooks(apr_pool_t *p)
181{
185}
186
187static const command_rec netware_cmds[] = {
189 "Full path to the CGI NLM module followed by a file extension. If the "
190 "first parameter is set to \"OS\" then the following file extension is "
191 "treated as NLM. The optional parameter \"detach\" can be specified if "
192 "the NLM should be launched in its own address space."),
193{ NULL }
194};
195
198 create_netware_dir_config, /* create per-dir config */
199 merge_netware_dir_configs, /* merge per-dir config */
200 NULL, /* server config */
201 NULL, /* merge server config */
202 netware_cmds, /* command apr_table_t */
203 register_hooks /* register hooks */
204};
205
206#endif
Symbol export macros and hook functions.
const char apr_size_t len
Definition ap_regex.h:187
APR-UTIL Buckets/Bucket Brigades.
APR general purpose library routines.
APR-UTIL registration of functions exported by modules.
APR Portability Routines.
apr_size_t const unsigned char unsigned int unsigned int d
Definition apr_siphash.h:72
APR Strings library.
static apr_pool_t * pconf
Definition event.c:441
#define ap_get_module_config(v, m)
#define AP_DECLARE_MODULE(foo)
ap_conf_vector_t * base
char * ap_server_root_relative(apr_pool_t *p, const char *fname)
Definition config.c:1594
void ap_hook_pre_config(ap_HOOK_pre_config_t *pf, const char *const *aszPre, const char *const *aszSucc, int nOrder)
Definition config.c:91
request_rec * r
#define AP_INIT_TAKE23(directive, func, mconfig, where, help)
#define OK
Definition httpd.h:456
#define APLOGNO(n)
Definition http_log.h:117
#define ap_log_rerror
Definition http_log.h:454
#define APLOG_ERR
Definition http_log.h:67
#define APLOG_MARK
Definition http_log.h:283
int ap_sys_privileges_handlers(int inc)
Definition core.c:5062
#define APR_EBADF
Definition apr_errno.h:704
#define APR_HOOK_FIRST
Definition apr_hooks.h:301
#define APR_REGISTER_OPTIONAL_FN(name)
#define OR_FILEINFO
#define STANDARD20_MODULE_STUFF
#define ap_strchr_c(s, c)
Definition httpd.h:2353
apr_size_t size
#define APR_SUCCESS
Definition apr_errno.h:225
int apr_status_t
Definition apr_errno.h:44
apr_dir_t * dir
const void * m
apr_cmdtype_e cmd
const char const char *const * args
apr_int32_t detach
@ APR_PROGRAM
Apache Configuration.
CORE HTTP Daemon.
Apache Logging library.
HTTP protocol handling.
Apache Request library.
HTTP Daemon routines.
apr_pool_t * p
Definition md_event.c:32
static void register_hooks(apr_pool_t *p)
CGI Script Execution Extension Module for Apache.
mod_core private header file
const char * argv[3]
return NULL
Definition mod_so.c:359
int i
Definition mod_so.c:347
Multi-Processing Modules functions.
static int netware_pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp)
A structure that represents the current request.
Definition httpd.h:845
char * filename
Definition httpd.h:1018
struct ap_conf_vector_t * per_dir_config
Definition httpd.h:1047
char * args
Definition httpd.h:1026
Apache script tools.