Deleted Added
full compact
simple_httpd.c (94135) simple_httpd.c (112205)
1/*-
2 * Simple_HTTPd v1.1 - a very small, barebones HTTP server
3 *
4 * Copyright (c) 1998-1999 Marc Nicholas <marc@netstor.com>
5 * All rights reserved.
6 *
7 * Major rewrite by William Lloyd <wlloyd@slap.net>
8 *

--- 13 unchanged lines hidden (view full) ---

22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 *
1/*-
2 * Simple_HTTPd v1.1 - a very small, barebones HTTP server
3 *
4 * Copyright (c) 1998-1999 Marc Nicholas <marc@netstor.com>
5 * All rights reserved.
6 *
7 * Major rewrite by William Lloyd <wlloyd@slap.net>
8 *

--- 13 unchanged lines hidden (view full) ---

22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 *
30 * $FreeBSD: head/release/picobsd/tinyware/simple_httpd/simple_httpd.c 94135 2002-04-07 17:42:27Z asmodai $
30 * $FreeBSD: head/release/picobsd/tinyware/simple_httpd/simple_httpd.c 112205 2003-03-13 22:06:10Z dwmalone $
31 */
32
33#include <sys/stat.h>
34#include <sys/time.h>
35#include <sys/types.h>
36#include <sys/socket.h>
37#include <sys/wait.h>
38#include <netinet/in.h>

--- 206 unchanged lines hidden (view full) ---

245 par=0;
246 if (par=strstr(filename,"?"))
247 {
248 *par=0;
249 par++;
250 }
251 if (access(filename,X_OK)) goto conti;
252 stat (filename,&file_status);
31 */
32
33#include <sys/stat.h>
34#include <sys/time.h>
35#include <sys/types.h>
36#include <sys/socket.h>
37#include <sys/wait.h>
38#include <netinet/in.h>

--- 206 unchanged lines hidden (view full) ---

245 par=0;
246 if (par=strstr(filename,"?"))
247 {
248 *par=0;
249 par++;
250 }
251 if (access(filename,X_OK)) goto conti;
252 stat (filename,&file_status);
253 if (setuid(file_status.st_uid)) return(0);
254 if (seteuid(file_status.st_uid)) return(0);
253 if (setuid(file_status.st_uid)) return;
254 if (seteuid(file_status.st_uid)) return;
255 if (!fork())
256 {
257 close(1);
258 dup(con_sock);
259 //printf("HTTP/1.0 200 OK\nContent-type: text/html\n\n\n");
260 printf("HTTP/1.0 200 OK\r\n");
261 /* Plug in environment variable, others in log_line */
262 putenv("SERVER_SOFTWARE=FreeBSD/PicoBSD");
263
264 execlp (filename,filename,par,(char *)0);
265 }
266 wait(&i);
255 if (!fork())
256 {
257 close(1);
258 dup(con_sock);
259 //printf("HTTP/1.0 200 OK\nContent-type: text/html\n\n\n");
260 printf("HTTP/1.0 200 OK\r\n");
261 /* Plug in environment variable, others in log_line */
262 putenv("SERVER_SOFTWARE=FreeBSD/PicoBSD");
263
264 execlp (filename,filename,par,(char *)0);
265 }
266 wait(&i);
267 return(0);
267 return;
268 }
269 conti:
270 if (filename == NULL) {
271 http_output(http_405[0]);
272 http_output(http_405[1]);
273 goto end_request;
274 }
275 /* End of CGI handling */

--- 191 unchanged lines hidden (view full) ---

467 wait3(0,WNOHANG,0);
468 exit(0);
469}
470
471
472char *adate()
473{
474 static char out[50];
268 }
269 conti:
270 if (filename == NULL) {
271 http_output(http_405[0]);
272 http_output(http_405[1]);
273 goto end_request;
274 }
275 /* End of CGI handling */

--- 191 unchanged lines hidden (view full) ---

467 wait3(0,WNOHANG,0);
468 exit(0);
469}
470
471
472char *adate()
473{
474 static char out[50];
475 long now;
475 time_t now;
476 struct tm *t;
477 time(&now);
478 t = localtime(&now);
479 sprintf(out, "%02d:%02d:%02d %02d/%02d/%02d",
480 t->tm_hour, t->tm_min, t->tm_sec,
481 t->tm_mday, t->tm_mon+1, t->tm_year );
482 return out;
483}
476 struct tm *t;
477 time(&now);
478 t = localtime(&now);
479 sprintf(out, "%02d:%02d:%02d %02d/%02d/%02d",
480 t->tm_hour, t->tm_min, t->tm_sec,
481 t->tm_mday, t->tm_mon+1, t->tm_year );
482 return out;
483}