Return a dictionary of what changes need to be made for a file

    .. versionchanged:: Neon

        selinux attributes added

    CLI Example:

    .. code-block:: bash

        salt '*' file.check_managed_changes /etc/httpd/conf.d/httpd.conf salt://http/httpd.conf '{hash_type: 'md5', 'hsum': <md5sum>}' root, root, '755' jinja True None None base

def check_managed_changes(
        name,
        source,
        source_hash,
        source_hash_name,
        user,
        group,
        mode,
        attrs,
        template,
        context,
        defaults,
        saltenv,
        contents=None,
        skip_verify=False,
        keep_mode=False,
        seuser=None,
        serole=None,
        setype=None,
        serange=None,
        **kwargs):
    '''
    Return a dictionary of what changes need to be made for a file

    .. versionchanged:: Neon

        selinux attributes added

    CLI Example:

    .. code-block:: bash

        salt '*' file.check_managed_changes /etc/httpd/conf.d/httpd.conf salt://http/httpd.conf '{hash_type: 'md5', 'hsum': <md5sum>}' root, root, '755' jinja True None None base
    '''
    # If the source is a list then find which file exists
    source, source_hash = source_list(source,           # pylint: disable=W0633
                                      source_hash,
                                      saltenv)

    sfn = ''
    source_sum = None

    if contents is None:
        # Gather the source file from the server
        sfn, source_sum, comments = get_managed(
            name,
            template,
            source,
            source_hash,
            source_hash_name,
            user,
            group,
            mode,
            attrs,
            saltenv,
            context,
            defaults,
            skip_verify,
            **kwargs)

        # Ensure that user-provided hash string is lowercase
        if source_sum and ('hsum' in source_sum):
            source_sum['hsum'] = source_sum['hsum'].lower()

        if comments:
            __clean_tmp(sfn)
            raise CommandExecutionError(comments)
        if sfn and source and keep_mode:
            if _urlparse(source).scheme in ('salt', 'file') \
                    or source.startswith('/'):
                try:
                    mode = __salt__['cp.stat_file'](source, saltenv=saltenv, octal=True)
                except Exception as exc:
                    log.warning('Unable to stat %s: %s', sfn, exc)
    changes = check_file_meta(name, sfn, source, source_sum, user,
                              group, mode, attrs, saltenv, contents,
                              seuser=seuser, serole=serole, setype=setype, serange=serange)
    __clean_tmp(sfn)
    return changes