def cloneMeta(logger, originFile, destinationFile):
    '''
    Copies all permissions, ownership and security context (secon) data
    from originFile to destinationFile. This function does not work on Mac OS X
    systems.

    @param originFile: full file path to copy metadata from
    @param destinationFile: full file path to copy metadata to

    @author bemalmbe
    '''

    # note that the stat tool is not always installed by default on all systems
    # - namely: solaris and derivations thereof

    env = Environment()

    if env.getosfamily() == 'darwin':
        return

    try:

        # clone permissions; doesn't work on mac os x
        if env.getosfamily() == 'freebsd':
            (stdout, stderr) = Popen(["stat -f %Op " + originFile], shell=True,
                                     stdout=PIPE).communicate()
        else:
            (stdout, stderr) = Popen(["stat -c %a " + originFile], shell=True,
                                     stdout=PIPE).communicate()

        if stdout and isinstance(stdout, str):

            if not re.match("^[0-9]*$", stdout):
                logger.log(LogPriority.DEBUG,
                           'Improperly formatted permissions string returned')

            formattedperms = stdout.strip()

            # the freebsd version of the stat command can only return a string
            # which contains the file type code prepended to the octal
            # permissions string we must therefor strip the preceeding file
            # type code in order to perform a chmod with it
            if len(formattedperms) > 3:
                while len(formattedperms) > 3:
                    formattedperms = formattedperms[1:]

            os.system('chmod ' + formattedperms + ' ' + destinationFile)

            # clone ownership
            (stdout, stderr) = Popen(["stat -c %U:%G " + originFile],
                                     shell=True, stdout=PIPE).communicate()

            formattedownership = stdout.strip()

            os.system('chown ' + formattedownership + ' ' + destinationFile)

            # clone secon; doesn't work on mac os x
            if env.getosfamily() != 'darwin':

                os.system('chcon --reference=' + originFile + ' ' + \
                          destinationFile)

        else:

            logger.log(LogPriority.DEBUG, 'stat command failed to get ' + \
                       'output. Is the stat command available on this ' + \
                       'system type?')
            return

    except (OSError):
        raise
    except Exception:
        raise