[Tutor] automatic account destruction
jb
jb at riseup.net
Sun Apr 18 13:09:30 EDT 2004
On Sun, Apr 18, 2004 at 02:09:00AM -0400, Kirk Bailey wrote:
> I give people free email accounts. From time to time, I have the task
> of searching for abandoned accounts and removing them, which is a time
> consuming chore. This is a bother, world class. So I am building a
> script which opens the first line of every email popbox and extracts
> the first line. This is formatted as:
> "From idiot1 at netzero.net Fri Nov 9 00:30:27 2001"
> (quotemarks mine, not found in data)
> and I must crunch as needed to turn it into SECONDS SINCE THE EPOCH.
you can use the os.stat function to do something similar (with the st_ctime
field) without reading the file. st_ctime is in seconds since the epoch, if
i remember correctly.
> I then add a magic number to it (the number of seconds in 2 months),
> and compare it to NOW. If that sum is smaller than NOW, the message is
> VERY OLD, and we assume the account is abandoned, and delete it. We
> repeat this loop for every popbox in the directory, which contains
> nothing else BUT mailboxes, glob.glob('*.') to the rescue here.
>
> This script is still in alpha stage, but I thought the list may find
> the process to do this crunching intresting.
>
> I am unsure how to have a script run a su function. Sure,
> os.system('rmuser'+filename)
> comes to mind, but will FreeBSD accept such commands from a script
> running as a cronjob?
if you really want that you can run such a script in root' crontab, or
use sudo and a (NOPASSWD) option. however, running rmuser automatically
seems a bit scary! i would advocate the use of a confirmation step
somewhere in this process :)
> I will post the incomplete script on the tinylist site. Click THIS
> http://www.tinylist.org/abandontest.txt
> to view it.
>
> Please keep in mind this script is untested as of yet and can use LOTS
> of work, and I welcome advice. As always, it is COPIOUSLY commented.
>
More information about the Tutor
mailing list