AuthcNDS module - some feedback please.

1999-11-30 Thread Scott Fagg

I have cobbled together a working AuthcNDS module that allows me to authenticate users 
against the netware NDS tree within our office. 

My apache server is running on a RH5.2 box with some of the Caldera netware RPMs 
installed.
Server Version: Apache/1.3.9 (Unix) mod_fastcgi/2.2.2 PHP/3.0.12 mod_perl/1.21

The module doesn't communicate directly with the NDS, but instead uses a command line 
tool (nwlogin) to do the password checking. Unfortunately spawning that process is 
rather time consuming so once the user is authenticated, the module sets a cookie 
based on the username, IP, a 'secret' and MD5 hashes it. 

The module, when asked to authenticate a user, first checks for that cookie. If it 
doesn't exist, it then goes to the NDS.

I used one of the Apache auth-cookie modules as a starting point.

I need to fix up the spawning of the nwlogin process as i think the users password 
would be visible in the output from 'ps auxw'. Perhaps i should pipe the password to 
nwlogin instead of passing it as a command line arguement.

Any other suggestions for tidying it up? Have i made any glaring mistakes? (this is my 
first mod_perl effort)

Unfortunately it is not self contained and is reliant upon the nwlogin tool that comes 
with the Caldera RPMs.

===
package Apache::AuthcNDS;
#
# file: Apache/AuthcNDS.pm
#
# performs authentication against the NDS and makes use of cookies to cache
# authentication info so that we dont have to reauth for every single hit
# which can be quite time consuming as the auth process requires the use of
# an external shell program.
#

use strict;
use MD5;
use CGI::Cookie;
use Apache::Constants qw(:common);

my $r;

sub handler 
{
$r = shift;
my ($cookie , $user, $auth_cookie , $authstring, $md5check, $newcookie , 
$cookie_text);

my ($res, $sent_pw) = $r->get_basic_auth_pw;
return $res if $res != OK; 

$user = $r->connection->user;

#
# the secret is the only bit of text not derived from the user
# this stops them from creating a fake cookie ( i hope )
# 

my $secret = 'elegiac';

#
# search thru the cookies for ours...
# if our cookie shows up, they must have already authenticated
# if so i can avoid the expensive NDS lookup
#

($auth_cookie) = ( ($r->header_in("Cookie") || "") =~ /Auth_NDS_ID=([^;]+)/);

if ($auth_cookie) 
{
$md5check = join('-', $user , &MakeHash($user , $r->auth_type , 
$r->auth_name , $secret));

if ($md5check eq $auth_cookie)
{ return OK; }
}

# failing that we have to actually check their credentials
# against the NDS

if (!&auth_nds ( $user , $sent_pw )) 
{
# authentication failed !
# log that and clear the cookie on the users machine
$r->note_basic_auth_failure;
$r->log_reason("Authentication of [$user] against NDS 
failed.", $r->filename);
$r->err_headers_out->{'Set-Cookie'}  = "Auth_NDS_ID=";
return AUTH_REQUIRED;
} 
else
{
# authentication succeeded, so let them know, and set the 
cookie for future reference

$cookie_text = join('-', $user , &MakeHash($user , 
$r->auth_type , $r->auth_name , $secret));
$newcookie = new CGI::Cookie(-name => 'Auth_NDS_ID',
-value => $cookie_text);

$r->err_headers_out->{'Set-Cookie'}  = $newcookie;
return OK;
}
}

#==
# make up the hash to be placed in the cookie (hash cookies? ;)
#==
sub MakeHash()
{

my ($u , $at , $an , $d) = @_;

my $authstring = $u . $at . $an . $d;

return MD5->hexhash($authstring)
}

#==
# check the username and password against the NDS
#==
sub auth_nds()
{
my ($user_abs , $current, $authenticated);

my ($user,$pass) = @_;

# dont process if username or password is blank 
if (!$user || !$pass) { return 0;}

# check to see if someone else is logged in

$current = `nwwhoami`;

# if someone else is currently logged in then note that and wait 1 
second
if ($current) { $r->log_reason ("someone already logged in. sleeping 
for 1s." , $r->filename) ; sleep 1; }

 

Re: Apache::ASP (Newbie Install Issues)

1999-11-30 Thread Joshua Chamas

"N. Blaine Morgan" wrote:
>
>  ># Generic apache directives to make asp start ticking.
>  >
>  >   SetHandler perl-script
>  >   PerlHandler Apache::ASP
>  >   PerlSetVar Global /tmp
>  >
> 
> When I commented out the > # PerlSetVar Global /tmp
> 
> I it worked.
> 
> I though .htaccess overrode settings in the srm.conf
> 

I glad you got it working.  It can be quite an ordeal
the first time. :(  The .htaccess doesn't do anything 
unless you have configured somewhere to enable .htaccess
with 

  AllowOverride All

I tried to put this in some visible place, check out:
http://www.nodeworks.com/asp/config.html , also the 
CONFIG section of 'perldoc Apache::ASP'
 
CONFIG

   Use with Apache. Copy the ./site/eg directory from the ASP installation 
to
   your Apache document tree and try it out! You have to put 

 AllowOverride All

   in your  config section to let the .htaccess file in the 
./site/eg
   installation directory do its work. 

   If you want a STARTER config file, just look at the .htaccess file in 
the
   ./site/eg directory. 

If you have any better ideas on how to document this, I'm 
all ears. 

-- Joshua
_
Joshua Chamas   Chamas Enterprises Inc.
NodeWorks >> free web link monitoring   Huntington Beach, CA  USA 
http://www.nodeworks.com1-714-625-4051



Re: Apache::ASP (Newbie Install Issues)

1999-11-30 Thread N. Blaine Morgan

At 07:57 PM 11/30/99 -0800, Joshua Chamas wrote:
>The global.asa will be found in Global, which you defined
>to be /tmp/asp.  If you want the ./site/eg stuff to work, you need
>to copy over its .htaccess file, or set your Global to .
>for starters.
>
>For more info, check out perldoc Apache::ASP
>or http://www.nodeworks.com/asp/
>
>-- Joshua

Ok, I the .htaccess file has been there all along.

I even recopied it with the command
(cd /usr/src/Apache-ASP-0.16/site/eg; tar cf - .) | tar -xvf -

< Yeah I Figured it out ->

 From the Readme

 >Here is a Location directive that you might put in a *.conf Apache
 >configuration file. Set the optional ones if you want, the defaults are
 >fine. The settings are documented below.
 >
 ># Generic apache directives to make asp start ticking.
 >
 >   SetHandler perl-script
 >   PerlHandler Apache::ASP
 >   PerlSetVar Global /tmp
 >

When I commented out the > # PerlSetVar Global /tmp

I it worked.

I though .htaccess overrode settings in the srm.conf



N. Blaine Morgan  Given God and time nothing is impossible
[EMAIL PROTECTED]

-=> Imagination is more important than knowledge.  -Albert Einstein <=- 



Re: User registration/login module...

1999-11-30 Thread Bill Desjardins

Arnel,

I am in the process of writing the same login methods you want. It is
mostly done and does not use Apache for basic Auth. The site completely
generated from A MySQL database and uses a TransHandler to sort out the
authorization. I do the Auth in the TransHandler so I can rewrite the URL
as soon as possible in the request. I wrote all the auth code myself and
it probably isnt the best, but you can check it out and use it of youd
like. Without any warranty of course ;-) Also, it is constantly changing
from daya to day with updates just to let you know.

http://web.carracing.com/Apache_Car

Good Luck,

Bill

===
Bill Desjardinshttp://www.carracing.com
[EMAIL PROTECTED]Tel: 305.205.8644
FREE Homepages for Racers and Race Tracks!!

On Tue, 30 Nov 1999, Arnel Estanislao wrote:

> Hello,
> 
> Is there a "best way" to accomplish the following user registration/login 
> system:
> 
> - User attempts to visit a password-protected section of the site.
> - If user is not yet authenticated (using DBI/DBD::Pg), user is redirected 
> to a login/registration page.  (We are NOT using Basic authentication).
> - User logs in or registers.
> - User is given a session key and is taken to the URL they were originally 
> trying to visit.
> - Session expires after X amount of time.
> 
> We're thinking about using "Authen::Ticket" or "Apache::AuthCookie", but 
> wanted to get some real-world validation of our approach, or find out about 
> other modules that have been used to successfully implement the above.
> 
> Thanks!!!
> 
> Arnel
> 
> __
> Get Your Private, Free Email at http://www.hotmail.com
> 



Re: User registration/login module...

1999-11-30 Thread Ken Williams

I do that with Apache::AuthCookie, and that seems to be the standard thing to
do with it.  Works fine.  I've never used Authen::Ticket, though.


[EMAIL PROTECTED] (Arnel Estanislao) wrote:
>Hello,
>
>Is there a "best way" to accomplish the following user registration/login 
>system:
>
>- User attempts to visit a password-protected section of the site.
>- If user is not yet authenticated (using DBI/DBD::Pg), user is redirected 
>to a login/registration page.  (We are NOT using Basic authentication).
>- User logs in or registers.
>- User is given a session key and is taken to the URL they were originally 
>trying to visit.
>- Session expires after X amount of time.
>
>We're thinking about using "Authen::Ticket" or "Apache::AuthCookie", but 
>wanted to get some real-world validation of our approach, or find out about 
>other modules that have been used to successfully implement the above.
>
>Thanks!!!
>
>Arnel
>
>__
>Get Your Private, Free Email at http://www.hotmail.com
>

  ------
  Ken Williams Last Bastion of Euclidity
  [EMAIL PROTECTED]The Math Forum




Re: Apache::ASP (Newbie Install Issues)

1999-11-30 Thread Joshua Chamas

"N. Blaine Morgan" wrote:
> 
> 
> Alias /pasp/ /usr/home/httpd/pasp/
> 
>  DirectoryIndex index.html index.shtml index.cgi
>  SetHandler perl-script
>  PerlHandler Apache::ASP
>  PerlSetVar Global /tmp/asp
> 
> 
> Ok, now for my current snag..
> 
> I put the example stuff in /usr/home/httpd/pasp/eg
> 
> And it almost works but after much testing I have concluded that
> nothing in global.asa is defined
> when  httpd://myserver.com/pasp/eg/index.html is accessed/executed.
> 

The global.asa will be found in Global, which you defined
to be /tmp/asp.  If you want the ./site/eg stuff to work, you need
to copy over its .htaccess file, or set your Global to . 
for starters. 

For more info, check out perldoc Apache::ASP
or http://www.nodeworks.com/asp/

-- Joshua
_
Joshua Chamas   Chamas Enterprises Inc.
NodeWorks >> free web link monitoring   Huntington Beach, CA  USA 
http://www.nodeworks.com1-714-625-4051



User registration/login module...

1999-11-30 Thread Arnel Estanislao

Hello,

Is there a "best way" to accomplish the following user registration/login 
system:

- User attempts to visit a password-protected section of the site.
- If user is not yet authenticated (using DBI/DBD::Pg), user is redirected 
to a login/registration page.  (We are NOT using Basic authentication).
- User logs in or registers.
- User is given a session key and is taken to the URL they were originally 
trying to visit.
- Session expires after X amount of time.

We're thinking about using "Authen::Ticket" or "Apache::AuthCookie", but 
wanted to get some real-world validation of our approach, or find out about 
other modules that have been used to successfully implement the above.

Thanks!!!

Arnel

__
Get Your Private, Free Email at http://www.hotmail.com



Apache::ASP (Newbie Install Issues)

1999-11-30 Thread N. Blaine Morgan

Ok, I have mod_perl installed
I then picked up Apache::ASP from CPAN built it and all the required modules.

I have the following entries in my Apache configuration files


AllowOverride All
DirectoryIndex index.html index.shtml index.cgi
Options ExecCGI


Alias /pasp/ /usr/home/httpd/pasp/

 DirectoryIndex index.html index.shtml index.cgi
 SetHandler perl-script
 PerlHandler Apache::ASP
 PerlSetVar Global /tmp/asp


Ok, now for my current snag..

I put the example stuff in /usr/home/httpd/pasp/eg

And it almost works but after much testing I have concluded that 
nothing in global.asa is defined 
when  httpd://myserver.com/pasp/eg/index.html is accessed/executed.

Thanks for any help..





N. Blaine Morgan  Given God and time nothing is impossible
[EMAIL PROTECTED]

-=> Imagination is more important than knowledge.  -Albert Einstein <=- 



Re: Modperl script doesn't increment access log

1999-11-30 Thread G.W. Haywood

Hi there,

On Tue, 30 Nov 1999, Jim Goodwin wrote:

> Because of the nature of mod perl, we only get one 'hit' in the
> Stronghold access logs when the .pl scripts are run. 

Yup, that's right, unless the script doesn't exist, in which case my
acces_log looks like this for example:

[30/Nov/1999:15:31:53 +] "GET /cgi-bin/JOSvisitlog.pl HTTP/1.0" 404 225

or unless the request is POST in which case I get for example

[30/Nov/1999:18:59:23 +] "POST /cgi-bin/JOSplaceorder.pl HTTP/1.0" 200 2629

It says in the Eagle book (page 360) that there are a number of log 
handlers on CPAN including Apache::DBILogger and Apache::Traffic.

It says also (page 364) that you should look at Apache::DBILog and
Apache::DBILogConfig ``before rolling your own''.

Any use?

Kind regards,
Ged Haywood.

PS: I sell the Eagle Book.  And all the others.



RE: How to pass and process a large array of strings in HTMEmbperl

1999-11-30 Thread Gerald Richter

>
> I'm trying to pass a large array of strings to a Embperl document
> whose sole
> purpose is to display fatal errors.  The method errors() returns
> an array reference
> to an array that contains the following strings:
>[..]
> I've tried the following:
>
>  href="http://[+$ENV{SERVER_NAME}+]/error.epl?msg=[+$a->errors()+]"
> >Errors
>[..]
>
>  href="http://localhost/error.epl?msg=Mail+address+error:+Missing+s
> treet+address=
> Mail+address+error:+Missing+city/province&Mail+address+error:+Inva
> lid+or+missing+
> country=Mail+address+error:+Invalid+or+missing+zip+code&Missing+or
> +invalid+home+phone+
> number=">Errors
>

Embperl converts your array ref to name/values pairs. (Watch for the = and &
in the url).

If you want to transfer it as one string, just join the strings together.
e.g.

href="http://[+$ENV{SERVER_NAME}+]/error.epl?msg=[+ join (',',
@{$a->errors()}) +]"

Gerald




-
Gerald Richterecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post:   Tulpenstrasse 5 D-55276 Dienheim b. Mainz
E-Mail: [EMAIL PROTECTED] Voice:+49 6133 925151
WWW:http://www.ecos.de  Fax:  +49 6133 925152
-



Re: Modperl script doesn't increment access log

1999-11-30 Thread darren chamberlain

Hi Jim,

One thing you could try--this is a hack, not a solution--is to use Apache::Log,
create a subroutine to be used as a PerlLogHandler, and use $r->push_handler
to make sure it gets called. Or create a separate module and set that as the
PerlLogHandler in the conf file.

Or, even more of a hack, use $r->log->warn("message") (or $r->log->error() or
whatever) and do it yourself.

darren

Jim Goodwin ([EMAIL PROTECTED]) wrote:
> Hello,
> 
> I posted this previously, but I may not have worded it properly. I'll
> try again here.. Sorry for the inconvenience - I won't post it again.
> 
> We are running a Stronghold server 2.4.2 and mod perl 1.19. Our mod perl
> scripts are run as .pl,  and they work fine.
> 
> Because of the nature of mod perl, we only get one 'hit' in the
> Stronghold access logs when the .pl scripts are run. After that, once
> they're in memory subsequent requests do not appear in the access log
> (although the images etc that the .pl scripts call do appear in the
> logs).
> 
> Would adding something like: use Apache::Constants to the .pl script
> result in each request being logged?
> 
> Sorry if this has been answered elsewhere, or if it's too obvious. I
> could not find information on this anywhere.
> 
> If anyone can help or point me in the right direction I would appreciate
> it. Thanks
> 
> Jim Goodwin
> 

-- 
Paul's Law: You can't fall off the floor.



Modperl script doesn't increment access log

1999-11-30 Thread Jim Goodwin

Hello,

I posted this previously, but I may not have worded it properly. I'll
try again here.. Sorry for the inconvenience - I won't post it again.

We are running a Stronghold server 2.4.2 and mod perl 1.19. Our mod perl
scripts are run as .pl,  and they work fine.

Because of the nature of mod perl, we only get one 'hit' in the
Stronghold access logs when the .pl scripts are run. After that, once
they're in memory subsequent requests do not appear in the access log
(although the images etc that the .pl scripts call do appear in the
logs).

Would adding something like: use Apache::Constants to the .pl script
result in each request being logged?

Sorry if this has been answered elsewhere, or if it's too obvious. I
could not find information on this anywhere.

If anyone can help or point me in the right direction I would appreciate
it. Thanks

Jim Goodwin




How to pass and process a large array of strings in HTMEmbperl

1999-11-30 Thread Erich L. Markert

I'm trying to pass a large array of strings to a Embperl document whose sole 
purpose is to display fatal errors.  The method errors() returns an array reference
to an array that contains the following strings:

Mail address error: Missing street address
Mail address error: Missing city/province
Mail address error: Invalid or missing zip code
Work address error: Invalid union name
Missing or invalid home phone number

I've tried the following:

http://[+$ENV{SERVER_NAME}+]/error.epl?msg=[+$a->errors()+]">Errors

It works to the point that it returns all the errors messages in this link but when I 
click on the link error.epl doesn't seem to receive all the strings.  The actual 
expansion of this becomes:

http://localhost/error.epl?msg=Mail+address+error:+Missing+street+address=
Mail+address+error:+Missing+city/province&Mail+address+error:+Invalid+or+missing+
country=Mail+address+error:+Invalid+or+missing+zip+code&Missing+or+invalid+home+phone+
number=">Errors

If in error.epl I have the following:  [+ $fdat{msg} +] nothing is displayed.

TIA.
--
__
Mr. Erich L. Markert [EMAIL PROTECTED]
Computer Learning Center TEL (914)422-4328
Pace University
1 Martine Ave
White Plains, New York 10606-1932

Those who do not understand Unix are condemned to reinvent it, poorly.
-- Henry Spencer



Re: Eagle Book - mod_hello.c, hello.pl :)

1999-11-30 Thread Michael Dearman



Gerd Kortemeyer wrote:
> 
> Michael Dearman <[EMAIL PROTECTED]> wrote:
> 
> > I've come close to figuring this one out buy following some of the
> > Hello $ENV{REMOTE_HOST}
> >

> Stas Bekman wrote:
> 
> > This is an easy prove that %ENV is set (while not all variables are
> > present as with mod_cgi, particularly REMOTE_HOST isn't there...)

Yes, there's a 'printenv' script in the cgi-bin dir.

>From http://www.apache.org/docs/upgrading_to_1_3.html

> REMOTE_HOST CGI variable changed. In Apache 1.2 and earlier, the REMOTE_HOST 
>environment variable made
> available to CGI scripts was set to either the full DNS name of the client, or else 
>to the client's IP
> address if the name was not known. This behaviour differed from that specified by
> the CGI specification, which defines this variable as being NULL if the name isn't 
>known. In Apache 1.3, we
> have made this correction. REMOTE_ADDR always contains the client's IP address, but 
>REMOTE_HOST is only
> defined when the server has been able to determine the client's DNS name.

>  
> I think that is what you are seeing, rather than any problem with the
> environment in general.
> 
> - Gerd.

[the >'s aren't correct. Tried to reformat to make clearer and properly
acknowledge the help]

Thanks!!

That was it. Specifically - I don't have DNS set up on my home network.
REMOTE_ADDR did the trick.
And thanks for pointing out those resources. Should help with other
problems with examples in the Book.

*Saaalute*
Michael Dearman



Re: Limitations of DBI::ProxyServer (was: pool of DB connections?)

1999-11-30 Thread Jochen Wiedmann

"G.W. Haywood" wrote:

> I'd like to see a mode added to DBI::ProxyServer whereby a single
> server process serviced multiple clients in a round-robin manner.
> Obviously in this mode there's a risk of slow queries cloging up
> (blocking) the proxy, but for many applications it would still be
> very useful. Most significantly it would enable connect_cached to
> be used to implement a (kind-of) connection pool.
>
> I'm sure there must be someone out there willing to have a go at
> implementing it. It can't be that hard.

IMO the best was to do this is as follows:

  1.) Create a new subclass of the Net::Daemon module, that is based on
  the select() call. It could work like Net::Daemon in mode
--single.
  2.) Make RPC::PlServer working with that class.
  3.) You are done.

Bye,

Jochen


-- 
Jochen Wiedmann [EMAIL PROTECTED]
Life has brown and green eyes. :-)  +49 711 7168586




RE: Limitations of DBI::ProxyServer (was: pool of DB connections?)

1999-11-30 Thread Young, Geoffrey S.

Hi all...

I never took a look at the DBI::ProxyServer code, but I tried to whip up
something similar to the round-robin format that Tim suggests (to little
avail).  Although my reasons were different than the original start of this
thread, there were two bits of functionality I was trying to get at:

1) ability to limit the size of the pool - to maintain, say, a 5
user license across 20 http processes.
2) prespawining of the limited pool during httpd startup - similar
to Apache::DBI's connect_on_init()

Anyway, if someone is formally taking on this task, just thought I'd voice
some functionality that would be interesting, and that others might be
seeking as well...

--Geoff
a willing tester :)

> -Original Message-
> From: Tim Bunce [SMTP:[EMAIL PROTECTED]]
> Sent: Monday, November 29, 1999 5:04 PM
> To:   Randal L. Schwartz; [EMAIL PROTECTED]
> Cc:   Ed Park; Oleg Bartunov; modperl; dbi-users
> Subject:  Limitations of DBI::ProxyServer (was: pool of DB
> connections?)
> 
[snip]

> I'd like to see a mode added to DBI::ProxyServer whereby a single
> server process serviced multiple clients in a round-robin manner.
> Obviously in this mode there's a risk of slow queries cloging up
> (blocking) the proxy, but for many applications it would still be
> very useful. Most significantly it would enable connect_cached to
> be used to implement a (kind-of) connection pool.
> 
> Sadly I don't have the time to work on that. I'm not sure if Jochen
> Wiedmann (the author of DBI::ProxyServer, DBD::Proxy and the RPC::*
> modules they sit on) either has the time or is interested in doing the
> work. On the other hand, given how useful this functionality would be,
> I'm sure there must be someone out there willing to have a go at
> implementing it. It can't be that hard. [Volunteers welcome but please
> coordinate with Jochen and myself.]
> 
[snip]

> I hope that helps.
> 
> Tim.



Re: Embperl and header output

1999-11-30 Thread Erich L. Markert

The code works properly it was just a problem with
display_errors_as_html() method that was sending data to STDOUT.

Thanks to Gerald for showing me the error of my ways...  He pointed out
that I needed to set the EMBPERL_OPTIONS to redirect output to the
Embperl stream...  This solved my problem.

"G.W. Haywood" wrote:
> 
> Hi there,
> 
> On Mon, 29 Nov 1999, Erich L. Markert wrote:
> 
> > skeleton copy of the code below.
> >
> > [-
> > use Apache;
> > use Apache::Constants qw(REDIRECT);
> >
> > error checking and form validation going on here...
> >
> > $new_applicant and $errors are set appropriately here...
> > -]
> >
> > 
> > Untitled Document
> > 
> > 
> > [$ if( ( $new_applicant ) || ( $errors ) ) $]
> > [+ $application->display_errors_as_html() if( ($errors) || 
>($application->errors()) ); +]
> > [+ $student->display_errors_as_html() if( $student->errors()); +]
> >
> > http://$ENV{SERVER_NAME}/Nactel/new-application.epl! +]" 
>ENCTYPE="application/x-www-form-urlencoded">
> > 
> >
> > [$ else $]
> > [-
> > use Apache;
> > use Apache::Constants qw(REDIRECT);
> >
> > $req_rec->header_out("Location" => 
>qq!http://$ENV{SERVER_NAME}/Nactel/common/contact-info.epl?application_id=$fdat{'application_id'}&form_name=$fdat{'form_name'}!);
> > $req_rec->status(REDIRECT);
> > -]
> > [$ endif $]
> >
> > 
> > 
> >
> 
> The nesting in this example looks a bit strange to me.
> Have you taken this from your working (failing) code?
> 
> Kind regards,
> Ged.

--
__
Mr. Erich L. Markert [EMAIL PROTECTED]
Computer Learning Center TEL (914)422-4328
Pace University
1 Martine Ave
White Plains, New York 10606-1932

Those who do not understand Unix are condemned to reinvent it, poorly.
-- Henry Spencer



Re: Limitations of DBI::ProxyServer (was: pool of DB connections?)

1999-11-30 Thread G.W. Haywood

Hi there,

On Mon, 29 Nov 1999, Tim Bunce wrote:

> I'd like to see a mode added to DBI::ProxyServer whereby a single
> server process serviced multiple clients in a round-robin manner.
> Obviously in this mode there's a risk of slow queries cloging up
> (blocking) the proxy, but for many applications it would still be
> very useful. Most significantly it would enable connect_cached to
> be used to implement a (kind-of) connection pool.
> 
> I'm sure there must be someone out there willing to have a go at
> implementing it. It can't be that hard.

If it's not that hard, I volunteer to _have a look_ at it.  It looks
like the sort of thing I'm going to need to do if my plans don't kill
me in the execution.  But time is short, I'm new to mod_perl, I never 
did get very on with object orientation and I've never written an SQL
query.  Having said that, I'm completely comfortable with assembler, 
C and C++, perl, Btree/ISAM, screwing around in Unix and so on, so I 
can give it a go.

All I need is a reading list.

And - because I'm an Englishman - some time.

Kind regards,
Ged Haywood.



RE: Please Help

1999-11-30 Thread G.W. Haywood

Hi there, Thang,

On Mon, 29 Nov 1999, Thang Nguyen wrote:

> Yes I've followed your step, but I still got the same problem as before
> my dir structure is
> /usr/local/apache   linked to /usr/local/apache_1.3.9 and
> /usr/local/mod_perl linked to /usr/local/apache_1.3.9

Is this really what you have for the mod_perl directory?

I don't think that will work.  You need to have another
directory called /usr/local/mod_perl-1.21 
and a soft link  /usr/local/mod_perl

The mod_perl stuff goes in /usr/local/mod_perl-1.21 
not in /usr/local/apache_1.3.9

If you have put everything into /usr/local/apache then I think
you should start again, by deleting the entire directory tree.

That's probably a good idea at this stage in any case.  Is it
easy for you to get new copies of the distribution files?  If 
so do that, to make sure you are starting with the right stuff.

Here are the distribution files I used:
=

-rw-r--r--   1 ged  users 1514725 Oct 23 13:43 apache_1.3.9.tar.gz
-rw-r--r--   1 ged  users  327633 Oct 17 17:40 mod_perl-1.21.tar.gz

-rw-r--r--   1 ged  users  161352 Oct 17 17:57 CGI.pm-2.56.tar.gz
-rw-r--r--   1 ged  users   11099 Oct 17 19:29 Crypt-SSLeay-0.14.tar.gz
-rw-r--r--   1 ged  users   90875 Oct 17 19:31 Digest-MD5-2.09.tar.gz
-rw-r--r--   1 ged  users   13456 Oct 17 18:29 HTML-Pager-0.01.tar.gz
-rw-r--r--   1 ged  users   24205 Oct 17 17:58 HTML-Parser-2.23.tar.gz
-rw-r--r--   1 ged  users   31799 Oct 23 15:39 HTML-Template-0.96.tar.gz
-rw-r--r--   1 ged  users   18495 Oct 23 15:40 HTML-Validator-0.12.tar.gz
-rw-r--r--   1 ged  users   29286 Oct 17 19:34 IO-Socket-SSL-0.73.tar.gz
-rw-r--r--   1 ged  users   10682 Oct 17 18:26 MIME-Base64-2.11.tar.gz
-rw-r--r--   1 ged  users   38637 Oct 23 15:04 Net_SSLeay.pm-1.05.tar.gz
-rw-r--r--   1 ged  users   77886 Oct 17 18:24 URI-1.04.tar.gz
-rw-r--r--   1 ged  users   61041 Oct 17 20:03 libnet-1.0607.tar.gz
-rw-r--r--   1 ged  users  143058 Oct 17 18:10 libwww-perl-5.45.tar.gz
-rw-r--r--   1 ged  users 1569702 Oct 23 15:12 openssl-0.9.4.tar.gz
-rw-r--r--   1 ged  users 286 Oct 23 15:12 openssl-0.9.4.tar.gz.asc
-rw-r--r--   1 ged  users  60 Oct 23 15:13 openssl-0.9.4.tar.gz.md5
-rw-r--r--   1 ged  users 1211410 Oct 23 19:16 sgml-lib.tar.gz
-rw-r--r--   1 ged  users   62847 Oct 23 19:19 xhtml1.tgz
=

Here is the directory structure I used:

The permissions on many of the directories in this list are 
NOT SUITABLE for a server attached to the network.

=
/usr/local/

drwxr-xr-x   2 root root 1024 Nov 24  1993 etc/
drwxr-xr-x   2 root bin  1024 Nov 24  1993 sbin/
drwxr-xr-x  22 root root 1024 Jun  2  1994 man/
drwxr-xr-x   3 root root 1024 Apr  8  1999 doc/
drwxr-xr-x   2 root root 1024 Aug 18 16:57 src/
drwxr-xr-x   8 root root 1024 Oct 13 20:27 lib/
drwxr-xr-x   2 root root 1024 Oct 13 20:27 include/
drwxr-xr-x   2 root bin  2048 Oct 22 22:23 bin/
drwxr-xr-x   2 root root 1024 Oct 22 22:23 info/
drwxr-xr-x   4 root root 1024 Oct 22 22:23 share/
drwxr-xr-x  10 161  20   1024 Nov 25 22:03 apache_1.3.9/
drwxr-xr-x  25 ged  users1024 Nov 26 15:00 mod_perl-1.21/
drwxr-xr-x   8 root root 1024 Nov 25 19:04 ssl/
-rw-r--r--   1 ged  users 1514725 Oct 23 13:43 apache_1.3.9.tar.gz
lrwxrwxrwx   1 root root   12 Nov 25 18:16 apache -> apache_1.3.9/
lrwxrwxrwx   1 root root   13 Nov 25 18:18 mod_perl -> mod_perl-1.21/

/usr/local/apache_1.3.9
-rw-r--r--   1 root root26414 Aug 13 07:58 Makefile.tmpl
drwxr-xr-x  20 root root 1024 Nov 25 18:51 apache_perl_modules/
drwxr-xr-x   3 ged  nogroup  1024 Nov 29 18:50 cgi-bin/
drwxr-xr-x   2 root nogroup  1024 Nov 27 17:34 conf/
-rw-r--r--   1 root root 4701 Jul 29 19:12 config.layout
-rwx--   1 root root52983 Aug 14 09:29 configure*
drwxr-xr-x   3 root root 1024 Nov 25 21:42 docs/
drwxr-xr-x   3 ged  users1024 Nov 25 21:46 htdocs/
drwxr-xr-x   3 ged  users2048 Aug 16 19:28 icons/
drwxr-xr-x   2 root nogroup  1024 Nov 29 12:48 logs/
drwxr-xr-x  11 ged  users1024 Nov 25 20:48 src/

/usr/local/mod_perl_1.21
drwxr-xr-x   2 ged  users1024 Nov 25 20:47 Apache/
-rw-r--r--   1 ged  users   10894 Dec 22  1998 CREDITS
-rw-r--r--   1 ged  users  111251 Jul  3 00:33 Changes
drwxr-xr-x   2 ged  users1024 Nov 25 20:47 Connection/
drwxr-xr-x   2 ged  users1024 Nov 25 20:47 Constants/
drwxr-xr-x   2 ged  users1024

Re: Embperl and header output

1999-11-30 Thread G.W. Haywood

Hi there,

On Mon, 29 Nov 1999, Erich L. Markert wrote:

> skeleton copy of the code below.
> 
> [-
> use Apache;
> use Apache::Constants qw(REDIRECT);
> 
> error checking and form validation going on here...
> 
> $new_applicant and $errors are set appropriately here...
> -]
> 
> 
> Untitled Document
> 
> 
> [$ if( ( $new_applicant ) || ( $errors ) ) $]
> [+ $application->display_errors_as_html() if( ($errors) || ($application->errors()) 
>); +]
> [+ $student->display_errors_as_html() if( $student->errors()); +]
> 
> http://$ENV{SERVER_NAME}/Nactel/new-application.epl! +]" 
>ENCTYPE="application/x-www-form-urlencoded">
> 
> 
> [$ else $]
> [-
> use Apache;
> use Apache::Constants qw(REDIRECT);
> 
> $req_rec->header_out("Location" => 
>qq!http://$ENV{SERVER_NAME}/Nactel/common/contact-info.epl?application_id=$fdat{'application_id'}&form_name=$fdat{'form_name'}!);
> $req_rec->status(REDIRECT);
> -]
> [$ endif $]
> 
> 
> 
> 

The nesting in this example looks a bit strange to me.
Have you taken this from your working (failing) code?

Kind regards,
Ged.



Re: Eagle Book - mod_hello.c, hello.pl :)

1999-11-30 Thread Gerd Kortemeyer

Michael Dearman <[EMAIL PROTECTED]> wrote:

> I've come close to figuring this one out buy following some of the
> questions I've seen here. But...
>
> Hello $ENV{REMOTE_HOST}
>
> The remote host doesn't show. Printing out the %ENV, it tain't there.
> But where does Perl get it. From CGI.pm (which is installed) or where?

Stas Bekman wrote:

> This is an easy prove that %ENV is set (while not all variables are
> present as with mod_cgi, particularly REMOTE_HOST isn't there...)

To my knowledge, seems like all environment variables are present. We are
making extensive use of %ENV in our mod_perl content handlers - the $r's
subprocess environment is completely copied over to %ENV for the last stage of
the Apache request cycle (including additional session environment variables
you might have set along the way in your authentication handlers).

However, REMOTE_HOST is not even present for mod_cgi anymore, Apache changed
the way they handle that environment variable with Version 1.3, so that now it
is standards compliant and rather useless, see
http://www.apache.org/docs/upgrading_to_1_3.html


> REMOTE_HOST CGI variable changed. In Apache 1.2 and earlier, the REMOTE_HOST 
>environment variable made available to CGI scripts was set
>  to either the full DNS name of the client, or else to the client's IP address 
>if the name was not known. This behaviour differed from that specified by
>  the CGI specification, which defines this variable as being NULL if the name 
>isn't known. In Apache 1.3, we have made this correction.
>  REMOTE_ADDR always contains the client's IP address, but REMOTE_HOST is only 
>defined when the server has been able to determine the client's
>  DNS name.
>

I think that is what you are seeing, rather than any problem with the
environment in general.

- Gerd.



begin:vcard 
n:Kortemeyer;Gerd
tel;fax:(517) 432-2175
tel;work:(517) 432-5468
x-mozilla-html:FALSE
url:http://www.lite.msu.edu/kortemeyer/
org:LITE Lab;DSME MSU
version:2.1
email;internet:[EMAIL PROTECTED]
title:Instructional Technology Specialist
adr;quoted-printable:;;123 North Kedzie Labs=0D=0AMichigan State University;East Lansing;MI;48824;USA
fn:Gerd Kortemeyer
end:vcard



Re: Eagle Book, Camel Book :)

1999-11-30 Thread G.W. Haywood

Hi all,

On Tue, 30 Nov 1999, Ofer Inbar wrote:

>  "This may seem a bit weird, but that's okay, because it is weird."
> -- Larry Wall in perlref(1) man page, Perl 5.001

also Camel Book, 2nd edition, p. 37.

Kind regards,
Ged Haywood.



Re: Eagle Book - mod_hello.c, hello.pl :)

1999-11-30 Thread Stas Bekman

On Tue, 30 Nov 1999, Ofer Inbar wrote:

> Michael Dearman <[EMAIL PROTECTED]> wrote:
> > I've come close to figuring this one out buy following some of the
> > questions I've seen here. But...
> > 
> > Hello $ENV{REMOTE_HOST}
> > 
> > The remote host doesn't show. Printing out the %ENV, it tain't there.
> > But where does Perl get it. From CGI.pm (which is installed) or where?
> 
> %ENV is the environment.  CGI uses the environment to pass values from
> the web server to the CGI program.  If your script was running under
> CGI, the web server would put REMOTE_HOST, and other things, in the
> environment, before forking to run your script.  But you're not using
> CGI, you're using mod_perl.  

> The server isn't setting CGI environment variables 

This is not quite true. The server does sets the %ENV to emulate mod_cgi
in order to server modules like CGI.pm that expects these variables to be
available for their convenience. This setting adds an overhead, which you
might consider to reduce. For more info read:
http://perl.apache.org/guide/performance.html#PerlSetupEnv_Off

This is an easy prove that %ENV is set (while not all variables are
present as with mod_cgi, particularly REMOTE_HOST isn't there...)

PerlModule MyEnv

  SetHandler perl-script
  PerlHandler MyEnv


package MyEnv;
use Apache;
use Apache::Constants;
sub handler{ 
  my $r = shift; 
  print $r->send_http_header("text/plain"); 
  print map {"$_ => $ENV{$_}\n"} keys %ENV;
  return OK;
}
1;

http://localhost/env prints:

SERVER_SOFTWARE => Apache/1.3.10-dev (Unix) mod_perl/1.21_01-dev
DOCUMENT_ROOT => /home/httpd/docs
GATEWAY_INTERFACE => CGI-Perl/1.1
REMOTE_ADDR => 127.0.0.1
SERVER_PROTOCOL => HTTP/1.0
SERVER_SIGNATURE => Apache/1.3.10-dev Server at
inx006.iil.intel.com Port 80

REQUEST_METHOD => GET
QUERY_STRING => 
HTTP_USER_AGENT => Mozilla/4.7 [en] (X11; I; Linux 2.2.12-20 i686)
PATH => /bin:/usr/bin
HTTP_CONNECTION => Keep-Alive
HTTP_ACCEPT => image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
image/png, */*
REMOTE_PORT => 3167
SERVER_ADDR => 127.0.0.1
HTTP_ACCEPT_LANGUAGE => en
MOD_PERL => mod_perl/1.21_01-dev
SCRIPT_NAME => /env
SCRIPT_FILENAME => /home/httpd/docs/env
HTTP_ACCEPT_ENCODING => gzip
SERVER_NAME => inx006.iil.intel.com
REQUEST_URI => /env
HTTP_ACCEPT_CHARSET => iso-8859-1,*,utf-8
SERVER_PORT => 80
HTTP_HOST => localhost
SERVER_ADMIN => [EMAIL PROTECTED]

> and forking to run your script.  Your script is being run by
> a code module that is part of the web server.  You need to use Apache
> specific calls to get the information you need from the web server.
> mod_perl makes this easy to do using the "Apache request object":
> 
>  $request = Apache->request;
>  $connection = $request->connection;
>  $remote_ip = $connection->remote_ip;
> 
> Read more about the request object in the mod_perl documentation, to
> find out how to ask it for the other kinds of information a CGI script
> normally gets out of the environment.  Remember, mod_perl is not CGI
> (although with Apache::Registry it can look quite similar to CGI)
> 
>   --  Cos (Ofer Inbar)  --  [EMAIL PROTECTED]  [EMAIL PROTECTED]
>   --  Exodus Professional Services  --  [EMAIL PROTECTED]
>  "This may seem a bit weird, but that's okay, because it is weird."
> -- Larry Wall in perlref(1) man page, Perl 5.001
> 
> 



___
Stas Bekman  mailto:[EMAIL PROTECTED]www.singlesheaven.com/stas  
Perl,CGI,Apache,Linux,Web,Java,PC at  www.singlesheaven.com/stas/TULARC
www.apache.org  & www.perl.com  == www.modperl.com  ||  perl.apache.org
single o-> + single o-+ = singlesheavenhttp://www.singlesheaven.com