Changeset b42118c for asadb/mit


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.

File:
1 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):
Note: See TracChangeset for help on using the changeset viewer.