]>
Commit | Line | Data |
---|---|---|
d7890844 | 1 | diff -ru cgiwrap-4.1/cgiwrap.c cgiwrap-4.1-bs/cgiwrap.c |
83ec11e3 | 2 | --- cgiwrap-4.1/cgiwrap.c 2008-06-16 16:34:37.000000000 +0200 |
d7890844 | 3 | +++ cgiwrap-4.1-bs/cgiwrap.c 2010-04-21 16:12:44.431392749 +0200 |
83ec11e3 | 4 | @@ -36,6 +36,7 @@ |
5 | int main (int argc, char *argv[]) | |
6 | { | |
7 | char *userStr; /* User name */ | |
8 | + char *pt_path; | |
9 | char *scrStr; /* Name of script */ | |
10 | char *scriptPath; /* Path to script file */ | |
11 | char *cgiBaseDir; /* Base directory for cgi scripts in user's dir */ | |
12 | @@ -141,7 +142,10 @@ | |
13 | /* Determine the base directory where this user's CGI scripts | |
14 | are to be stored */ | |
15 | DEBUG_Msg(""); | |
16 | - cgiBaseDir = GetBaseDirectory(user); | |
17 | + //cgiBaseDir = GetBaseDirectory(user); | |
18 | + pt_path = FetchPT(); | |
19 | + DEBUG_Str("PATH_TRANSLATED z FetchPT(): ", pt_path); | |
20 | + cgiBaseDir = getBasedir(pt_path); | |
21 | DEBUG_Str("Script Base Directory: ", cgiBaseDir); | |
22 | #if defined(CONF_MULTIUSER_CGI_DIR) | |
23 | DEBUG_Str("MultiUser Script Base Directory: ", CONF_MULTIUSER_CGI_DIR); | |
144b4332 | 24 | @@ -151,7 +155,9 @@ |
25 | if ( !DirExists(cgiBaseDir) ) | |
26 | #endif | |
27 | { | |
28 | - MSG_Error_NoScriptDir(); | |
29 | + cgiBaseDir = GetBaseDirectory(user); | |
30 | + DEBUG_Str("Script Base Directory2: ", cgiBaseDir); | |
31 | + //MSG_Error_NoScriptDir(); | |
32 | } | |
33 | ||
34 | /* Get the script name from the given data */ | |
d7890844 | 35 | Only in cgiwrap-4.1-bs: cgiwrap.c.orig |
36 | diff -ru cgiwrap-4.1/fetch.c cgiwrap-4.1-bs/fetch.c | |
83ec11e3 | 37 | --- cgiwrap-4.1/fetch.c 2008-06-16 16:34:37.000000000 +0200 |
d7890844 | 38 | +++ cgiwrap-4.1-bs/fetch.c 2010-04-21 16:16:10.773900019 +0200 |
39 | @@ -34,12 +34,14 @@ | |
83ec11e3 | 40 | DEBUG_Msg("\n"); |
41 | ||
42 | userStr = (char *) 0; | |
43 | - pathInfoString = getenv("PATH_INFO"); | |
44 | + //pathInfoString = getenv("PATH_INFO"); | |
45 | + pathInfoString = getenv("PATH_TRANSLATED"); | |
46 | if ( pathInfoString ) /* use PATH_INFO */ | |
47 | { | |
48 | if ( pathInfoString[0] != 0 ) | |
49 | { | |
50 | - DEBUG_Msg("Trying to extract user from PATH_INFO."); | |
51 | + //DEBUG_Msg("Trying to extract user from PATH_INFO."); | |
52 | + DEBUG_Msg("Trying to extract user from PATH_TRANSLATED."); | |
53 | ||
d7890844 | 54 | userStr = GetPathComponents(1, pathInfoString); |
83ec11e3 | 55 | } |
83ec11e3 | 56 | @@ -82,6 +84,10 @@ |
57 | return userStr; | |
58 | } | |
59 | ||
60 | +char *FetchPT(void) { | |
d7890844 | 61 | + return getenv("PATH_TRANSLATED"); |
83ec11e3 | 62 | +} |
63 | + | |
64 | char *FetchScriptString( char *basedir ) | |
65 | { | |
66 | char *tempStr, *tempStr2; | |
67 | @@ -99,7 +105,8 @@ | |
68 | { | |
69 | DEBUG_Msg("Trying to extract script from PATH_INFO"); | |
70 | ||
71 | - scrStr = StripPathComponents(1,pathInfoString); | |
d7890844 | 72 | + //scrStr = StripPathComponents(1,pathInfoString); |
144b4332 | 73 | + scrStr = StripPathComponents(0,pathInfoString); |
83ec11e3 | 74 | if ( ! strlen(scrStr) ) { scrStr = 0; } |
75 | ||
76 | DEBUG_Str("Extracted PATH_INFO", scrStr); | |
d7890844 | 77 | Only in cgiwrap-4.1-bs: fetch.c.orig |
78 | diff -ru cgiwrap-4.1/fetch.h cgiwrap-4.1-bs/fetch.h | |
83ec11e3 | 79 | --- cgiwrap-4.1/fetch.h 2008-06-16 16:34:37.000000000 +0200 |
d7890844 | 80 | +++ cgiwrap-4.1-bs/fetch.h 2010-04-21 16:10:14.423934798 +0200 |
83ec11e3 | 81 | @@ -26,3 +26,4 @@ |
82 | ||
83 | char *FetchUserString(void); | |
84 | char *FetchScriptString(char *basedir); | |
85 | +char *FetchPT(void); | |
d7890844 | 86 | Only in cgiwrap-4.1-bs: fetch.h.orig |
87 | diff -ru cgiwrap-4.1/util.c cgiwrap-4.1-bs/util.c | |
83ec11e3 | 88 | --- cgiwrap-4.1/util.c 2008-06-16 16:34:37.000000000 +0200 |
d7890844 | 89 | +++ cgiwrap-4.1-bs/util.c 2010-04-21 16:20:17.478653598 +0200 |
90 | @@ -840,6 +840,53 @@ | |
83ec11e3 | 91 | } |
92 | ||
93 | ||
94 | +char *GetPathComponent(int count, char *path) | |
95 | +{ | |
d7890844 | 96 | + char *tmp; |
97 | + int i, j, found; | |
98 | + int done; | |
99 | + int len; | |
100 | + | |
101 | + tmp = strdup(path); | |
102 | + len = strlen(tmp); | |
103 | + | |
104 | + /* First skip over any leading /'s */ | |
105 | + i = 0; | |
106 | + done = 0; | |
107 | + while ( i<len && !done ) | |
108 | + { | |
109 | + if ( path[i] == '/' ) | |
110 | + { | |
111 | + i++; | |
112 | + } | |
113 | + else | |
114 | + { | |
115 | + done = 1; | |
116 | + } | |
117 | + } | |
118 | + | |
119 | + | |
120 | + /* Now, only copy a certain number of components */ | |
121 | + j = 0; | |
122 | + found = 0; | |
123 | + i = 12; | |
124 | + while ( i<len && found < count) | |
125 | + { | |
126 | + if ( path[i] == '/' ) | |
127 | + { | |
128 | + found++; | |
129 | + } | |
130 | + if ( found < count ) | |
131 | + { | |
132 | + tmp[j] = path[i]; | |
133 | + j++; | |
134 | + } | |
135 | + i++; | |
136 | + } | |
137 | + tmp[j] = 0; | |
138 | + | |
139 | + return tmp; | |
83ec11e3 | 140 | +} |
141 | ||
142 | /* | |
143 | * Extract all but the first 'count' components of 'path' | |
d7890844 | 144 | @@ -887,6 +934,49 @@ |
83ec11e3 | 145 | return tmp; |
146 | } | |
147 | ||
148 | +char* getBasedir(char* path) { | |
d7890844 | 149 | + char *new_path; |
150 | + char *last; | |
151 | + char *file_name; | |
83ec11e3 | 152 | + |
d7890844 | 153 | + new_path = strdup( path ); |
154 | + if ( new_path == NULL ) | |
155 | + return 2; | |
83ec11e3 | 156 | + |
157 | +find_last: | |
d7890844 | 158 | + last = strrchr( new_path, '/' ); |
159 | + if ( last[1] == '\0' ) { | |
160 | + last[0] = '\0'; | |
161 | + goto find_last; | |
162 | + } | |
83ec11e3 | 163 | + |
d7890844 | 164 | + last[0] = '\0'; |
165 | + file_name = last + 1; | |
83ec11e3 | 166 | + |
d7890844 | 167 | + return new_path; |
83ec11e3 | 168 | +} |
169 | + | |
170 | +char* getBasename(char* path) { | |
d7890844 | 171 | + char *new_path; |
172 | + char *last; | |
173 | + char *file_name; | |
83ec11e3 | 174 | + |
d7890844 | 175 | + new_path = strdup( path ); |
176 | + if ( new_path == NULL ) | |
177 | + return 2; | |
83ec11e3 | 178 | + |
179 | +find_last: | |
d7890844 | 180 | + last = strrchr( new_path, '/' ); |
181 | + if ( last[1] == '\0' ) { | |
182 | + last[0] = '\0'; | |
183 | + goto find_last; | |
184 | + } | |
83ec11e3 | 185 | + |
d7890844 | 186 | + last[0] = '\0'; |
187 | + file_name = last + 1; | |
83ec11e3 | 188 | + |
d7890844 | 189 | + return file_name; |
83ec11e3 | 190 | +} |
191 | ||
192 | /* | |
193 | * Set Environment Variables | |
d7890844 | 194 | @@ -1463,6 +1553,7 @@ |
83ec11e3 | 195 | |
196 | /* check if we find old path_info (with user) in the path_translated string */ | |
197 | buf = strstr(new_pt, old_pi); | |
d7890844 | 198 | + /* |
83ec11e3 | 199 | if ( buf ) |
d7890844 | 200 | { |
201 | /* if so, copy in what we determined pathinfo should be after stripping off user portion */ | |
202 | @@ -1495,6 +1586,7 @@ | |
83ec11e3 | 203 | |
204 | return; | |
205 | } | |
d7890844 | 206 | + */ |
83ec11e3 | 207 | } |
208 | ||
209 | ||
d7890844 | 210 | Only in cgiwrap-4.1-bs: util.c.orig |
211 | diff -ru cgiwrap-4.1/util.h cgiwrap-4.1-bs/util.h | |
83ec11e3 | 212 | --- cgiwrap-4.1/util.h 2008-06-16 16:34:37.000000000 +0200 |
d7890844 | 213 | +++ cgiwrap-4.1-bs/util.h 2010-04-21 16:10:14.423934798 +0200 |
83ec11e3 | 214 | @@ -49,6 +49,9 @@ |
215 | void VerifyExecutingUser(void); | |
216 | char *BuildScriptPath(char *basedir, char *scrStr); | |
217 | char *GetPathComponents(int count, char *path); | |
218 | +char *GetPathComponent(int count, char *path); | |
219 | +char *getBasedir(char *path); | |
220 | +char *getBasename(char *path); | |
221 | char *StripPathComponents(int count, char *path); | |
222 | void ChangeID ( struct passwd *user); | |
223 | void ChangeAuxGroups(struct passwd *user); |