PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Logiciels d'hébergement > comp.mail.imap > track user login
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.mail.imap Discussion of IMAP-based mail systems.

track user login

Réponse
 
LinkBack Outils de la discussion
Vieux 12/03/2006, 15h08   #1
Pål Monstad
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut track user login

Hi!

I think I'm running imap2000 on Fedora core 2. I know user login actions are
logged in /etc/log/maillog. It is hard to track which user have logged in
and which has never logged in. I'd like to have a log with user login
statistic, i.g. when a certain user logged in, years back in time, only
containing the last user's login. Is there a way to tell imapd to run a
script each time a user logs in? I'd like to have a script which changes
date stamp on a user specific file each time a user logs in. Is this
possible, or is there any other way around this?
--
Pål Monstad


  Réponse avec citation
Vieux 12/03/2006, 18h37   #2
Mark Crispin
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: track user login

On Sun, 12 Mar 2006, P$Be(Bl Monstad wrote:
> I think I'm running imap2000 on Fedora core 2.


If you are really running imap-2000, that is a very old version of UW
imapd. Drop whatever you are doing and immediately upgrade to the latest
release version, imap-2004g:
ftp://ftp.cac.washington.edu/mail/imap.tar.Z

If you feel adventuresome (you must be for running such an old version),
you could try a development snapshot of imap-2006:
ftp://ftp.cac.washington.edu/mail/imap-2006.DEV.tar.Z
although note that a major update is coming in the next few weeks.

> I know user login actions are
> logged in /etc/log/maillog. It is hard to track which user have logged in
> and which has never logged in. I'd like to have a log with user login
> statistic, i.g. when a certain user logged in, years back in time, only
> containing the last user's login. Is there a way to tell imapd to run a
> script each time a user logs in? I'd like to have a script which changes
> date stamp on a user specific file each time a user logs in. Is this
> possible, or is there any other way around this?


There isn't anything in UW imapd itself to do that, but it would be very
easy to write code to do this. The file that you want to edit is
imap-????/src/osdep/unix/log_std.c
It consists of a single function, loginpw(). What you want to do is
insert code in that function to perform whatever action you like.

Note that, although loginpw() is called with a struct passwd * for the
user that is logging in, that struct (in pw) may be clobbered by the
initgroups() call depending upon your C library (hence the seemingly
pointless and silly copy of the uid and name). So, if you need any of
that data for your action, be sure that you either do it before the
initgroups() call or do a save.

For example, here's a modified version that will create/update the
timestamp of a file called ".lastimap" in the user's home directory (this
is off the top of my head, I haven't actually tested it).

#define STAMP "/.lastimap"

long loginpw (struct passwd *pw,int argc,char *argv[])
{
uid_t uid = pw->pw_uid;
char *name = cpystr (pw->pw_name);
char *stamp = strcat (strcpy ((char *) fs_get (strlen (pw->pw_dir) +
sizeof (STAMP)),pw->pw_dir),
STAMP);
long ret = !(setgid (pw->pw_gid) || initgroups (name,pw->pw_gid) ||
setuid (uid));
int fd = ret ? creat (stamp,0400) : -1;
if (fd >= 0) close (fd);
fs_give ((void **) &stamp);
fs_give ((void **) &name);
return ret;
}

-- Mark --

http://panda.com/mrc
Democracy is two wolves and a sheep deciding what to eat for lunch.
Liberty is a well-armed sheep contesting the vote.
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 08h14.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,08061 seconds with 10 queries