Apache::AuthenCache for mod_perl 1.99

2004-09-13 Thread Dan Sully
I've made a quick port of this to mod_perl 1.99 - surprised to not see it already.
Attached a diff and the full module.
-D
--
"A good messenger expects to get shot." --Larry Wall
# $Id: AuthenCache.pm,v 1.6 2001/01/03 19:17:56 cgilmore Exp $
#
# Author  : Jason Bodnar, Christian Gilmore
# Created On  : Long ago
# Status  : Functional
#
# PURPOSE
#User Authentication Cache
#
###

# Package name
package Apache::AuthenCache;

# Required libraries
use strict;

use mod_perl;
use constant MP2 => $mod_perl::VERSION < 1.99 ? 0 : 1;

BEGIN { 

if (MP2) {

require Apache2;
require Apache::Access;
require Apache::RequestRec;
require Apache::RequestUtil;
require Apache::RequestIO;
require Apache::ServerUtil;
require Apache::Const;
Apache::Const->import(-compile => qw(OK AUTH_REQUIRED DECLINED DONE));

require APR::Table;

} else {

require Apache;
require Apache::Constants;
Apache::Constants->import(qw(OK AUTH_REQUIRED DECLINED DONE));
}
}

use Apache::Log ();
use IPC::Cache;

# Global variables
$Apache::AuthenCache::VERSION = '0.1';

###
###
# handler: hook into Apache/mod_perl API
###
###
sub handler {
my $r = shift;

# only the first internal request
unless ($r->is_initial_req()) {
return MP2 ? Apache::OK() : Apache::Constants::OK();
}

# Get configuration
my $nopasswd = $r->dir_config('AuthenCache_NoPasswd') || 'off';
my $encrypted= $r->dir_config('AuthenCache_Encrypted') || 'on';
my $casesensitive= $r->dir_config('AuthenCache_CaseSensitive') || 'on';
my $cache_time_limit = $r->dir_config('AuthenCache_CacheTime') || 900;
my $auth_name= $r->auth_name();

# Clear for paranoid security precautions
my %notes = ('AuthenCache' => 'miss');

if (MP2) {

my $table = APR::Table::make($r->pool(), 1);
   $table->set(%notes);

$r->notes($table);

} else {

$r->notes(%notes);
}

# Get response and password
my ($res, $passwd_sent) = $r->get_basic_auth_pw();
return $res if $res; # e.g. HTTP_UNAUTHORIZED

# If the user left the username field blank, we must catch it and DECLINE
# for the downstream handler
my $user_sent = MP2 ? $r->user() : $r->connection()->user();

unless ($user_sent) {
return MP2 ? Apache::DECLINED() : Apache::Constants::DECLINED();
}

$r->log->debug("handler: username=$user_sent");

# Do we want Windows-like case-insensitivity?
if ($casesensitive eq 'off') {
$user_sent = lc($user_sent);
}

# Create or retreive the cache (if already created)
# Use the Realm name ($auth_name) for different caches for each realm
my $cache  = IPC::Cache->new({ namespace => $auth_name });
my $passwd = $cache->get($user_sent);

# User not in cache
unless ($passwd) {
$r->log->debug("handler: user/group not in cache; returning DECLINED");
return MP2 ? Apache::DECLINED() : Apache::Constants::DECLINED();
}

# Is the user in the cache
$r->log->debug("handler: using cached passwd for $user_sent");

# Allow no password
if ($nopasswd eq 'on' and not length($passwd)) {

$r->log->debug("handler: no password required; returning DONE");

# Must return DECLINED so that user has a chance to put in no password
return MP2 ? Apache::DONE() : Apache::Constants::DONE();
}

# If nopasswd is off, reject user
unless (length($passwd_sent) and length($passwd)) {

$r->log->debug("handler: user $user_sent: empty password(s) rejected" 
.  $r->uri);

# Must return DECLINED so that user has a chance to put in a new 
password
return MP2 ? Apache::DECLINED() : Apache::Constants::DECLINED();
}

# Is crypt is needed
if ($encrypted eq 'on') {
my $salt = substr($passwd, 0, 2);
$passwd_sent = crypt($passwd_sent, $salt);
}

unless ($passwd_sent eq $passwd) {

$r->log->debug("AuthenCache::handler: user $user_sent: password 
mismatch" .  $r->uri);

# Must return DECLIN

Re: Apache::AuthenCache for mod_perl 1.99

2004-09-13 Thread Dan Sully
* Stas Bekman <[EMAIL PROTECTED]> shaped the electrons to say...
Dan, you probably want to CC the authors, in case they are not listening 
here... so it'll end up on CPAN... Thanks.
Already done - we'll see if they're listening elsewhere.
-D
--
"A good messenger expects to get shot." --Larry Wall
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Apache::Cookie->new/bake broken - mod_perl 2

2004-11-10 Thread Dan Sully
I'm running into an interesting problem, using Apache::SessionManager.
My first request to the webpage successfully generates a cookie, and I see it
in my browser's jar. The next response though, the Apache::Cookie->fetch()
gets a truncated cookie (md5 sum), and can't tie to the previous session and
creates a new one. Now, you may think this is a problem with fetching, and not 
baking.
But if I make Apache::SessionManager use CGI::Cookie for the baking, and
continue to use Apache::Cookie for the fetch, everything works fine. A
debug print ->as_string() of the Apache::Cookie->new/bake shows valid data.
I'm going to debug this further - but if anyone has ideas, it'd be most 
appreciated.
This is Apache 2.0.52, mod_perl 1.99_17, libapreq2-2.04-dev (latest).
This happens in every browser I use.
Thanks.
-D
--
 I'm partial to lipstick lesbians, I guess, but I suppose that's
a little like saying you're partial to blue when you're blind.
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: Apache::Cookie->new/bake broken - mod_perl 2

2004-11-11 Thread Dan Sully
* Joe Schaefer <[EMAIL PROTECTED]> shaped the electrons to say...
My first request to the webpage successfully generates a cookie, and I see it
in my browser's jar. The next response though, the Apache::Cookie->fetch()
gets a truncated cookie (md5 sum), and can't tie to the previous session and
creates a new one. Now, you may think this is a problem with fetching,
and not baking. 

But if I make Apache::SessionManager use CGI::Cookie for the baking, and
continue to use Apache::Cookie for the fetch, everything works fine. A
debug print ->as_string() of the Apache::Cookie->new/bake shows valid data.
What is the length of the session cookie you're baking?  Set-Cookie
headers aren't supposed to exceed 4KB.
Quite under 4k - it's just a 32bit MD5 hash from 
Apache::Session::Generate::MD5
If that's not the problem, do you notice any difference in the
->as_string() outputs for Apache::Cookie versus CGI::Cookie?
No. Which confuses me all the more.
-D
--
bacon happens.
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


mod_perl2 crash with php loaded.

2004-11-23 Thread Dan Sully
So this just started happening, and I'm trying to track down why.
I recently upgraded to BerkelyDB 4.3.21, and now mod_perl (1.99_17 or SVN
Trunk) and PHP (4.3.9 or 5.0.2) don't like to play together anymore. I can
have one or the other loaded, but not both. Downgrading to the previous
version of BDB doesn't fix this. Core dumps every time - here's the backtrace:
#0  0xb773c30b in Perl_gv_fetchmeth () from 
/pkg/httpd-2.0.52/modules/mod_perl.so
(gdb) bt
#0  0xb773c30b in Perl_gv_fetchmeth () from 
/pkg/httpd-2.0.52/modules/mod_perl.so
#1  0xb773c7bf in Perl_gv_fetchmeth_autoload () from 
/pkg/httpd-2.0.52/modules/mod_perl.so
#2  0xb773ee27 in Perl_Gv_AMupdate () from /pkg/httpd-2.0.52/modules/mod_perl.so
#3  0xb773f195 in Perl_gv_handler () from /pkg/httpd-2.0.52/modules/mod_perl.so
#4  0x0063 in ?? ()
(gdb) q
I've tried compiling with MP_DEBUG=1 to get line numbers or more info, but no 
luck there.
perl is 5.8.3, no threads. Apache 2.0.52 prefork. Linux based system.
Thanks for any direction you can point me in.
-D
--
Minds are like parachutes... they work best when open.
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: mod_perl2 crash with php loaded.

2004-11-23 Thread Dan Sully
* Stas Bekman <[EMAIL PROTECTED]> shaped the electrons to say...
Nope - I only have one version of BDB on my system, and both are linked
against the same. As is Apache itself.
What about your perl? ldd libperl.so?
My perl doesn't have a shared lib - static only. And I don't compile in bdb 
to perl at any rate.
-D
--
There was supposed to be a big kaboom.
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: mod_perl2 crash with php loaded.

2004-11-23 Thread Dan Sully
* Stas Bekman <[EMAIL PROTECTED]> shaped the electrons to say...
To submit problems reports please always following these guidelines:
http://perl.apache.org/bugs/
Ok
Most likely php and perl are linked against different -ldb versions and 
that's why you have the problem. recompile both with the same library and 
chances are that this will resolve your problem.
Nope - I only have one version of BDB on my system, and both are linked
against the same. As is Apache itself.
-D
--
There was supposed to be a big kaboom.
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: mod_perl2 crash with php loaded.

2004-11-23 Thread Dan Sully
* Stas Bekman <[EMAIL PROTECTED]> shaped the electrons to say...
My perl doesn't have a shared lib - static only. 
ldd perl then.
Nope.
And I don't compile in bdb to perl at any rate.
Yes, but what about 3rd party modules. e.g. DB::* (NDBM.so, etc.)?
Only DB_File & BerkeleyDB. Both are linked against the new BDB lib.
Like I said - that's the only change I've made - that doesn't mean it's
what's actually causing the problem. How can I get gdb to give me a line
number on a core dump? I'm compiling MP with MP_DEBUG, which sets -g. For
everything else, that's good enough.
-D
--
There was supposed to be a big kaboom.
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: Apache::Request

2005-01-14 Thread Dan Sully
* John D Groenveld shaped the electrons to say...
I've had no problems so far with libapreq2-2.04-dev, but with light usage.
http://httpd.apache.org/apreq/>
$ /opt/apache2/perl-5.8.6/bin/perl -MApache::Request -le 'print 
$Apache::Request::VERSION' 2.04-dev
There are a few critical fixes related to cookie handling which haven't made
it into an official "release" yet. I've also found a bug where
Apache::Request used to let you set ->status(), but doesn't anymore.
-D
--
They're techno trousers, ex-NASA, fantastic for walkies!


Re: shared memory

2005-03-15 Thread Dan Sully
* Perrin Harkins shaped the electrons to say...
On Tue, 2005-03-15 at 14:11 -0500, Jonathan Vanasco wrote:
sqlite3 is closer in speed to bdb than mysql, and offers more of the 
'accessibility' that mysql offers.
i find myself using it much more than bdb lately
SQLite2 was pretty slow when I benchmarked it for simple hash-like
usage.  MySQL beat it by miles.  If the new one is faster, I'll have to
try my benchmarks again.  Does it do anything fancier for concurrency
than locking the whole database like the older versions did?
We're finding that sqlite3 / DBD::SQLite is much faster than MySQL now.
It has a slightly better locking system, where you can upgrade the locks to
an exclusive writer and many readers. But it still locks the whole database.
-D
--
 what're the units of the coefficient of agnosticity? I don't knows per 
hour?


Re: Apache::Request

2005-03-27 Thread Dan Sully
* D. Hageman shaped the electrons to say...
You can get Apache::Request for mod_perl 2 from the apache website.
Please note that if you use the ->upload feature that you might want to 
pull down a version out of svn as it is buggy in the released tarball.
Speaking of - when will there be another release of Apache::Request?
-D
--
"This basis of our government being the opinion of  the people, the very first 
object should be to keep that right;
and were it left to me to decided whether we should have a government without 
newspapers, or newspapers without a
government, I should not hesitate a moment to prefer the latter." - Thomas 
Jefferson


Re: [UPGRADE]: Apache::DBI 0.96 for mod_perl 2.0 RC5

2005-06-23 Thread Dan Sully

* Philip M. Gollucci shaped the electrons to say...


http://p6m7g8.net/Apache-DBI-0.96.tar.gz
was supposed to be 
http://p6m7g8.net/Apache-DBI/Apache-DBI-0.96.tar.gz


I symlinked it in my site so both should be valid now.


Ask - Can this version be released to CPAN?

Apache::DBI as shipped from CPAN is completely useless on MP2.

-D
--
vacation (n) : an extended trip away from home in search of inconvenient ways 
to connect to the Internet.


Re: [UPGRADE]: Apache::DBI 0.96 for mod_perl 2.0 RC5

2005-06-24 Thread Dan Sully

* Jan Eden shaped the electrons to say...


Ask - Can this version be released to CPAN?

Apache::DBI as shipped from CPAN is completely useless on MP2.



It is not. With the help of this list, I have been able to get it up


Exactly. _With the help of this list_.

One shouldn't need that. One should be able to download Apache::DBI from
CPAN, and have it just work, according to all the documentation that's out 
there.

Given that this is really a critical piece of infrastructure, I would go so
far as to say it should be packaged with MP2 itself. 


-D
--
"They that can give up essential liberty to obtain a little temporary safety deserve 
neither liberty nor safety." - Benjamin Franklin


UDP Protocol Handler?

2005-07-20 Thread Dan Sully

Has anyone written a protocol handler for UDP?

If so - could you share any examples?

Thanks.

-D
--
Indifference will certainly be the downfall of mankind, but who cares?


Re: UDP Protocol Handler?

2005-08-03 Thread Dan Sully

* Will Whittaker shaped the electrons to say...


Yeah, I'm working on this right now, using Gozer's patch.  I'm at OSCON right
now, so if you can find me, we can talk about it.


Thanks - unfortunately I'm not at OSCon - I can wait though. :)

-D
--
 and I also learned that a meat vortex takes meat away from you.