Example #1
0
def level2_signature_for(message,
                         seed,
                         username,
                         password=None,
                         sulfur=None,
                         calculate=1,
                         file=_SHADOW_FILE):
    # Get sulfur based on arguments...
    if sulfur is None:
        if password is None:
            sulfur = sulfur_for(username, password, 0, file)
        else:
            sulfur = sulfur_for(username, password, 1, file)
    elif len(sulfur) != 2:
        raise EInvalidValue('sulfur must be None or a two character string.')
    # Calculate the crypted, sulfurfree password based on the arguments...
    sf_pass = None
    if password is None:
        passwd = _ShadowFile(file)
        passwd.load()
        entry = passwd[username]
        sf_user = sulfurfree(entry.crypt())
    else:
        sf_pass = sulfurfree(
            crypted_password(username, password, sulfur, calculate, file))
    # Calculate the crypted, sulfurfree username based on the arguments...
    sf_user = sulfurfree(
        crypted_username(username, password, sulfur, calculate, file))
    md5 = _MD5(sf_pass)
    md5.update(seed)
    md5.update(message)
    return _join(sf_user, md5.hexdigest().lower())
Example #2
0
def level2_signature_for(message, seed, username, password=None,
                         sulfur=None, calculate=1, file=_SHADOW_FILE):
    # Get sulfur based on arguments...
    if sulfur is None:
        if password is None:
            sulfur = sulfur_for(username, password, 0, file)
        else:
            sulfur = sulfur_for(username, password, 1, file)
    elif len(sulfur) != 2:
        raise EInvalidValue('sulfur must be None or a two character string.')
    # Calculate the crypted, sulfurfree password based on the arguments...
    sf_pass = None
    if password is None:
        passwd = _ShadowFile(file)
        passwd.load()
        entry = passwd[username]
        sf_user = sulfurfree(entry.crypt())
    else:
        sf_pass = sulfurfree(crypted_password(username, password,
                                              sulfur, calculate, file))
    # Calculate the crypted, sulfurfree username based on the arguments...
    sf_user = sulfurfree(crypted_username(username, password,
                                          sulfur, calculate, file))
    md5 = _MD5(sf_pass)
    md5.update(seed)
    md5.update(message)
    return _join(sf_user, md5.hexdigest().lower())
Example #3
0
def _embelish_string(text, attributes):
    escape = _EscapeSequences.NORMAL
    if attributes == _TextAttributes.BOLD:
        escape = _EscapeSequences.BOLD
    elif attributes == _TextAttributes.UNDERLINE:
        escape = _EscapeSequences.UNDERLINE
    elif attributes == (_TextAttributes.BOLD|_TextAttributes.UNDERLINE):
        escape = _EscapeSequences.BOLDUNDERLINE
    return _join((escape, text, _EscapeSequences.NORMAL), "")
Example #4
0
def _embelish_string(text, attributes):
    escape = _EscapeSequences.NORMAL
    if attributes == _TextAttributes.BOLD:
        escape = _EscapeSequences.BOLD
    elif attributes == _TextAttributes.UNDERLINE:
        escape = _EscapeSequences.UNDERLINE
    elif attributes == (_TextAttributes.BOLD | _TextAttributes.UNDERLINE):
        escape = _EscapeSequences.BOLDUNDERLINE
    return _join((escape, text, _EscapeSequences.NORMAL), "")
Example #5
0
def sulfur_for(username, password, calculate=1, file=_SHADOW_FILE):
    if calculate:
        text = _join(username, password)
        crc = _crc16(text)
        b1 = _saltchars[(crc >> 8) % 64]
        b2 = _saltchars[(crc & 0xff) % 64]
        return "%s%s" % (b1, b2)
    shadow_file = _ShadowFile(file)
    shadow_file.load()
    shadow = shadow_file[username]
    return shadow.crypt()[3:5]
Example #6
0
def sulfur_for(username, password,
               calculate=1, file=_SHADOW_FILE):
    if calculate:
        text = _join(username, password)
        crc = _crc16(text)
        b1 = _saltchars[(crc >> 8) % 64]
        b2 = _saltchars[(crc & 0xff) % 64]
        return "%s%s" % (b1, b2)
    shadow_file = _ShadowFile(file)
    shadow_file.load()
    shadow = shadow_file[username]
    return shadow.crypt()[3:5]
Example #7
0
class _TextAttributes:
    NORMAL    = 0
    BOLD      = 1
    UNDERLINE = 2

def _embelish_string(text, attributes):
    escape = _EscapeSequences.NORMAL
    if attributes == _TextAttributes.BOLD:
        escape = _EscapeSequences.BOLD
    elif attributes == _TextAttributes.UNDERLINE:
        escape = _EscapeSequences.UNDERLINE
    elif attributes == (_TextAttributes.BOLD|_TextAttributes.UNDERLINE):
        escape = _EscapeSequences.BOLDUNDERLINE
    return _join((escape, text, _EscapeSequences.NORMAL), "")

_MOTD = _join(
    (_EscapeSequences.CLEAR_SCREEN,
     _embelish_string("Mediator Operating Environment %s" % _MOE_VERSION,
                      _TextAttributes.BOLD),
     _embelish_string("Mediator Framework (tm) %s" % _RELEASE,
                      _TextAttributes.BOLD),
     "",
     _embelish_string("Serial number %s" % _SERIAL_NUMBER,
                      _TextAttributes.BOLD),
     "",
     ""),
    '\n')

def as_string():
    return _MOTD
Example #8
0
class _TextAttributes:
    NORMAL = 0
    BOLD = 1
    UNDERLINE = 2


def _embelish_string(text, attributes):
    escape = _EscapeSequences.NORMAL
    if attributes == _TextAttributes.BOLD:
        escape = _EscapeSequences.BOLD
    elif attributes == _TextAttributes.UNDERLINE:
        escape = _EscapeSequences.UNDERLINE
    elif attributes == (_TextAttributes.BOLD | _TextAttributes.UNDERLINE):
        escape = _EscapeSequences.BOLDUNDERLINE
    return _join((escape, text, _EscapeSequences.NORMAL), "")


_MOTD = _join(
    (_EscapeSequences.CLEAR_SCREEN,
     _embelish_string("Mediator Operating Environment %s" % _MOE_VERSION,
                      _TextAttributes.BOLD),
     _embelish_string("Mediator Framework (tm) %s" % _RELEASE,
                      _TextAttributes.BOLD), "",
     _embelish_string("Serial number %s" % _SERIAL_NUMBER,
                      _TextAttributes.BOLD), "", ""), '\n')


def as_string():
    return _MOTD
Example #9
0
def traceback(application='unknown', limit=None):
    stack = _extract_stack(limit)
    formatted_stack = _format_list(stack[:-1])
    _log(application, types.TB, _join(formatted_stack,''))
    return
Example #10
0
def traceback(application='unknown', limit=None):
    stack = _extract_stack(limit)
    formatted_stack = _format_list(stack[:-1])
    _log(application, types.TB, _join(formatted_stack, ''))
    return
Example #11
0
def context_seed(seed, context):
    return _MD5(_join(seed, context)).hexdigest().lower()
Example #12
0
def context_seed(seed, context):
    return _MD5(_join(seed, context)).hexdigest().lower()