// Copyright 2003 Data Helper, Inc. // This program is realeased under the // GNU GENERAL PUBLIC LICENSE Version 2. // See COPYING.GPL for information. // Mark Willcox // Run this after the POP connection is authenticated. #include "postpop.h" #include #include #include #include #include #include #include int main( int argc, char **argv ) { int fp; int dot; char ip[16]; char *lastDot; char fn[PATH_MAX]; if (argc < 2) _exit( 2 ); if (! getenv( "TCPREMOTEIP")) _exit( 2 ); if (strlen( getenv( "TCPREMOTEIP")) > 15) _exit( 2 ); strncpy( ip, getenv( "TCPREMOTEIP" ), 16 ); if (strlen( ip ) < 7) _exit( 2 ); strcpy( fn, IP_DIR ); for (dot = 0; dot < DIR_DEPTH; ++dot) { lastDot = strrchr( ip, '.' ); if (! lastDot) _exit( 2 ); *lastDot++ = '\0'; strcat( fn, lastDot ); mkdir( fn, 0755 ); strcat( fn, "/" ); } strcat( fn, ip ); fp = creat( fn, S_IRWXU | S_IRGRP | S_IROTH ); close( fp ); execvp(argv[1],argv + 1); _exit(111); return 0; }