src/server/safs/pcheck.c

Tue, 13 Aug 2019 22:03:19 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Tue, 13 Aug 2019 22:03:19 +0200
changeset 209
a6d8181a8127
parent 139
29ac9aed4889
permissions
-rw-r--r--

replace source with . in configure script and fix toolchain detection

116
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 *
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
4 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
5 *
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
6 * THE BSD LICENSE
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
7 *
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
8 * Redistribution and use in source and binary forms, with or without
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
9 * modification, are permitted provided that the following conditions are met:
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
10 *
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 * Redistributions of source code must retain the above copyright notice, this
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
12 * list of conditions and the following disclaimer.
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
13 * Redistributions in binary form must reproduce the above copyright notice,
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
14 * this list of conditions and the following disclaimer in the documentation
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 * and/or other materials provided with the distribution.
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16 *
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17 * Neither the name of the nor the names of its contributors may be
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
18 * used to endorse or promote products derived from this software without
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
19 * specific prior written permission.
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20 *
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
25 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
26 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
28 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
30 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
31 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
32 */
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
33
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
34 /*
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
35 * open web server code from safs/pcheck.cpp
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
36 */
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
37
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
38 #include "pcheck.h"
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
39
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
40 #include "../util/pblock.h"
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
41
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
42 /* --------------------------- pcheck_find_path --------------------------- */
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
43
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
44
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
45 /*
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
46 * Takes a given path, and figures out if there is any path_info attached.
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
47 * If no explicit path_info was provided by nametrans, and the file doesn't
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
48 * exist as specified, it tries to find it by groping through the filesystem.
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
49 *
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
50 * This type of implicit path_info cannot be attached to directories. Such
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
51 * a request will be flagged as not found.
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
52 *
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
53 * pb unused.
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
54 */
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
55
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
56 static char* find_param(char *uri, char *param)
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
57 {
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
58 // Find ;parameters on the end of uri
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
59 if (param > uri) {
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
60 if (*param == FILE_PATHSEP) {
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
61 --param;
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
62 }
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
63 while (param > uri && *param != FILE_PATHSEP && *param != ';') {
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
64 --param;
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
65 }
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
66 if (*param == ';') {
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
67 return param;
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
68 }
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
69 }
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
70
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
71 return NULL;
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
72 }
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
73
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
74 static PRBool set_path_info(Request *rq, char *uri, int path_info_depth)
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
75 {
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
76 // Find trailing path components in uri, e.g. the "/baz;qux/quux" in
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
77 // "/cgi-bin/foo.pl;bar/baz;qux/quux" (here path_info_depth would be 2)
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
78 char *path_info = &uri[strlen(uri)];
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
79 while (path_info > uri && path_info_depth) {
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
80 --path_info;
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
81 if (*path_info == FILE_PATHSEP) {
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
82 --path_info_depth;
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
83 }
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
84 }
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
85
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
86 if (*path_info) {
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
87 pblock_nvinsert("path-info", path_info, rq->vars);
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
88 return PR_TRUE;
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
89 }
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
90
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
91 return PR_FALSE;
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
92 }
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
93
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
94 int pcheck_find_path(pblock *pb, Session *sn, Request *rq)
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
95 {
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
96 char *path = pblock_findkeyval (pb_key_path, rq -> vars);
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
97 char *path_info = pblock_findkeyval (pb_key_path_info , rq -> vars);
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
98 char *script_name = pblock_findkeyval (pb_key_script_name, rq -> vars);
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
99 //NSFCFileInfo *finfo = NULL;
139
29ac9aed4889 fixes some memory errors and startup with broken config
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
100 struct stat stbuf;
29ac9aed4889 fixes some memory errors and startup with broken config
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
101 struct stat *finfo = NULL;
116
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
102
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
103 rq->directive_is_cacheable = 1;
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
104
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
105 if (path_info != NULL || script_name != NULL || path == NULL)
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
106 return REQ_NOACTION;// ruslan: bail out right away for performance (no need to go into file cache)
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
107
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
108 if (!*path)
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
109 return REQ_NOACTION;
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
110
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
111 /*
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
112 if ((INTrequest_info_path(path, rq, NULL) == PR_SUCCESS))
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
113 return REQ_NOACTION;
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
114 */
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
115
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
116 rq->directive_is_cacheable = 0;
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
117
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
118 path_info = &path[strlen(path) - 1];
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
119
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
120 char *forward = pblock_findkeyval(pb_key_find_pathinfo_forward, rq->vars);
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
121 char *base = NULL;
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
122 if (forward) {
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
123 base = pblock_findval("ntrans-base" , rq -> vars);
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
124 if (!base) forward = NULL;
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
125 }
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
126
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
127 int path_info_depth = 0;
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
128
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
129 if(!forward) {
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
130 while (1) {
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
131 /* Change all occurrences of '/' to FILE_PATHSEP for WIN32 */
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
132 for( ; path_info != path; --path_info)
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
133 if (*path_info == FILE_PATHSEP)
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
134 break;
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
135 for( ; path_info != path; --path_info) {
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
136 ++path_info_depth;
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
137 if (*(path_info - 1) != FILE_PATHSEP)
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
138 break;
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
139 }
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
140
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
141 if (path_info == path)
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
142 break;
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
143
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
144 *path_info = '\0';
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
145 //if ((INTrequest_info_path(path, rq, &finfo) == PR_SUCCESS) && finfo) {
139
29ac9aed4889 fixes some memory errors and startup with broken config
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
146 struct stat *st = request_stat_path(path, rq);
29ac9aed4889 fixes some memory errors and startup with broken config
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
147 if(st) {
29ac9aed4889 fixes some memory errors and startup with broken config
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
148 finfo = &stbuf;
29ac9aed4889 fixes some memory errors and startup with broken config
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
149 stbuf = *st;
29ac9aed4889 fixes some memory errors and startup with broken config
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
150 free(st);
29ac9aed4889 fixes some memory errors and startup with broken config
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
151 }
29ac9aed4889 fixes some memory errors and startup with broken config
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
152 if(finfo) {
116
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
153 //if (finfo->pr.type != PR_FILE_FILE) {
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
154 if(S_ISDIR(finfo->st_mode)) {
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
155 *path_info = FILE_PATHSEP;
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
156 if (set_path_info(rq, pblock_findkeyval(pb_key_uri, rq->reqpb), 0)) {
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
157 return REQ_PROCEED;
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
158 }
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
159 break;
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
160 } else {
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
161 set_path_info(rq, pblock_findkeyval(pb_key_uri, rq->reqpb), path_info_depth);
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
162 return REQ_PROCEED;
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
163 }
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
164 } else {
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
165 *path_info-- = FILE_PATHSEP;
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
166 }
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
167 }
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
168 /* This was changed to support virtual documents */
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
169 return REQ_NOACTION;
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
170 } else {
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
171 int baselen = strlen(base);
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
172 if (strncmp(path, base, baselen))
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
173 return REQ_NOACTION;
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
174
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
175 path_info = &path[baselen];
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
176 if (*path_info == '/')
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
177 path_info++;
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
178
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
179 while (1) {
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
180 for( ; *path_info; ++path_info)
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
181 if (*path_info == FILE_PATHSEP)
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
182 break;
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
183
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
184 if (!*path_info) {
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
185 if (set_path_info(rq, pblock_findkeyval(pb_key_uri, rq->reqpb), 0)) {
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
186 return REQ_PROCEED;
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
187 }
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
188 break;
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
189 }
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
190
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
191 *path_info = '\0';
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
192 //if ((INTrequest_info_path(path, rq, &finfo) == PR_SUCCESS) && finfo) {
139
29ac9aed4889 fixes some memory errors and startup with broken config
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
193 struct stat *st = request_stat_path(path, rq);
29ac9aed4889 fixes some memory errors and startup with broken config
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
194 if(st) {
29ac9aed4889 fixes some memory errors and startup with broken config
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
195 stbuf = *st;
29ac9aed4889 fixes some memory errors and startup with broken config
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
196 finfo = &stbuf;
29ac9aed4889 fixes some memory errors and startup with broken config
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
197 free(st);
29ac9aed4889 fixes some memory errors and startup with broken config
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
198 }
29ac9aed4889 fixes some memory errors and startup with broken config
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
199 if(finfo) {
116
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
200 //if (finfo->pr.type != PR_FILE_FILE) {
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
201 if(S_ISDIR(finfo->st_mode)) {
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
202 *path_info++ = FILE_PATHSEP;
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
203 } else {
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
204 char *uri = pblock_findkeyval(pb_key_uri, rq->reqpb);
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
205 *path_info = FILE_PATHSEP;
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
206 #ifdef XP_WIN32
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
207 char *unmpath = pblock_findval("unmuri", rq->vars);
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
208 if (unmpath) {
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
209 char *nm = &path_info[strlen(path_info)-1];
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
210 char *unm = &unmpath[strlen(unmpath)-1];
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
211 while(nm != path_info && unm != unmpath) {
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
212 if (*nm != *unm) {
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
213 if (*unm == '\\' && *nm == '/')
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
214 *nm = *unm;
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
215 else
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
216 PR_ASSERT(0);
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
217 }
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
218 nm--;
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
219 unm--;
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
220 }
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
221 uri = unmpath;
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
222 }
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
223 #endif
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
224 char *t = path_info;
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
225 for(; *t; ++t)
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
226 if (*t == FILE_PATHSEP)
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
227 ++path_info_depth;
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
228 *path_info = '\0';
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
229 set_path_info(rq, uri, path_info_depth);
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
230 return REQ_PROCEED;
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
231 }
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
232 }
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
233 else {
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
234 *path_info = FILE_PATHSEP;
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
235 break;
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
236 }
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
237 }
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
238
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
239 /* This was changed to support virtual documents */
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
240 return REQ_NOACTION;
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
241 }
d7a186cf87f6 adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
242 }

mercurial