Trouble with -T switch

Ask a Question related to PERL Beginners, Design and Development.

  1. #1

    Default Trouble with -T switch

    Hi everybody,

    I'm having trouble with setting the path to my sendmail program when using the -T switch. It's a simple script that creates a from, asks for an email adresse and sends an answer after the form was submitted. I keep getting the following error message although I've set the $ENV{'PATH'} in the script. Can anyone help?

    Error message:
    Insecure directory in $ENV{PATH} while running with -T switch at /usr/local/httpd/cgi-bin/subscribe.pl line 45.

    Here is a part of the code
    ________snippet______

    #!/usr/bin/perl -wT
    #Pull in modules, create form etc.


    sub send_mail {
    my $a = shift;
    $a = check($a); #sub that check's the email adress
    print ("Thank your for ordering our Newsletter.");
    $ENV{'PATH'} = "|/usr/sbin/sendmail -oi -t -odq";
    open(SENDMAIL, "$ENV{'PATH'}") or die "Can't fork for sendmail: $!\n"; print SENDMAIL <<"FILE";
    From: JUVE Newsline <juve-newsline\@juve.de>
    To: <$a>
    ..
    ..etc

    }
    _____Snippet______

    Thanks Marcus



    Marcus Willemsen
    Online Redaktion
    Juve Verlag GmbH
    Sachsenring. 6
    50677 Köln
    ++49 (0)221 91 38 80 16
    [url]www.juve.de[/url]


    Geschäftsführer: Dr. Astrid Gerber, Dr. Aled W. Griffiths
    Sitz der Gesellschaft: Köln
    Amtsgericht Köln HRB 29593, Gerichtsstand: Köln
    Bankverbindung: Stadtsparkasse Köln, BLZ 37050198, Kto-Nr. 4772281

    Marcus Willemsen Guest

  2. Similar Questions and Discussions

    1. Switch question
      In some languages, you can do the following in a Switch statement...is there a way to do this in PHP? Thanks in advance switch($voteraction){...
    2. RCR: New interpreter switch
      One place where perl's heavy use of implicit variables scores is in quick one-liners from the command prompt. I think ruby would be more appealing...
    3. Switch to 12" G4 - ?'s
      I am looking for an ultraportable to do powerpoint and word on, and take on the road for presentations, It must work flawlessly with my desktop...
    4. Trying to use a here doc within a switch
      I'm trying to use here docs within a switch to output html. The code below works (i.e. prints a Foo1 headline below my tab graphic) but if I take...
    5. VisualAge 6 installation trouble on aix 5.2, gcc trouble too :)
      I've installed gcc 3.x from UCLA site. and I got this error - In file included from test.c:23: /usr/include/pthread.h:554: error: parse error...
  3. #2

    Default Re: Trouble with -T switch

    > Hi everybody,
    >
    > I'm having trouble with setting the path to my sendmail program when
    using the -T switch. It's a simple script that creates a from, asks for
    an email adresse and sends an answer after the form was submitted. I
    keep getting the following error message although I've set the
    $ENV{'PATH'} in the script. Can anyone help?
    >
    > Error message:
    > Insecure directory in $ENV{PATH} while running with -T switch at
    /usr/local/httpd/cgi-bin/subscribe.pl line 45.
    >
    > Here is a part of the code
    > ________snippet______
    >
    > #!/usr/bin/perl -wT
    > #Pull in modules, create form etc.
    >
    >
    > sub send_mail {
    > my $a = shift;
    > $a = check($a); #sub that check's the email adress
    > print ("Thank your for ordering our Newsletter.");
    > $ENV{'PATH'} = "|/usr/sbin/sendmail -oi -t -odq";
    > open(SENDMAIL, "$ENV{'PATH'}") or die "Can't fork for sendmail:
    $!\n"; print SENDMAIL <<"FILE";
    > From: JUVE Newsline <juve-newsline\@juve.de>
    > To: <$a>
    > .
    > .etc
    >
    > }
    > _____Snippet______
    You haven't shown us where you are untainting $ENV{'PATH'}... I assume
    you have read perldoc taint ??

    How about not shelling out to sendmail in the above manner at all, and
    instead use a module to send your messages? There are many available
    and unless you are a Sendmail pro you shouldn't bother with it directly.

    [url]http://danconia.org[/url]
    Wiggins D Anconia Guest

  4. #3

    Default RE: Trouble with -T switch

    > > Hi everybody,
    > >
    > > I'm having trouble with setting the path to my sendmail program when
    > using the -T switch. It's a simple script that creates a
    > from, asks for an email adresse and sends an answer after the
    > form was submitted. I keep getting the following error
    > message although I've set the $ENV{'PATH'} in the script. Can
    > anyone help?
    > >
    > > Error message:
    > > Insecure directory in $ENV{PATH} while running with -T switch at
    > /usr/local/httpd/cgi-bin/subscribe.pl line 45.
    > >
    > > Here is a part of the code
    > > ________snippet______
    > >
    > > #!/usr/bin/perl -wT
    > > #Pull in modules, create form etc.
    > >
    > >
    > > sub send_mail {
    > > my $a = shift;
    > > $a = check($a); #sub that check's the email adress
    > > print ("Thank your for ordering our Newsletter.");
    > > $ENV{'PATH'} = "|/usr/sbin/sendmail -oi -t -odq";
    > > open(SENDMAIL, "$ENV{'PATH'}") or die "Can't fork for sendmail:
    > $!\n"; print SENDMAIL <<"FILE";
    > > From: JUVE Newsline <juve-newsline\@juve.de>
    > > To: <$a>
    > > .
    > > .etc
    > >
    > > }
    > > _____Snippet______
    >
    > You haven't shown us where you are untainting $ENV{'PATH'}...
    > I assume you have read perldoc taint ??
    I'm not explicitly untainting $ENV{'PATH'}. As far as I understood
    Programming Perl setting the path is enough, but apparently it is not. I
    thought only data has to be untained?
    >
    > How about not shelling out to sendmail in the above manner at
    > all, and instead use a module to send your messages? There
    > are many available and unless you are a Sendmail pro you
    > shouldn't bother with it directly.
    I would love to use Mail::Mailer or MimeLite but we are having a bit of
    trouble with our ISP and it's always a bit of a hassle to get CPAN
    Modules installed.

    Marcus

    [url]http://danconia.org[/url]
    Marcus Willemsen Guest

  5. #4

    Default RE: Trouble with -T switch

    > > > Hi everybody,
    > > >
    > > > I'm having trouble with setting the path to my sendmail program when
    > > using the -T switch. It's a simple script that creates a
    > > from, asks for an email adresse and sends an answer after the
    > > form was submitted. I keep getting the following error
    > > message although I've set the $ENV{'PATH'} in the script. Can
    > > anyone help?
    > > >
    > > > Error message:
    > > > Insecure directory in $ENV{PATH} while running with -T switch at
    > > /usr/local/httpd/cgi-bin/subscribe.pl line 45.
    > > >
    > > > Here is a part of the code
    > > > ________snippet______
    > > >
    > > > #!/usr/bin/perl -wT
    > > > #Pull in modules, create form etc.
    > > >
    > > >
    > > > sub send_mail {
    > > > my $a = shift;
    > > > $a = check($a); #sub that check's the email adress
    > > > print ("Thank your for ordering our Newsletter.");
    > > > $ENV{'PATH'} = "|/usr/sbin/sendmail -oi -t -odq";
    > > > open(SENDMAIL, "$ENV{'PATH'}") or die "Can't fork for sendmail:
    > > $!\n"; print SENDMAIL <<"FILE";
    > > > From: JUVE Newsline <juve-newsline\@juve.de>
    > > > To: <$a>
    > > > .
    > > > .etc
    > > >
    > > > }
    > > > _____Snippet______
    > >
    > > You haven't shown us where you are untainting $ENV{'PATH'}...
    > > I assume you have read perldoc taint ??
    > I'm not explicitly untainting $ENV{'PATH'}. As far as I understood
    > Programming Perl setting the path is enough, but apparently it is not. I
    > thought only data has to be untained?
    >
    Ah, I see what you are doing now. I am a little surprised that it is
    complaining though I don't know the exact methods it uses. Setting
    $ENV{'PATH'} as you have done seems very awkward to me, there is no
    reason to assign the path (and arguments) of your sendmail call to the
    global %ENV hash. Does it work if you assign it to a plain scalar? If
    you must have it in %ENV I would suggest choosing a key that is not a
    default and commonly used one...
    > >
    > > How about not shelling out to sendmail in the above manner at
    > > all, and instead use a module to send your messages? There
    > > are many available and unless you are a Sendmail pro you
    > > shouldn't bother with it directly.
    >
    > I would love to use Mail::Mailer or MimeLite but we are having a bit of
    > trouble with our ISP and it's always a bit of a hassle to get CPAN
    > Modules installed.
    >
    Yeh sometimes that is a problem. I assume you know that modules don't
    have to be installed into a root owned directory? In cases where you
    don't have shell access this won't help much, always something I check
    for when deciding amongst ISPs...

    [url]http://danconia.org[/url]

    Wiggins D Anconia Guest

  6. #5

    Default RE: Trouble with -T switch

    Hi Marcus,

    Marcus Willemsen wrote:
    >>>Hi everybody,
    >>>
    >>>I'm having trouble with setting the path to my sendmail program
    >>>when using the -T switch.
    >>>Here is a part of the code
    >> > ________snippet______
    >> >
    >> > #!/usr/bin/perl -wT
    >> > #Pull in modules, create form etc.
    >> >
    >> >
    >> > sub send_mail {
    >> > my $a = shift;
    >> > $a = check($a); #sub that check's the email adress
    >> > print ("Thank your for ordering our Newsletter.");
    >> > $ENV{'PATH'} = "|/usr/sbin/sendmail -oi -t -odq";
    >> > open(SENDMAIL, "$ENV{'PATH'}") or die "Can't fork for sendmail:
    Why don't you set $ENV{'PATH'} to something else and open the filehandle for sendmail explicitly?

    $ENV{'PATH'} = "";
    open (SENDMAIL, "|/usr/sbin/sendmail -oi -t -odq");

    It's one more line (for setting $ENV{'PATH'}, but it should stop -T from complaining.

    Are you aware of [email]beginners-cgi@perl.org[/email]? I posted my CGI questions to [email]beginners@perl.org[/email] until someone notified me of this list.

    - Jan
    --
    If all else fails read the instructions. - Donald Knuth
    Jan Eden Guest

  7. #6

    Default RE: Trouble with -T switch

    Thanks Jan,

    It worked.
    > $ENV{'PATH'} = "";
    > open (SENDMAIL, "|/usr/sbin/sendmail -oi -t -odq");
    > Are you aware of [email]beginners-cgi@perl.org[/email]? I posted my CGI
    > questions to [email]beginners@perl.org[/email] until someone notified me of
    > this list.
    Yes, I am. And I don't know why I didn't post my question there. But on
    the other hand using taint mode applies none CGI scripts as well, so I
    thought this list might be appropriate.

    Grettings Marcus
    >
    > - Jan
    > --
    > If all else fails read the instructions. - Donald Knuth
    >
    Marcus Willemsen Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139