ngx_uint_t ngx_max_module;
+u_char *ngx_prefix;
static ngx_uint_t ngx_show_help;
static ngx_uint_t ngx_show_version;
static ngx_uint_t ngx_show_configure;
-static u_char *ngx_prefix;
static u_char *ngx_conf_file;
static u_char *ngx_conf_params;
static char *ngx_signal;
ngx_int_t
ngx_create_paths(ngx_cycle_t *cycle, ngx_uid_t user)
{
+ u_char *prefix;
ngx_err_t err;
ngx_uint_t i;
ngx_path_t **path;
for (i = 0; i < cycle->paths.nelts; i++) {
if (ngx_chrooted) {
- if (chdir(NGX_PREFIX) == -1) {
+ if (ngx_prefix)
+ prefix = ngx_prefix;
+ else
+ prefix = NGX_PREFIX;
+ if (chdir(prefix) == -1) {
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
- "chdir(\"%s\") failed", NGX_PREFIX);
+ "chdir(\"%s\") failed", prefix);
return NGX_ERROR;
}
ngx_strip_chroot(&path[i]->name);
void
ngx_strip_chroot(ngx_str_t *path)
{
- if (!ngx_strncmp(path->data, NGX_PREFIX, strlen(NGX_PREFIX))) {
+ int plen;
+ u_char *prefix;
+
+ if (ngx_prefix)
+ prefix = ngx_prefix;
+ else
+ prefix = NGX_PREFIX;
+
+ if (prefix[strlen(prefix) - 1] == '/')
+ plen = strlen(prefix) - 1;
+ else
+ plen = strlen(prefix);
+
+ if (!ngx_strncmp(path->data, prefix, strlen(prefix))) {
char *x, *buf = malloc(path->len);
- x = ngx_cpystrn(buf, path->data + strlen(NGX_PREFIX) - 1,
- path->len);
+ x = ngx_cpystrn(buf, path->data + plen, path->len);
path->len = (x - buf);
path->data = buf;
}
extern int ngx_argc;
extern char **ngx_argv;
extern char **ngx_os_argv;
+extern u_char *ngx_prefix;
extern ngx_pid_t ngx_pid;
extern ngx_socket_t ngx_channel;