import userdir_gpg, userdir_ldap, sys, traceback, time, ldap, os, commands
import pwd, tempfile
import subprocess
import userdir_gpg, userdir_ldap, sys, traceback, time, ldap, os, commands
import pwd, tempfile
import subprocess
SSHFingerprint = re.compile('^(\d+) ([0-9a-f\:]{47}) (.+)$')
SSHRSA1Match = re.compile('^^(.* )?\d+ \d+ \d+')
SSHFingerprint = re.compile('^(\d+) ([0-9a-f\:]{47}) (.+)$')
SSHRSA1Match = re.compile('^^(.* )?\d+ \d+ \d+')
res = l.search_s(BaseDn,ldap.SCOPE_ONELEVEL,"uid="+uid, ['sudoPassword']);
if len(res) != 1:
raise UDFormatError, "Not exactly one hit when searching for user"
res = l.search_s(BaseDn,ldap.SCOPE_ONELEVEL,"uid="+uid, ['sudoPassword']);
if len(res) != 1:
raise UDFormatError, "Not exactly one hit when searching for user"
try:
Res = FinishConfirmSudopassword(l, GetAttr(DnRecord,"uid"), Attrs)
try:
Res = FinishConfirmSudopassword(l, GetAttr(DnRecord,"uid"), Attrs)
- Email = mimetools.Message(sys.stdin,0);
- Msg = GetClearSig(Email);
+ mail = email.parser.Parser().parse(sys.stdin);
+ Msg = GetClearSig(mail);
ErrMsg = "Message is not PGP signed:"
if Msg[0].find("-----BEGIN PGP SIGNED MESSAGE-----") == -1 and \
ErrMsg = "Message is not PGP signed:"
if Msg[0].find("-----BEGIN PGP SIGNED MESSAGE-----") == -1 and \
- try:
- Index = pgp.text.index("\n\n") + 2
- except ValueError:
- Index = pgp.text.index("\n\r\n") + 3
- PlainText = pgp.text[Index:]
+ e = email.parser.Parser().parsestr(pgp.text)
+ PlainText = e.get_payload(decode=True)
- RC.Clean();
- ErrMsg = "The replay cache rejected your message. Check your clock!";
- Rply = RC.Check(pgp.sig_info);
- if Rply != None:
- RC.close()
- raise UDNotAllowedError, Rply;
- RC.Add(pgp.sig_info);
- RC.close()
+ RC.process(pgp.sig_info)
- Sender = Email.getheader("Reply-To");
- if Sender == None:
- Sender = Email.getheader("From");
- if Sender == None:
- raise UDFormatError, "Unable to determine the sender's address";
+ Sender = mail['Reply-To']
+ if not Sender: Sender = mail['From']
+ if not Sender: raise UDFormatError, "Unable to determine the sender's address";