use pipe extension with a c compiled file

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

use pipe extension with a c compiled file

Jordi Moles
Hi,

i've been using for some time now the pipe extension and perl scripts to
handle the data.

The thing is that with perl i get the info with these commands:

shift(@ARGV)   // for variables like {@mailbox}

$_  //the email itself

anyway.... the thing is that i've been trying to move to a c compiled
script and i can get variables through argc, argv, but not the mail content.

i though i could do so with STDIN, but i haven't managed to do it...

could someone give a brief example about how to get all this data from a
c script and send it back to postfix?

thanks.
Reply | Threaded
Open this post in threaded view
|

Re: use pipe extension with a c compiled file

Victor Duchovni
On Thu, Jun 12, 2008 at 06:48:18PM +0200, Jordi Moles Blanco wrote:

> could someone give a brief example about how to get all this data from a
> c script and send it back to postfix?

The message content is available on standard input. There are many
good books on C-programming in a Unix environment. You could start with
Kernighan and Pike.

I must point out that mail delivery agents written in C pose significant
security pitfalls for the novice programmer. If you don't already know
how to do this, writing a production LDA or filter in C is perhaps not a
good idea.

This said, there are pitfalls in Perl also. One common bug is to create
a single string shell command-line when passing arguments from untrusted
sources to child processes.

        DO NOT: system("$cmd").
        DO: system { "/executable" } @args;

        DO NOT: exec("$cmd").
        DO: exec { "/executable" } @args;

Anyway, it is unrealistic to run a programming class here. Good luck.

--
        Viktor.

Disclaimer: off-list followups get on-list replies or get ignored.
Please do not ignore the "Reply-To" header.

To unsubscribe from the postfix-users list, visit
http://www.postfix.org/lists.html or click the link below:
<mailto:[hidden email]?body=unsubscribe%20postfix-users>

If my response solves your problem, the best way to thank me is to not
send an "it worked, thanks" follow-up. If you must respond, please put
"It worked, thanks" in the "Subject" so I can delete these quickly.
Reply | Threaded
Open this post in threaded view
|

Re: use pipe extension with a c compiled file

Jordi Moles
Hi,

thanks for the info, now that i know that it's done through stdin, i
will try to deal with it again.

thank you.

En/na Victor Duchovni ha escrit:

> On Thu, Jun 12, 2008 at 06:48:18PM +0200, Jordi Moles Blanco wrote:
>
>  
>> could someone give a brief example about how to get all this data from a
>> c script and send it back to postfix?
>>    
>
> The message content is available on standard input. There are many
> good books on C-programming in a Unix environment. You could start with
> Kernighan and Pike.
>
> I must point out that mail delivery agents written in C pose significant
> security pitfalls for the novice programmer. If you don't already know
> how to do this, writing a production LDA or filter in C is perhaps not a
> good idea.
>
> This said, there are pitfalls in Perl also. One common bug is to create
> a single string shell command-line when passing arguments from untrusted
> sources to child processes.
>
> DO NOT: system("$cmd").
> DO: system { "/executable" } @args;
>
> DO NOT: exec("$cmd").
> DO: exec { "/executable" } @args;
>
> Anyway, it is unrealistic to run a programming class here. Good luck.
>
>