Wed, 28 Dec 2016 12:23:51 +0100
using host header to select virtual server
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; |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
100 | struct stat *finfo; |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
101 | |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
102 | rq->directive_is_cacheable = 1; |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
103 | |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
104 | if (path_info != NULL || script_name != NULL || path == NULL) |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
105 | 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
|
106 | |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
107 | if (!*path) |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
108 | return REQ_NOACTION; |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
109 | |
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 | if ((INTrequest_info_path(path, rq, NULL) == PR_SUCCESS)) |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
112 | return REQ_NOACTION; |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
113 | */ |
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 | rq->directive_is_cacheable = 0; |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
116 | |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
117 | path_info = &path[strlen(path) - 1]; |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
118 | |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
119 | 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
|
120 | char *base = NULL; |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
121 | if (forward) { |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
122 | base = pblock_findval("ntrans-base" , rq -> vars); |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
123 | if (!base) forward = NULL; |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
124 | } |
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 | int path_info_depth = 0; |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
127 | |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
128 | if(!forward) { |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
129 | while (1) { |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
130 | /* Change all occurrences of '/' to FILE_PATHSEP for WIN32 */ |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
131 | for( ; path_info != path; --path_info) |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
132 | if (*path_info == FILE_PATHSEP) |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
133 | break; |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
134 | for( ; path_info != path; --path_info) { |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
135 | ++path_info_depth; |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
136 | if (*(path_info - 1) != FILE_PATHSEP) |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
137 | break; |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
138 | } |
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 | if (path_info == path) |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
141 | break; |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
142 | |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
143 | *path_info = '\0'; |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
144 | //if ((INTrequest_info_path(path, rq, &finfo) == PR_SUCCESS) && finfo) { |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
145 | if((finfo = request_stat_path(path, rq)) != NULL) { |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
146 | //if (finfo->pr.type != PR_FILE_FILE) { |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
147 | if(S_ISDIR(finfo->st_mode)) { |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
148 | *path_info = FILE_PATHSEP; |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
149 | 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
|
150 | free(finfo); |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
151 | return REQ_PROCEED; |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
152 | } |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
153 | break; |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
154 | } else { |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
155 | 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
|
156 | free(finfo); |
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 | } else { |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
160 | *path_info-- = FILE_PATHSEP; |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
161 | } |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
162 | } |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
163 | /* This was changed to support virtual documents */ |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
164 | return REQ_NOACTION; |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
165 | } else { |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
166 | int baselen = strlen(base); |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
167 | if (strncmp(path, base, baselen)) |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
168 | return REQ_NOACTION; |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
169 | |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
170 | path_info = &path[baselen]; |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
171 | if (*path_info == '/') |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
172 | path_info++; |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
173 | |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
174 | while (1) { |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
175 | for( ; *path_info; ++path_info) |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
176 | if (*path_info == FILE_PATHSEP) |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
177 | break; |
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 | if (!*path_info) { |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
180 | 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
|
181 | return REQ_PROCEED; |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
182 | } |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
183 | break; |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
184 | } |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
185 | |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
186 | *path_info = '\0'; |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
187 | //if ((INTrequest_info_path(path, rq, &finfo) == PR_SUCCESS) && finfo) { |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
188 | if((finfo = request_stat_path(path, rq)) != NULL) { |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
189 | //if (finfo->pr.type != PR_FILE_FILE) { |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
190 | if(S_ISDIR(finfo->st_mode)) { |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
191 | *path_info++ = FILE_PATHSEP; |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
192 | } else { |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
193 | char *uri = pblock_findkeyval(pb_key_uri, rq->reqpb); |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
194 | *path_info = FILE_PATHSEP; |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
195 | #ifdef XP_WIN32 |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
196 | char *unmpath = pblock_findval("unmuri", rq->vars); |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
197 | if (unmpath) { |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
198 | char *nm = &path_info[strlen(path_info)-1]; |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
199 | char *unm = &unmpath[strlen(unmpath)-1]; |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
200 | while(nm != path_info && unm != unmpath) { |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
201 | if (*nm != *unm) { |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
202 | if (*unm == '\\' && *nm == '/') |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
203 | *nm = *unm; |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
204 | else |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
205 | PR_ASSERT(0); |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
206 | } |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
207 | nm--; |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
208 | unm--; |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
209 | } |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
210 | uri = unmpath; |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
211 | } |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
212 | #endif |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
213 | char *t = path_info; |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
214 | for(; *t; ++t) |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
215 | if (*t == FILE_PATHSEP) |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
216 | ++path_info_depth; |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
217 | *path_info = '\0'; |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
218 | set_path_info(rq, uri, path_info_depth); |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
219 | free(finfo); |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
220 | return REQ_PROCEED; |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
221 | } |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
222 | free(finfo); |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
223 | } |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
224 | else { |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
225 | *path_info = FILE_PATHSEP; |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
226 | break; |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
227 | } |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
228 | } |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
229 | |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
230 | /* This was changed to support virtual documents */ |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
231 | return REQ_NOACTION; |
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 | } |