PerlAccessHandler
Folks, My PerlAccessHandler is being executed twice per each request. Is this a normal behavior for an access handler? Here is my .conf entry Location /myHandler SetHandler perl-script # run is a wrapper for my handler # all common methods which many of my handlers # use are stored in the super class of myHandler # in which run is a part of. # Also wraps myHandler in a try {} catch { ... # block. PerlHandler myHandler-run PerlAccessHandler myAccess . . . /Location The access handler's job is to check for cookies and last login time. There are no fancy codes there... However, on every request, the handler is invoked twice. Can someone make a suggestion as to why this is happening? Thanks in advance -r
Using a module that is not quite mod_perl compliant
To the list of mod_perl experts, If a third-party module uses global variables internally that causes persistence of the data under mod_perl, is there a fix. This particular module has a lot of dependencies on other modules, so fixing the third-party stuff may not be practical. It really saves me a lot of work, but I obviously can't use it if I'll have multi-user data corruption. Currently running on Win2000, Apache 1.3.12 and mod_perl 1.24, perl 5.6.0. It is a cgi that runs under Apache::Registry. It doesn't do any of the exotic handler stuff that mod_perl does - it's just a cgi that queries Oracle. Any canned solutions to this type of problem? Would moving my code to a module help? Thanks Chuck Goehring
RE: apache mod_perl + suid question
Ahhh...forgot to mention...but the below approach did't work :-( It does not even go into the wrapper script when I use the system command. thanks. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Friday, July 26, 2002 7:13 PM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: RE: apache mod_perl + suid question Thanks Vitor... I have something very similar to what you mention below..only that I am taking the username and passwd from the apache gui. Then I encrypt the passwd and send that to wrapper(i.e. suid_file) script. So I have something like system($wrapper), where $wrapper = suid_file.pl encrupted passwd username. I changed the suid_file to 4750 and have the ownership and group as root,root. I am also runing Apache as root. I don't have httpd as a user or group. Do I need to ? Also do I need to use the ystem command, can't I just do $ret = `$wrapper` ? thanks. -Tushar -Original Message- From: Vitor [mailto:[EMAIL PROTECTED]] Sent: Friday, July 26, 2002 7:04 PM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: RES: apache mod_perl + suid question Hello Tushar, Try this : $suid_file = file_path/suidfile.pl; $user = nobody; $passwd = kdsak; (system($suid_file,$user,$$passwd)) or die Error in suid operation $! ; Note that suid_file need the following commands : - chmod 4750 - chown root:httpd Regards, Vitor -Mensagem original- De: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Enviada em: sexta-feira, 26 de julho de 2002 19:41 Para: [EMAIL PROTECTED] Assunto: apache mod_perl + suid question Hello, I am trying to write a password changing program. For this I have a mod_perl subroutine from where I am trying to execute a perl script(with suid permissions 4711), which is a wrapper and in turn calls the usermod command on linux with the old and new passwords. The problem I am having: 1: The usermod command doesn't get executed. I have tried debugging this...by having a log file(/usr/local/apache/logs) and the mod_perl process does open the wrapper script..but then does nothing. It does not execute the command. What am I doing wrong ? I know there might be some quirks with suid permissons and I would like to know how can I overcome this. I have something like below from mod_perl subroutine: my $ret_val = `$wrapper`; Within the wrapper perl script, I call usermond with the passwds by doing: $ret = `$usermondcmd 21` Any help would be much appreciated. thanks a lot. -Tushar
RE: apache mod_perl + suid question
Thanks Vitor... I have something very similar to what you mention below..only that I am taking the username and passwd from the apache gui. Then I encrypt the passwd and send that to wrapper(i.e. suid_file) script. So I have something like system($wrapper), where $wrapper = suid_file.pl encrupted passwd username. I changed the suid_file to 4750 and have the ownership and group as root,root. I am also runing Apache as root. I don't have httpd as a user or group. Do I need to ? Also do I need to use the ystem command, can't I just do $ret = `$wrapper` ? thanks. -Tushar -Original Message- From: Vitor [mailto:[EMAIL PROTECTED]] Sent: Friday, July 26, 2002 7:04 PM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: RES: apache mod_perl + suid question Hello Tushar, Try this : $suid_file = file_path/suidfile.pl; $user = nobody; $passwd = kdsak; (system($suid_file,$user,$$passwd)) or die Error in suid operation $! ; Note that suid_file need the following commands : - chmod 4750 - chown root:httpd Regards, Vitor -Mensagem original- De: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Enviada em: sexta-feira, 26 de julho de 2002 19:41 Para: [EMAIL PROTECTED] Assunto: apache mod_perl + suid question Hello, I am trying to write a password changing program. For this I have a mod_perl subroutine from where I am trying to execute a perl script(with suid permissions 4711), which is a wrapper and in turn calls the usermod command on linux with the old and new passwords. The problem I am having: 1: The usermod command doesn't get executed. I have tried debugging this...by having a log file(/usr/local/apache/logs) and the mod_perl process does open the wrapper script..but then does nothing. It does not execute the command. What am I doing wrong ? I know there might be some quirks with suid permissons and I would like to know how can I overcome this. I have something like below from mod_perl subroutine: my $ret_val = `$wrapper`; Within the wrapper perl script, I call usermond with the passwds by doing: $ret = `$usermondcmd 21` Any help would be much appreciated. thanks a lot. -Tushar
RE: apache mod_perl + suid question
Yes, I am running it as /usr/sbin/usermod. I can run my wrapper with a simple perl script written on linux. The problem appears when I try to run it through the apache mod_perl. thanks. -Tushar -Original Message- From: Philip Mak [mailto:[EMAIL PROTECTED]] Sent: Friday, July 26, 2002 6:50 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: apache mod_perl + suid question On Fri, Jul 26, 2002 at 06:40:31PM -0400, [EMAIL PROTECTED] wrote: 1: The usermod command doesn't get executed. I have tried debugging this...by having a log file(/usr/local/apache/logs) and the mod_perl process does open the wrapper script..but then does nothing. It does not execute the command. What am I doing wrong ? Try '/usr/sbin/usermod' instead of 'usermod'. It may be a path issue. Also, 'usermod' might have to be run interactively (rather than reading from standard input), so you may have to create a virtual terminal in order to interface with usermod. (I might be wrong on this, and I can't elaborate further.)
mod_perl PerlAccessHandler/PerlAuthenHandler question
I'm a verteran CGIer but a new mod-perl user. I have got the mod-perl running fine for the content handling. But when I try to step in to other stages like Authentication, and have trouble in setting PerlAccessHandler PerlAuthenHandler etc. If I put ###== Location /mpl/hello SetHandler perl-script PerlHandler Apache::Hello /Location ###== in the perl.conf file, it's ok. I got the expected from the browser. But when I changed above to ###== PerlModule Apache::AuthAnon Location /mpl/hello AuthName Anonymous AuthType Basic PerlAuthenHandler Apache::AuthAnon require valid-user PerlSetVar Anonymous anonymous|anybody SetHandler perl-script PerlHandler Apache::Hello /Location ###== and try to restart the server, I got Syntax error on line 9 of /usr/local/apache/conf/perl.conf: Invalid command 'PerlAuthenHandler', perhaps mis-spelled or defined by a module not included in the server configuration When I set up .htaccess in a directory test under DocumentRoot, ###== PerlAccessHandler Apache::GateKeeper PerlSetVar Gate closed ###== and try to access this directory, the server gives the Internal Error: /usr/local/apache/htdocs/test/.htaccess: Invalid command 'PerlAccessHandler', perhaps mis-spelled or defined by a module not included in the server configuration I can add use Apache::GateKeeper (); in the startup.pl and start the server without problem, so the module itself should be in the proper path for tyhe server to load. Any help on this will be apprieciated. Harry GreatLodge.com
Re: IPC::MM and mod_perl
I'm not sure about IPC::MM, but IPC::ShareLite (the one I use) lets you specify permissions and whatnot when you create the shared memory segment. Perhaps that module will work better for you. IPC::Shareable is also a good one. On Thursday 25 July 2002 07:38 pm, Marc Kelly wrote: This may be more of an Apache question, but I saw a thread in the mod_perl archives on caching methods that is relevant. I'd like to use IPC::MM to store data in shared memory across child processes, but I've run into permissions problems. I'm assuming this is because I'm creating the cache in startup.pl which is run by root, and trying to store data in a child process that is run as user apache. If I create the cache in a child process, I can write to it, but lose the ability to use it in other child processes. The IPC::MM perldoc mentions file permissions, but I think that's for a file-based cache, which doesn't apply here. I could be wrong on that and just setting the permissions incorrectly. I haven't found a lot of documentation about using this library, so maybe this isn't the proper way for it to be used. I'm on Linux (RH 7.3/2.4.18-3) and apache 1.3.22. Thanks, mk -- Cory 'G' Watson Hack, lest ye rust.
Re: Using a module that is not quite mod_perl compliant
If a third-party module uses global variables internally that causes persistence of the data under mod_perl, is there a fix. You can manually clear them in a cleanup handler. If they're in a separate package, you can clear the whole namespace of the package. Take a look at the code for this in Apache::PerlRun. - Perrin
Attempting persistence
I'm looking at converting a large CGI installation over to mod_perl. The code is clean, so moving it to Apache::Registry isn't causing any problems, but I'd like to get the most bang out of the conversion that I can. Currently the code is a set of scripts that all call modules that are subclasses of a local subclass of CGI::Application (I realize the subclassing is hitting our efficency, but it's deemed worthwhile for the advantages it brings). These modules have run-modes as per standard CGI::App, and return to CGI::App a scalar ref of HTML, which CGI::App outputs with the appropriate headers via CGI.pm. The scalar ref our modules return are content files processed through a Template Toolkit template. I'm seeing the following potential areas of speed improvements: - CGI::App could be altered to use Apache::Request. I haven't looked into the code yet, but I recall from previous scans that it isn't overly complex (the beauty is in the simplicity, after all), so if the efficiency is worth it, and if CGI::App can't be easily coaxed into it, I should be able to fork my own to do Apache::Request. Of course, I'm doubtless not the first to consider this, so has someone already invented this wheel? - My Template Toolkit object could be reused, along the lines of Apache::DBI. (Since that object isn't changed in any session, just processes some data and returns a result). Sadly, I'm not clear on how to do this. Apache::Template is a handler in it's own right, so it won't do what I seek. Should I jump into Apache::DBI to see how it does it, or is there some documentation on how to create persistant objects that survive between connections? [Actually, I want more than a persistant TT2 object, since I have a wrapper module that has some helpful interface routines, so I'd want that to be persistant as well.] I've looked at perl.apache.org and skimmed the eagle book without finding this, but it is a bit specific, so I could have missed it. Thanks in advance for any help.
apache mod_perl + suid question
Hello, I am trying to write a password changing program. For this I have a mod_perl subroutine from where I am trying to execute a perl script(with suid permissions 4711), which is a wrapper and in turn calls the usermod command on linux with the old and new passwords. The problem I am having: 1: The usermod command doesn't get executed. I have tried debugging this...by having a log file(/usr/local/apache/logs) and the mod_perl process does open the wrapper script..but then does nothing. It does not execute the command. What am I doing wrong ? I know there might be some quirks with suid permissons and I would like to know how can I overcome this. I have something like below from mod_perl subroutine: my $ret_val = `$wrapper`; Within the wrapper perl script, I call usermond with the passwds by doing: $ret = `$usermondcmd 21` Any help would be much appreciated. thanks a lot. -Tushar
Re: apache mod_perl + suid question
On Fri, Jul 26, 2002 at 06:40:31PM -0400, [EMAIL PROTECTED] wrote: 1: The usermod command doesn't get executed. I have tried debugging this...by having a log file(/usr/local/apache/logs) and the mod_perl process does open the wrapper script..but then does nothing. It does not execute the command. What am I doing wrong ? Try '/usr/sbin/usermod' instead of 'usermod'. It may be a path issue. Also, 'usermod' might have to be run interactively (rather than reading from standard input), so you may have to create a virtual terminal in order to interface with usermod. (I might be wrong on this, and I can't elaborate further.)
RE: CGI Scripts w/mod_perl
Try running "which perl" and use that path for your #!/usr/bin/perl line. Then rename your script as .cgi and see if that helps. Mark -Original Message-From: Christina [mailto:[EMAIL PROTECTED]]Sent: Friday, July 26, 2002 9:32 AMTo: [EMAIL PROTECTED]Subject: CGI Scripts w/mod_perl Hi, I installed a CGI script last night, only to later realize the server is running mod_perl, instead of Perl. I have never worked with mod_perl before,so I'm wondering if this is why the script won't function on the server. The script calls for a change in the first line of the code in all .pl files if the path to perl is different from #!/usr/bin/perl, but I can't find anything in the server to indicate what the path should be using mod_perl. I am completely confused at this point so any guidance in the right direction would be greatly appreciated! Thanks, Christina
DBI fails to load in startup.pl
- Original Message - From: pascal To: [EMAIL PROTECTED] Sent: Friday, July 26, 2002 3:19 PM Subject: DBI fails to load in startup.pl Hi on windows XP professionnal 2002 with apache2/modperl/perl58 from RK /pub/other directory (apache /2.0.40-dev (win32) mod_perl/1.99_05-dev/ perl/v5.8.0) adding the line use DBI() ; to the startup.pl file makes apache segfaults (in module perl58.dll) (perl -MDBI -e "print $DBI::VERSION" outputs 1.30) best regards pascal barbedor here is the complete startup.pl use Apache2 ();use ModPerl::Util ();use Apache::RequestRec ();use Apache::RequestIO ();use Apache::RequestUtil ();use Apache::Server ();use Apache::ServerUtil ();use Apache::Connection ();use Apache::Log ();use Apache::Const -compile = ':common';use APR::Const -compile = ':common';use APR::Table ();use Apache::compat ();use ModPerl::Registry ();use CGI (); #added use Data::Table();use File::Cache(); use XML::Simple();use XML::LibXML () ;use XML::LibXSLT () ;use XML::XPath () ; use IO::String();use Data::Dumper ; use DBI(); --line that makes fail the starting of apache1;
RE: CGI Scripts w/mod_perl
On Fri, 26 Jul 2002, Mark Coffman wrote: Try running which perl and use that path for your #!/usr/bin/perl line. Then rename your script as .cgi and see if that helps. Um.. yeah, ignore all my locate tribble. 'which' is the way to go. That wasn't a question.
RES: apache mod_perl + suid question
Tushar, It's not recommeded to run apache as root. (Security issues). I have some applications that uses system command under mod_perl without problems. Try to execute you wrapper script in command line. Execute it with /usr/bin/perl -T (tainted mode), that checks if your script is safe. If you got error results, you will know why it's not working. $ret = `$wrapper` , also should work in you configuration (running apache as root). Regards, Vitor -Mensagem original- De: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Enviada em: sexta-feira, 26 de julho de 2002 20:13 Para: [EMAIL PROTECTED]; [EMAIL PROTECTED] Assunto: RE: apache mod_perl + suid question Thanks Vitor... I have something very similar to what you mention below..only that I am taking the username and passwd from the apache gui. Then I encrypt the passwd and send that to wrapper(i.e. suid_file) script. So I have something like system($wrapper), where $wrapper = suid_file.pl encrupted passwd username. I changed the suid_file to 4750 and have the ownership and group as root,root. I am also runing Apache as root. I don't have httpd as a user or group. Do I need to ? Also do I need to use the ystem command, can't I just do $ret = `$wrapper` ? thanks. -Tushar -Original Message- From: Vitor [mailto:[EMAIL PROTECTED]] Sent: Friday, July 26, 2002 7:04 PM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: RES: apache mod_perl + suid question Hello Tushar, Try this : $suid_file = file_path/suidfile.pl; $user = nobody; $passwd = kdsak; (system($suid_file,$user,$$passwd)) or die Error in suid operation $! ; Note that suid_file need the following commands : - chmod 4750 - chown root:httpd Regards, Vitor -Mensagem original- De: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Enviada em: sexta-feira, 26 de julho de 2002 19:41 Para: [EMAIL PROTECTED] Assunto: apache mod_perl + suid question Hello, I am trying to write a password changing program. For this I have a mod_perl subroutine from where I am trying to execute a perl script(with suid permissions 4711), which is a wrapper and in turn calls the usermod command on linux with the old and new passwords. The problem I am having: 1: The usermod command doesn't get executed. I have tried debugging this...by having a log file(/usr/local/apache/logs) and the mod_perl process does open the wrapper script..but then does nothing. It does not execute the command. What am I doing wrong ? I know there might be some quirks with suid permissons and I would like to know how can I overcome this. I have something like below from mod_perl subroutine: my $ret_val = `$wrapper`; Within the wrapper perl script, I call usermond with the passwds by doing: $ret = `$usermondcmd 21` Any help would be much appreciated. thanks a lot. -Tushar
Re: odd behavior of localtime
Without any real testing, may I suggest that the $date in the localtime call be surrounded in parens? Whenever I have dealt with localtime, I have found it to be finicky about that. Probably won't fix your current problem, but can save you headaches later. --Jon R. Dermot Paikkos wrote: Hi I have the following sub in a script: use Apache::Constants qw(OK NOT_FOUND); use Apache::Request; use Apache::Template; use strict; 131 sub week { 132my $date = time(); 133my ($monthday,$weekday,$yearday)=(localtime $date)[3,6,7]; 134(my $weeknum) = int($yearday / 7) + 1; 135return ($weeknum,$yearday,$date,$monthday); 136 } I confess I stole it straight out of the perl cookbook - bighorn sheep - and it should return the week number of the year. It doesn't. $date is set but all the other vars are uninitialized (expect the + 1 of course) so I end up with the week as 1. I tried this as a snippet on its own and it works. I can't figure out why it doesn't with mod_perl. I was a bit unsure of whether $date = time(); should be scalar or an array but neither work. I have a feeling I am doing something (Dooh) stupid here. Can anyone spot a mistake? Thanx. Dp. ~~ Dermot Paikkos * [EMAIL PROTECTED] Network Administrator @ Science Photo Library Phone: 0207 432 1100 * Fax: 0207 286 8668
Re: odd behavior of localtime
* Dermot Paikkos [EMAIL PROTECTED] [2002-07-26 09:14]: I tried this as a snippet on its own and it works. I can't figure out why it doesn't with mod_perl. I was a bit unsure of whether $date = time(); should be scalar or an array but neither work. You haven't mentioned how you are calling it. From within a template (you mention Apache::Template), from within a handler, or where? (darren) -- The man who is denied the opportunity of making decisions of importance begins to regard as important the decisions he is allowed to make. -- C. Northcote Parkinson
Re: CGI Scripts w/mod_perl
I'm sending out the sincerest of thank you's to all of you who helped me with my problem earlier today! I was offline most of the afternoon, but found your messages this evening and miracle of all miracles, I actually got the script to work. Thanks everyone! Christina - Original Message - From: Mark Coffman To: Christina ; [EMAIL PROTECTED] Sent: Friday, July 26, 2002 9:43 AM Subject: RE: CGI Scripts w/mod_perl Try running "which perl" and use that path for your #!/usr/bin/perl line. Then rename your script as .cgi and see if that helps. Mark -Original Message-From: Christina [mailto:[EMAIL PROTECTED]]Sent: Friday, July 26, 2002 9:32 AMTo: [EMAIL PROTECTED]Subject: CGI Scripts w/mod_perl Hi, I installed a CGI script last night, only to later realize the server is running mod_perl, instead of Perl. I have never worked with mod_perl before,so I'm wondering if this is why the script won't function on the server. The script calls for a change in the first line of the code in all .pl files if the path to perl is different from #!/usr/bin/perl, but I can't find anything in the server to indicate what the path should be using mod_perl. I am completely confused at this point so any guidance in the right direction would be greatly appreciated! Thanks, Christina