Re: Apache::Cookie

2003-06-03 Thread Jason Galea
Have you consulted the documentation?

http://search.cpan.org/author/JIMW/libapreq-1.1/Cookie/Cookie.pm#value

cap wrote:
i have an application that uses CGI and sets the cookie values as a hashref.
im then attempting to retreive the values with Apache::Cookie with:
$cookies = Apache::Cookie-fetch;

$ccokies is a hashref so i should be able to get the individual values with:

$cookies-{uid};

right?  however, this doesn't appear to work.







Re: [mp2] changing http:// to https: in TransHandler

2003-03-08 Thread Jason Galea
sorry if OT..

Hi Nick,

please tell me I'm wrong (I'll be a happy camper), but I thought that you 
couldn't use name virtual server for SSL.

Name server requires HTTP/1.1 which supplies a Host header so the server can 
tell which virtual server you want. With SSL this header is encrypted so 
apache can't read it to know which virtual server it's for.

Or does it work this way by defaulting to the first virtual server listening 
on port 443?

Or is Apache2 doing something funky to make this work?

..again, I really would like to be wrong about this. I host from home on ADSL 
and thought I'd have to pay for more IP's if I wanted to secure a section of 
my site.

J

Nick Tonkin wrote:
On Sat, 8 Mar 2003 [EMAIL PROTECTED] wrote:


Hi -

I'm not much of a mod_perl scripter (yet), but having been
totally defeated my mod_rewrite, I am trying to use mod_perl
to push clients into using https when accessing a particular
server (I am using named-based virtual hosting).
I want to do something like this (the real one will be
more complicated - but this is a baby test):
-in httpd.conf-

PerlTransHandler +MyApache::ForceSecure

-handler-

package MyApache::ForceSecure;
use strict;
use warnings;
use Apache::RequestRec ();
use Apache::Const -compile = qw(DECLINED);
sub handler
{
 my $r = shift;
 my $url = $r-url;
 if ($url =~ m{^http://bcbk}i) {
   $url =~ s/^http:/https:/i;
   $r-url ($url);
 }
 return Apache::DECLINED;
}
1;
Which is great, but there is *no* $r-url. I know there is a $r-uri, but
how can I get to the whole ball of wax: from http://...? I can't find
it in the docs.
Aloha = Beau;


Beau:

I _just_ went through this on my system. You would probably want to use
the following to change the URI as you wish:
my $uri = APR::URI-parse($r-pool, $r-construct_url);
$uri-scheme('https');
my $new_uri = $uri-unparse;
However, the overall strategy is probably not what you want, due to the
way SSL works. When a browser requests a secure connection, the SSL
connection (to the secure port) is established _before_ even the HTTP
connection. Thus it is impossible to change the scheme (http vs https)
once you have arrived at your server. The only way to do this with a Perl
handler is to generate a 302 external redirect.
mod_rewrite can be complicated, sure, but I do think it's the way to
go in this situation. You need:
- two sub-domains in DNS, let's say www.my_domain.com and secure.my_domain.com
- a sub-directory /secure in your webdocs root (or something else able to matched with 
a regex)
- the following in your httpd.conf:
Listen 80
Listen 443
NameVirtualHost 12.34.56.789:80
NameVirtualHost 12.34.56.789:443
VirtualHost 12.34.56.789:80

ServerName   www.my_domain.com
RewriteEngine   on
RewriteCond  %{REQUEST_URI}  /secure/
RewriteRule  ^/(.*)$   https://secure.my_domain.com/$1 [R,L]
/VirtualHost

VirtualHost 12.34.56.789:443

ServerName   secure.my_domain.com
RewriteEngine   on
RewriteCond  %{REQUEST_URI}  !/secure
RewriteRule  ^/(.*)$   http://www.my_domain.com/$1 [R,L]
/VirtualHost

This allows you to have relative links on all your pages. All links on
www.my_domain.com will point to http://www. on port 80, and all links on
secure.my_domain.com will point to https://secure. on port 443. The server
will simply rewrite and redirect all links that do not match either
/secure/ or !/secure.
Hope this helps,

- nick

PS If you have more than one domain needing to use https, you can put it
on an arbitrary port so long as you configure the server (not apache) to
listen on it, and then hard-code the port number in the mod_rewrite rule.



Re: mysql question

2003-01-23 Thread Jason Galea
you better duck dude.
slightly is slightly understating the off-topicness of your post..


Martin Moss wrote:

slightly off topic,
but is it possible to grant permissions to a user on multiple tables in one
sql statement in mysql?


From mysql.com:-


GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP
- ON bankaccount.*
- TO custom@localhost
- IDENTIFIED BY 'stupid';

can I do this
ON bankaccount.*,user.*,customer.*

Marty








Re: Dynamlcally loading modules at run-time

2002-10-03 Thread Jason Galea


Hi Jochen,

I'd recommend having a read of this
http://perl.apache.org/docs/1.0/guide/performance.html#Sharing_Memory

Not sure how much it applies to your situation, but basically, unless the 
different modules are very large and rarely used you really want to load them 
all at server startup. That way your server processes will be sharing the 
majority of your code and memory use will be optimised increasing the number 
of server processes you'll be able to run. Loading more modules after startup 
will increase the size of each process independantly, increasing your overall 
memory use.

cheers,

J

Jochen Lillich wrote:
 Hi,
 
 I'm writing my first mod_perl handler. I'd like to make the handler some
 kind of dispatcher that dynamically loads certain modules depending on
 the URI called:
 
 /foo/index = require foo; $result = foo::index();
 /foo/other = require foo; $result = foo::other();
 /bar/index = require bar; $result = bar::index();
 
 I'd like to ask for your advice there. Is this a clever way to go in
 the first place? And how would i best code this concept? Or is there a
 better way to reach a modular structure in a big web application?
 
 Best regards,
 
   Jochen
 
 .
 




Re: mod_perl, OpenPGP Math::Pari - Solved

2002-02-07 Thread Jason Galea


someone coulda told me to RTFM.. 8) then again I've read it before, so 
it probably wouldn't have helped, but just for those who have doubts...

PerlFreshRestart is BAD!!

but it's bad in a weird way cos it didn't affect my test server, but 
when I turned it off on the production server everything was good 
again... 8)

J


Jason Galea wrote:
 
 
 Ged Haywood wrote:
 

 There's a file in the mod_perl directory called SUPPORT.  (That bit
 about 'perl -V' was taken from there. :)  SUPPORT contains detailed
 instructions about what to do when mod_perl crashes, including what
 information to provide and how to generate a stack backtrace.

 73,
 Ged.

 
 yeh, read that... I guess I shoudn't have used the word crashes as 
 it's really dies when it tries to do a numeric comparison on an 
 alphanumeric string, which is entirely reasonable, so I'm not getting a 
 core dump, and I don't think mod_perl itself is at fault. I suspect the 
 implementation of GP/Pari as I ended up with the worst case as 
 mentioned in the Math::Pari install and manually copied (as instructed) 
 what I guess is a 'C' library file of some description (paricfg.h - I am 
 by no stretch a C programmer..) to the proper location. It all seemed to 
 work ok after that and as I had had troubles prior I already had my test 
 scripts which all ran fine so I thought Hooray! Then I implemented the 
 real system and got the errors mentioned.
 
 What I still don't understand is why the test scripts run ok, but the 
 mod_perl implementation doesn't. (But on my dev server everything works 
 as it should..)
 
 I'm going to reinstall GP/Pari on the production server using the 
 src.rpm I found on the Pari site, then if that goes ok I might be able 
 to install/update Math::Pari without errors, then maybe it'll all work.. 
 that's the plan anyway..
 
 cheers,
 
 


-- 
J
Web Developer

Eight Degrees Off Centre
http://www.eightdegrees.com.au/




Re: mod_perl, OpenPGP Math::Pari

2002-02-05 Thread Jason Galea


 [snip]
 
 perl -V
 
 That's lower case perl, upper case V.
 
 [snip]

now that's funny!



ok, so I was babbling.. try this. A simple perl script useing 
Crypt::OpenPGP runs fine from the command line while the same subroutine 
used in a mod_perl module on the same machine crashes. Why? Its nothing 
to do with global variables, multiple runs, or random occurances.

I put a warn statement into Crypt::Primes to show the offending variable 
$B represented as 'B'. The only line I can find in Crypt::Primes that 
sets the value of $B is:
my $B = floor ( $c_opt * ( $k ** 2 ) );

'floor' is imported from Math::Pari which according to the docs does not 
use any enviromental variables.

Throughout the run from the commandline $B remains an everchanging 
integer, while during the mod_perl run it suddenly becomes something 
else (37e5156f in the example below) subsequently crashing the program 
when it is involved in a numeric comparison.

and, yeh, if no one else has any suggestions this time, I'll drop it.
Thanks, Tom, for the nudge I needed to get this far..

cheers,

J


run from the commandline (test_pgp_gen.pl):



my $attrib = {
Size  = '2048',
Identity  = 'PGP EzyDVD [EMAIL PROTECTED]',
Password  = 'a new passphrase for you',
};

my $self = {
EV_config = {
PGPKeyLoc = 'd_main/data/.pgptest',
},
};

# test Key Generation
($self) = pgp_keygen($self,$attrib);

exit;

sub pgp_keygen{
##
my ($self,$attrib) = @_;
my $file = time;
warn Generating Keys;
use Crypt::OpenPGP;
warn Creating Keychain;
my $keychain = Crypt::OpenPGP-new;
warn Generating Keys with:\n\tType = 'RSA'\n\tSize = 
$attrib-{'Size'}\n\tIdentity = $attrib-{'Identity'}\n\tPassphrase = 
$attrib-{'Password'};
 my ($public, $private) = $keychain-keygen (
   
   Type = 'RSA',
   
   Size  = $attrib-{'Size'},
   
   Identity  = $attrib-{'Identity'},
   
   Passphrase  = $attrib-{'Password'},
# 
   
   Verbosity = 1,
   
   ) or die $keychain-errstr();
warn Generating complete. Saving..;

$public = $public-save;
open(PUBLIC,'',$$self{'EV_config'}{'PGPKeyLoc'}/$file.'.public');
print PUBLIC $public;
close(PUBLIC);

$private = $private-save;
open(PRIVATE,'',$$self{'EV_config'}{'PGPKeyLoc'}/$file.'.private');
print PRIVATE $private;
close(PRIVATE);
warn Saving complete.;

return ($self);
}

[]$ perl test_pgp_gen.pl
Generating Keys at test_pgp_gen.pl line 29.
Creating Keychain at test_pgp_gen.pl line 31.
Generating Keys with:
 Type = 'RSA'
 Size = 2048
 Identity = PGP EzyDVD [EMAIL PROTECTED]
Passphrase = a new passphrase for you at test_pgp_gen.pl line 33.
B = 43, r = 0.5, k = 22, q = 5347 at 
/usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
B = 151, r = 0.506631180276321, k = 41, q = 2267129 at 
/usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
B = 506, r = 0.53037992595081, k = 75, q = 2196811726937 at 
/usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
B = 1520, r = 0.562081100800386, k = 130, q = 26428241092041745277471 at 
/usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
B = 3352, r = 0.667875988226359, k = 193, q = 
688430562782715717240302427312908015051 at 
/usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
B = 9564, r = 0.588637765080919, k = 326, q = 
965545119950202842999573881663024114299390132769541041 at 
/usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
B = 29240, r = 0.56933184524636, k = 570, q = 
1079008567477111753397094310847156029079713553247572710822855637214539638256680204084416659
 
at /usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
B = 94371, r = 0.554913243836389, k = 1024, q = 
2738877267722396215978314103886896155676111721678953257651796203192310298619466435015458288033302116849702218709734148499773910739678380930731862293431860017467060796038877
 
at /usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
B = 60, r = 0.5, k = 26, q = 24359 at 
/usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
B = 190, r = 0.533359128724712, k = 46, q = 48084667 at 
/usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
B = 392, r = 0.674066449056276, k = 66, q = 43830135663841 at 

Re: mod_perl, OpenPGP Math::Pari

2002-02-05 Thread Jason Galea



Ged Haywood wrote:

 
 There's a file in the mod_perl directory called SUPPORT.  (That bit
 about 'perl -V' was taken from there. :)  SUPPORT contains detailed
 instructions about what to do when mod_perl crashes, including what
 information to provide and how to generate a stack backtrace.
 
 73,
 Ged.
 

yeh, read that... I guess I shoudn't have used the word crashes as 
it's really dies when it tries to do a numeric comparison on an 
alphanumeric string, which is entirely reasonable, so I'm not getting a 
core dump, and I don't think mod_perl itself is at fault. I suspect the 
implementation of GP/Pari as I ended up with the worst case as 
mentioned in the Math::Pari install and manually copied (as instructed) 
what I guess is a 'C' library file of some description (paricfg.h - I am 
by no stretch a C programmer..) to the proper location. It all seemed to 
work ok after that and as I had had troubles prior I already had my test 
scripts which all ran fine so I thought Hooray! Then I implemented the 
real system and got the errors mentioned.

What I still don't understand is why the test scripts run ok, but the 
mod_perl implementation doesn't. (But on my dev server everything works 
as it should..)

I'm going to reinstall GP/Pari on the production server using the 
src.rpm I found on the Pari site, then if that goes ok I might be able 
to install/update Math::Pari without errors, then maybe it'll all work.. 
that's the plan anyway..

cheers,


-- 
J
Web Developer

Eight Degrees Off Centre
http://www.eightdegrees.com.au/




mod_perl, OpenPGP Math::Pari

2002-02-04 Thread Jason Galea


OK, this has got me stumped.. so it just has to be something obvious..

I am attemting to use Crypt::OpenPGP to encrypt some data. To do this I 
need to generate some keys.. (ok that's all obvious too..get to the 
point, J)

On my development server everything runs fine producing useable public  
private keys. I've added a subroutine to my lil web system (running on 
mod_perl) that takes the required arguements and feeds them to OpenPGP's 
keygen method. On our production server this dies with the message 
[error] PARI:  ***   incorrect type in comparison. at 
/usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 683.

Now what's really got me stumped, is feeding the same sub with the same 
arguements in an independant perl script run from the command line on 
the production (and development) server runs fine and produces usable 
public  private keys.

My only guess is that somehow mod_perl on the production server is using 
  a different library of modules than perl run from the command line is 
using but I can't believe that I wouldn't have had troubles long ago if 
that were the case.

Anyone? any clues on where to start looking?

Development Apache/1.3.20 (Unix) mod_perl/1.25
Production  Apache/1.3.20 (Unix) mod_perl/1.26

cheers

-- 
J
Web Developer

Eight Degrees Off Centre
http://www.eightdegrees.com.au/




Re: Apache::MP3::Skin and PerlSetVar

2001-11-28 Thread Jason Galea

Patrick Buckingham wrote:

 I just install Apache::MP3 and it works fine but if I try to use ::Skin
 I get these messages for PerlSetVar
 
 PerlSetvar takes two arguments Perl config var and value This does
 this with ::Sortlist also. But with the straight MP3 modules I can use
 PerlSetVar 
 
   SetHandler perl-script
   PerlHandler Apache::MP3::Skin
   PerlSetVar  CacheDir   /usr/tmp/mp3_cache
   PerlSetVar  SortFieldsAlbum,Title,-Duration
   PerlSetVar HomePath /sounds   # optional
   PerlSetVar DefaultSkin default.tmpl   # required
 
 This is the config
 
 
 Thanks,
 
   Patrick
 
 .
 
 


try taking out the comments, ie # optional  # required (or just 
move them to a separate line) - it's worked for me before.. I don't 
think PerlSetVar recognises the # as the start of a comment.



-- 
J
Web Developer

Eight Degrees Off Centre
http://www.eightdegrees.com.au/