]> git.pld-linux.org Git - packages/cgiwrap.git/blob - cgiwrap-customhtmlerrors.patch
- allow custom html error pages to be displayed instead of CGIWraps ones which are...
[packages/cgiwrap.git] / cgiwrap-customhtmlerrors.patch
1 diff -ur cgiwrap-4.1/config.h.in cgiwrap-4.1-bs/config.h.in
2 --- cgiwrap-4.1/config.h.in     2008-06-16 16:34:37.000000000 +0200
3 +++ cgiwrap-4.1-bs/config.h.in  2010-04-08 03:06:39.605240484 +0200
4 @@ -114,6 +114,9 @@
5  /* support a shared multi-user cgi directory */
6  #undef CONF_MULTIUSER_CGI_DIR
7  
8 +/* custom html error pages */
9 +#undef CONF_CUSTOMHTMLERR
10 +
11  /* pass script to php interpreter if suffix */
12  #undef CONF_PHP_INTERPRETER
13  
14 diff -ur cgiwrap-4.1/configure.in cgiwrap-4.1-bs/configure.in
15 --- cgiwrap-4.1/configure.in    2008-06-16 16:34:37.000000000 +0200
16 +++ cgiwrap-4.1-bs/configure.in 2010-04-07 22:56:50.905243224 +0200
17 @@ -584,6 +584,25 @@
18                 AC_DEFINE_UNQUOTED(CONF_CGIDIR,"public_html/cgi-bin", [cgi dir relative to user home dir])
19         ])
20  
21 +AC_MSG_CHECKING(for path to html error pages)
22 +AC_ARG_WITH( custom-html-errors, 
23 +       [  --with-custom-html-errors=PATH  (disabled)]
24 +       [  path where you want to store your custom error pages], 
25 +       [ 
26 +               if test "x$withval" = xyes; then
27 +                       AC_MSG_RESULT([must specify path, disabled.])
28 +               elif test "x$withval" = xno; then
29 +                       AC_MSG_RESULT([must specify path, disabled.])
30 +               elif test "x$withval" = x; then
31 +                       AC_MSG_RESULT([must specify path, disabled.])
32 +               else
33 +                       AC_MSG_RESULT([$withval])
34 +                       AC_DEFINE_UNQUOTED(CONF_CUSTOMHTMLERR, "$withval", [path to custom html error pages])
35 +               fi
36 +       ],
37 +       [ 
38 +               AC_MSG_RESULT([disabled.])
39 +       ])
40  
41  dnl
42  dnl Checking for what server userid cgiwrap will run as
43 diff -ur cgiwrap-4.1/msgs.c cgiwrap-4.1-bs/msgs.c
44 --- cgiwrap-4.1/msgs.c  2008-06-16 16:34:37.000000000 +0200
45 +++ cgiwrap-4.1-bs/msgs.c       2010-04-08 03:14:14.343509137 +0200
46 @@ -127,6 +127,30 @@
47         exit(1);
48  }
49  
50 +#if defined(CONF_CUSTOMHTMLERR)
51 +void Show_Custom_Html_Error(char *page)
52 +{
53 +       FILE *file;
54 +       char *read;
55 +       int ch;
56 +       //char *path = "/etc/cgiwrap/";
57 +       char *filename = BuildScriptPath(CONF_CUSTOMHTMLERR,page);
58 +       //char *filename = BuildScriptPath(path,page);
59 +       MSG_ContentType("text/html");
60 +       file = fopen(filename, "r");
61 +       if(file==NULL) {
62 +               printf("Error: can't open file.\n");
63 +               exit(1);
64 +       } else {
65 +               while ((ch = getc(file)) != EOF)
66 +                       putc(ch,stdout);
67 +               //printf("%s", read);
68 +               fclose(file);
69 +       }
70 +       exit(1);
71 +}
72 +#endif
73 +
74  void MSG_Info(void)
75  {
76         char *prefix_html = "<DD><B>";
77 @@ -357,6 +381,9 @@
78  
79  void MSG_Error_CGIWrapNotSetUID(void)
80  {
81 +#if defined(CONF_CUSTOMHTMLERR)
82 +       Show_Custom_Html_Error("CGIWrapNotSetUID.html");
83 +#else
84         if ( MSG_QuietErrors )
85         {
86                 MSG_Error_ServerConfigError();
87 @@ -376,11 +403,15 @@
88             MSG_Footer();
89             exit(1);
90         }
91 +#endif
92  }
93  
94  
95  void MSG_Error_ServerUserMismatch(void)
96  {
97 +#if defined(CONF_CUSTOMHTMLERR)
98 +       Show_Custom_Html_Error("ServerUserMismatch.html");
99 +#else
100         if ( MSG_QuietErrors )
101         {
102                 MSG_Error_ServerConfigError();
103 @@ -399,11 +430,15 @@
104                 MSG_Footer();
105                 exit(1);
106         }
107 +#endif
108  }
109  
110  
111  void MSG_Error_ServerUserNotFound(void)
112  {
113 +#if defined(CONF_CUSTOMHTMLERR)
114 +       Show_Custom_Html_Error("ServerUserNotFound.html");
115 +#else
116         if ( MSG_QuietErrors )
117         {
118                 MSG_Error_ServerConfigError();
119 @@ -452,11 +487,15 @@
120         MSG_Footer();
121         exit(1);
122         }
123 +#endif
124  }
125  
126  
127  void MSG_Error_ExecutionNotPermitted(char *path, char *reason)
128  {
129 +#if defined(CONF_CUSTOMHTMLERR)
130 +       Show_Custom_Html_Error("ExecutionNotPermitted.html");
131 +#else
132         MSG_Header("CGIWrap Error", "Execution of this script not permitted");
133  
134         if ( MSG_QuietErrors )
135 @@ -487,10 +526,14 @@
136  
137         MSG_Footer();
138         exit(1);
139 +#endif
140  }
141  
142  void MSG_Error_AccessControl(char *why, char *allowfile, char *denyfile)
143  {
144 +#if defined(CONF_CUSTOMHTMLERR)
145 +       Show_Custom_Html_Error("AccessControl.html");
146 +#else
147  
148         if ( MSG_QuietErrors )
149         {
150 @@ -526,10 +569,14 @@
151                 MSG_Footer();
152         }
153         exit(1);
154 +#endif
155  }
156  
157  void MSG_Error_SystemError(char *when)
158  {
159 +#if defined(CONF_CUSTOMHTMLERR)
160 +       Show_Custom_Html_Error("SystemError.html");
161 +#else
162         MSG_Header("CGIWrap Error", "System Error");
163         printf("CGIWrap encountered a system error.\n");
164  
165 @@ -561,11 +608,15 @@
166         
167         MSG_Footer();
168         exit(1);
169 +#endif
170  }
171  
172  
173  void MSG_Error_ExecFailed(void)
174  {
175 +#if defined(CONF_CUSTOMHTMLERR)
176 +       Show_Custom_Html_Error("ExecFailed.html");
177 +#else
178         MSG_Header("CGIWrap Error", "Script Execution Failed");
179  
180         printf("CGIWrap encountered an error while attempting to execute\n");
181 @@ -621,10 +672,14 @@
182         
183         MSG_Footer();
184         exit(1);
185 +#endif
186  }
187  
188  void MSG_Error_NoSuchUser(char *user)
189  {
190 +#if defined(CONF_CUSTOMHTMLERR)
191 +       Show_Custom_Html_Error("NoSuchUser.html");
192 +#else
193         if ( MSG_QuietErrors )
194         {
195                 MSG_Error_RequestError();
196 @@ -645,10 +700,14 @@
197         MSG_Footer();
198         exit(1);
199         }
200 +#endif
201  }
202  
203  void MSG_Error_NoScriptDir(void)
204  {
205 +#if defined(CONF_CUSTOMHTMLERR)
206 +       Show_Custom_Html_Error("NoScriptDir.html");
207 +#else
208         if ( MSG_QuietErrors )
209         {
210                 MSG_Error_RequestError();
211 @@ -663,6 +722,7 @@
212         }
213         MSG_Footer();
214         exit(1);
215 +#endif
216  }
217  
218  void MSG_Error_ServerConfigError(void)
219 diff -ur cgiwrap-4.1/msgs.h cgiwrap-4.1-bs/msgs.h
220 --- cgiwrap-4.1/msgs.h  2008-06-16 16:34:37.000000000 +0200
221 +++ cgiwrap-4.1-bs/msgs.h       2010-04-07 22:56:50.905243224 +0200
222 @@ -28,6 +28,7 @@
223  extern int MSG_QuietErrors;
224  extern int MSG_Need_NPH_Header;
225  
226 +void Show_Custom_Html_Error(char *page);
227  void MSG_ContentType(char *typestring);
228  void MSG_Header(char *title, char *msg);
229  void MSG_Footer(void);
This page took 0.079461 seconds and 3 git commands to generate.