#include #include #include #define CMDS 3 char cmd[][30]={ "Return-Path:", "Date:", "Subject:" }; int is_root( char * user ); int main( int argc, char *argv[]) { char str[4001]; char aux[200]; char *p,*q; int i; FILE *mail, *fwd; char user[400]; char date[400]; char subject[400]="No subject"; if ( argc != 2) exit( 1); fwd=fopen("/root/mbox","a+"); while((!feof(stdin))&&(gets(str))) { fprintf(fwd,"%s\n",str); p=strtok(str," "); q=strtok(NULL,"\n"); if(p!=NULL) for (i=0;i\n"); strcpy(user,p); break; case 1: /*Date*/ p=strtok(q,"<>\n"); strcpy(date,p); break; case 2: /*Subject*/ p=strtok(q,"<>\n"); strcpy(subject,p); break; default: break; } } } } sprintf(aux,"/bin/mail %s,%s",user, argv[1]); mail=popen(aux,"w"); fprintf(mail, "Subject: Re: %s (fwd)\n" "\n\n\t- SPDsoft: Automatic answer -\n" "\t- Your e-mail of %s\n" "\t (%s)\n" "\t has been forwarded to the System Manager address:\n" "\n\t\t%s\n" "\n\n\t- Please, use this address in your next mail and update\n" "\t- your address book\n\n\n\t\tThanks!\n", subject, date, subject, argv[1] ); pclose(mail); fclose(fwd); exit(0); } int is_root( char * user ) { char *root[] = { "root", "daemon" }; int i; int result = 0; for( i=0 ; (i