bashrcbackticks.netrc

.netrc, .fetchmailrc, and non-hardcoded passwords


Is there any way .netrc or .fetchmailrc can

  1. fetch passwords from environment variables, or
  2. fetch them from a spawned/forked shell?

mutt can do it with something like this:

set my_pw_gmail=`some shell command that emits to stdout`

Is there any similar ability in either of these RC files?

Thanks!


Solution

  • It depends on how the config file is read and interpreted. This means that the c/c++/java or whatever has to call the equivalent of system() on the back tic-ed string.

    BSD's ftp and gnu ftp use environment variables to look for .netrc. For gnu (what you probably have) export NETRC=/path/to/different where /path/to/different is the directory where one version of .netrc lives. It also will use HOME for the default .netrc

    Read here: http://www.manpagez.com/man/1/ftp/

    BSD ftp uses the HOME variable to look for .netrc.

    fetchmail is different

    HOME_ETC
    If the HOME_ETC variable is set, fetchmail will read $HOME_ETC/.fetchmailrc instead of ~/.fetchmailrc.
    If HOME_ETC and FETCHMAILHOME are both set, HOME_ETC will be ignored.
    

    See : http://linux.die.net/man/1/fetchmail

    So, environment variables are an answer to your question, since you were implying their use by your query. But the answer means you need several different files, not just one.