Example #1
0
def _selinux_prepare(absInstallDir):
    """If this is Linux and SELinux is installed and enabled,
    then we need to set the security context on the SciMoz plugin
    to allow shared object text relocation.

    See bug 43260 and bug 46275 for details.
    """
    if not sys.platform.startswith("linux"):
        return

    import selinuxlib
    selinux = selinuxlib.SELinux()
    
    if not selinux.is_installed():
        log.debug("SELinux is not installed.")
        return
    log.debug("SELinux is installed.")

    # We must allow Komodo to have stack execution privileges, which is
    # required by certain Python modules (ssl, hashlib), otherwise Komodo
    # will fail to register some core PyXPCOM components - bug 85504.
    komodoBin = join(absInstallDir, "lib", "mozilla", "komodo")
    selinux.allow_stack_execution(komodoBin)

    for so_path in _gen_so_paths(absInstallDir):
        if not selinux.is_path_labeled(so_path):
            log.debug("%s: setting context just won't work, skipping", 
                      so_path)
            continue
        # Trying these covers RHEL (texrel_shlib_t), FC5 (textrel_shlib_t)
        # and CentOS (shlib_t).
        contexts_to_try = ["texrel_shlib_t", "textrel_shlib_t", "shlib_t"]
        context = selinux.context_from_path(so_path)
        if context is not None:
            context_to_try = context.split(':')[-1]
            if context_to_try not in contexts_to_try:
                contexts_to_try.append(context_to_try)
        for context_to_try in contexts_to_try:
            log.debug("trying chcon(%r, %r)", so_path, context_to_try)
            try:
                selinuxlib.chcon(so_path, context_to_try)
            except selinuxlib.SELinuxError, ex:
                pass
            else:
                break
        else:
            msg = ("could not set SELinux security context for "
                   "'%s': '%s' contexts failed"
                   % (so_path, "', '".join(contexts_to_try)))
            if selinux.is_enabled():
                raise Error(msg)
            else:
                log.warn(msg + " (this can be safely ignored if you do "
                               "not use SELinux on your system)")
                break
Example #2
0
def _selinux_prepare(absInstallDir):
    """If this is Linux and SELinux is installed and enabled,
    then we need to set the security context on the SciMoz plugin
    to allow shared object text relocation.

    See bug 43260 and bug 46275 for details.
    """
    if not sys.platform.startswith("linux"):
        return

    import selinuxlib
    selinux = selinuxlib.SELinux()
    
    if not selinux.is_installed():
        log.debug("SELinux is not installed.")
        return
    log.debug("SELinux is installed.")

    # We must allow Komodo to have stack execution privileges, which is
    # required by certain Python modules (ssl, hashlib), otherwise Komodo
    # will fail to register some core PyXPCOM components - bug 85504.
    komodoBin = join(absInstallDir, "lib", "mozilla", "komodo")
    selinux.allow_stack_execution(komodoBin)

    for so_path in _gen_so_paths(absInstallDir):
        if not selinux.is_path_labeled(so_path):
            log.debug("%s: setting context just won't work, skipping", 
                      so_path)
            continue
        # Trying these covers RHEL (texrel_shlib_t), FC5 (textrel_shlib_t)
        # and CentOS (shlib_t).
        contexts_to_try = ["texrel_shlib_t", "textrel_shlib_t", "shlib_t"]
        context = selinux.context_from_path(so_path)
        if context is not None:
            context_to_try = context.split(':')[-1]
            if context_to_try not in contexts_to_try:
                contexts_to_try.append(context_to_try)
        for context_to_try in contexts_to_try:
            log.debug("trying chcon(%r, %r)", so_path, context_to_try)
            try:
                selinuxlib.chcon(so_path, context_to_try)
            except selinuxlib.SELinuxError, ex:
                pass
            else:
                break
        else:
            msg = ("could not set SELinux security context for "
                   "'%s': '%s' contexts failed"
                   % (so_path, "', '".join(contexts_to_try)))
            if selinux.is_enabled():
                raise Error(msg)
            else:
                log.warn(msg + " (this can be safely ignored if you do "
                               "not use SELinux on your system)")
                break