Beispiel #1
0
def check_elf_libs(fpath):
    try:
        out = util.check_output(['ldd', fpath], env={'LANG': 'C'}).splitlines()
    except CalledProcessError as e:
        result = LDDNOTDYNAMIC_RE.match(e.stdout)
        if result and e.returncode == 1:
            logging.debug('Not continuing to check libs as the executable is not dynamic')
            return {}
        else:
            raise
    except:
        raise

    libs = {}
    for r_line in out:
        line = LDD_RE.match(r_line)
        if not line:
            logging.warning('Failed to parse ldd line "%s"!', r_line)
            continue

        if line.group(2) == 'not found':
            libs[line.group(1)] = None
        elif not line.group(2):
            # This is most likely a line like "linux-vdso.so.1 (0x00007fff847fe000)" which we can ignore.
            continue
        else:
            libs[line.group(1)] = line.group(2)

    return libs
Beispiel #2
0
def check_elf_libs(fpath):
    try:
        out = util.check_output(['ldd', fpath], env={'LANG': 'C'}).splitlines()
    except CalledProcessError as e:
        result = LDDNOTDYNAMIC_RE.match(e.stdout)
        if result and e.returncode == 1:
            logging.debug(
                'Not continuing to check libs as the executable is not dynamic'
            )
            return {}
        else:
            raise
    except:
        raise

    libs = {}
    for r_line in out:
        line = LDD_RE.match(r_line)
        if not line:
            logging.warning('Failed to parse ldd line "%s"!', r_line)
            continue

        if line.group(2) == 'not found':
            libs[line.group(1)] = None
        elif not line.group(2):
            # This is most likely a line like "linux-vdso.so.1 (0x00007fff847fe000)" which we can ignore.
            continue
        else:
            libs[line.group(1)] = line.group(2)

    return libs
Beispiel #3
0
def get_lib_path(filename):
    global _LIB_CACHE

    if not _LIB_CACHE:
        data = util.check_output(["ldconfig", "-p"], env={"LANG": "C"}).splitlines()
        _LIB_CACHE = {}

        for line in data[1:]:
            m = LDCONF_RE.match(line)
            if not m:
                logging.warning('Failed to parse ldconfig line "%s"!', line)
                continue

            _LIB_CACHE[m.group(1)] = m.group(2)

    return _LIB_CACHE.get(filename)
Beispiel #4
0
def get_lib_path(filename):
    global _LIB_CACHE

    if not _LIB_CACHE:
        data = util.check_output(['ldconfig', '-p'], env={
            'LANG': 'C'
        }).splitlines()
        _LIB_CACHE = {}

        for line in data[1:]:
            m = LDCONF_RE.match(line)
            if not m:
                logging.warning('Failed to parse ldconfig line "%s"!', line)
                continue

            _LIB_CACHE[m.group(1)] = m.group(2)

    return _LIB_CACHE.get(filename)
Beispiel #5
0
def run_fs2_silent(params):
    base_path = center.settings['base_path']
    fs2_bin = params[0]

    if not os.path.isfile(fs2_bin):
        return -128, None

    mode = os.stat(fs2_bin).st_mode
    if mode & stat.S_IXUSR != stat.S_IXUSR:
        # Make it executable.
        os.chmod(fs2_bin, mode | stat.S_IXUSR)

    # We copy the existing environment to avoid omitting any values that may be necessary for running the binary
    # properly
    env = dict(os.environ)
    # AppImages are a bit special since they are themselves ELF executables which contain the actual FSO executable so
    # it makes no sense to examine the binary for missing libraries
    if sys.platform.startswith(
            'linux') and not fs2_bin.lower().endswith(".appimage"):
        ld_path, missing = fix_missing_libs(fs2_bin)
        if len(missing) > 0:
            return -127, None

        env['LD_LIBRARY_PATH'] = ld_path

    try:
        try:
            output = util.check_output(params,
                                       env=env,
                                       cwd=base_path,
                                       stderr=subprocess.DEVNULL)
            rc = 0
        except CalledProcessError as e:
            # check_output raises this error if the return code was anything other than 0
            rc = e.returncode
            output = e.output
    except OSError:
        return -129, None

    if rc == 3221225595:
        # We're missing a DLL
        return -127, None

    return rc, output
Beispiel #6
0
def check_elf_libs(fpath):
    out = util.check_output(['ldd', fpath], env={'LANG': 'C'}).splitlines()
    libs = {}

    for r_line in out:
        line = LDD_RE.match(r_line)
        if not line:
            logging.warning('Failed to parse ldd line "%s"!', r_line)
            continue

        if line.group(2) == 'not found':
            libs[line.group(1)] = None
        elif not line.group(2):
            # This is most likely a line like "linux-vdso.so.1 (0x00007fff847fe000)" which we can ignore.
            continue
        else:
            libs[line.group(1)] = line.group(2)

    return libs
Beispiel #7
0
def check_elf_libs(fpath):
    out = util.check_output(["ldd", fpath], env={"LANG": "C"}).splitlines()
    libs = {}

    for r_line in out:
        line = LDD_RE.match(r_line)
        if not line:
            logging.warning('Failed to parse ldd line "%s"!', r_line)
            continue

        if line.group(2) == "not found":
            libs[line.group(1)] = None
        elif not line.group(2):
            # This is most likely a line like "linux-vdso.so.1 (0x00007fff847fe000)" which we can ignore.
            continue
        else:
            libs[line.group(1)] = line.group(2)

    return libs
Beispiel #8
0
def run_fs2_silent(params):
    base_path = center.settings['base_path']
    fs2_bin = params[0]

    if not os.path.isfile(fs2_bin):
        return -128, None

    mode = os.stat(fs2_bin).st_mode
    if mode & stat.S_IXUSR != stat.S_IXUSR:
        # Make it executable.
        os.chmod(fs2_bin, mode | stat.S_IXUSR)

    # We copy the existing environment to avoid omitting any values that may be necessary for running the binary
    # properly
    env = dict(os.environ)
    if sys.platform.startswith('linux'):
        ld_path, missing = fix_missing_libs(fs2_bin)
        if len(missing) > 0:
            return -127, None

        env['LD_LIBRARY_PATH'] = ld_path

    try:
        try:
            output = util.check_output(params,
                                       env=env,
                                       cwd=base_path,
                                       stderr=subprocess.DEVNULL,
                                       no_hide=True)
            rc = 0
        except CalledProcessError as e:
            # check_output raises this error if the return code was anything other than 0
            rc = e.returncode
            output = e.output
    except OSError:
        return -129, None

    if rc == 3221225595:
        # We're missing a DLL
        return -127, None

    return rc, output
Beispiel #9
0
def run_fs2_silent(params):
    base_path = center.settings['base_path']
    fs2_bin = params[0]

    if not os.path.isfile(fs2_bin):
        return -128, None

    mode = os.stat(fs2_bin).st_mode
    if mode & stat.S_IXUSR != stat.S_IXUSR:
        # Make it executable.
        os.chmod(fs2_bin, mode | stat.S_IXUSR)

    # We copy the existing environment to avoid omitting any values that may be necessary for running the binary
    # properly
    env = dict(os.environ)
    if sys.platform.startswith('linux'):
        ld_path, missing = fix_missing_libs(fs2_bin)
        if len(missing) > 0:
            return -127, None

        env['LD_LIBRARY_PATH'] = ld_path

    try:
        try:
            output = util.check_output(params, env=env, cwd=base_path, stderr=subprocess.DEVNULL, no_hide=True)
            rc = 0
        except CalledProcessError as e:
            # check_output raises this error if the return code was anything other than 0
            rc = e.returncode
            output = e.output
    except OSError:
        return -129, None

    if rc == 3221225595:
        # We're missing a DLL
        return -127, None

    return rc, output
Beispiel #10
0
def get_lib_path(filename):
    global _LIB_CACHE

    if not _LIB_CACHE:
        _LIB_CACHE = {}

        try:
            env = os.environ.copy()
            env['LANG'] = 'C'
            data = util.check_output(['ldconfig', '-p'], env=env).splitlines()
        except subprocess.CalledProcessError:
            logging.exception('Failed to run ldconfig!')
            return None

        for line in data[1:]:
            m = LDCONF_RE.match(line)
            if not m:
                logging.warning('Failed to parse ldconfig line "%s"!', line)
                continue

            _LIB_CACHE[m.group(1)] = m.group(2)

    return _LIB_CACHE.get(filename)
Beispiel #11
0
def get_lib_path(filename):
    global _LIB_CACHE

    if not _LIB_CACHE:
        _LIB_CACHE = {}

        try:
            env = os.environ.copy()
            env['LANG'] = 'C'
            data = util.check_output(['ldconfig', '-p'], env=env).splitlines()
        except subprocess.CalledProcessError:
            logging.exception('Failed to run ldconfig!')
            return None

        for line in data[1:]:
            m = LDCONF_RE.match(line)
            if not m:
                logging.warning('Failed to parse ldconfig line "%s"!', line)
                continue

            _LIB_CACHE[m.group(1)] = m.group(2)

    return _LIB_CACHE.get(filename)
Beispiel #12
0
    def set_us_layout(self):
        key_layout = util.check_output(['setxkbmap', '-query'])
        self._key_layout = key_layout.splitlines()[2].split(':')[1].strip()

        util.call(['setxkbmap', '-layout', 'us'])
Beispiel #13
0
    def set_us_layout(self):
        key_layout = util.check_output(["setxkbmap", "-query"])
        self._key_layout = key_layout.splitlines()[2].split(":")[1].strip()

        util.call(["setxkbmap", "-layout", "us"])