Changeset b42118c


Ignore:
Timestamp:
Sep 17, 2012, 2:08:56 AM (13 years ago)
Author:
Alex Dehnert <adehnert@…>
Branches:
master, space-access, stable, stage
Children:
49724e4
Parents:
ac9b167
git-author:
Alex Dehnert <adehnert@…> (09/17/12 02:08:56)
git-committer:
Alex Dehnert <adehnert@…> (09/17/12 02:08:56)
Message:

kinit when creating a MoiraList? object

This allows group/diffs.py to work without kinit'ing outside the script, fixing
the key deficiency in ac9b167bcf85a9f723e27967649c2c033f2259da.

Location:
asadb
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • asadb/mit/__init__.py

    r08d4fa6 rb42118c  
    11import os
    22import subprocess
     3import tempfile
    34import ldap
    45import ldap.filter
     
    1314from django.core.validators import URLValidator, ValidationError
    1415
    15 import settings
     16from django.conf import settings
    1617
    1718def zephyr(msg, clas='message', instance='log', rcpt='nobody',):
     
    5657def pag_check_output(args, **kwargs):
    5758    return pag_check_helper(subprocess.check_output, args, **kwargs)
     59
     60def kinit(keytab=None, principal=None, autodelete=True, ):
     61    if not keytab:
     62        keytab = settings.KRB_KEYTAB
     63    if not principal:
     64        principal = settings.KRB_PRINCIPAL
     65    assert keytab and principal
     66    fd = tempfile.NamedTemporaryFile(mode='rb', prefix="krb5cc_djmit_", delete=autodelete, )
     67    env = dict(KRB5CCNAME=fd.name)
     68    kinit_cmd = ['kinit', '-k', '-t', keytab, principal, ]
     69    subprocess.check_call(kinit_cmd, env=env)
     70    return fd
    5871
    5972class ScriptsRemoteUserMiddleware(RemoteUserMiddleware):
  • asadb/util/mailinglist.py

    rac9b167 rb42118c  
    11import subprocess
     2
     3import mit
    24
    35
     
    1517BLANCHE_PATH="/usr/bin/blanche"
    1618class MoiraList(MailingList):
     19    def __init__(self, *args, **kwargs):
     20        super(MoiraList, self).__init__(*args, **kwargs)
     21        self.ccache = mit.kinit()
     22
    1723    def list_members(self, ):
    1824        raise NotImplementedError
     
    5561        # changes, and use -al / -dl with a tempfile as appropriate.
    5662
     63        env = dict(KRB5CCNAME=self.ccache.name)
    5764        cmdline = [BLANCHE_PATH, self.name, ]
    5865
     
    7279            stdout=subprocess.PIPE,
    7380            stderr=subprocess.STDOUT,
     81            env=env,
    7482        )
    7583        stdout, stderr = res.communicate()
Note: See TracChangeset for help on using the changeset viewer.