Hi,

You should absolutely NOT use this script !
It has serious security issues.
Instead, use the following script:
____________

#!/usr/bin/perl

# In case you want to disable the forwarding, but defer the messages,
# uncomment the next 2 lines! 
# print "Can not deliver Domain Forwading Yet !";
# exit 111;

# Explaining the script. Look at:
# http://www.w3.org/Security/Faq/wwwsf5.html#Q44

# You can take advantage of this feature to open up a pipe without
# going through a shell. By calling open on the magic character
# sequence |-, you fork a copy of Perl and open a pipe to the copy.
# The child copy can then exec another program using the argument
# list variant of exec().
#   my $result =  open (SORT,"|-");
#   die "Couldn't open pipe to subprocess" unless defined($result);
#   exec "/usr/bin/sort",$uservariable or die "Couldn't exec sort"
#        if $result == 0;
#   for my $line (@lines) {
#     print SORT $line,"\n";
#   }
#   close SORT;

# The initial call to open() tries to fork a copy of Perl. If the
# call fails it returns an undefined value and the script immediately
# dies (you might want to do something more sophisticated, such as
# sending an HTML error message to the user). Otherwise, the result
# will return zero to the child process, and the child's process ID
# to the parent. The child process checks the result value, and
# immediately attempts to exec the sort program. If something fails
# at this point, the child quits.
# The parent process can then print to the SORT filehandle in
# the normal way.

open(M,"|-") || print "Problem with Domain Forwarding (Fork not \
possible)" && exit 111;
$uservariable="$ENV{LOCAL}\@$ARGV[0]";
exec "/var/qmail/bin/qmail-inject",$uservariable || print "Problem \ 
with Domain Forwarding (Could not execute qmail-inject)" && exit 111;
if ($result == 0){
  while(<STDIN>) { print M $_; }
}
close M;

___

( \ at the end of the line means that the line continues at the next 
line, I did that just for formatting this email you might wanna 
remove those \ !)

-Ace




> The following code fragment:
> 
> #!/usr/bin/perl
> open(M, "|/common/services/qmail-ldap/bin/qmail-inject
> $ENV{LOCAL}\@$ARGV[0]");
> while(<STDIN>) { print M $_; }
> close M;
> 
> Seems to break when multiple To: recips are supplied..  Any
> suggestions?
> 
> 
> starting delivery 101956: msg 1060524 to local
> [EMAIL PROTECTED] delivery 101956: deferral:
> mailaddr:[EMAIL PROTECTED] /'/LDAP_lookup_succeeded
> qmail-inject:_fatal:_unable_to_parse_this_line:/To:_username@forwarded
> domain .com
> ;[EMAIL PROTECTED];[EMAIL PROTECTED];;/preline:_fatal:_unable_t
> o_copy _input:_broken_pipe/
> 
> [EMAIL PROTECTED] is the only valid address for said domain
> and the delivery program is set as such...
> 
> Delivery Program: /qmail-ldap/bin/preline
> /qmail-ldap/bin/forward-domain forwardeddomain.mydomain.com
> 
> 
> kstone at win dot net
> 
> 
> 
> 



| Ace Suares, Internet Consultancy and Training
| Keizersgracht 132, 1015 CW AMSTERDAM, NL
| phone: 06 557 06 554    (+31 6 557 06 554)
| fax: 08 48 707 705      (+31 84 870 770 5)
| mailto:[EMAIL PROTECTED] PGP Key idea: 0x39B81FE5
| http://www.suares.com

Reply via email to