[mp1] 64 bit perl/apache and 32 bit shared objects
I'm having a bit of trouble with a 64 bit versions of perl and apache not playing nice with 32 bit shared objects under linux. We have an external shared object binary supplied by a vendor that we can link our XS code against just fine, but when we attempt to actually use the shared methods, perl core dumps. I think the problem is that the conversion from 64-bit T_IVs to ints is 32 bits too long for the shared methods, but I'm not 100% certain I'm right. Anyone ever run into this problem before? Can I solve it with XS? Rob -- Robert Landrum Systems Programmer -- 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: reposting form values
Torsten Foertsch wrote: On Tuesday 28 November 2006 21:31, Patrick Galbraith wrote: Quick question - how does one do a repost (using POST, not GET) form values? This would be in a redirect TransHandler. Your only chance is to proxy the request to the other server. You cannot use a Location header to trigger a POST. You could also pump out HTML and call form.submit() with Javascript. Other than that, Torsten is correct. Use LWP to proxy the post data back to the client. Rob
Re: DBI AutoCommit goes away when db connection is killed
Lev Lvovsky wrote: In testing out persistent connections while using transactions, we've noticed that while in a loop which continuously begins and ends a transaction, killing the persistent connection which Apache::DBI is maintaining causes the still-running handler to report things like: error: DBD driver has not implemented the AutoCommit attribute at /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi/DBI.pm line 1668. 1 -> STORE for DBD::mysql::db (DBI::db=HASH(0x9bf49cc)~INNER 'AutoCommit' 0) thr#915dc30 --> do_error Turning off AutoCommit failed error 21 recorded: Turning off AutoCommit failed <-- do_error STORE DBI::db=HASH(0x9bf49cc) 'AutoCommit' => 0 !! ERROR: 21 CLEARED by call to begin_work method -> begin_work for DBD::mysql::db (DBI::db=HASH(0x9b8678c)~0x9bf49cc) thr#915dc30 So, your code is calling begin_work, fetching a value, storing a value, and committing? The store will fail if the database connection goes away, and it'll do so when it attempts communicate with the server to set AutoCommit to 0. You might want to call $dbh->ping before calling your store routine. Either way, the way to make this fault tolerant is with eval. Once you've determined that there's been a fault, and that the fault means that the database is down, try to reconnect. Continue to try to reconnect until the database comes back online. Then retry the original failed transaction. Once you reconnect, the connection is persistent again. At least, that's been my experience with postgresql. Rob
Re: DBI AutoCommit goes away when db connection is killed
Lev Lvovsky wrote: Once you reconnect, the connection is persistent again. At least, that's been my experience with postgresql. This is exactly what I've been thinking to do, but I've not seen anything within Apache::DBI that allows me to reconnect per se. How do I perform that action? Also, forgive this question if it seems a little obtuse, but in the startup.pl file, I do something like this: Apache::DBI->connect_on_init(...) My experience with Apache::DBI has been that it needs no special setup. All I've ever done is: my $dbh; $cnt = 0; while(!$dbh) { eval { $dbh = DBI->connect(); }; if($@) { warn("DB Down: $@"); sleep 5; $cnt++; } last if $cnt > 3; } unless($dbh) { # show user an error page } Rob
Re: Instability at startup for Apache2/mod_perl2 using worker MPM
Perrin Harkins wrote: David Scott wrote: I've built Apache 2.2.3 and mod_perl 2.0.3 with libapreq 2.08 and the worker MPM. There appears to be some kind of race condition at startup that prevents the server from coming up. This only happens once in a while, and can be fixed by some minor configuration or code change (ie, adding a 'print STDERR "foobar\n"' to one of my Perl modules can cause the problem to occur; moving the print statement by one line can fix it). This sounds like a possible issue with your code and threaded perl. It doesn't ring a bell as a general mod_perl issue. Interesting problem. I remember reading about an issue with threading (not specific to apache or mod_perl) that occured when file descriptors were being modified while there were contents in the buffer. Just for giggles, try { local $|=1; use MyModules; ... } Rob
Re: reset multiple cookies
Marc Lambrichs wrote: Date: Sun, 10 Dec 2006 12:50:09 GMT Server: Apache Set-Cookie: auth_tkt=; path=/; domain=main.domain.com; expires=Sun, 10-Dec-2006 11:50:09 GMT Set-Cookie: auth_tkt=; path=/; domain=first.domain.com; expires=Sun, 10-Dec-2006 11:50:09 GMT Set-Cookie: auth_tkt=; path=/; domain=second.domain.com; expires=Sun, 10-Dec-2006 11:50:09 GMT I'm no expert, but it looks like you might be setting expired cookies, in which case the browser will ignore them. Was this your intent? Rob
Re: Forking to an interactive program under mod_perl
Alex Beamish wrote: What I'm trying to do is come up with scaled page images from a PDF on the fly. Thus, I want to launch Ghostscript and then ask for a couple of page images. So, launching Ghostscript and getting the first page might happen on the first request; subsequent requests would come back to the Ghostscript session left running from the first request, and thus would be able to quickly produce the required page image. Suggestions welcome. What you're gonna need is a daemon that lives outside of mod_perl. It's job will be to answer ghost script requests made from within your mod_perl handler, track open files, purge unused files, and generally do all the things you want to do. I don't really see a clean way to do it otherwise. I've never used it, but doing a CPAN search revealed GSAPI, a perl GhostScript interface. That might be a good place to go. Good luck, Rob
Re: Forking to an interactive program under mod_perl
Alex Beamish wrote: I'll deal with multiple documents with some combination of stale timers and LRU slots, but that's not really what I see as the most complicated or difficult part of this problem. For this particular application, my inactivity timer will probably by 10-15 minutes, and I'll expect to have 6-8 documents open at any given time, so it shouldn't be a big drain on memory. And I will probably be able to set something up that signals that a document has been expired as well .. (this is just me thinking out loud) .. Thanks for your feedback .. I think named pipes is my next focus. Sockets will be the way to go on this, rather than pipes. I don't want to say pipes are a dead technology, but by using sockets, you can move your gs application off your web servers (if load ever gets that high) without having to rewrite any code, something that isn't possible with a pipe (not without netcat, anyway). There's probably a good reason for it, but why not just pre-generate all of your page images? Even when new documents are added, a cron could be setup to come along (once a minute even) and convert those PDFs to images. Are these PDFs dynamically generated? Rob
Re: The case of the disappearing plus sign
Chris Schults wrote: It appears that the "+" is getting stripped out at some point as the script is returning results for "water pollution" instead of "water+pollution". Is it possible that Apache is the culprit or should we be looking more closely at our script or rewrite rule? The test would be to hit /cgi-bin/script.pl? with the water+pollution keyword. The problem is most CGI variable processors are going to replace + with a space. I doubt this is an issue with rewrite. You might need to pass the URL encoded string instead of water+pollution... That would be water%2Bpollution. Rob
Re: localhost vs vhost problem
Well.. For one thing, vhost1.turnbui.net isn't a ServerName entry or a ServerAlias entry. I'd start by adding that. Rob turnbui wrote: ServerName ianst.homeip.net DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/iansthtdocs" # ErrorLog logs/ianst-host-error.log # CustomLog logs/ianst-host-access.log common ServerAlias ianst ScriptAlias /cgi-bin/ "C:/Program Files/Apache Software Foundation/Apache2.2/iansthtdocs/cgi-bin/" # Alias /perl/"C:/Program Files/Apache Software Foundation/Apache2.2/iansthtdocs/perl/" # # Alias /asp/"C:/Program Files/Apache Software Foundation/Apache2.2/iansthtdocs/asp/" # PerlModule Apache::ASP SetHandler perl-script # this line stops it finding my /cgi-bin/iansCaptcha.asp file ?? ie prevents SSI's from perl/... PerlHandler Apache::ASP # next 2 go together in place of above - requires Apache/Registry.pm @INC #PerlHandler Apache::Registry #PerlSendHeader On # PerlSetVar Global . PerlSetVar Global c:/tmp PerlSetVar StateDir c:/tmp/asp PerlSetVar CookiePath / #
Re: localhost vs vhost problem
turnbui wrote: Sorry Rob, just my vain attempt to protect the innocent. In fact it is ianst.homeip.net that I am using. Sorry to mislead. Okay. So just to rehash here... ASP does not work at: http://ianst.homeip.net/asp ASP works correctly at: http://localhost/asp localhost isn't a server listed in your VirtualHost section in either ServerName or ServerAlias. That means that the VirtualHost section isn't even a consideration when hitting localhost. Figure out what combination of configuration elements are being used when localhost is accessed and I think you will have found the combination to include in your VirtualHost section. Rob
Re: localhost vs vhost problem
Perrin Harkins wrote: Robert Landrum wrote: localhost isn't a server listed in your VirtualHost section in either ServerName or ServerAlias. That means that the VirtualHost section isn't even a consideration when hitting localhost. Doesn't that mean it just takes the first VirtualHost that appears in the file? Actually, it's been literally 5 years since I've done any named virtualhost stuff, so it could've changed in that time... But as I recall, it will use the global configuration as defined by httpd.conf, not any one specific VirtualHost block. Again, this is based on the default setup (of 5 years hence), which I believe had: Listen *:80 Rob
Re: Bug Report
Snook, Adrian (London) wrote: 3. This is the core dump trace: (if you get a core dump): Core was generated by `/home -k start'. Program terminated with signal 11, Segmentation fault. #0 0x002f201e in free () from /lib/tls/libc.so.6 (gdb) bt full #0 0x002f201e in free () from /lib/tls/libc.so.6 No symbol table info available. #1 0x0121d0a5 in nnfldlc () from /finman- ds1/ora01/app/oracle/product/9.2.0/lib/libclntsh.so.9.0 No symbol table info available. #2 0x0121cad7 in nnflrlc () from /finman- ds1/ora01/app/oracle/product/9.2.0/lib/libclntsh.so.9.0 No symbol table info available. Hmm... Interesting. Everything looks good right up until this point, which I believe is attempting to resolve names. Oracle naming conventions suck. Just a shot in the dark... Try changing tnsnames.ora to connect to the IP address rather than the hostname, if that's what you're using. You should also be able to test this without apache. Just run a script with something like $|=1; while(1) { $dbh = DBI->connect(); $dbh->disconnect; print "Connected\n"; } Rob
Re: Lost ENV variable value .........
Tracy12 wrote: Thanks, If this is the case, How can we preserve the REMOTE_USER value and forward/redirect to the other application ( running on same Apache Server) which is based on the REMOTE_USER environment variable, which is set in my perl module in the first application. I was under the impression $ENV{'REMOTE_USER') variable can be used for such purposes. I think you've got this idea or notion that this is the right way to do whatever it is you're trying to do and are asking questions that don't really make sense to us. Maybe we could help more if we knew what it was you were really trying to do. But if thats not an option... If I wanted to get remote user from one request to the next, I would pass it as a URL parameter. Something like /cgi/rUser.pl?remote_user=foobar&other=options Your other option is to set a cookie containing this user id, or if security is an issue, use a session, with a unique id for the cookie. Rob
Re: Lost ENV variable value .........
Perrin Harkins wrote: After successful authentication we need to pass the control to another application(which is running on the same apache server) which depend on the REMOTE_USER value which we set. That will work fine, as long as your auth handler runs in the same request as the thing that wants to look at REMOTE_USER. If you do an external redirect, that creates a totally separate request from the client. You need to set your handler as the auth handler for the location that you want to protect, not go the auth handler and then redirect to the location. I think what Perrin is saying is that you don't want your authentication handler to perform the location redirect. In fact, you don't want a location redirect at all. You want to return OK if the user is authenticated (i.e. the username and passsword are verified by the CAS service) and AUTH_REQUIRED otherwise. At least that's how it was in MP1 and it's probably pretty much the same in MP2. Rob
Re: Lost ENV variable value .........
Tracy12 wrote: 1) As we dont use the apache basic authentication but our CAS authentication. If the authentication is not successful how can we redirect to the CAS login page. Ah-ha... So CAS authentication is done via a webform of some type, which means that it uses cookies. Am I correct in this? I'm not positive about this, but I think you probably want a PerlAuthzHandler instead. In this handler you would confirm that the user is logged into the CAS system, set the REMOTE_USER environment variable, and return OK. If the user wasn't logged in, then you'd redirect to the CAS login page. 2) As we dont use the basic authentication in apache in the above httpd.conf entry what the values should we give for AuthType , AuthName in the above Location declaration. I think, with PerlAuthzHandler you only need to specify a "Requires valid-user" to make it work. Rob
Re: Port/Sheme information
Tracy12 wrote: How can we retrieve the URL Scheme (http/https ?) from a perl module, Port given that only input parameter is $r should we use my $uri = Apache::URI->parse($r) and $uri->scheme; I use $r->get_server_port. If it's 80 it's http, if it's 443, it's https. Of course, this breaks if you run them on different ports. Rob
Re: Redirects?
Will Fould wrote: I have a strange issue with a particular script that sometimes (often) generates a 302 to another script without a clear reason why. Oddly enough, I simply placed a few "warn('blah')" code snippets to crudely determine from the error log where it was happening in production (because I cannot replicate the issue in development (linux client/local server)) but with the Warn() statements, if seems to no longer happen !! -- any suggestions/clues where I might look? This is the only script that does this under the same location/configuration. Could this be an issue with buffering? The warns might be triggering a buffer flush. $|=1 might solve the issue once the warns are removed. Rob
Re: file descriptor for client socket?
Daniel Risacher wrote: Is it possible to get the file descriptor for the client socket from the RequestRec? I.e. something like $r->FILENO (which doesn't seem to work) or perhaps $r->connection->client_socket->os_sock (os_sock exists in the APR structure in C, but there doesn't seem to be a perl accessor method.) Reason I want to do this... I'm trying write a perl module to pass the connection to another process using File::FDpasser. $fd = fileno(STDOUT); won't work? Is this really what you want to do? I think apache will still terminate the connection (I'm not sure there's away to avoid that). Rob
Re: Session Handling/Set Session attributes
Tracy12 wrote: My perl authentication handler works fine BUT the biggest problem inside my Auth handler I do some resource intenstive tasks and if everything successful set the REMOTE_USER env variable. But for the subsequent requests from the same user (after the initial Authentication is successful) how can I bypass these resource intensive tasks because the user already been authenticated (but I need REMOTE_USER value for subsequent request I would use Apache::Session and store a cookie that says that this user is authenticated. The session would include to be set for REMOTE_USER. The user would only get the session cookie if they had successfully authenticated. It should work fine and will likely solve your performance problem. Rob
Re: Catching errors
Jonathan Mangin wrote: sub handler { my $r = shift; my $req = Apache2::Request->new($r); my $foo; # eval {$foo = $req->param('foo')}; $foo = $req->param('foo'); You might want to make sure $r is really $r. If you configure apache such that you use PerlHandler Foo->handler, I believe the first argument is 'Foo', followed by $r. Rob
Re: mod_perl best practices cleanup
Tracy12 wrote: I tried to declare use vars qw( $SESSION_CLEANUP_COUNTER); and increment within the code doent seem to work, Shoud i increment this in a specific hanlder. You really need to heed the advice of the list and consider using the a cron job to expire old sessions. It's really not that hard to do. #!/usr/bin/perl use strict; my $path = shift; # path to session directory my $exp = shift; # time sessions are valid (in seconds) my $now = time; opendir(DIR,$path) or die "could not open dir: $path: $!"; while(my $file = readdir(DIR)) { my $fp = "$path/$file"; my $mtime = (stat($fp))[9]; if($now > ($mtime + $exp)) { unlink($fp); # remove the file if expired } } closedir(DIR); __END__ I didn't test this, so it probably doesn't work as written. But it should be close enough to give you the idea. All it does is delete files when they have been sitting around for more than a certain number of seconds. Add that to cron as something like * * * * * /path/to/session_remover.pl /path/to/session/dir 3600 That'll check for newly expired sessions every minute and delete any that are older than 3600 seconds (1 hour). Good luck, Rob
Re: Troubleshooting Apache2 Segfaults
Joel Gwynn wrote: Here's my backtrace, any ideas? #0 0xb7a58743 in modperl_dir_config (my_perl=0x81b6eb0, r=0x823ce98, s=0x203a6e6f, key=0x8800c38 "CONFIG_FILE", sv_val=0x0) at modperl_util.c:516 #1 0xb78dae84 in XS_Apache2__RequestRec_dir_config (my_perl=0x81b6eb0, cv=0x82cd074) at RequestUtil.xs:301 I believe the reason it's dumping core is because modperl_dir_config is trying to copy the value requested to the sv_val, which is null. Looks like a bad dir_config call. Are you doing anything funky, like passing in undef, or maybe calling it without an assignment (although that shouldn't cause this error)? Rob
Re: Troubleshooting Apache2 Segfaults
Joel Gwynn wrote: Interesting. I just might be doing that: $config_file = $self->param('r')->dir_config('CONFIG_FILE'); In my section, I have this: PerlSetVar CONFIG_FILE /projects/funnyr_dev/private/config.ini And of course I'm not using flock on that file. Hmmm. Try changing that up... my $r = $self->param('r'); if(defined $r) { $config_file = $r->dir_config('CONFIG_FILE'); } else { # handle no $r } Give that a shot and see if it solves the problem. Rob
Re: Troubleshooting Apache2 Segfaults
Perrin Harkins wrote: My guess is that $self has a lifespan longer than one request, so you are trying to use a $r object from a previous request. Would $r still be defined in that instance? Rob
Re: undefined routines & mod_dbd
Garnier, Jeremie wrote: use Apache2::Module (); # test if an Apache module is loaded if (Apache2::Module::loaded('mod_dbd.c')) { … } But it dones: Undefined subroutine &Apache2::Module::loaded call at… I suspect that this may be because you're not actually running in mod_perl. Aside from that, I don't see any methods actually defined in Apache2::Module::loaded... not even a bootstrap. So it might need to be loaded from something like Apache2. Rob
Re: Where does "MoveNext" belong to?
Patrix Diradja wrote: while(!$rsnya->{EOF}){ my $tab4l = $rsnya->fetchrow_array; print "\$tab4l: $tab4l \n"; $rsnya->movenext; } Not a mod_perl question, per se, but try while(my $tab4l = $rsnya->fetchrow_array) { print "\$tab4l: $tab4l\n"; } Rob
Re: Perl Authentication Handler and Cookie Issue
Sumit Shah wrote: Hello, I have a Mod Perl authentication handler and it needs to retrieve the session id from a cookie. It is unable to retrieve any cookies and I get the following error. It does not even print any of the cookies. I would appreciate any help with this. my $token = $cookies{'SessionID'}->value; chomp($token); $log->error("3. Session ID ==> $token"); You're trying to call a method against a value that may or may not exist. That's a big no-no. if(defined $cookies{'SessionID'}) { $token = $cookies{'SessionID'}->value; } else { $log->error("No SessionID cookie"); } Rob
Re: Server Side Image Maps & libapreq / cgi
Jonathan Vanasco wrote: How can I reliably catch this under libapreq / cgi ? ( the former for current use, the latter just-for-kicks ) As far as libapreq is concerned, I can't find any way -- it seems to be an odd special-case html spec. The short answer is: don't use server side image maps. And yes, the long answer is to parse the URI yourself. I ran into the same issue a few (7?) years ago. Rob
Re: Sry, 1 more question.. Apache2::Reload goofiness
[EMAIL PROTECTED] wrote: This is getting very frustrating, so I guess I should ask about this before I scrap the whole project and go back to CGI. I'm using Apache::Reload during development since I'm constantly making changes to code. However, it does not appear to be working right. Is this a bug that I have to live with or is there something I can do? Apache::Reload is based on timestamps, IIRC. So if you're uploading a file from your machine to another machine, make sure both machines have the same time (down to a few seconds) or else Apache::Reload won't see the changes. Starting and Stopping apache the only absolute way to ensure that changes to modules are loaded that I've found. Perrin will probably disagree. :) Rob
Re: Server Side Image Maps & libapreq / cgi
Jonathan Vanasco wrote: On Feb 20, 2007, at 3:56 PM, Robert Landrum wrote: The short answer is: don't use server side image maps. That's not an option. I need to catch the xy on a gif. And yes, the long answer is to parse the URI yourself. arhh. ok. already doing that , but ok. You can make it a form and us it as a submit. Then it sends the x and y coords as name.x=10&name.y=20. I think. Rob
Re: Perl Authentication Handler and Cookie Issue
Sumit Shah wrote: I printed out the contents of the Cookie attribute in the request header and I can see the cookie present in the header. I read all the contents into a hash and then try to check for its existence. The if(exists($hashMap{'SSOTokenID'})) condition fails. Does it have anything to do with data types? How can I check for its existence? Here is the code snippet: my $cookie = $r->headers_in->{'Cookie'}; my @cookieArray = split(";",$cookie); There's your problem... my @coolieArray = split(/\;\s/,$cookie); All of your hash keys will have a space prepended. Rob
Re: Sample Web Application that uses mod_perl
aqua wrote: Dear Group, Some of you might have tried the mod_perl for the first time and tested with simple web application and it should be there some-where in your system. Could you please post a few. The problem is that it isn't exactly a simple thing. It sounds like you're looking for something as simple as a CGI, but mod_perl is much more than that. One of the things that mod_perl does is "handle" some portion of the request you send to Apache. There are lots of options... In order to do that, you have to configure Apache to pass control to mod_perl. This can be achieved in several ways... Once Apache has handed the request to mod_perl, mod_perl decides what modules to load, what to call, and so on. So you can see, it's not simple. But it is powerful, and worth understanding. If I were in your position, I might try asking questions about the problem I was trying to solve, rather than asking for solutions first. Rob
Re: Error intercept.
Benoit Plessis wrote: $r -> headers_out->set('Content-Length', length $error_page); Hmm... Incident sur l'hebergement
Re: PerlAuthenHandler called twice?
Hadmut Danisch wrote: For some reason the module is called twice for every request. Is this a HEAD/GET problem? Maybe you're seeing the browser doing a HEAD request, then a full GET request? Rob
Re: Using or working around File::MMagic under mod_perl
Mark Stosberg wrote: Hello, Recently I ran into a bug with File::MMagic where it returns inconsistent results under mod_perl. Could it simply be a matter of fixing the use of the DATA handle, as Stats suggest here? http://mail-archives.apache.org/mod_mbox/perl-modperl/200403.mbox/[EMAIL PROTECTED] Yep. It's definitly the problem. The work around is to pass a magic definition file into MMagic when the object is created. Easier said than done. Maybe the best solution is move the DATA section to a variable. It's not as elegant as reading the data from a DATA section, but it's mod_perl compliant. Hmm... You might try adding this to your startup.pl (or whatever is per-loading perl modules). # a bit of a hack use vars qw($magicObject); BEGIN { if($ENV{MOD_PERL}) { # load from $magicObject = File::MMagic->new(); # save it globally { no strict; # save original method *{"File::MMagic::original_new"} = *{"File::MMagic::new"}{CODE}; # replace original method *{"File::MMagic::new"} = sub { return $magicObject; }; } # end no strict } } It's untested. And it probably leaks memory, too. :( Rob
Re: Zend PHP
Martin Moss wrote: I just had a demo of the Zend Platform and framework for php. It's got some really nice stuff, but ultimately the reason we may decide to ditch perl and move to php (h I know booo) will be down to support. OR lackthereof for Perl... I've been writing perl for 10 years now (I know, a newbie :), but in those ten years, there's never been anything for which I've needed to ask "support" for. I've never once encountered a honest *perl* bug. Any questions, about anything, have been answered by the perl book, or perl cookbook. As far as coding is concerned, CPAN has proved to be the most valuable resource. In writing in other languages, I often find myself having to search hi-and-low for source, libraries, or documentation on how to do common, trivial things... Things which are easily found in CPAN. PHP is okay, and has almost the same level of community support as perl (although it kinda feels a bit less organized). The perl/mod_perl community has always been there with helpful advice when I needed assistance. I don't see it going away. I'm sure the Zend cool-aid is tasty, but I'll stick with perl for now... :) Rob
Re: Zend PHP
Martin Moss wrote: Many thanks to you all for your posts, Much food for thought... ultimately the decision is out of my hands, which is why I'm looking for useful perl based alternatives to propose to the powers that be. My favorite perl based alternative is HTML::Mason. Simple, fast, and good, and an ASP/PHP user would feel right at home (for the most part). Rob
Re: UTF8 fun with SOAP::Lite and mod_perl 1.3.33
Drew Wilson wrote: But I cannot figure out WHERE this conversion is being done. I've picked through SOAP::Lite enough to know that unicode conversions are probably more than it knows how to handle. However, SOAP::Data::encode_data uses a regex to munge data. Perhaps there's a conversion happening in the regex engine that breaks the UTF8. Rob
Re: MP1 Security issue
Chris Shiflett wrote: That's a weak defense. If you're a proponent of full disclosure, say so, but don't use ignorance as your defense in the same email where you claim to not be a "dumb guy." I am a dumb guy, and I would have done the exact same thing Randal did. I just don't think about security in terms of secrecy. It's not a full disclosure thing at all, at least for me. Despite the (perceived) violation of protocol, Randal's message did light a fire under the asses of a lot of mod_perl developers, and made known a potential security issue. I'd say that's mission accomplished. Rob
Re: "Insecure dependency in eval while running setgid" error
Fred Moyer wrote: Or maybe this is a bug in getegid where it's not clearing a previous memory state. What platform is this on? sun4-solaris His first post had a list of modules in a stack trace, which is where I grabbed that. I googled, but didn't find anything relevant. :( See if fgrep -r 'perl' * | grep '-T' in you modules directory returns anything. Also make sure PerlTaintCheck On isn't in your config. Also, a lot of times I'll put -T in the shebang line of my handler.pl or startup.pl, which will enable Taint checking. Rob
Re: "Insecure dependency in eval while running setgid" error
[EMAIL PROTECTED] wrote: Unfortunately turning taint mode off isn't an option for me. My application is client facing and so we want to continue to make use of the security mechanism that taint mode gives us. Keep taint mode on in dev, so you can identify your issues in development, then turn in off in prod. Rob
Re: "Insecure dependency in eval while running setgid" error
Perrin Harkins wrote: On 3/28/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Keep taint mode on in dev, so you can identify your issues in > development, then turn in off in prod. Is that actually the generally recommended approach? It's hard to know for sure that you've tried every code path in dev, even if you do use coverage analysis. Here's the bit that's causing the issue... # DON'T LOOK NOW! - blindly untainting can make you go blind! $block =~ /(.*)/s; $block = $1; $block = eval $block; That's a little bit nasty, but perfectly valid. $block is coming from a document containing some sort of code, I think. I didn't dig too deep. You could add: warn "BLOCK: $block\n"; just above the eval, which will log all the "blocks" that are being eval to figure out which one is giving you the trouble. Rob
Re: "Insecure dependency in eval while running setgid" error
[EMAIL PROTECTED] wrote: I'm hoping tho that if I can create a small test case under mod_perl then that opens up myself/someone-on-the-list trying it with other combinations of perl & mod_perl. If you log the pid in the access file, you should be able to determine the serious of page hits that eventually led to the failure, maybe. Also, do you have any limits on the number of requests a child process can serve? If so, does the error appear only after apache has spawned a new child? Rob
Re: SOPE::Lite / prcessing complex data types at server side
Tobias Regneri wrote: package MyService; sub AddGroupAttributes { ($self, $provider, $group, $attrlist) = @_; ($name, $hashref) = split('=', $attrlist); $params = $$hashref; ... } the variables $provider and $group are set correctly but the hash for the list items is empty. Do I have to override the deserializer (if yes, is there any documentation available) or am I handling the parameters in the wrong way? SOAP lite does some weird things. 0.55 especially. If you aren't using 0.67 (or later), then you might want to upgrade. I would use Data::Dumper; warn(Dumper([EMAIL PROTECTED])); and see what's in the logs. It should be: provider group attrlist[item 0] attrlist[item 1] ... Rob
Re: SOAP::Lite / processing complex data types at server side
Tobias Regneri wrote: Given the following xml structure of the data to process Name1 Val1 Name2 Val2 SOAP::Lite will build the internal representation $VAR1 = [ bless( { 'ListItem' => [ bless( { 'Name' => 'Name1', 'Value' => 'Val1' } ), bless( { 'Name' => 'Name2', 'Value' => 'Val2' } ) ] }, 'List' ) ]; print $VAR1->[0]->{ListItem}->[0]->{Name}."\n"; would print "Name1". # item key value pairs... for my $item (@{$VAR1->[0]->{ListItem}}) { print "$item->{Name} => $item->{Value}\n"; } Rob
Re: 200 vhosts, 5 sets of libs, 2GB RAM, 1 httpd (seeking advice)
Chris Hagglund wrote: The trouble is, as each vhost loads this config file for its plain and SSL vhost directives, the amount of memory being used seems to be going up, and restarting apache is taking longer and longer. Intead of loading it over and over again (twice for vhosts with ssl!) I am hoping to find a way to tell apache to load PROD mp configuration, then load 100 PROD vhosts that will all share it, then load TEST mp configuration, then load 20 vhosts that use those libs, etc, but I am getting error like: 'mod_perl is already running, too late for PerlSwitches' when I am trying to start setting this up. It sounds like you want a two tier architecture. The front end will proxy a set of mod_perl servers running behind it. The front end will be configured to point to either your TEST, DEV, PROD, dev1, or dev2 apache instances. Each apache instance will only load one set of modules. It should reduce the amount of memory being used substantially and speed up apache restarts. Rob
Re: Charts and Graphs
Bill Whillers wrote: I'm wondering what people are using for efficiently generating charts and graphs on the fly from within a mod_perl environment. I've been using GD::Graph for a while but I'm hoping to get a bit more feature-deep. I'm not terribly concerned about getting a bit more complicated if it means better efficiency and/or better control, etc. Not an opensource solution... But we implemented Corda with pretty good success. GD only got us so far before we wanted graphs that were a bit more "Executive-friendly". It ain't easy to use though. But the graphs are hard to beat. Rob
Re: Lock Files - File is permanently locked
Justin Luster wrote: Does anyone know what might be happening? We are only using Apache::Registry in this instance. I can’t see how a lexically scoped file handle that is being locked is not being unlocked once the process ends. The process isn't ending if you're using Apache::Registry. I think you'll need to use Fcntl qw(:flock); flock $FileHandle, LOCK_UN; unless you set the Max child process config option to 1 (in which case, apache::registry would be useless). Also, if you're using child locking like this, you can write the requesting process's PID to the .lock (or whatever) file. Then a cron job could come along and reap your .lock's if the PID is no longer running. Then your file would only ever be locked for at most a minute. Seems like overkill though. Rob
Re: Lock Files - File is permanently locked
Justin Luster wrote: Here is an example of a call to OpenFile(). You will notice that I'm additionally locking the file itself as well as the lock file (I figured it would not hurt to have both methods): my $LockFileHandle = authlib::FileLock("udata_" . $strRespNum . "_lck.cgi", 1); #Read restart question name my ($DataFileHandle, $blnError) = authlib::OpenFile($strDataFileName, "update", 1, 1); authlib::LockMe($DataFileHandle, 1); authlib::RestartQNameWrite($DataFileHandle, $strRestartQName); close $DataFileHandle; close authlib::FileUnLock($LockFileHandle); Seems like an awful lot of code... open(DATAFILE,">$strDataFileName") or die; flock(DATAFILE,LOCK_EX); seek(DATAFILE,0,0); eval { authlib::RestartQNameWrite(\*DATAFILE,$strRestartQName); }; flock(DATAFILE,LOCK_UN); close(DATAFILE); if($@) { die $@; } Code like that has never failed me on Solaris or Linux. I don't write W32 code, so maybe it's more complicated than that. Also, > close authlib::FileUnLock($LockFileHandle); That seems like an error waiting to happen, since FileUnLock doesn't return a file handle. Rob
Re: Lock Files - File is permanently locked
Justin Luster wrote: Seems like an awful lot of code... open(DATAFILE,">$strDataFileName") or die; flock(DATAFILE,LOCK_EX); seek(DATAFILE,0,0); eval { authlib::RestartQNameWrite(\*DATAFILE,$strRestartQName); }; flock(DATAFILE,LOCK_UN); close(DATAFILE); if($@) { die $@; } *sighs* I need to proofread my code samples more. Ignore this cause it completely wrong. The code I cited was "append" code, rather than "rewrite" code. Oh well. Rob
Re: Malformed header from script
michael watson (IAH-C) wrote: Sorry for the confusion The code also actually attempts to print out HTML headers ie " etc" but these DO NOT come through to the webpage - instead, a bunch of special characters are printed out... Right... because the and tags are being (incorrectly) shoved into the Content-type field by apache.. From the command line do: HEAD http://my.web.host.com I bet you'll see Content-Type: or something close to that. Apache is expecting the first two lines of your output to be a content type header. I suspect that the reason you're running into this issue is because the original code was never intended to be run as a Apache::Registry script, and that the content type printing is being controlled by a global variable. i.e. print "Content-type: foo/bar\n\n" if($HEADER_PRINTED == 0); $HEADER_PRINTED = 1; That global variable is never being reset to 0, and thus all requests (except the very first) end up being sent across without a header. I could be wrong, but I would start grepping for 'Content-type' in the code. Rob
Re: Malformed header from script
michael watson (IAH-C) wrote: [Wed Apr 18 09:56:55 2007] [notice] Apache/2.2.4 (Unix) mod_perl/2.0.3 Perl/v5.8.0 configured -- resuming normal operations [Wed Apr 18 09:56:57 2007] [error] [client 149.155.40.20] malformed header from script. Bad header=: mapview [Wed Apr 18 09:56:57 2007] [warn] /perl/Gallus_gallus/mapview did not send an HTTP header [Wed Apr 18 09:57:45 2007] [error] [client 149.155.42.148] malformed header from script. Bad header=: mapview [Wed Apr 18 09:57:45 2007] [warn] /perl/Gallus_gallus/mapview did not send an HTTP header So this is Ensembl were dealing with, correct? I must confess, I don't really know what the Apache::Registry and ModPerl::Registry modules actually do, but the code in question is handled by ModPerl::Registry. From httpd.conf (mostly a perl script!): That's okay. I've never actually used either of them. In the CGI world, when a perl script is called it's read, parsed, compiled, and executed for each request. Then the script terminates. ModPerl::Registry reads, parses, and compiles the perl script once, and just keeps it in memory for any subsequent requests. The caveat is that sometimes global variables don't get reset to their original states because, well, the script doesn't ever exit. $Location{"/perl"}={ SetHandler => 'perl-script', PerlHandler => 'ModPerl::Registry', # Options => '+ExecCGI', allow => 'from all', # PerlSendHeader => 'On', PerlOptions => '+ParseHeaders', }; This all seems right. It should be examining the output of contigview and mapview to determine if there's a content type header, and if not, it will send text/html. I suspect that /perl may not actually be running in mod_perl. I would add a file to /perl called env. #!/usr/bin/perl print "Content-type: text/plain\n\n"; for (keys %ENV) { print "$_ => $ENV{$_}\n"; } That should print out a line like MOD_PERL => 'mod_perl/2.0.3' if it's working correctly. If not, it's a configuration problem. Maybe the /perl location config isn't in the virtual host you're using? Rob
Re: Getting user input during apache startup
Krist van Besien wrote: The code works insofar that it waits 5 seconds and than proceeds with the default I set, but it completely ignores any keypresses I make. It is as if STDIN is not available at the time this code runs. If I replace the ReadKey(5) with a ReadKey(5,STDIN) I get a syntax error. I suspect that apache may be closing STDIN before it reads the config. Maybe. You could try: close(STDIN); # just in case open(STDIN,"/dev/tty"); ReadMode('cbreak'); print "Press a key\n"; while (1) { $key = ReadKey(-1); if($key) { print "got $key\n"; last; } } ReadMode('restore'); Rob
Re: TIF image file
Michael Peters wrote: Vaughn, Terry wrote: I have some TIF files that I transferred from a windows box to a linux box over a Samba connection. I cannot get Apache to display the file.TIF with this simple .htm It's not apache that's having problems. I don't believe TIF images can be displayed by web browsers. That's correct. There are plugins to do this, and I think a new flash jobber that can open and load tifs. You could look into image magick for doing conversions on the fly for things like previewing before downloading. Just a thought... Rob
[mp1] Eval in Mason causes segfault
I've run into a strange error recently and wanted to see if anyone else had come across this. Basically, I have have a set of database handles created as globals in the HTML::Mason::Commands namespace. To use these, we assign them to an object. i.e.: my $obj = new Foo; $obj->{my_dbh} = $my_dbh; ... Sometimes a mason component will need to make use of more than one of these exported global database handles. To achieve this, I did the following... for my $dbhname (qw(some other handles)) { eval "\$obj->{${dbhname}_dbh} = \$${dbhname}_dbh;"; } In essence: $obj->{some_dbh} = $some_dbh; $obj->{other_dbh} = $other_dbh; $obj->{handles_dbh} = $handles_dbh; Randomly this will throw a segfault. Just for kicks, I tried: for my $dbhname (qw(some other handles)) { eval "\$obj->{${dbhname}_dbh} = \$HTML::Mason::Commands::${dbhname}_dbh;"; } Magically, no more segfaults. I'm sure that this issue has probably been fixed in later versions (ours is very old), but just wanted to give a heads up in case someone else ran into this issue. Rob
[mp2] HTML::Mason and Missing content
We're seeing some very strange behavior with HTML::Mason/Apache 2.2/MP2 that only affects a few of our files. I'm able to reproduce it reliably. We have a custom handler method that handles all requests to our site by passing them off to HTML::Mason (with exceptions for images, and the like). On some pages, the first few lines of HTML output are missing. If I add a newline to the very first line of the mason component, all of the content appears (see below). This has led me to believe that the issue is related to headers. Something is eating the first few lines of all out our output up until the the first blank line. Those lines however, do not appear in the header output of the request, though. They just seem to disappear somewhere inside apache2.2. Has anyone seen this problem before? We didn't experience it under MP1. Thanks, Rob - foo.mc: -- START -- Foo File Testing Apache 2.2: <% $now %> <%init> my $now = scalar localtime; <%attr> no_formatting=>1 menubar=>0 navbar=>0 footer=>0 subnav=>0 -- END -- Output: -- START -- Connection: close Date: Mon, 07 Apr 2008 18:41:48 GMT Server: Apache/2.2.8 (Unix) mod_ssl/2.2.8 OpenSSL/0.9.7m mod_perl/2.0.3 Perl/v5.8.7 Content-Type: text/html Client-Date: Mon, 07 Apr 2008 18:41:48 GMT Client-Peer: XXX Client-Response-Num: 1 Client-Transfer-Encoding: chunked - foo_fixed.mc: -- START -- Foo File Testing Apache 2.2: <% $now %> <%init> my $now = scalar localtime; <%attr> no_formatting=>1 menubar=>0 navbar=>0 footer=>0 subnav=>0 -- END -- Output: -- START -- Connection: close Date: Mon, 07 Apr 2008 18:43:04 GMT Server: Apache/2.2.8 (Unix) mod_ssl/2.2.8 OpenSSL/0.9.7m mod_perl/2.0.3 Perl/v5.8.7 Content-Type: text/html Client-Date: Mon, 07 Apr 2008 18:43:04 GMT Client-Peer: XX Client-Response-Num: 1 Client-Transfer-Encoding: chunked Title: Foo File Foo File Testing Apache 2.2: Mon Apr 7 14:43:04 2008 -- END --
Re: [mp2] HTML::Mason and Missing content
Felipe de Jesús Molina Bravo wrote: Hi how did you installed modperl ... static or dinamic? Dynamic... But I'm not getting segfaults. The issue was caused by having PerlSendHeader On. Switching it to off, the problem went away. Rob
[JOB] Perl/mod_perl/Mason Developer
The Infrastructure Development team at AOL is looking to hire a perl developer to assist in the development of our internal infrastructure. The good: Great pay and benefits. The work is steady, interesting, and important to AOL operations. The bad: It's AOL. Required skills: Perl, DBI, HTML::Mason, Apache, mod_perl. Unix based OS experience is required. Desired skills: PostgresQL, Sybase, Oracle, RPM. Java and perl based web services experience is a plus. Please send resume to Robert Landrum: [EMAIL PROTECTED]
Re: [JOB] Perl/mod_perl/Mason Developer
This is an onside position only in Dulles, VA. Sorry for the confusion... Rob Robert Landrum wrote: The Infrastructure Development team at AOL is looking to hire a perl developer to assist in the development of our internal infrastructure. The good: Great pay and benefits. The work is steady, interesting, and important to AOL operations. The bad: It's AOL. Required skills: Perl, DBI, HTML::Mason, Apache, mod_perl. Unix based OS experience is required. Desired skills:PostgresQL, Sybase, Oracle, RPM. Java and perl based web services experience is a plus. Please send resume to Robert Landrum: [EMAIL PROTECTED]