diff --git a/ofrak_patch_maker/CHANGELOG.md b/ofrak_patch_maker/CHANGELOG.md index 6a208d7f9..e24e2aaa7 100644 --- a/ofrak_patch_maker/CHANGELOG.md +++ b/ofrak_patch_maker/CHANGELOG.md @@ -4,6 +4,8 @@ All notable changes to `ofrak-patch-maker` will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased](https://github.com/redballoonsecurity/ofrak/tree/master) +### Fixed +- Remove option to read or install toolchain.conf from/to "/etc/toolchain.conf" ([#342](https://github.com/redballoonsecurity/ofrak/pull/342)) ## [4.0.1](https://github.com/redballoonsecurity/ofrak/compare/ofrak-patch-maker-v.4.0.0...ofrak-patch-maker-v.4.0.1) ### Added diff --git a/ofrak_patch_maker/Makefile b/ofrak_patch_maker/Makefile index 3b85f9017..8c311007f 100644 --- a/ofrak_patch_maker/Makefile +++ b/ofrak_patch_maker/Makefile @@ -2,19 +2,12 @@ PYTHON=python3 PIP=pip3 -# toolchain.conf is a file mapping ID to the various binaries responsible for preprocessing, -# assembling, compiling, linking, analyzing binaries for each currently supported toolchain. -.PHONY: toolchain_conf -toolchain_conf: - cp ofrak_patch_maker/toolchain.conf /etc/toolchain.conf - mv ofrak_patch_maker/toolchain.conf ofrak_patch_maker/toolchain.conf.bak - .PHONY: install -install: toolchain_conf +install: $(PIP) install . .PHONY: develop -develop: toolchain_conf +develop: $(PIP) install -e .[test] .PHONY: inspect diff --git a/ofrak_patch_maker/README.md b/ofrak_patch_maker/README.md index c74e0e80a..5de9952ca 100644 --- a/ofrak_patch_maker/README.md +++ b/ofrak_patch_maker/README.md @@ -38,8 +38,8 @@ as well as the [code references for PatchMaker](https://ofrak.com/docs/reference ## Dependencies This Python package only includes the Python code for the PatchMaker and does not include any of the toolchains which the PatchMaker utilizes! These would have to be -installed individually and added to a `toolchain.conf`, which by default is placed in `/etc`. -An example of the `toolchain.conf` can be found [here](https://github.com/redballoonsecurity/ofrak/blob/master/ofrak_patch_maker/toolchain.conf), +installed individually and added to `toolchain.conf`, which is bundled with this package. +An example of the `toolchain.conf` can be found [here](https://github.com/redballoonsecurity/ofrak/blob/master/ofrak_patch_maker/ofrak_patch_maker/toolchain.conf), and examples of how to install the toolchains can be found [here](https://github.com/redballoonsecurity/ofrak/blob/master/ofrak_patch_maker/Dockerstub). ## Testing diff --git a/ofrak_patch_maker/ofrak_patch_maker/toolchain/utils.py b/ofrak_patch_maker/ofrak_patch_maker/toolchain/utils.py index 0224093ca..dbcdf0ce0 100644 --- a/ofrak_patch_maker/ofrak_patch_maker/toolchain/utils.py +++ b/ofrak_patch_maker/ofrak_patch_maker/toolchain/utils.py @@ -1,10 +1,10 @@ import configparser -import math import os -import platform from multiprocessing import Pool, cpu_count from typing import Optional, Dict, Mapping, Tuple +import math + from ofrak_patch_maker.toolchain.model import BinFileType, Segment from ofrak_type.error import NotFoundError from ofrak_type.memory_permissions import MemoryPermissions @@ -26,31 +26,20 @@ def get_file_format(path): def get_repository_config(section: str, key: Optional[str] = None): """ - Find config file and values. Look in user's `~/etc` directory followed by `/etc`. + Get config values from toolchain.conf. :param section: section name in config file :param key: key in `config[section]` :raises SystemExit: If `config[section]` or `config[section][key]` not found. - :raises KeyError: If the `$HOME` environment variable is not found. :return Union[str, List[Tuple[str, str]]]: the result of ``config.get(section, key)`` or ``config.items(section)`` """ config = configparser.RawConfigParser() config_name = "toolchain.conf" - if platform.system().find("CYGWIN") > -1 or platform.system().find("Windows") > -1: - config_root = "/winetc" - else: - config_root = "/etc" local_config = os.path.join(os.path.dirname(__file__), os.path.pardir) - config_paths = [config_root, local_config] - try: - local_etc = os.path.join(os.environ["HOME"], "etc") - config_paths = [local_etc] + config_paths - except KeyError: - print("unable to find home directory") - + config_paths = [local_config] error_by_config_file: Dict[str, Exception] = dict() for p in config_paths: conf = os.path.join(p, config_name)