diff -r 000000000000 -r 6f7a81934006 lib/courier-authlib/chain.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/courier-authlib/chain.c Wed Jan 16 22:39:43 2008 +0100 @@ -0,0 +1,67 @@ +/* +** Copyright 1998 - 1999 Double Precision, Inc. See COPYING for +** distribution information. +*/ + +#if HAVE_CONFIG_H +#include "config.h" +#endif +#include +#include +#include +#if HAVE_UNISTD_H +#include +#endif +#if HAVE_FCNTL_H +#include +#endif + +#include "auth.h" + +static const char rcsid[]="$Id: chain.c,v 1.1 2000/04/13 17:55:05 bruce Exp $"; + +void authchain(int argc, char **argv, const char *buf) +{ +int pipes[2]; +pid_t p; +int l, n; +char **vec; +char *prog; + + vec=authcopyargv(argc, argv, &prog); + if (!prog || open("/dev/null", O_RDONLY) != 3) authexit(1); + + if (pipe(pipes)) + { + perror("pipe"); + authexit(1); + } + while ((p=fork()) < 0) + { + perror("fork"); + sleep(3); + } + close(3); + + if (p) + { + dup(pipes[0]); + close(pipes[0]); + close(pipes[1]); + execv(prog, vec); + perror(prog); + authexit(1); + } + l=strlen(buf); + close(3); + close(pipes[0]); + while (l) + { + n=write(pipes[1], buf, l); + if (n <= 0) break; + buf += n; + l -= n; + } + close(pipes[1]); + authexit(1); +}