Skip to content

Commit

Permalink
Replaced GEF_RC to a Path object (#775)
Browse files Browse the repository at this point in the history
  • Loading branch information
hugsy committed Jan 9, 2022
1 parent 8de60eb commit 5f641bb
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions gef.py
Expand Up @@ -133,7 +133,7 @@ def update_gef(argv: List[str]) -> int:
DEFAULT_PAGE_ALIGN_SHIFT = 12
DEFAULT_PAGE_SIZE = 1 << DEFAULT_PAGE_ALIGN_SHIFT

GEF_RC = os.getenv("GEF_RC") or os.path.join(os.getenv("HOME"), ".gef.rc")
GEF_RC = pathlib.Path(os.getenv("GEF_RC")).absolute() if os.getenv("GEF_RC") else pathlib.Path().home() / ".gef.rc"
GEF_TEMP_DIR = os.path.join(tempfile.gettempdir(), "gef")
GEF_MAX_STRING_LENGTH = 50

Expand All @@ -153,10 +153,10 @@ def update_gef(argv: List[str]) -> int:
GEF_PROMPT_OFF = "\001\033[1;31m\002{0:s}\001\033[0m\002".format(GEF_PROMPT)


gef = None
__registered_commands__ = []
__registered_functions__ = []
__registered_architectures__ = {}
gef : "Gef" = None
__registered_commands__ : List["GenericCommand"] = []
__registered_functions__ : List["GenericFunction"] = []
__registered_architectures__ : Dict[Union[int, str], "Architecture"] = {}


def reset_all_caches() -> None:
Expand All @@ -180,7 +180,6 @@ def reset() -> None:
arch = gef.arch
del gef

gef = None
gef = Gef()
gef.setup()

Expand Down Expand Up @@ -10799,10 +10798,10 @@ def invoke(self, args, from_tty) -> None:
for alias in gef.session.aliases:
cfg.set("aliases", alias._alias, alias._command)

with open(GEF_RC, "w") as fd:
with GEF_RC.open("w") as fd:
cfg.write(fd)

ok("Configuration saved to '{:s}'".format(GEF_RC))
ok("Configuration saved to '{:s}'".format(str(GEF_RC)))
return


Expand Down Expand Up @@ -10853,7 +10852,7 @@ def invoke(self, args: str, from_tty) -> None:
gef_makedirs(gef.config["gef.tempdir"])

if not quiet:
ok("Configuration from '{:s}' restored".format(Color.colorify(GEF_RC, "bold blue")))
ok("Configuration from '{:s}' restored".format(Color.colorify(str(GEF_RC), "bold blue")))
return


Expand Down Expand Up @@ -11494,7 +11493,7 @@ class Gef:
memory, settings, etc.)."""
def __init__(self) -> None:
self.binary: Optional[Elf] = None
self.arch = GenericArchitecture() # see PR #516, will be reset by `new_objfile_handler`
self.arch: Architecture = GenericArchitecture() # see PR #516, will be reset by `new_objfile_handler`
self.config: Dict[str, Any] = GefSettingsManager()
self.ui = GefUiManager()
return
Expand Down

0 comments on commit 5f641bb

Please sign in to comment.