From b375da4f34a65409d2e657c12e434c279c3199dc Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 4 Nov 2003 17:57:04 +0000 Subject: adding --- bin/create-fetchmailrc | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 bin/create-fetchmailrc (limited to 'bin/create-fetchmailrc') diff --git a/bin/create-fetchmailrc b/bin/create-fetchmailrc new file mode 100644 index 000000000..7b28bfbc0 --- /dev/null +++ b/bin/create-fetchmailrc @@ -0,0 +1,46 @@ +#!/usr/bin/perl -w +# this quick hack helps you generate/maintain .fetchmailrc files from +# FS::acct_snarf data. it is run from a shellcommands export as: +# create-fetchmailrc $username $dir $snarf_machine1 $snarf_username1 $snarf__password1 $snarf_machine2 $snarf_username2 $snarf__password2 $snarf_machine3 $snarf_username3 $snarf__password3 $snarf_machine4 $snarf_username4 $snarf__password4 $snarf_machine5 $snarf_username5 $snarf__password5 $snarf_machine6 $snarf_username6 $snarf__password6 $snarf_machine7 $snarf_username7 $snarf__password7 $snarf_machine8 $snarf_username8 $snarf__password8 $snarf_machine9 $snarf_username9 $snarf__password9 $snarf_machine10 $snarf_username10 $snarf__password10 + +use strict; +use POSIX qw( setuid setsid ); + +my $header = <$filename") or die "can't open $filename: $!\n"; +chown 0600, $filename or die "can't chown 600 $filename: $!\n"; +print FETCHMAILRC $header; + +while ($ARGV[0]) { + my( $s_machine, $s_username, $s_password ) = splice( @ARGV, 0, 3 ); + print FETCHMAILRC < Date: Wed, 5 Nov 2003 11:13:40 +0000 Subject: fixup --- bin/create-fetchmailrc | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'bin/create-fetchmailrc') diff --git a/bin/create-fetchmailrc b/bin/create-fetchmailrc index 7b28bfbc0..e92971140 100644 --- a/bin/create-fetchmailrc +++ b/bin/create-fetchmailrc @@ -1,10 +1,10 @@ #!/usr/bin/perl -w # this quick hack helps you generate/maintain .fetchmailrc files from # FS::acct_snarf data. it is run from a shellcommands export as: -# create-fetchmailrc $username $dir $snarf_machine1 $snarf_username1 $snarf__password1 $snarf_machine2 $snarf_username2 $snarf__password2 $snarf_machine3 $snarf_username3 $snarf__password3 $snarf_machine4 $snarf_username4 $snarf__password4 $snarf_machine5 $snarf_username5 $snarf__password5 $snarf_machine6 $snarf_username6 $snarf__password6 $snarf_machine7 $snarf_username7 $snarf__password7 $snarf_machine8 $snarf_username8 $snarf__password8 $snarf_machine9 $snarf_username9 $snarf__password9 $snarf_machine10 $snarf_username10 $snarf__password10 +# create-fetchmailrc $username $dir $snarf_machine1 $snarf_username1 $snarf__password1 $snarf_machine2 $snarf_username2 $snarf__password2 ... use strict; -use POSIX qw( setuid setsid ); +use POSIX qw( setuid setgid ); my $header = <$filename") or die "can't open $filename: $!\n"; -chown 0600, $filename or die "can't chown 600 $filename: $!\n"; +chown $uid, $gid, $filename or die "can't chown $uid.$gid $filename: $!\n"; +chmod 0600, $filename or die "can't chmod 600 $filename: $!\n"; print FETCHMAILRC $header; while ($ARGV[0]) { @@ -33,14 +37,9 @@ END close FETCHMAILRC; -my $gid = scalar(getgrnam($username)) or die "can't find $username's gid\n"; -my $uid = scalar(getpwnam($username)) or die "can't find $username's uid\n"; - setgid($gid) or die "can't setgid $gid\n"; setuid($uid) or die "can't setuid $uid\n"; +$ENV{HOME} = $homedir; -exec(qw( fetchmail -a -K --antispam "550,451" -d 180 -f ), $filename); -die "can't execute fetchmail: $!"; - - +system(qq(fetchmail -a -K --antispam "550,451" -d 180 -f $filename)); -- cgit v1.2.1 From 24b5d695250eb0e93d50f35d0fa46776223d2a68 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 3 Mar 2004 16:32:08 +0000 Subject: fix for case where no .fetchmailrc should be create and fetchmail should not be run --- bin/create-fetchmailrc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'bin/create-fetchmailrc') diff --git a/bin/create-fetchmailrc b/bin/create-fetchmailrc index e92971140..11bde0ce3 100644 --- a/bin/create-fetchmailrc +++ b/bin/create-fetchmailrc @@ -22,6 +22,8 @@ my $filename = "$homedir/.fetchmailrc"; my $gid = scalar(getgrnam($username)) or die "can't find $username's gid\n"; my $uid = scalar(getpwnam($username)) or die "can't find $username's uid\n"; +exit unless $ARGV[0]; + open(FETCHMAILRC, ">$filename") or die "can't open $filename: $!\n"; chown $uid, $gid, $filename or die "can't chown $uid.$gid $filename: $!\n"; chmod 0600, $filename or die "can't chmod 600 $filename: $!\n"; -- cgit v1.2.1