in reply to Logging logins!

One way would be to write a mod_perl auth handler...
Warning: Untestest code, but looks ok :)
package Apache::LogAuth; use strict; use Apache::Constants qw(:common); sub handler { my $r = shift; my ($res, $sent_pw) = $r->get_basic_auth_pw; return $res if $res != OK; my $user = $r->connection->user; unless ($user && $sent_pw) { return AUTH_REQUIRED; } open(SOMELOG,">>somelogfile") || return DECLINED; print SOMELOG $user,"\n"; close(SOMELOG); return OK; } 1;
Ofcourse you can use $r->log->debug. The Apache config file should then contain something like
<LOCATION /> AuthName Restricted AuthType Basic PerlAuthenHandler Apache::LogAuth require valid-user </LOCATION>
Another option is to just log $ENV{REMOTE_USER} with a script... but that doesn't specifically cover logins :)
Update: This is a mod_perl solution! If you don't have a clue about this, just forget it

Greetz
Beatnik
... Quidquid perl dictum sit, altum viditur.

Replies are listed 'Best First'.
Re: Re: Logging logins!
by scisuk (Initiate) on May 20, 2002 at 13:10 UTC
    Thanks,

    I see what you are saying - as I have not used mod_perl before can I bee dense and ask how I would implement that on the server?

    the .htaccess file is located as follows:

    http://www.domain.ext/secure/.htaccess

    and the admint script/password file are as follows:

    http://www.domain.ext/cgi-bin/admin.pl
    and
    http://www.domain.ext/cgi-bin/.htpasswd

    Would the mod_perl sit in the secure directory?
      mod_perl is an Apache/Perl integration module. You usually consult the webserver admin about using it. I wouldn't recommend installing it (even if you had rights) if you don't know what you're doing :) Go for a less complex method of doing what you want. If you feel comfortable with perl, look into mod_perl and give this a try.
      Anyway, if the admin asks, the settings defined above go in the apache config file (like httpd.conf) and the module goes in the Apache subdir in your Perl directory (I don't mean cgi-bin !). I do assume your admin has a clue and you have a VERY good reason to do this :)

      Greetz
      Beatnik
      ... Quidquid perl dictum sit, altum viditur.
        The reason for me needing to do this is purely to keep a text log of who logs in.

        In the following form or similar would be fine:

        user1 : 20/05/02 @ 12:00
        user3 : 20/05/02 @ 12:01
        user2 : 20/05/02 @ 12:02
        user5 : 20/05/02 @ 12:03
        user4 : 20/05/02 @ 12:04


        That is the only real details I need, and would like to keep it as simple as possible while sticking to the use of the .htaccess file.