On Tue, 05 Apr 2005 08:56:04 -0400
"Dave Nebinger" <[EMAIL PROTECTED]> wrote:

> You're probably looking at a permissions problem.  Sendmail (and other
> mailers) typically run as non-root.  Therefore when you are trying to
> open/root/test.data it's probably failing miserably, throwing an
> exception, and bailing.
> Try changing to /tmp/test.data and see what happens.
This is correct.

Also, the code provided writes to file all the stuff it receives via its
command line arguments vector, which is not the right thing to do if (as
is more likely) sendmail passes the mail text via standard input, in
which case you have to rewrite your program such as follows:


#define _GNU_SOURCE

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
        FILE   *out;
        size_t  len  = 0;
        char   *line = NULL;

        out = fopen("/tmp/output.txt", "w");
        if (!out) abort();

        while (getline(&line, &len, stdin) != -1)
                fprintf(out, "%s", line);

        fclose(out);

        return EXIT_SUCCESS;
}


Bye
Michele Noberasco

-- 
A child of five could understand this!  Fetch me a child of five.

Attachment: pgpIgr2jH36Ne.pgp
Description: PGP signature

Reply via email to