# There are five ways to give the password for the remote IMAP
# server:
#
-# 1. No password at all specified in the config file. If a matching
-# entry is found in ~/.netrc (see netrc (5) for information) the
-# password from the matching entry will be used. Otherwise you
-# will be prompted for the password when OfflineIMAP starts.
+# 1. No password at all specified in the config file. If a matching entry is
+# found in ~/.netrc (see netrc (5) for information) the password from the
+# matching entry will be used. If there is no ~/.netrc file but there is an
+# /etc/netrc file, the password will instead be taken from there. Otherwise
+# you will be prompted for the password when OfflineIMAP starts.
#
# 2. The remote password stored in this file with the remotepass
# option. Example:
if netrcentry:
return netrcentry[0]
+ try:
+ netrcentry = netrc.netrc('/etc/netrc').authentificator(self.gethost())
+ except IOError, inst:
+ if inst.errno != errno.ENOENT:
+ raise
+ else:
+ if netrcentry:
+ return netrcentry[0]
+
+
def getport(self):
return self.getconfint('remoteport', None)
user = self.getconf('remoteuser')
if user == None or user == netrcentry[0]:
return netrcentry[2]
+ try:
+ netrcentry = netrc.netrc('/etc/netrc').authenticators(self.gethost())
+ except IOError, inst:
+ if inst.errno != errno.ENOENT:
+ raise
+ else:
+ if netrcentry:
+ user = self.getconf('remoteuser')
+ if user == None or user == netrcentry[0]:
+ return netrcentry[2]
return None
def getfolder(self, foldername):