fetchmail-friends
[Top] [All Lists]

[fetchmail] Re: directory change

2002-07-02 01:10:25
Quoting from Sunil Shetye's mail on Mon, Jul 01, 2002 at 05:45:41PM +0530:
All this can be traced back to the innocuous looking chdir("/") in the
daemonize() function. There are several possible alternatives:

Here is a solution which is different from the solutions suggested
before:

1) save the current directory.

2) parse the command line arguments. any relative file mentioned
should be expanded with respect to the current directory.

3) parse the rcfile. any relative file mentioned should be expanded
with respect to the location of the rcfile.

4) do a chdir("/").

5) when reexecing, restore to the saved directory first.

Note that "fetchmail -V" should now always show the full pathnames!

When getcwd() is not available, steps 1, 4, and 5 above are skipped.
So, reexecing will not cause any problems as chdir() is now skipped.

Please ignore the previous patches in this thread while applying this
patch.

e.g.:

If rcfile has

set logfile "tmp/fetchmail.logs"

$ echo $HOME
/home/shetye
$ pwd
/var
$ fetchmail
    (logs to "/home/shetye/tmp/fetchmail.logs")
    (previously logged to "/var/tmp/fetchmail.logs")
$ touch ~/.fetchmailrc
$ fetchmail
    (continues logging there)
    (previously logged to "/tmp/fetchmail.logs")
$ fetchmail -q
$ fetchmail -L tmp/fetchmail.logs
    (logs to "/var/tmp/fetchmail.logs")
    (previously logged to "/var/tmp/fetchmail.logs")
$ touch ~/.fetchmailrc
$ fetchmail
    (continues logging there)
    (previously logged to "/tmp/fetchmail.logs")

Sunil Shetye.

Attachment: fetchmail-5.9.13-relative.patch
Description: Text document

<Prev in Thread] Current Thread [Next in Thread>