Exemplo n.º 1
0
def format_file_results(row, server=None):
    encoding = ''
    checksum = row['checksum'] or ''
    is_binary = row['is_binary'] == 'Y'
    raw_contents = rhnSQL.read_lob(row['file_contents'])
    if is_binary:
        contents = raw_contents
    else:
        contents = rhnSQL._fix_encoding(raw_contents or '')

    if server and not is_binary and contents:
        interpolator = ServerTemplatedDocument(server,
                                               start_delim=row['delim_start'],
                                               end_delim=row['delim_end'])
        contents = interpolator.interpolate(contents)
        if row['checksum_type']:
            checksummer = hashlib.new(row['checksum_type'])
            checksummer.update(contents.encode())
            checksum = checksummer.hexdigest()

    if contents:
        client_caps = rhnCapability.get_client_capabilities()
        if client_caps and 'configfiles.base64_enc' in client_caps:
            encoding = 'base64'
            if is_binary:
                contents = contents
            else:
                contents = contents.encode()
            contents = base64.encodestring(contents).decode()
    if row.get('modified', False):
        m_date = xmlrpclib.DateTime(str(row['modified']))
    else:
        m_date = ''

    return {
        'path': row['path'],
        'config_channel': row['config_channel'],
        'file_contents': contents,
        'symlink': row['symlink'] or '',
        'checksum_type': row['checksum_type'] or '',
        'checksum': checksum,
        'verify_contents': True,
        'delim_start': row['delim_start'] or '',
        'delim_end': row['delim_end'] or '',
        'revision': row['revision'] or '',
        'username': row['username'] or '',
        'groupname': row['groupname'] or '',
        'filemode': row['filemode'] or '',
        'encoding': encoding or '',
        'filetype': row['label'],
        'selinux_ctx': row['selinux_ctx'] or '',
        'modified': m_date,
        'is_binary': row['is_binary'] or '',
    }
Exemplo n.º 2
0
def format_file_results(row, server=None):
    encoding = ''
    contents = None
    contents = rhnSQL.read_lob(row['file_contents']) or ''
    checksum = row['checksum'] or ''

    if server and (row['is_binary'] == 'N') and contents:

        interpolator = ServerTemplatedDocument(server,
                                               start_delim=row['delim_start'],
                                               end_delim=row['delim_end'])
        contents = interpolator.interpolate(contents)
        if row['checksum_type']:
            checksummer = hashlib.new(row['checksum_type'])
            checksummer.update(contents)
            checksum = checksummer.hexdigest()

    if contents:
        client_caps = rhnCapability.get_client_capabilities()
        if client_caps and 'configfiles.base64_enc' in client_caps:
            encoding = 'base64'
            contents = base64.encodestring(contents)
    if row.get('modified', False):
        m_date = xmlrpclib.DateTime(str(row['modified']))
    else:
        m_date = ''

    return {
        'path': row['path'],
        'config_channel': row['config_channel'],
        'file_contents': contents,
        'symlink': row['symlink'] or '',
        'checksum_type': row['checksum_type'] or '',
        'checksum': checksum,
        'verify_contents': True,
        'delim_start': row['delim_start'] or '',
        'delim_end': row['delim_end'] or '',
        'revision': row['revision'] or '',
        'username': row['username'] or '',
        'groupname': row['groupname'] or '',
        'filemode': row['filemode'] or '',
        'encoding': encoding or '',
        'filetype': row['label'],
        'selinux_ctx': row['selinux_ctx'] or '',
        'modified': m_date,
        'is_binary': row['is_binary'] or '',
    }
Exemplo n.º 3
0
def format_file_results(row, server=None):
    encoding = ''
    contents = None
    contents = rhnSQL.read_lob(row['file_contents']) or ''

    if server and (row['is_binary'] == 'N') and contents:

        interpolator = ServerTemplatedDocument(server,
                                               start_delim=row['delim_start'],
                                               end_delim=row['delim_end'])
        contents = interpolator.interpolate(contents)

    if contents:
        client_caps = rhnCapability.get_client_capabilities()
        if client_caps and 'configfiles.base64_enc' in client_caps:
            encoding = 'base64'
            contents = base64.encodestring(contents)
    if row.get('modified', False):
        m_date = xmlrpclib.DateTime(str(row['modified']))
    else:
        m_date = ''

    return {
        'path'          : row['path'],
        'config_channel': row['config_channel'],
        'file_contents' : contents,
        'symlink' : row['symlink'] or '',
        'checksum_type' : row['checksum_type'] or '',
        'checksum'      : row['checksum'] or '',
        'delim_start'   : row['delim_start'] or '',
        'delim_end'     : row['delim_end'] or '',
        'revision'      : row['revision'] or '',
        'username'      : row['username'] or '',
        'groupname'     : row['groupname'] or '',
        'filemode'      : row['filemode'] or '',
        'encoding'      : encoding or '',
        'filetype'      : row['label'],
        'selinux_ctx'   : row['selinux_ctx'] or '',
        'modified'      : m_date,
    }
Exemplo n.º 4
0
def format_file_results(row, server=None):
    encoding = ''
    contents = None 
    contents = rhnSQL.read_lob(row['file_contents']) or ''

    if server and (row['is_binary'] == 'N') and contents:

        interpolator = ServerTemplatedDocument(server,
                                               start_delim=row['delim_start'],
                                               end_delim=row['delim_end'])
        contents = interpolator.interpolate(contents)


    if contents:
        client_caps = rhnCapability.get_client_capabilities()
        if client_caps and client_caps.has_key('configfiles.base64_enc'):
            encoding = 'base64'
            contents = base64.encodestring(contents)
        
    return {
        'path'          : row['path'],
        'config_channel': row['config_channel'],
        'file_contents' : contents,
        'symlink' : row['symlink'] or '', 
        'checksum_type' : row['checksum_type'] or '',
        'checksum'      : row['checksum'] or '',
        'delim_start'   : row['delim_start'] or '',
        'delim_end'     : row['delim_end'] or '',
        'revision'      : row['revision'] or '',
        'username'      : row['username'] or '',
        'groupname'     : row['groupname'] or '',
        'filemode'      : row['filemode'] or '',
        'encoding'      : encoding or '',
        'filetype'      : row['label'],
        'selinux_ctx'   : row['selinux_ctx'] or '',
    }