Efficient pre-loading of symlinks and virtual directories
It's well known that Apache::Registry will load and compile the same script multiple times when a site contains Apache::Registry scripts in mutliple directories, symlinked and aliased to different URLs (perhaps as a means of different levels of access restriction to the same scripts). An easy (and efficient) way of avoiding this is to map the virtual Apache perl module name to the underlying file's inode#, instead of its URL. As an extra bonus, this makes pre-loading scripts a breeze, because you no longer need to write a complex translation callback to map between filenames and URLs. in Registry.pm, the following code: my $script_name = $path_info $uri =~ /\Q$path_info\E$/ ? substr($uri, 0, length($uri)-length($path_info)) : $uri; $script_name =~ s:/+$:/__INDEX__:; if ($Apache::Registry::NameWithVirtualHost $r-server-is_virtual) { my $name = $r-get_server_name; $script_name = join "", $name, $script_name if $name; } # Escape everything into valid perl identifiers $script_name =~ s/([^A-Za-z0-9_\/])/sprintf("_%2x",unpack("C",$1))/eg; # second pass cares for slashes and words starting with a digit $script_name =~ s{ (/+) # directory (\d?) # package's first character }[ "::" . (length $2 ? sprintf("_%2x",unpack("C",$2)) : "") ]egx; --- can be replaced with --- my ($dev,$inode) = stat(_); # get fs device and inode numbers my $script_name = "::FileAt::Dev${dev}::Inode${inode}"; # generate script name --- For increased performance and decreased memory usage, with no duplicate-loading. And easy pre-loading! (i didn't make a patch for this since the changes are so trivial, and perhaps there's a good reason for the current way of doing it that i didn't think of.) ~fredrik
Apache::Session problems
Apache::Session::MySQL won't save session state. Apache::Session::File returns the following error: Insecure dependency in open while running with -T switch at /usr/local/lib/perl5/site_perl/5.6.0/Apache/Session/Lock/File.pm line 40. here's the code in question: sub put_or_del_session { my ($self, $r, %session) = @_; if ($self-command eq 'logout') { tied{%session}-delete; my $cookie = Apache::Cookie-new( $r, -name= 'SessionID', -path= $self-{uri}, -domain = $self-{config}-{TicketServerName}, -expires = '-10m', -value = '' ); $cookie-bake; } elsif (($self-page eq 'frame' $self-command eq 'make') or $self-page eq 'action') { $session{state} = $self-{state}; $session{timestamp} = time; } $r-log_error("put_or_del_session: session_id is $self-{session_id}"); $r-log_error("put_or_del_session: state is " . Dumper $session{state}); undef %session; } sub get_session { my ($self, $r) = @_; my %session; my $cookie_str = $r-header_in('Cookie'); my %cookies = $cookie_str eq '' ? ( ) : Apache::Cookie-parse($cookie_str); if (exists $cookies{SessionID}) { my $session_id = $cookies{SessionID}-value; #tie %session, 'Apache::Session::MySQL', $session_id, #{ # DataSource = $self-{config}-{Session_DB}, # UserName = $self-{config}-{Search_DB_User}, # Password = $self-{config}-{Search_DB_Password}, # LockDataSource = $self-{config}-{Session_DB}, # LockUserName = $self-{config}-{Search_DB_User}, # LockPassword = $self-{config}-{Search_DB_Password}, #}; tie %session, 'Apache::Session::File', $session_id, { Directory = '/tmp/apache/session', LockDirectory = '/tmp/apache/session/lock' }; } else { #tie %session, 'Apache::Session::MySQL', undef, #{ # DataSource = $self-{config}-{Session_DB}, # UserName = $self-{config}-{Search_DB_User}, # Password = $self-{config}-{Search_DB_Password}, # LockDataSource = $self-{config}-{Session_DB}, # LockUserName = $self-{config}-{Search_DB_User}, # LockPassword = $self-{config}-{Search_DB_Password}, #}; tie %session, 'Apache::Session::File', undef, { Directory = '/tmp/apache/session', LockDirectory = '/tmp/apache/session/lock' }; $session{state} = { account = {}, command = '', step= '', order = {} }; my $cookie = Apache::Cookie-new( $r, -name= 'SessionID', -path= $self-{uri}, -domain = 'www.physemp.com', -value = $session{_session_id} ); $cookie-bake; } $self-{state} = $session{state}; $self-{session_id} = $session{_session_id}; $r-log_error("get_session: session_id is $self-{session_id}"); $r-log_error('get_session: $session{state} is ' . Dumper $session{state}); $r-log_error('get_session: $self-{state} is ' . Dumper $self-{state}); return %session; }
Re: Apache::Filter
[EMAIL PROTECTED] (Manfred Hui) wrote: I have recently installed Kent Williams' Apache::Filter Module, and tested it with the supplied UC module and it worked with simple cgi scripts. However I have experienced a problem though when my cgi calls CGI.pm's redirect() and header(). Instead of getting the appropiate headers, eg. 302 Moved. I get a standard Content-type: text/html without reference to any location headers. I was wondering if anyone else had experienced the same problem and/or have a solution to this? Here is what my cgi script looks like. #!/usr/bin/perl -w use CGI; my $ob = new CGI; print $ob-redirect('http://www.cnn.com'); My Apache PerlHandler is set to Apache::RegistryFilter Apache::UC Manfred, I think there is a problem with the CGI-redirect method, because it uses Apache-request (and there is a problem with that). So your script must use shift() to get the current request object, and then send headers manually. Try this instead (untested): #!/usr/bin/perl -w my $r = shift; $r-err_header_out(Location = 'http://www.cnn.com'); $r-status(302); $r-send_http_header(); The downside of this, of course, is that it won't work under regular CGI. ------ Ken Williams Last Bastion of Euclidity [EMAIL PROTECTED]The Math Forum
Re: Apache::Session problems
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 At 3:24 AM +1000 3/28/01, Cees Hek wrote: $session-{data}-{_session_id}, which is really just the $session_id variable that you pulled out of a Cookie in your code below (and cookies are automatically tainted since it comes from the user). You will have to untaint the $session_id variable before you pass it to Apache::Session, and this error message should go away. See the perl manpages on how to untaint variables... It looks to me like there's code in Session.pm that validates the session id to make sure it's safe. It seems to me that it would be appropriate for that code to untaint the data at that point. There are a lot of routines that use that variable for generating file names, and running perl -T with a web server is not a bad idea. - -- Kee Hinckley - Somewhere.Com, LLC - Cyberspace Architects Now Playing - Folk, Rock, odd stuff - http://www.somewhere.com/playlist.cgi I'm not sure which upsets me more: that people are so unwilling to accept responsibility for their own actions, or that they are so eager to regulate everyone else's. -BEGIN PGP SIGNATURE- Version: PGPfreeware 7.0.3 for non-commercial use http://www.pgp.com iQA/AwUBOsA2sSZsPfdw+r2CEQL4uwCfU85AJURfZ0TNFngN11DLQZcwcbQAoJJ+ 7Z/zsw0lOURKvcClTTAf82gF =veaU -END PGP SIGNATURE-
apache compress / apache filter / mason
Hi, i didnt know where to post so i m sorry if this was off topic i am working in a mod_perl enviroment using mason 1.0, i d like to have compressed the ouput with gzip i know that there are two options apache compress and mod_gzip, id been told that making mod_dav to work with mod_perl is rather hard, so i should be using apache compress i also have learned that the way to make them work would be with apache filter, has anybody done this? if so can i see a copy of your mod_perl handler, an example from someone using mason would be great but im sure as hell that any other handler (Embperl, apache ::ASP, template toolkit) could be very helpful as well thanks rene mendoza
cvs commit: modperl-2.0/pod modperl_dev.pod
sbekman 01/03/26 05:37:08 Modified:pod modperl_dev.pod Log: Geoff's patch Revision ChangesPath 1.9 +2 -2 modperl-2.0/pod/modperl_dev.pod Index: modperl_dev.pod === RCS file: /home/cvs/modperl-2.0/pod/modperl_dev.pod,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- modperl_dev.pod 2001/01/06 02:41:22 1.8 +++ modperl_dev.pod 2001/03/26 13:37:08 1.9 @@ -19,7 +19,7 @@ % cd .. % buildconf % ./configure --prefix=$HOME/apache-2.0 \ - --with-mpm=mpmt_pthread --enable-so + --with-mpm=threaded --enable-so % make make install For bleeding edge Perl: @@ -100,7 +100,7 @@ =head2 Configure and compile Apache % cd ../httpd-2.0 - % ./configure --with-mpm=mpmt_pthread + % ./configure --with-mpm=threaded % make
cvs commit: modperl-2.0/xs/Apache/Module Apache__Module.h
dougm 01/03/26 07:51:51 Modified:xs/Apache/Module Apache__Module.h Log: s/top_module/ap_top_module/ Revision ChangesPath 1.2 +1 -1 modperl-2.0/xs/Apache/Module/Apache__Module.h Index: Apache__Module.h === RCS file: /home/cvs/modperl-2.0/xs/Apache/Module/Apache__Module.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- Apache__Module.h 2001/03/25 22:32:10 1.1 +++ Apache__Module.h 2001/03/26 15:51:50 1.2 @@ -1,2 +1,2 @@ #define mpxs_Apache__Module_top_module(CLASS) \ -(CLASS ? top_module : top_module) +(CLASS ? ap_top_module : ap_top_module)
cvs commit: modperl-2.0/xs/tables - New directory
dougm 01/03/26 08:04:22 modperl-2.0/xs/tables - New directory
cvs commit: modperl-2.0/xs/tables/current/ModPerl - New directory
dougm 01/03/26 08:04:45 modperl-2.0/xs/tables/current/ModPerl - New directory
cvs commit: modperl-2.0/xs/tables/current/Apache StructureTable.pm
dougm 01/03/26 08:06:23 Added: xs/tables/current/Apache StructureTable.pm Log: current version of Apache::StructureTable (generated by C::Scan/Apache::ParseSource) Revision ChangesPath 1.1 modperl-2.0/xs/tables/current/Apache/StructureTable.pm Index: StructureTable.pm === package Apache::StructureTable; # !! # ! WARNING: generated by Apache::ParseSource/0.02 # ! Mon Mar 26 07:44:04 2001 # ! do NOT edit, any changes will be lost ! # !! $Apache::StructureTable = [ { 'elts' = [ { 'name' = 'first', 'type' = 'union block_hdr *' }, { 'name' = 'last', 'type' = 'union block_hdr *' }, { 'name' = 'cleanups', 'type' = 'cleanup *' }, { 'name' = 'subprocesses', 'type' = 'process_chain *' }, { 'name' = 'sub_pools', 'type' = 'apr_pool_t *' }, { 'name' = 'sub_next', 'type' = 'apr_pool_t *' }, { 'name' = 'sub_prev', 'type' = 'apr_pool_t *' }, { 'name' = 'parent', 'type' = 'apr_pool_t *' }, { 'name' = 'free_first_avail', 'type' = 'char *' }, { 'name' = 'apr_abort', 'type' = 'int(*)(int retcode)' }, { 'name' = 'prog_data', 'type' = 'apr_hash_t *' } ], 'type' = 'apr_pool_t' }, { 'elts' = [ { 'name' = 'data', 'type' = 'unsigned char[16]' } ], 'type' = 'apr_uuid_t' }, { 'elts' = [ { 'name' = 'link', 'type' = '_ANON 63' }, { 'name' = 'type', 'type' = 'const apr_bucket_type_t *' }, { 'name' = 'length', 'type' = 'apr_off_t' }, { 'name' = 'start', 'type' = 'apr_off_t' }, { 'name' = 'data', 'type' = 'void *' } ], 'type' = 'apr_bucket' }, { 'elts' = [], 'type' = 'ap_HOOK_post_config_t' }, { 'elts' = [], 'type' = 'apr_interface_e' }, { 'elts' = [ { 'name' = 'tv_sec', 'type' = '__time_t' }, { 'name' = 'tv_usec', 'type' = '__suseconds_t' } ], 'type' = 'apr_os_imp_time_t' }, { 'elts' = [ { 'name' = 'pFunc', 'type' = 'ap_HOOK_get_suexec_identity_t *' }, { 'name' = 'szName', 'type' = 'const char *' }, { 'name' = 'aszPredecessors', 'type' = 'const char * const *' }, { 'name' = 'aszSuccessors', 'type' = 'const char * const *' }, { 'name' = 'nOrder', 'type' = 'int' } ], 'type' = 'ap_LINK_get_suexec_identity_t' }, { 'elts' = [ { 'name' = 'pFunc', 'type' = 'ap_HOOK_http_method_t *' }, { 'name' = 'szName', 'type' = 'const char *' }, { 'name' = 'aszPredecessors', 'type' = 'const char * const *' }, { 'name' = 'aszSuccessors', 'type' = 'const char * const *' }, { 'name' = 'nOrder', 'type' = 'int' } ], 'type' = 'ap_LINK_http_method_t' }, { 'elts' = [ { 'name' = 'pool', 'type' = 'apr_pool_t *' }, { 'name' = 'pconf', 'type' = 'apr_pool_t *' }, { 'name' = 'argc', 'type' = 'int' }, { 'name' = 'argv', 'type' = 'const char * const *' }, { 'name' = 'short_name', 'type' = 'const char *' } ], 'type' = 'process_rec' }, { 'elts' = [], 'type' = 'apr_OFN_ap_ssi_parse_string_t' }, { 'elts' = [], 'type' = 'ap_HOOK_optional_fn_retrieve_t' }, { 'elts' = [ { 'name' = 'dptr', 'type' = 'char *' }, { 'name' = 'dsize', 'type' = 'apr_size_t' } ], 'type' = 'apr_datum_t' }, { 'elts' = [], 'type' = 'apr_time_t' }, { 'elts' = [ { 'name' = 'pool', 'type' = 'apr_pool_t *' }, { 'name' = 'connection', 'type' = 'conn_rec *' }, { 'name' = 'server',
cvs commit: modperl-2.0/examples/lib - New directory
dougm 01/03/26 08:20:13 modperl-2.0/examples/lib - New directory
cvs commit: modperl-2.0/examples/lib/Apache - New directory
dougm 01/03/26 08:20:24 modperl-2.0/examples/lib/Apache - New directory
cvs commit: modperl-site/embperl Changes.pod.1.html index.html
richter 01/03/26 09:30:52 Modified:embperl Changes.pod.1.html index.html Log: Embperl Webpages - Changes Revision ChangesPath 1.206 +1 -1 modperl-site/embperl/Changes.pod.1.html Index: Changes.pod.1.html === RCS file: /home/cvs/modperl-site/embperl/Changes.pod.1.html,v retrieving revision 1.205 retrieving revision 1.206 diff -u -r1.205 -r1.206 --- Changes.pod.1.html2001/03/26 06:40:56 1.205 +++ Changes.pod.1.html2001/03/26 17:30:49 1.206 @@ -21,7 +21,7 @@ [a href="" HOME/a]nbsp;nbsp; [a href="Changes.pod.cont.html"CONTENT/a]nbsp;nbsp; [a href="Changes.pod.cont.html"PREV (Revision History - Content)/a]nbsp;nbsp; [a href="Changes.pod.2.html"NEXT (1.3.1 (RELEASE) 13 Feb. 2001)/a]nbsp;nbsp; brhr P -Last Update: Mon Mar 26 07:40:49 2001 (MET) +Last Update: Mon Mar 26 18:30:30 2001 (MET) P NOTE: This version is only available via A HREF="CVS.pod.1.html#INTRO" "CVS"/A 1.122 +12 -1 modperl-site/embperl/index.html Index: index.html === RCS file: /home/cvs/modperl-site/embperl/index.html,v retrieving revision 1.121 retrieving revision 1.122 diff -u -r1.121 -r1.122 --- index.html2001/03/26 06:40:56 1.121 +++ index.html2001/03/26 17:30:50 1.122 @@ -2,7 +2,18 @@ html head -titleEmbperl - Embed Perl in Your HTML Documents/title +meta name="Author" content="Gerald Richter" +meta name="Publisher" content="Firma ecos gmbh, D-55276 Dienheim, Tulpenstrasse 5" +meta name="Robots" content="INDEX" +meta name="Description" +content="Embperl is a system for building dynamic Websites. It gives you the power to embed Perl code in your HTML documents and the ability to build your Web site out of small reusable objects in a OO-style." +meta name="Keywords" +content="Embperl,Perl,Apache,mod_perl,dynamic Websites,Object,embed,XML,SSI,Webobjects,OO" +meta name="Title" +content="Embperl - Building dynamic Websites with Perl" + +titleEmbperl - Building dynamic Websites with Perl/title +/head body bgcolor="#FF"table border="0" cellpadding="0" cellspacing="0" width="100%"trtd table border="0" width="100%" @@ -187,7 +198,7 @@ blockquote pfont color="#808080" size=1hr HTML::Embperl - Copyright (c) 1997-2001 Gerald Richter / ECOS lt;[EMAIL PROTECTED]gt; - Last Update $Id: index.html,v 1.121 2001/03/26 06:40:56 richter Exp $/font/p + Last Update $Id: index.html,v 1.122 2001/03/26 17:30:50 richter Exp $/font/p /blockquote /td/tr!--msnavigation--/table/body /html
cvs commit: modperl-2.0 Makefile.PL
dougm 01/03/26 18:32:50 Modified:.Makefile.PL Log: only one version of the source tables is currently supported, so just hardwire it for now Revision ChangesPath 1.29 +3 -2 modperl-2.0/Makefile.PL Index: Makefile.PL === RCS file: /home/cvs/modperl-2.0/Makefile.PL,v retrieving revision 1.28 retrieving revision 1.29 diff -u -r1.28 -r1.29 --- Makefile.PL 2001/03/26 22:07:12 1.28 +++ Makefile.PL 2001/03/27 02:32:49 1.29 @@ -85,8 +85,9 @@ sub generate_xs { my $httpd_version = shift; -my $tables_version = - $httpd_version =~ /-dev$/ ? 'current' : $httpd_version; +my $tables_version = 'current'; +#XXX: support versioning +#$httpd_version =~ /-dev$/ ? 'current' : $httpd_version; my $tables_dir = "xs/tables/$tables_version"; unshift @INC, $tables_dir;
cvs commit: modperl-2.0 00README_FIRST
dougm 01/03/26 18:39:47 Modified:.00README_FIRST Log: add a hint about blib Revision ChangesPath 1.15 +8 -0 modperl-2.0/00README_FIRST Index: 00README_FIRST === RCS file: /home/cvs/modperl-2.0/00README_FIRST,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- 00README_FIRST2001/03/26 16:21:35 1.14 +++ 00README_FIRST2001/03/27 02:39:47 1.15 @@ -49,6 +49,14 @@ PerlSwitches -T /home/dougm/test/startup.pl +hint: rather than 'make install' point mod_perl at your blib in startup.pl: + + use blib qw(/home/dougm/ap/modperl-2.0); + +or + + PerlSwitches -Mblib=/home/dougm/ap/modperl-2.0 + it is possible to configure Perl*Handlers and callback into apache, much is the same as 1.x, but plenty is different at the moment. there will be a compat layer in the future.
cvs commit: modperl-site/embperl Changes.pod.1.html
richter 01/03/26 20:27:19 Modified:embperl Changes.pod.1.html Log: Embperl Webpages - Changes Revision ChangesPath 1.207 +1 -1 modperl-site/embperl/Changes.pod.1.html Index: Changes.pod.1.html === RCS file: /home/cvs/modperl-site/embperl/Changes.pod.1.html,v retrieving revision 1.206 retrieving revision 1.207 diff -u -r1.206 -r1.207 --- Changes.pod.1.html2001/03/26 17:30:49 1.206 +++ Changes.pod.1.html2001/03/27 04:27:19 1.207 @@ -21,7 +21,7 @@ [a href="" HOME/a]nbsp;nbsp; [a href="Changes.pod.cont.html"CONTENT/a]nbsp;nbsp; [a href="Changes.pod.cont.html"PREV (Revision History - Content)/a]nbsp;nbsp; [a href="Changes.pod.2.html"NEXT (1.3.1 (RELEASE) 13 Feb. 2001)/a]nbsp;nbsp; brhr P -Last Update: Mon Mar 26 18:30:30 2001 (MET) +Last Update: Tue Mar 27 06:26:57 2001 (MET) P NOTE: This version is only available via A HREF="CVS.pod.1.html#INTRO" "CVS"/A
cvs commit: modperl-2.0/xs/tables/current/ModPerl FunctionTable.pm
dougm 01/03/26 20:40:37 Modified:xs/Apache/RequestIO Apache__RequestIO.h xs/tables/current/ModPerl FunctionTable.pm Log: fix Apache::RequestRec::TIEHANDLE Revision ChangesPath 1.4 +4 -3 modperl-2.0/xs/Apache/RequestIO/Apache__RequestIO.h Index: Apache__RequestIO.h === RCS file: /home/cvs/modperl-2.0/xs/Apache/RequestIO/Apache__RequestIO.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- Apache__RequestIO.h 2001/03/16 05:32:35 1.3 +++ Apache__RequestIO.h 2001/03/27 04:40:36 1.4 @@ -68,8 +68,9 @@ return nrd; } -static MP_INLINE SV *mpxs_Apache__RequestRec_TIEHANDLE(SV *classname, - SV *obj) +static MP_INLINE +request_rec *mpxs_Apache__RequestRec_TIEHANDLE(SV *classname, + request_rec *r) { -return obj; +return r; } 1.2 +4 -4 modperl-2.0/xs/tables/current/ModPerl/FunctionTable.pm Index: FunctionTable.pm === RCS file: /home/cvs/modperl-2.0/xs/tables/current/ModPerl/FunctionTable.pm,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- FunctionTable.pm 2001/03/26 16:06:59 1.1 +++ FunctionTable.pm 2001/03/27 04:40:36 1.2 @@ -2,7 +2,7 @@ # !! # ! WARNING: generated by ModPerl::ParseSource/0.01 -# ! Mon Mar 26 07:44:14 2001 +# ! Mon Mar 26 20:36:51 2001 # ! do NOT edit, any changes will be lost ! # !! @@ -2685,15 +2685,15 @@ 'name' = 'mpxs_ap_get_client_block' }, { -'return_type' = 'SV *', +'return_type' = 'request_rec *', 'args' = [ { 'name' = 'classname', 'type' = 'SV *' }, { -'name' = 'obj', -'type' = 'SV *' +'name' = 'r', +'type' = 'request_rec *' } ], 'name' = 'mpxs_Apache__RequestRec_TIEHANDLE'