]> git.pld-linux.org Git - packages/cgiwrap.git/blob - cgiwrap-bs.patch
- BR: autoconf
[packages/cgiwrap.git] / cgiwrap-bs.patch
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
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);
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 */
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
39 @@ -34,12 +34,14 @@
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  
54                         userStr = GetPathComponents(1, pathInfoString);
55                 }
56 @@ -82,6 +84,10 @@
57         return userStr;
58  }
59  
60 +char *FetchPT(void) {
61 +       return getenv("PATH_TRANSLATED");
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);
72 +                       //scrStr = StripPathComponents(1,pathInfoString);
73 +                       scrStr = StripPathComponents(0,pathInfoString);
74                         if ( ! strlen(scrStr) ) { scrStr = 0; }
75  
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
81 @@ -26,3 +26,4 @@
82   
83  char *FetchUserString(void);
84  char *FetchScriptString(char *basedir);
85 +char *FetchPT(void);
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
90 @@ -840,6 +840,53 @@
91  }
92  
93  
94 +char *GetPathComponent(int count, char *path)
95 +{
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;
140 +}
141  
142  /*
143   * Extract all but the first 'count' components of 'path'
144 @@ -887,6 +934,49 @@
145         return tmp;
146  }
147  
148 +char* getBasedir(char* path) {
149 +       char *new_path;
150 +       char *last;
151 +       char *file_name;
152 +
153 +       new_path = strdup( path );
154 +       if ( new_path == NULL )
155 +               return 2;
156 +
157 +find_last:
158 +       last = strrchr( new_path, '/' );
159 +       if ( last[1] == '\0' ) {
160 +               last[0] = '\0';
161 +               goto find_last;
162 +       }
163 +
164 +       last[0] = '\0';
165 +       file_name = last + 1;
166 +
167 +       return new_path;
168 +}
169 +
170 +char* getBasename(char* path) {
171 +       char *new_path;
172 +       char *last;
173 +       char *file_name;
174 +
175 +       new_path = strdup( path );
176 +       if ( new_path == NULL )
177 +               return 2;
178 +
179 +find_last:
180 +       last = strrchr( new_path, '/' );
181 +       if ( last[1] == '\0' ) {
182 +               last[0] = '\0';
183 +               goto find_last;
184 +       }
185 +
186 +       last[0] = '\0';
187 +       file_name = last + 1;
188 +
189 +       return file_name;
190 +}
191  
192  /*
193   * Set Environment Variables
194 @@ -1463,6 +1553,7 @@
195  
196         /* check if we find old path_info (with user) in the path_translated string */
197         buf = strstr(new_pt, old_pi);
198 +       /*
199         if ( buf )
200         {
201                 /* if so, copy in what we determined pathinfo should be after stripping off user portion */
202 @@ -1495,6 +1586,7 @@
203  
204                 return;
205         }
206 +       */
207  }
208  
209  
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
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);
This page took 0.071321 seconds and 3 git commands to generate.