Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 355251 - net-mail/fetchmail - improvement on init-script
Summary: net-mail/fetchmail - improvement on init-script
Status: RESOLVED WONTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Unspecified (show other bugs)
Hardware: All Linux
: High enhancement
Assignee: Net-Mail Packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-16 21:33 UTC by Uwe Lohmann
Modified: 2011-08-24 09:27 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
proposed init-script for fetchmail (fetchmail init script,1010 bytes, text/plain)
2011-02-16 21:34 UTC, Uwe Lohmann
Details
proposal for /etc/conf.d/fetchmail (config_fetchmail.txt,303 bytes, text/plain)
2011-02-16 22:19 UTC, Uwe Lohmann
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Uwe Lohmann 2011-02-16 21:33:34 UTC
Hi,

Don’t get me wrong, but, although the current fetchmail init-script is working, I am of the opinion that it should be improved.

My understanding is, that the current fetchmail init-script has the following disadvantages:

a) 2 different configuration files are existing in /etc (/etc/fetchmailrc and /etc/conf.d/fetchmail)

b) The configuration file /etc/fetchmailrc includes the information and identification of the users to receive their mails from the external user mailboxes. Each user should therefore be able to modify this file, but currently only root can do it. – In addition, the program fetchmailconf creates, modifies and supports only the ~/.fetchmailrc file and not /etc/fetchmailrc. Consequently, the information from all user ~ / fetchmailrc needs to be transferred by root into the /etc/fetchmailrc. This is acceptable for a single user system, but not for a multi user system.

c) In the fetchmail documentation (e.g. man fetchmail) is always shown that fetchmail expects its configuration for each user in the user home directory in the file  ~/.fetchmailrc

d) The file /etc/conf.d/fetchmail controls (currently) only the time interval for the daemon mode.  

I suggest to use only one configuration file in /etc (/etc/conf.d/fetchmail) to control the administrative options/tasks (postmaster, mda, logging, etc.) and to use the ~/.fetchmailrc  under the control of each single user as described in the fetchmail documentation. 

Tgis can be achieved with the attached init-script, below an extract from the script.

The advantage is the strict deviation between administration options/tasks and user definitions. All parameters defined in /etc/conf.d/fetchmail supersede the parameter set by users (~/.fetchmailrc).
The proposed script allows the administrator also, to define for which user fetchmail shall be started (default is for all users).

OUOTE
…
start() {
        ebegin "Starting fetchmail"
        if [ -z $USERS ]; then
            # No user is defined in /etc/conf.d/fetchmail ==> get all users
            USERS=`cat /etc/passwd | grep home | cut -d ':' -f1`
        fi

	# simple function to get all options defined in /etc/conf.d/fetchmail
	OPTIONS=`cat /etc/conf.d/fetchmail | grep \"--\" | grep -v \"#\" | tr '\n' ' ' `

        for user in $USERS 
        do
           if [ -f /home/$user/.fetchmailrc ]; then
		# only, if user has a ~./fetchmailrc file
                su $user -c "/usr/bin/fetchmail --pidfile $piddir/$user.pid $OPTIPNS"
           fi
        done
        eend ${?}
}
…
UNQOUTE

The script is starting a separate fetchmail instance for each single user with the user-defined permissions. The advantage is that each user can setup his parameters independently and differently.

I have tested the script and found it successfully working. Of course, the script is basic and asks for improvement. But therefore, I would like to open the discussion.


Regards,
Uwe
Comment 1 Uwe Lohmann 2011-02-16 21:34:37 UTC
Created attachment 262801 [details]
proposed init-script for fetchmail
Comment 2 Uwe Lohmann 2011-02-16 22:19:43 UTC
Created attachment 262807 [details]
proposal for /etc/conf.d/fetchmail
Comment 3 Eray Aslan gentoo-dev 2011-08-24 09:27:02 UTC
This is way too fragile.  It might work in your case but won't work in general.  Closing as WONTFIX.

I don't think running fetchmail as a system wide daemon is such a good choice anyway.