You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Eric Schwartz <em...@pobox.com> on 2003/09/12 09:01:24 UTC
Apache::Session permissions problem
I found a pretty useful article at
http://www.linuxjournal.com/article.php?sid=4143 on how to use
Apache::Session with Mason. I followed the article, more or less, and
ended up with this bit of code in my handler.pl to tie() my $session
variable to an Apache::Session class:
eval {
tie %HTML::Mason::Commands::session, 'Apache::Session::DBI',
($cookies{$session_cookie_name} ?
$cookies{$session_cookie_name}->value() : undef),
{
DataSource => $dbsource,
UserName => $dbuser,
Password => $dbpass
};
};
All the database variables are correct; I use them elsewhere with no
problem. The problem is that the session seems to be intermittent--
some pages seem to recognize it, others don't. This smelled a lot like
a problem where the session was getting set in one Apache instance and
not others, so I wondered if the session was getting stored in the
database correctly; after the previous eval, all I ever get in $@ is:
Permission denied at
/Library/Perl/Apache/Session/SysVSemaphoreLocker.pm line 46.
Which seems to indicate it isn't. I STFW, and found several people who
seem to have had the same problem I have, but the solutions proffered
involve ipcs and ipcrm, which don't exist on my Mac OS X 10.2.6 system.
Suggestions are more than welcome; I'm not quite sure how
Session::SysVSempaphoreLocker got involved in the first place, since I
don't explicitly reference it.
Mightily confused,
-=Eric
Re: Apache::Session permissions problem
Posted by Enrico Sorcinelli <e....@pisa.iol.it>.
On Fri, 12 Sep 2003 01:01:24 -0600
Eric Schwartz <em...@pobox.com> wrote:
Hi Eric,
> I found a pretty useful article at
> http://www.linuxjournal.com/article.php?sid=4143 on how to use
> Apache::Session with Mason.
I wrote a tutorial on session management with HTML::Mason and
Apache::SessionManager (a wrapper around Apache::Session) available at:
http://search.cpan.org/author/ENRYS/Apache-SessionManager-0.06/SessionManager/cookpod.pod#Apache::SessionManager_WITH_HTML::Mason
I hope that it will be useful for you.
Yes, I know, now there is a Mason extension to handle sessions (not in the
Mason core), _but_:
1) when I wrote Apache::SessionManager, the extension wasn't yet available :-)
(moreover A::SM has a session expiration/inactivity built-in cleanup
mechanism)
2) with Apache::SessionManager you can use session object also in other Apache
life request phases than Response phase (for example I need session
in Authentication phase). With MasonX::Request::WithApacheSession you cannot
(if I not mistake)
3) There is no way to use URI session tracking (session id is embedded in left
side of the URI)
In all other case, MasonX::Request::WithApacheSession works fine.
by
- Enrico
RE: Apache::Session permissions problem
Posted by Perrin Harkins <pe...@elem.com>.
> Is there a, or are there initiatives to keep an 'accurate' document
> repository?
The field of knowledge is too broad for any one person to maintain,
especially since the main people who maintain the site docs are quite busy
building mod_perl 2. This is why we count on individuals stepping up and
sending in corrections to outdated things they find in the docs.
> I personally like perl.apache.org as a starting point, but
> it is quite restricted to mod_perl and mod_perl alone. (This is not
> meant as a rude remark!). Should and could this be broader containing
> links to interesting articles on 'well known subjects'?
There are quite a few links to other sources on perl.apache.org. My basic
rule of thumb is to start with the most specific source of documentation.
In your case, since you are trying to use Mason, you should look on the
Mason site. There you would have found a note that the article you read
is outdated, and a link to the current docs:http://masonhq.com/user/adpacifico/ApacheSessionMason.html
> PS: Apache::Session::DBI might be ancient, when I did some research for
> this mail I stumbled upon
> http://perl.apache.org/docs/1.0/guide/snippets.html#An_example_of_using_Apac> he__Session__DBI_with_cookies. Perhaps it is a good beginning to try to
> keep/get outdated and ancient stuff from Our Main Source of
> Information?
Yes, it would definitely be good to update or remove that snippet. A
patch would certainly be appreciated.
- Perrin
Re: Apache::Session permissions problem
Posted by Perrin Harkins <pe...@elem.com>.
Eric,
Sorry if I came off overly critical. Many people have had problems
trying to use Mason with Apache::Session because of that article. This
is why on the Mason website the link to that article describes it as
outdated and steers people to newer documentation. (It probably should
also steer them to the new handler...)
Eric Schwartz wrote:
> Beggars can't be choosers, and all that, but would you mind telling me
> what handler you're talking about? I looked around for session handling
> and Mason, and that article was the best one I found in terms of
> explaining how it worked and how to use it.
Did you look on the Mason site, http://masonhq.com/? That's the best
place to find information on Mason. A search for "session" on that site
includes a reference to MasonX::Request::WithApacheSession, available
from CPAN. This is mentioned in the administrator's manual that comes
with Mason. It's possible that you have an old version of Mason that
predates this.
>> Apache::Session::DBI (which is what the article refers to) is ancient and
>> should not be used.
>
> How can I know this? The documentation for Apache::Session::DBIStore
> (which A::S::DBI refers to) doesn't say anything about being obsolete or
> deprecated. Is there an archive of received wisdom somewhere I should
> be checking to validate articles like the one I found?
The latest Apache::Session on CPAN is version 1.54, released in October
2001. The last release that included a module called
Apache::Session::DBI was version 1.03, released two years earlier. I'm
not certain what CPAN.pm would do if you told it to install
Apache::Session::DBI. It might install the old one, which would be very
unfortunate. Is that how you installed it?
>> You shouldn't use the IPC locking in Apache::Session. You didn't mention
>> which database you're using, but most of them have alternative ways of
>> doing locking. In my opinion, the locking approach taken in
>> Apache::Session is not a good one for the average web site and you should
>> simply turn it off by using the NullLocker.
>
>
> How?
By using Apache::Session::Flex. The configuration for
MasonX::Request::WithApacheSession also lets you do this.
> It's not
> particularly obvious from the documentation I can find that it's going
> to be used, or how to select alternative methods.
Look at the source and you'll see it. It's all much clearer in the more
recent release though.
> I installed
> Apache::Session from CPAN, and the docs refer to PosixFileLocker
> SysVSemaphoreLocker and NullLocker, but no perldocs for those modules
> are on my system.
The Apache::Session::PosixFileLocker and
Apache::Session::SysVSemaphoreLocker modules are included with
Apache::Session (although both are obsolete and only part of the old
version that you installed). They have no documentation, so perldoc
will not find them. The later equivalents (Apache::Session::Lock::File)
do have docs.
> 'perldoc Apache::Session::DBI' says it uses A::S::PosixFileLocker, not
> A::S::SysVSemaphoreLocker. Are the docs wrong, or the code?
The docs are wrong. You can see it refers to the semaphore locker if
you look at the source.
Basically, you stumbled across an old article that referred to an
obsolete version of Apache::Session, and all of your problems stem from
that. If you get a later version and check out the Mason handler and
the newer documentation on masonhq.com, I think it will all start to
make sense to you.
- Perrin
Re: Apache::Session permissions problem
Posted by Eric Schwartz <em...@pobox.com>.
On Saturday, Sep 13, 2003, at 09:22 America/Denver, Perrin Harkins
wrote:
>> I found a pretty useful article at
>> http://www.linuxjournal.com/article.php?sid=4143 on how to use
>> Apache::Session with Mason.
>
> I'm afraid that is not a very good article. It's out of date, and
> shows
> poor error handling. If you want to use sessions with Mason, you
> should
> be using the session handler that Mason provides. That is available on
> CPAN and is supported on the Mason list.
Beggars can't be choosers, and all that, but would you mind telling me
what handler you're talking about? I looked around for session
handling and Mason, and that article was the best one I found in terms
of explaining how it worked and how to use it.
> Apache::Session::DBI (which is what the article refers to) is ancient
> and
> should not be used.
How can I know this? The documentation for Apache::Session::DBIStore
(which A::S::DBI refers to) doesn't say anything about being obsolete
or deprecated. Is there an archive of received wisdom somewhere I
should be checking to validate articles like the one I found?
> You shouldn't use the IPC locking in Apache::Session. You didn't
> mention
> which database you're using, but most of them have alternative ways of
> doing locking. In my opinion, the locking approach taken in
> Apache::Session is not a good one for the average web site and you
> should
> simply turn it off by using the NullLocker.
How? I never asked for IPC locking; it somehow snuck in. It's not
particularly obvious from the documentation I can find that it's going
to be used, or how to select alternative methods. I installed
Apache::Session from CPAN, and the docs refer to PosixFileLocker
SysVSemaphoreLocker and NullLocker, but no perldocs for those modules
are on my system. I'm honestly trying to figure out how I can draw
those conclusions for myself, so I'm not stuck asking this list about
them.
>> Suggestions are more than welcome; I'm not quite sure how
>> Session::SysVSempaphoreLocker got involved in the first place, since I
>> don't explicitly reference it.
>
> Apache::Session::DBI uses it for locking.
'perldoc Apache::Session::DBI' says it uses A::S::PosixFileLocker, not
A::S::SysVSemaphoreLocker. Are the docs wrong, or the code?
-=Eric
RE: Apache::Session permissions problem
Posted by Frank Maas <fr...@cheiron-it.nl>.
> I'm afraid that is not a very good article. It's out of date,
...
> Apache::Session::DBI (which is what the article refers to) is ancient
> and should not be used.
I stumbled upon this problem quite a few times. Trying to get the hang
of using cookies for authentication and sessions there are tons of
modules and (a bit less...) articles, but they all seem outdated or
simply not useful. So I build something myself, but am not quite sure
this was the way to go.
I had the same experience when (OT, sorry) I looked into things about
using XML in combination with (mod_)perl. Most of the articles are rather
old and I have no clue if they are outdated. Here as well I made some
choices of my own, still thinking I am at least reinventing part of the
wheel.
Is there a, or are there initiatives to keep an 'accurate' document
repository? I personally like perl.apache.org as a starting point, but
it is quite restricted to mod_perl and mod_perl alone. (This is not
meant as a rude remark!). Should and could this be broader containing
links to interesting articles on 'well known subjects'? Should we then
need som (continuous) reviewing and rating mechanism to separate the
good from the bad? Or is Google still the way to go?
--Frank
PS: Apache::Session::DBI might be ancient, when I did some research for
this mail I stumbled upon
http://perl.apache.org/docs/1.0/guide/snippets.html#An_example_of_using_Apac
he__Session__DBI_with_cookies. Perhaps it is a good beginning to try to
keep/get outdated and ancient stuff from Our Main Source of Information?
Re: Apache::Session permissions problem
Posted by Perrin Harkins <pe...@elem.com>.
> I found a pretty useful article at
> http://www.linuxjournal.com/article.php?sid=4143 on how to use
> Apache::Session with Mason.
I'm afraid that is not a very good article. It's out of date, and shows
poor error handling. If you want to use sessions with Mason, you should
be using the session handler that Mason provides. That is available on
CPAN and is supported on the Mason list.
Apache::Session::DBI (which is what the article refers to) is ancient and
should not be used.
> Permission denied at
> /Library/Perl/Apache/Session/SysVSemaphoreLocker.pm line 46.
>
> Which seems to indicate it isn't. I STFW, and found several people who
> seem to have had the same problem I have, but the solutions proffered
> involve ipcs and ipcrm, which don't exist on my Mac OS X 10.2.6 system.
You shouldn't use the IPC locking in Apache::Session. You didn't mention
which database you're using, but most of them have alternative ways of
doing locking. In my opinion, the locking approach taken in
Apache::Session is not a good one for the average web site and you should
simply turn it off by using the NullLocker.
> Suggestions are more than welcome; I'm not quite sure how
> Session::SysVSempaphoreLocker got involved in the first place, since I
> don't explicitly reference it.
Apache::Session::DBI uses it for locking.
- Perrin