2 # this quick hack helps you generate/maintain .fetchmailrc files from
3 # FS::acct_snarf data. it is run from a shellcommands export as:
4 # create-fetchmailrc $username $dir $snarf_machine1 $snarf_username1 $snarf__password1 $snarf_machine2 $snarf_username2 $snarf__password2 ...
7 use POSIX qw( setuid setgid );
10 # Configuration created by create-fetchmailrc
11 set postmaster "postmaster"
18 my $username = shift @ARGV or die "no username specified\n";
19 my $homedir = shift @ARGV or die "no homedir specified\n";
20 my $filename = "$homedir/.fetchmailrc";
22 my $gid = scalar(getgrnam($username)) or die "can't find $username's gid\n";
23 my $uid = scalar(getpwnam($username)) or die "can't find $username's uid\n";
27 open(FETCHMAILRC, ">$filename") or die "can't open $filename: $!\n";
28 chown $uid, $gid, $filename or die "can't chown $uid.$gid $filename: $!\n";
29 chmod 0600, $filename or die "can't chmod 600 $filename: $!\n";
30 print FETCHMAILRC $header;
33 my( $s_machine, $s_username, $s_password ) = splice( @ARGV, 0, 3 );
34 print FETCHMAILRC <<END;
36 user '$s_username' there with password '$s_password' is '$username' here
42 setgid($gid) or die "can't setgid $gid\n";
43 setuid($uid) or die "can't setuid $uid\n";
44 $ENV{HOME} = $homedir;
46 system(qq(fetchmail -a -K --antispam "550,451" -d 180 -f $filename));