From 4b564bd56803885b932dc7750cdcf01aa5296929 Mon Sep 17 00:00:00 2001 From: John Goerzen Date: Tue, 27 Mar 2007 08:21:17 +0100 Subject: [PATCH] Added netrc support thanks to bboissin plus offlineimap at gmail dot com refs #14 --- offlineimap/repository/IMAP.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/offlineimap/repository/IMAP.py b/offlineimap/repository/IMAP.py index 33987e2..f0e23e7 100644 --- a/offlineimap/repository/IMAP.py +++ b/offlineimap/repository/IMAP.py @@ -20,7 +20,7 @@ from Base import BaseRepository from offlineimap import folder, imaputil, imapserver from offlineimap.folder.UIDMaps import MappedIMAPFolder from offlineimap.threadutil import ExitNotifyThread -import re, types, os +import re, types, os, netrc from threading import * class IMAPRepository(BaseRepository): @@ -109,6 +109,9 @@ class IMAPRepository(BaseRepository): user = self.getconf('remoteuser') if user != None: return user + netrcentry = netrc.netrc().authentificator(self.gethost()) + if netrcentry: + return netrcentry[0] def getport(self): return self.getconfint('remoteport', None) @@ -146,6 +149,11 @@ class IMAPRepository(BaseRepository): password = fd.readline().strip() fd.close() return password + netrcentry = netrc.netrc().authenticators(self.gethost()) + if netrcentry: + user = self.getconf('remoteuser') + if user == None or user == netrcentry[0]: + return netrcentry[2] return None def getfolder(self, foldername):