For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > October 2006 > a functionn is not called









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author a functionn is not called
magdafrog@yahoo.de

2006-10-01, 6:58 pm

hi,
have described my porblem in a comment.


check_newuser.cgi
-------------------------------
if($email) {
########################################
###############
#in this place the execution dies; i don see any error
messages; #
########################################
###############
Bitkit::UGM::email_new_user($email);
########################################
################
#but when i comment out the prevoius line and instead
try to send #
#the email 'direct' it works
#
########################################
################
my $subject="Herzlich willkommen";
my $body="Deine Email funktioniert";
my $from ="admin\@bitbione.de";
open (MAIL, "| /usr/bin/mail -s $subject $email");
print MAIL "$body\n";
}


UGM.pm
---------------
sub email_new_user($) {
my $subject = "Willkommen";
my $body = "Deine Email wurde aktiviert. \n\n\nDas ist eine
automatisch generierte Nachricht.\n MFG \n Deine Bitbone - Team";

Bitkit::Mail::send_email($_[0], $subject, $body );
}



Mail.pm
--------------
sub send_email($$$) {
my $to = shift;
my $subject = shift;
my $body = shift;

open (MAIL, "| /usr/bin/mail -s $subject $to");
print MAIL "$body\n";
}


Could anyone give me any hints why is so??

thanx in advance
greetings
magda muskala

nobull67@gmail.com

2006-10-01, 6:58 pm


magdafrog@yahoo.de wrote:

> check_newuser.cgi
> -------------------------------
> if($email) {
> ########################################
###############
> #in this place the execution dies; i don see any error
> messages; #
> ########################################
###############
> Bitkit::UGM::email_new_user($email);


I'm sorry, how did you conclude that it died here not somewhere in
email_new_user() ?

Have you tried putting a few print statements no narrow it down?

> open (MAIL, "| /usr/bin/mail -s $subject $email");


>From the name of the script check_newuser.cgi I suspect that this is a

CGI script and $email may contain data from an untrusted source. And
you are passing it to the Unix command line interpreter. You've just
given the 'new user' the ability to execute arbitrary code on your
system (under the user ID of the web werver).

Use the list form of open:

open (MAIL, '|-', '/usr/bin/mail', '-s', $subject, $email or die $!;

magdafrog@yahoo.de

2006-10-01, 6:58 pm

hi,
thank you for your answer!

nobull67@gmail.com schrieb:

>
> I'm sorry, how did you conclude that it died here not somewhere in
> email_new_user() ?
>
> Have you tried putting a few print statements no narrow it down?

yes, i have logged the executed steps, that why i have concluded it.



> Use the list form of open:
>
> open (MAIL, '|-', '/usr/bin/mail', '-s', $subject, $email or die $!;

omg! stupid me!
yep, it was exacly what i needed! there is a check function and every
time when a shell is opened program dies. when you use the list, it
works!

greetings
magda

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com