%USERACL Is Empty?!

W

William

basically %USERACL is a hash containing the key and values read from the
following file:
UserID=LoginID:Group:Name:Email:password:IsAdmin:Status:Servers:Lists:Logs:Macros:Eod:FileMgr:MacroList:pnL:EditPnL:BO
AADUBLINJORDAN=AADUBLINJORDAN:BO:AADUBLINJORDAN:AADUBLINJORDAN:XEV5iEfluxjWM:::::::::[]:[]:[]:
CHANKN=CHANKN:SYS:Kenneth Chan:[email protected]:XECiTZAqeyBjE:1:1::1:1:1:1:1:[]:[]:[]:

now for test.pl:

1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5 use CGI;
6
7 require "./mxrt_auth.pl";
8
9 my $query = new CGI;
10 my %USERACL = initAuthMgr($query); (see NOTE1 for initAuthMgr)
11
12 while ( (my $key, my $value) = each %USERACL) {
13 print "$key = $value\n";
14 }
15

Question #1) The following error was generated by "use warnings;"

[mk_murex@mkmxg00 /mkapp/webapps/mxrt-cgi/upload_repo 12:45:03]$ ./test.pl
output.txt
Can't locate warnings.pm in @INC (@INC contains:
/usr/perl5/5.00503/sun4-solaris /usr/perl5/5.00503
/usr/perl5/site_perl/5.005/sun4-solaris /usr/perl5/site_perl/5.005 .) at
../test.pl line 4.
BEGIN failed--compilation aborted at ./test.pl line 4.

NOTE1: for line 10 of test.pl:

mxrt_auth.pl::initAuthMrg is defined as follows:

sub initAuthMgr {
($AUTHQ) = @_;
%AUTH_INFO = $AUTHQ->cookie('MXRT_USERACL');
foreach (keys %AUTH_INFO) {
print ($AUTH_INFO{$_})."<br>";
}
return %AUTH_INFO;
}

Question #2) nothing is printed by line 12-14 of test.pl. (Even
without the line "use warnings;")

Why???

Expected output of the following script - test.pl:
IsAdmin=1
Status=1
Servers=1
....
 
P

Paul Lalli

William said:
basically %USERACL is a hash containing the key and values read from the
following file:
UserID=LoginID:Group:Name:Email:password:IsAdmin:Status:Servers:Lists:Logs:Macros:Eod:FileMgr:MacroList:pnL:EditPnL:BO
AADUBLINJORDAN=AADUBLINJORDAN:BO:AADUBLINJORDAN:AADUBLINJORDAN:XEV5iEfluxjWM:::::::::[]:[]:[]:
CHANKN=CHANKN:SYS:Kenneth Chan:[email protected]:XECiTZAqeyBjE:1:1::1:1:1:1:1:[]:[]:[]:

now for test.pl:

1 #!/usr/bin/perl
2

Please stop putting line-numbers in your posting. It makes it
annoyingly difficult to copy and paste your code to try to run it. If
a certain line number is relevant, specify it with a comment.
3 use strict;
4 use warnings;
5 use CGI;
6
7 require "./mxrt_auth.pl";
8
9 my $query = new CGI;
10 my %USERACL = initAuthMgr($query); (see NOTE1 for initAuthMgr)
11
12 while ( (my $key, my $value) = each %USERACL) {
13 print "$key = $value\n";
14 }
15

Question #1) The following error was generated by "use warnings;"

[mk_murex@mkmxg00 /mkapp/webapps/mxrt-cgi/upload_repo 12:45:03]$ ./test.pl
output.txt
Can't locate warnings.pm in @INC (@INC contains:
/usr/perl5/5.00503/sun4-solaris /usr/perl5/5.00503
/usr/perl5/site_perl/5.005/sun4-solaris /usr/perl5/site_perl/5.005 .) at
./test.pl line 4.
BEGIN failed--compilation aborted at ./test.pl line 4.

You have a very old version of Perl. I would suggest upgrading. If
that is not an option, remove 'use warnings;' and add ' -w' to the end
of your shebang line.
NOTE1: for line 10 of test.pl:

mxrt_auth.pl::initAuthMrg is defined as follows:

sub initAuthMgr {
($AUTHQ) = @_;
%AUTH_INFO = $AUTHQ->cookie('MXRT_USERACL');

It looks like you're not using strict in this file. Why not?
foreach (keys %AUTH_INFO) {
print ($AUTH_INFO{$_})."<br>";

Is this printing out what you expect it to? I'm betting not. I'm
betting you're not getting the said:
}
return %AUTH_INFO;
}

Question #2) nothing is printed by line 12-14 of test.pl. (Even
without the line "use warnings;")

Why???

Witout knowing the exact contents of %AUTH_INFO, there is no way to be
sure of the answer to that. What is the output of that function? Is
it actually printing the values of %AUTH_INFO that you expect it to?


Paul Lalli
 
X

xhoster

William said:
basically %USERACL is a hash containing the key and values read from the
following file:

No, it is not. Nowhere in your program do you read from the following
file and put it into that hash.
UserID=LoginID:Group:Name:Email:password:IsAdmin:Status:Servers:Lists:Log
s:Macros:Eod:FileMgr:MacroList:pnL:EditPnL:BO
AADUBLINJORDAN=AADUBLINJORDAN:BO:AADUBLINJORDAN:AADUBLINJORDAN:XEV5iEflux
jWM:::::::::[]:[]:[]: CHANKN=CHANKN:SYS:Kenneth
Chan:[email protected]:XECiTZAqeyBjE:1:1::1:1:1:1:1:[]:[]:[]:

Question #1) The following error was generated by "use warnings;"

[mk_murex@mkmxg00 /mkapp/webapps/mxrt-cgi/upload_repo 12:45:03]$
./test.pl
output.txt
Can't locate warnings.pm in @INC (@INC contains:
/usr/perl5/5.00503/sun4-solaris /usr/perl5/5.00503
/usr/perl5/site_perl/5.005/sun4-solaris /usr/perl5/site_perl/5.005 .) at
./test.pl line 4.
BEGIN failed--compilation aborted at ./test.pl line 4.

You have an ancient version of perl. It does not come with the warnings.pm
module. Either upgrade perl or don't "use warnings". (Use the -w switch
instead.)
NOTE1: for line 10 of test.pl:

mxrt_auth.pl::initAuthMrg is defined as follows:

sub initAuthMgr {
($AUTHQ) = @_;
%AUTH_INFO = $AUTHQ->cookie('MXRT_USERACL');

Does $AUTHQ have a cookie named MXRT_USERACL?
foreach (keys %AUTH_INFO) {
print ($AUTH_INFO{$_})."<br>";
}
return %AUTH_INFO;
}

Question #2) nothing is printed by line 12-14 of test.pl. (Even
without the line "use warnings;")

Why???

Probably because there is nothing to print.
Expected output of the following script - test.pl:
IsAdmin=1
Status=1
Servers=1
...

I didn't expect that to be the outcome.

Xho
 
W

William

William said:
basically %USERACL is a hash containing the key and values read from the
following file:
UserID=LoginID:Group:Name:Email:password:IsAdmin:Status:Servers:Lists:Logs:Macros:Eod:FileMgr:MacroList:pnL:EditPnL:BO
AADUBLINJORDAN=AADUBLINJORDAN:BO:AADUBLINJORDAN:AADUBLINJORDAN:XEV5iEfluxjWM:::::::::[]:[]:[]:
CHANKN=CHANKN:SYS:Kenneth Chan:[email protected]:XECiTZAqeyBjE:1:1::1:1:1:1:1:[]:[]:[]:

now for test.pl:

1 #!/usr/bin/perl
2

Please stop putting line-numbers in your posting. It makes it
annoyingly difficult to copy and paste your code to try to run it. If
a certain line number is relevant, specify it with a comment.

I have removed the line numbers and added the -w switch.

# test.pl
#!/usr/bin/perl -w

use strict;
use CGI;

require "./mxrt_auth.pl";

my $query = new CGI;
my %USERACL = initAuthMgr($query); # line 10

while ( (my $key, my $value) = each %USERACL) {
print "$key = $value\n";
}

It looks like you're not using strict in this file. Why not?

mxrt_auth.pl was written by another programmer.
I tried adding "use strict;" and -w on the shebang line, but I got the
following error/warnings:

mxrt_auth.pl: print (...) interpreted as function at ./mxrt_auth.pl line 42.
mxrt_auth.pl: Useless use of concatenation in void context at ./mxrt_auth.pl line 44.

mxrt_auth.pl: Execution of ./mxrt_auth.pl aborted due to compilation errors.

line 42, 44, and 86 are as follows:

#-------------------------------------------------------------------------------
# This function retuns the cookie for this session (hash format)
#-------------------------------------------------------------------------------
sub initAuthMgr {
($AUTHQ) = @_;
%AUTH_INFO = $AUTHQ->cookie('MXRT_USERACL'); # line 42
foreach (keys %AUTH_INFO) {
print ($AUTH_INFO{$_})."<br>"; # line 44
}
return %AUTH_INFO;
}


#-------------------------------------------------------------------------------
# Function to load the pull-down menus
#-------------------------------------------------------------------------------
sub authLog {
my ($msg, $useracl) = @_;

if ($useracl) {
%AUTH_INFO = %$useracl;
}

open (LOG, ">>my $MXRT_LOG") || return "Failed to open access log,
$!"; # line 86

flock(LOG, 2);

my $now = `date '+%m-%d-%Y %H:%M:%S'`;
chomp $now;

print LOG $now, " | ",
$AUTH_INFO{LoginID}, " | ",
$ENV{'REMOTE_HOST'}, " | ",
$ENV{'REMOTE_ADDR'}, " | ",
$ENV{'SCRIPT_NAME'} , " on ", $ENV{'HTTP_Host'} , " | ",
$msg,
"\n";

flock(LOG, 2);

close(LOG);
}
Is this printing out what you expect it to? I'm betting not. I'm
betting you're not getting the <br> tags at all.

Paul, you are right. I am not getting the <br> tags at all.
In fact, I got no output when I printed %AUTH_INFO.

Related question:
How do I check if 'MXRT_USERACL' is indeed the correct cookie name? (see
line 42 of mxrt_auth.pl as above)
Witout knowing the exact contents of %AUTH_INFO, there is no way to be
sure of the answer to that. What is the output of that function? Is
it actually printing the values of %AUTH_INFO that you expect it to?

No. No output is being printed from %AUTH_INFO.
 
W

William

William said:
basically %USERACL is a hash containing the key and values read from the
following file:

No, it is not. Nowhere in your program do you read from the following
file and put it into that hash.
UserID=LoginID:Group:Name:Email:password:IsAdmin:Status:Servers:Lists:Log
s:Macros:Eod:FileMgr:MacroList:pnL:EditPnL:BO
AADUBLINJORDAN=AADUBLINJORDAN:BO:AADUBLINJORDAN:AADUBLINJORDAN:XEV5iEflux
jWM:::::::::[]:[]:[]: CHANKN=CHANKN:SYS:Kenneth
Chan:[email protected]:XECiTZAqeyBjE:1:1::1:1:1:1:1:[]:[]:[]:

Question #1) The following error was generated by "use warnings;"

[mk_murex@mkmxg00 /mkapp/webapps/mxrt-cgi/upload_repo 12:45:03]$
./test.pl
output.txt
Can't locate warnings.pm in @INC (@INC contains:
/usr/perl5/5.00503/sun4-solaris /usr/perl5/5.00503
/usr/perl5/site_perl/5.005/sun4-solaris /usr/perl5/site_perl/5.005 .) at
./test.pl line 4.
BEGIN failed--compilation aborted at ./test.pl line 4.
Xho said:
You have an ancient version of perl. It does not come with the warnings.pm
module. Either upgrade perl or don't "use warnings". (Use the -w switch
instead.)

I have removed "use warnings" and put
#!/usr/bin/perl -w

on line 1 of mxrt_auth.pl instead.
Does $AUTHQ have a cookie named MXRT_USERACL?

KEY QUESTION:
How do I obtain a list of cookies for $AUTHQ?

Probably because there is nothing to print.

I agree. I just found out that %AUTH_INFO has 0 keys.

my check:

sub initAuthMgr {
($AUTHQ) = @_;
%AUTH_INFO = $AUTHQ->cookie('MXRT_USERACL');
my $num_keys = keys %AUTH_INFO;
print $num_keys; # problem found - %AUTH_INFO has 0 keys
foreach (keys %AUTH_INFO) {
print ($AUTH_INFO{$_})."<br>";
}
return %AUTH_INFO;
}
 
P

Paul Lalli

William said:
I have removed the line numbers and added the -w switch.

Thank you.
mxrt_auth.pl was written by another programmer.
I tried adding "use strict;" and -w on the shebang line, but I got the
following error/warnings:

No, not "but you got", "*AND* you got". That's exactly why we use
strict and -w, so Perl will tell you when you do something wrong.
mxrt_auth.pl: print (...) interpreted as function at ./mxrt_auth.pl line 42.
mxrt_auth.pl: Useless use of concatenation in void context at ./mxrt_auth.pl line 44.

mxrt_auth.pl: Execution of ./mxrt_auth.pl aborted due to compilation errors.

You skipped something. Neither of the first two outputs are errors,
they're both warnings. They wouldn't have caused the script to abort
due to compilation errors.
line 42, 44, and 86 are as follows:

#-------------------------------------------------------------------------------
# This function retuns the cookie for this session (hash format)
#-------------------------------------------------------------------------------
sub initAuthMgr {
($AUTHQ) = @_;
%AUTH_INFO = $AUTHQ->cookie('MXRT_USERACL'); # line 42
foreach (keys %AUTH_INFO) {
print ($AUTH_INFO{$_})."<br>"; # line 44

If those warnings are both correct, there's something screwy going on.
Both warnings are referring to this line. By using the parentheses,
the arguments to print stop after the first closing parenthesis. This
should be:
print "$AUTH_INFO{$_} said:
}
return %AUTH_INFO;
}


#-------------------------------------------------------------------------------
# Function to load the pull-down menus
#-------------------------------------------------------------------------------
sub authLog {
my ($msg, $useracl) = @_;

if ($useracl) {
%AUTH_INFO = %$useracl;
}

open (LOG, ">>my $MXRT_LOG") || return "Failed to open access log,
$!"; # line 86

You seem to be implying this line gave you an error. It would be nice
to see what that error message was.
Paul, you are right. I am not getting the <br> tags at all.

Well, that's because of the parentheses error I mentioned above.
In fact, I got no output when I printed %AUTH_INFO.

But that's because %AUTH_INFO is empty.
Related question:
How do I check if 'MXRT_USERACL' is indeed the correct cookie name? (see
line 42 of mxrt_auth.pl as above)

By checking the return value of the cookie method. If what it returns
is not defined, you gave an invalid cookie name.

No. No output is being printed from %AUTH_INFO.

So %AUTH_INFO is empty, which in turn means that the cookie was not
valid. Fix your cookie name.

Paul Lalli
 
P

Paul Lalli

William said:
KEY QUESTION:
How do I obtain a list of cookies for $AUTHQ?

It's not documented, but looking at the source code, it looks like you
should be able to do:
my @cookies = $AUTHQ->cookie();
to get a list of all the names of the cookies being sent to this
script.

Paul Lalli
 
X

xhoster

William said:
KEY QUESTION:
How do I obtain a list of cookies for $AUTHQ?

By analogy with the param() method, I assumed that calling cookie() with
no parameters gives you a list of cookie names. An experiment showed this
to be true, but it wasn't documented in the POD for CGI.

However, cookies have to be set by something. Presumably, you have control
or at least knowledge of the thing that sets those cookies. So the best
way to figure out what a cookie is called is probably to look in the code
that sets it, rather than by introspection of the submitted request.


Xho
 
P

Paul Lalli

By analogy with the param() method, I assumed that calling cookie() with
no parameters gives you a list of cookie names. An experiment showed this
to be true, but it wasn't documented in the POD for CGI.

Xho, as you can see in my reply to William, I believed this to be true
as well. However, I did find one very small reference to this ability.
In the description of raw_cookie(), we find this tiny snippet:

"You can use the regular cookie() method to get the names"

So, I don't think it's fair to say that this ability is not documented.
Just that it's not *well* documented...

Paul Lalli
 
X

xhoster

Paul Lalli said:
Xho, as you can see in my reply to William, I believed this to be true
as well. However, I did find one very small reference to this ability.
In the description of raw_cookie(), we find this tiny snippet:

"You can use the regular cookie() method to get the names"

So, I don't think it's fair to say that this ability is not documented.
Just that it's not *well* documented...

OK, I stand corrected.

Thanks,

Xho
 
W

William

It's not documented, but looking at the source code, it looks like you
should be able to do:
my @cookies = $AUTHQ->cookie();
to get a list of all the names of the cookies being sent to this
script.

My list of cookies is EMPTY!!

# mxrt_auth::initAuthMgr
sub initAuthMgr {
($AUTHQ) = @_;
%AUTH_INFO = $AUTHQ->cookie('MXRT_USERACL');
my $num_keys = keys %AUTH_INFO;
# print "$num_keys\n"; # problem found - %AUTH_INFO has 0 keys
my @cookies = $AUTHQ->cookie();
my $num_cookies = my @cookies;
print $num_cookies; # $num_cookies = 0!!!
foreach (keys %AUTH_INFO) {
print $AUTH_INFO{$_}."<br>";
}
return %AUTH_INFO;
}

for
%AUTH_INFO = $AUTHQ->cookie('MXRT_USERACL');

I know I am using CGI::cookie(). $AUTHQ is just a "new CGI". My
question #1): how come the list of cookies is empty?
question #2): how do I get the list of cookies to generate %USERACL
(ACL - Access Control List)

FYI: the main script that uses %USERACL:

# test.pl
#!/usr/bin/perl -w

use strict;
use CGI;

require "./mxrt_auth.pl";

my $query = new CGI;

# %USERACL has 0 items because initAuthMgr returns an EMPTY cookie
# i.e. the list of cookie names for AUTHQ is empty
my %USERACL = initAuthMgr($query);

while ( (my $key, my $value) = each %USERACL) {
print "$key = $value\n";
}
 
T

Tad McClellan

William said:
My list of cookies is EMPTY!!
[snip]

my @cookies = $AUTHQ->cookie();
my $num_cookies = my @cookies; ^^
^^
print $num_cookies; # $num_cookies = 0!!!


Why did you put that "my" there?

question #1): how come the list of cookies is empty?


Your code above is looking at a *different variable* whose
name happens to be @cookies. Take out the "my".
 
P

Paul Lalli

William said:
On Fri, 9 Dec 2005, Paul Lalli wrote:

My list of cookies is EMPTY!!

Stop shouting. Diagnose the problem. That's usually a far better
approach.
# mxrt_auth::initAuthMgr
sub initAuthMgr {
($AUTHQ) = @_;
%AUTH_INFO = $AUTHQ->cookie('MXRT_USERACL');
my $num_keys = keys %AUTH_INFO;
# print "$num_keys\n"; # problem found - %AUTH_INFO has 0 keys
my @cookies = $AUTHQ->cookie();
my $num_cookies = my @cookies;

Are you still not enabling warnings? Why not? With warnings enabled
(either via use warnings or the -w), this should give you:
"my" variable @cookies masks earlier declaration in same scope at...

You are setting a lexical variable @cookies to the return value of
$AUTHQ->cookie(). You are then creating *another* new lexical
variable, which happens to also be named @cookies, and returning the
size of that into $num_cookies.

Get rid of that my in front of the second @cookies.

Paul Lalli
 
T

Tassilo v. Parseval

Also sprach Paul Lalli:
William wrote:

Please stop putting line-numbers in your posting. It makes it
annoyingly difficult to copy and paste your code to try to run it. If
a certain line number is relevant, specify it with a comment.

Just for the record: I do like line-numbers. It makes it easier to refer
to certain bits of code when replying.

Also, they can be removed in any decent text-editor with just a few
key-strokes.

Tassilo
 
W

William

William said:
My list of cookies is EMPTY!!
[snip]

my @cookies = $AUTHQ->cookie();
my $num_cookies = my @cookies; ^^
^^
print $num_cookies; # $num_cookies = 0!!!
Why did you put that "my" there?




Your code above is looking at a *different variable* whose
name happens to be @cookies. Take out the "my".

I took out the "my". $num_cookies is still 0.

code that initializes $num_cookies:
# mxrt_auth.pl
#!/usr/bin/perl -w

require "./mxrt_vars.pl";

# we need this because perl CGI reference the environment variable
HTTP_COOKIE
# but vqsvr set the variable HTTP_Cookie (note the case!)
$ENV{'HTTP_COOKIE'}=$ENV{'HTTP_COOKIE'}; # line 7 - see below for warning

use strict;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
use Time::Local;

my $AUTHQ;
my %AUTH_INFO;
1;

#-------------------------------------------------------------------------------
# This function retuns the cookie for this session (hash format)
#-------------------------------------------------------------------------------
sub initAuthMgr {
($AUTHQ) = @_;
%AUTH_INFO = $AUTHQ->cookie('MXRT_USERACL');
my $num_keys = keys %AUTH_INFO;
# print "$num_keys\n"; # problem found - %AUTH_INFO has 0 keys
my @cookies = $AUTHQ->cookie();
my $num_cookies = @cookies;
print "number of cookies: $num_cookies\n";
foreach my $cookie ( @cookies ) {
print "current cookie: $cookie\n";
}
foreach (keys %AUTH_INFO) {
print $AUTH_INFO{$_}."<br>";
}
return %AUTH_INFO;
}


# mxrt_auth.pl::initAuthMgr is called as follows:

# test.pl
#!/usr/bin/perl -w

use strict;
use CGI;

require "./mxrt_auth.pl";

my $query = new CGI;

# %USERACL has 0 items because initAuthMgr returns an EMPTY cookie
# i.e. the list of cookie names for AUTHQ is empty
my %USERACL = initAuthMgr($query);

while ( (my $key, my $value) = each %USERACL) {
print "$key = $value\n";
}

My output when calling test.pl:

../test.pl
[Mon Dec 12 09:22:54 2005] test.pl: Use of uninitialized value at
../mxrt_auth.pl line 7.
(offline mode: enter name=value pairs on standard input)
foo=bar
number of cookies: 0


My problem comes down to filling in %USERACL with %AUTH_INFO. However,
MXRT_USERACL is not the correct cookie name, so %AUTH_INFO is empty. I
tried to find out the list of cookies names with

my @cookies = $AUTHQ->cookie();

but it turns out that my @cookies is also empty.

Question:
How to obtain the cookie name that I need to generate %USERACL?
 
W

William

Stop shouting. Diagnose the problem. That's usually a far better
approach.


Are you still not enabling warnings? Why not? With warnings enabled
(either via use warnings or the -w), this should give you:
"my" variable @cookies masks earlier declaration in same scope at....
I did enable warnings using -w.
You are setting a lexical variable @cookies to the return value of
$AUTHQ->cookie(). You are then creating *another* new lexical
variable, which happens to also be named @cookies, and returning the
size of that into $num_cookies.

Get rid of that my in front of the second @cookies.

I took out the "my". $num_cookies is still 0.

code that initializes $num_cookies:
# mxrt_auth.pl
#!/usr/bin/perl -w

require "./mxrt_vars.pl";

# we need this because perl CGI reference the environment variable
HTTP_COOKIE
# but vqsvr set the variable HTTP_Cookie (note the case!)
$ENV{'HTTP_COOKIE'}=$ENV{'HTTP_COOKIE'}; # line 7 - see below for
warning

use strict;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
use Time::Local;

my $AUTHQ;
my %AUTH_INFO;
1;

#-------------------------------------------------------------------------------
# This function retuns the cookie for this session (hash format)
#-------------------------------------------------------------------------------
sub initAuthMgr {
($AUTHQ) = @_;
%AUTH_INFO = $AUTHQ->cookie('MXRT_USERACL');
my $num_keys = keys %AUTH_INFO;
# print "$num_keys\n"; # problem found - %AUTH_INFO has 0 keys
my @cookies = $AUTHQ->cookie();
my $num_cookies = @cookies;
print "number of cookies: $num_cookies\n";
foreach my $cookie ( @cookies ) {
print "current cookie: $cookie\n";
}
foreach (keys %AUTH_INFO) {
print $AUTH_INFO{$_}."<br>";
}
return %AUTH_INFO;
}


# mxrt_auth.pl::initAuthMgr is called as follows:

# test.pl
#!/usr/bin/perl -w

use strict;
use CGI;

require "./mxrt_auth.pl";

my $query = new CGI;

# %USERACL has 0 items because initAuthMgr returns an EMPTY cookie
# i.e. the list of cookie names for AUTHQ is empty
my %USERACL = initAuthMgr($query);

while ( (my $key, my $value) = each %USERACL) {
print "$key = $value\n";
}

My output when calling test.pl:

../test.pl
[Mon Dec 12 09:22:54 2005] test.pl: Use of uninitialized value at
../mxrt_auth.pl line 7.
(offline mode: enter name=value pairs on standard input)
foo=bar
number of cookies: 0


My problem comes down to filling in %USERACL with %AUTH_INFO. However,
MXRT_USERACL is not the correct cookie name, so %AUTH_INFO is empty. I
tried to find out the list of cookies names with
my @cookies = $AUTHQ->cookie();

but it turns out that my @cookies is also empty.

Question:
How to obtain the cookie name that I need to generate %USERACL?
 
W

William

Stop shouting. Diagnose the problem. That's usually a far better
approach.


Are you still not enabling warnings? Why not? With warnings enabled
(either via use warnings or the -w), this should give you:
"my" variable @cookies masks earlier declaration in same scope at...

You are setting a lexical variable @cookies to the return value of
$AUTHQ->cookie(). You are then creating *another* new lexical
variable, which happens to also be named @cookies, and returning the
size of that into $num_cookies.

Get rid of that my in front of the second @cookies.

I took out the "my". $num_cookies is still 0.

code that initializes $num_cookies:
# mxrt_auth.pl
#!/usr/bin/perl -w

require "./mxrt_vars.pl";

# we need this because perl CGI reference the environment variable
HTTP_COOKIE
# but vqsvr set the variable HTTP_Cookie (note the case!)
$ENV{'HTTP_COOKIE'}=$ENV{'HTTP_COOKIE'}; # line 7 - see below for
warning

use strict;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
use Time::Local;

my $AUTHQ;
my %AUTH_INFO;
1;

#-------------------------------------------------------------------------------
# This function retuns the cookie for this session (hash format)
#-------------------------------------------------------------------------------
sub initAuthMgr {
($AUTHQ) = @_;
%AUTH_INFO = $AUTHQ->cookie('MXRT_USERACL');
my $num_keys = keys %AUTH_INFO;
# print "$num_keys\n"; # problem found - %AUTH_INFO has 0 keys
my @cookies = $AUTHQ->cookie();
my $num_cookies = @cookies;
print "number of cookies: $num_cookies\n";
foreach my $cookie ( @cookies ) {
print "current cookie: $cookie\n";
}
foreach (keys %AUTH_INFO) {
print $AUTH_INFO{$_}."<br>";
}
return %AUTH_INFO;
}


# mxrt_auth.pl::initAuthMgr is called as follows:

# test.pl
#!/usr/bin/perl -w

use strict;
use CGI;

require "./mxrt_auth.pl";

my $query = new CGI;

# %USERACL has 0 items because initAuthMgr returns an EMPTY cookie
# i.e. the list of cookie names for AUTHQ is empty
my %USERACL = initAuthMgr($query);

while ( (my $key, my $value) = each %USERACL) {
print "$key = $value\n";
}

My output when calling test.pl:

../test.pl
[Mon Dec 12 09:22:54 2005] test.pl: Use of uninitialized value at
../mxrt_auth.pl line 7.
(offline mode: enter name=value pairs on standard input)
foo=bar
number of cookies: 0


My problem comes down to filling in %USERACL with %AUTH_INFO. However,
MXRT_USERACL is not the correct cookie name, so %AUTH_INFO is empty. I
tried to find out the list of cookies names with
my @cookies = $AUTHQ->cookie();

but it turns out that my @cookies is also empty.

Question:
How to obtain the cookie name that I need to generate %USERACL?
 
P

Paul Lalli

William said:
I took out the "my". $num_cookies is still 0.

At this point, I'm confused as to what reason you have to believe it
should be anything else.
code that initializes $num_cookies:
# mxrt_auth.pl
#!/usr/bin/perl -w

Wait. Is that line really in your actual file? The "# mxrt_auth.pl"
line? If so, please get rid of it. Or at least move it. Your shebang
must be the VERY FIRST line of the file. No comments, no whitespace
before it. As it stands now, Perl will never see that -w, and so
warnings are produced.
require "./mxrt_vars.pl";

# we need this because perl CGI reference the environment variable
HTTP_COOKIE
# but vqsvr set the variable HTTP_Cookie (note the case!)
$ENV{'HTTP_COOKIE'}=$ENV{'HTTP_COOKIE'}; # line 7 - see below for warning

What on earth do you believe this is doing? You have effectively just
said:
$foo = $foo;
From your comment, it appears you *meant* to say:
$ENV{HTTP_COOKIE} = $ENV{HTTP_Cookie};
My output when calling test.pl:

./test.pl
[Mon Dec 12 09:22:54 2005] test.pl: Use of uninitialized value at
./mxrt_auth.pl line 7.
(offline mode: enter name=value pairs on standard input)
foo=bar
number of cookies: 0

Why do you believe you should be getting any cookies when the script is
run like this? What process do you think is setting $ENV{HTTP_COOKIE}
(or $ENV{HTTP_Cookie} for that matter)? Are you manually setting this
variable before running the scirpt? If so, show us. If not, I can't
see any reason for an expectation of any cookies at all.
My problem comes down to filling in %USERACL with %AUTH_INFO. However,
MXRT_USERACL is not the correct cookie name, so %AUTH_INFO is empty. I
tried to find out the list of cookies names with
my @cookies = $AUTHQ->cookie();

but it turns out that my @cookies is also empty.

As expected.
Question:
How to obtain the cookie name that I need to generate %USERACL?

Your problem is not in obtaining the cookie names, it's in the cookies
not being set to begin with.


Paul Lalli
 
W

William

At this point, I'm confused as to what reason you have to believe it
should be anything else.
This line is not in my actual file. I added this line to my posts to let
other posters know what file I am referring to. I will remove this line
from my future posts to avoid confusion.
This is the first line in my actual file.
What on earth do you believe this is doing? You have effectively just
said:
$foo = $foo;

$ENV{HTTP_COOKIE} = $ENV{HTTP_Cookie};

I think that what the previous developer meant to say. I was confused
when I was reading his script.

Lines 5-7 now read:
# we need this because perl CGI reference the environment variable HTTP_COOKIE
# but vqsvr set the variable HTTP_Cookie (note the case!)
$ENV{'HTTP_COOKIE'}=$ENV{'HTTP_Cookie'};
My output when calling test.pl:

./test.pl
[Mon Dec 12 09:22:54 2005] test.pl: Use of uninitialized value at
./mxrt_auth.pl line 7.
(offline mode: enter name=value pairs on standard input)
foo=bar
number of cookies: 0

Why do you believe you should be getting any cookies when the script is
run like this? What process> > # mxrt_auth.pl
do you think is setting
$ENV{HTTP_COOKIE}
(or $ENV{HTTP_Cookie} for that matter)? Are you manually setting this
variable before running the scirpt? If so, show us. If not, I can't
see any reason for an expectation of any cookies at all.

I tried the following on the command line:

echo $ENV{HTTP_Cookie}
/local/home/mk_murex/.kshrc{HTTP_Cookie}
echo $ENV{HTTP_COOKIE}
/local/home/mk_murex/.kshrc{HTTP_COOKIE}

However, in .kshrc, there is no entry as
HTTP_Cookie or HTTP_COOKIE.

If I were to add the line
export HTTP_Cookie=[x]

in .kshrc, what is the correct value for HTTP_Cookie?
(Or should I add export HTTP_COOKIE instead?)

As expected.


Your problem is not in obtaining the cookie names, it's in the cookies
not being set to begin with.

I agree. I now need to know how to set the cookie in .kshrc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top