1 diff -ru cgiwrap-4.1/cgiwrap.c cgiwrap-4.1-bs/cgiwrap.c
2 --- cgiwrap-4.1/cgiwrap.c 2008-06-16 16:34:37.000000000 +0200
3 +++ cgiwrap-4.1-bs/cgiwrap.c 2010-04-21 16:12:44.431392749 +0200
5 int main (int argc, char *argv[])
7 char *userStr; /* User name */
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 */
13 /* Determine the base directory where this user's CGI scripts
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);
25 if ( !DirExists(cgiBaseDir) )
28 - MSG_Error_NoScriptDir();
29 + cgiBaseDir = GetBaseDirectory(user);
30 + DEBUG_Str("Script Base Directory2: ", cgiBaseDir);
31 + //MSG_Error_NoScriptDir();
34 /* Get the script name from the given data */
35 Only in cgiwrap-4.1-bs: cgiwrap.c.orig
36 diff -ru cgiwrap-4.1/fetch.c cgiwrap-4.1-bs/fetch.c
37 --- cgiwrap-4.1/fetch.c 2008-06-16 16:34:37.000000000 +0200
38 +++ cgiwrap-4.1-bs/fetch.c 2010-04-21 16:16:10.773900019 +0200
43 - pathInfoString = getenv("PATH_INFO");
44 + //pathInfoString = getenv("PATH_INFO");
45 + pathInfoString = getenv("PATH_TRANSLATED");
46 if ( pathInfoString ) /* use PATH_INFO */
48 if ( pathInfoString[0] != 0 )
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.");
54 userStr = GetPathComponents(1, pathInfoString);
60 +char *FetchPT(void) {
61 + return getenv("PATH_TRANSLATED");
64 char *FetchScriptString( char *basedir )
66 char *tempStr, *tempStr2;
69 DEBUG_Msg("Trying to extract script from PATH_INFO");
71 - scrStr = StripPathComponents(1,pathInfoString);
72 + //scrStr = StripPathComponents(1,pathInfoString);
73 + scrStr = StripPathComponents(0,pathInfoString);
74 if ( ! strlen(scrStr) ) { scrStr = 0; }
76 DEBUG_Str("Extracted PATH_INFO", scrStr);
77 Only in cgiwrap-4.1-bs: fetch.c.orig
78 diff -ru cgiwrap-4.1/fetch.h cgiwrap-4.1-bs/fetch.h
79 --- cgiwrap-4.1/fetch.h 2008-06-16 16:34:37.000000000 +0200
80 +++ cgiwrap-4.1-bs/fetch.h 2010-04-21 16:10:14.423934798 +0200
83 char *FetchUserString(void);
84 char *FetchScriptString(char *basedir);
86 Only in cgiwrap-4.1-bs: fetch.h.orig
87 diff -ru cgiwrap-4.1/util.c cgiwrap-4.1-bs/util.c
88 --- cgiwrap-4.1/util.c 2008-06-16 16:34:37.000000000 +0200
89 +++ cgiwrap-4.1-bs/util.c 2010-04-21 16:20:17.478653598 +0200
94 +char *GetPathComponent(int count, char *path)
101 + tmp = strdup(path);
104 + /* First skip over any leading /'s */
107 + while ( i<len && !done )
109 + if ( path[i] == '/' )
120 + /* Now, only copy a certain number of components */
124 + while ( i<len && found < count)
126 + if ( path[i] == '/' )
130 + if ( found < count )
143 * Extract all but the first 'count' components of 'path'
148 +char* getBasedir(char* path) {
153 + new_path = strdup( path );
154 + if ( new_path == NULL )
158 + last = strrchr( new_path, '/' );
159 + if ( last[1] == '\0' ) {
165 + file_name = last + 1;
170 +char* getBasename(char* path) {
175 + new_path = strdup( path );
176 + if ( new_path == NULL )
180 + last = strrchr( new_path, '/' );
181 + if ( last[1] == '\0' ) {
187 + file_name = last + 1;
193 * Set Environment Variables
194 @@ -1463,6 +1553,7 @@
196 /* check if we find old path_info (with user) in the path_translated string */
197 buf = strstr(new_pt, old_pi);
201 /* if so, copy in what we determined pathinfo should be after stripping off user portion */
202 @@ -1495,6 +1586,7 @@
210 Only in cgiwrap-4.1-bs: util.c.orig
211 diff -ru cgiwrap-4.1/util.h cgiwrap-4.1-bs/util.h
212 --- cgiwrap-4.1/util.h 2008-06-16 16:34:37.000000000 +0200
213 +++ cgiwrap-4.1-bs/util.h 2010-04-21 16:10:14.423934798 +0200
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);