sub do_auth_check { # get self object and CGI query object my $self = shift; my $q = $self->query(); # get user info from cookies my($uname,$pwd) = ( $q->cookie('username'), $q->cookie('password') ) +; warn($uname.':'.$pwd); # DEBUG use only # build command my $com = 'env QUERY_STRING=username='.$uname.'\;password='.$pwd.' / +usr/bin/custom_auth_tool'; warn('running command "'.$com.'"'); # DEBUG use only # run command through a pipe open(WEBOS,"$com|"); $com = join('', <WEBOS>); close(WEBOS); # remove newlines (should also take care of tainting, IIRC) $com =~ s/\x0D?\x0A//g; warn('ran command "'.$com.'"'); # DEBUG use only return $com; }
so, the command seems to output a blank string, which i would normally attribute to permissions, but if I run the following script:evan:password at AppTest.pm line 554. running command "env QUERY_STRING=username=evan\;password=password /us +r/bin/custom_auth_tool" at AppTest.pm line 561. ran command: "" at AppTest.pm line 566.
this works, and i get the following:#!perl use strict; use CGI; my $q = new CGI; my $uname = $q->cookie('username'); my $pwd = $q->cookie('password'); my $com = 'env QUERY_STRING=username='.$uname.'\;password='.$pwd.' /us +r/bin/custom_auth_tool'; print "Content-Type: text/plain\n\n", "Command:\n$com\n\n"; open(WEBOS,"$com|"); $com = join('', <WEBOS>); close(WEBOS); print "Result:\n$com\n\n";
i thought perhaps it was because the test script above had executable permissions, whereas AppTest.pm (where the do_auth sub is) didnt, it was just being used by an instance script. so, i chmodded AppTest.pm, but to no avail...i'm stumped, can anyone see anything i've missed?Command: env QUERY_STRING=username=evan\;password=password /usr/bin/custom_auth +_tool Result: user evan authenticated
EDIT: escaped semicolons in the commands per Fletch's suggestion. the original problem still persists...thanks for the suggestion though!
__________
Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
- Terry Pratchett
In reply to blank string returned from piped command by EvanK
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |