Skip to content
Snippets Groups Projects
Commit 56c1812d authored by David Huss's avatar David Huss :speech_balloon:
Browse files

Try priviledge escalation

parent 517da8b8
No related branches found
No related tags found
No related merge requests found
__version__ = '0.1.4'
__version__ = '0.1.6'
from common_config.common import *
\ No newline at end of file
......@@ -385,12 +385,13 @@ def create_config():
try:
selection["path"].mkdir(mode=0o755, parents=True, exist_ok=True)
except PermissionError:
python_path = f"{sys.prefix}/bin/python3"
print()
print("Error: Didn't have the permissions to create the config directory at {}".format(selection["path"]), file=sys.stderr)
print("Hint: Change the owner of the directory temporarily to {} or run {} config create with more permissions".format(getpass.getuser(), APPLICATION_NAME))
print(f"Error: Didn't have the permissions to create the config directory at {selection['path']}", file=sys.stderr)
print(f"Hint: Change the owner of the directory temporarily to {getpass.getuser()} or run {APPLICATION_NAME} config create with more permissions", file=sys.stderr)
print(f"Hint: The python executable used by this script is located at \"{python_path}\"", file=sys.stderr)
# Run again with priviledges
python_path = f"{sys.prefix}/bin/python3"
subprocess.call(['sudo', python_path, *sys.argv])
sys.exit()
......@@ -423,12 +424,16 @@ def create_config():
try:
config_path.write_text(DEFAULT_CONFIG)
except PermissionError as e:
python_path = f"{sys.prefix}/bin/python3"
print()
print(f"Error: Didn't have the permissions to write the file to {config_path}", file=sys.stderr)
print(f" Directory \"{selection['path']}\" belongs to user {selection['path'].owner()} (was running as user {getpass.getuser()})", file=sys.stderr)
print()
print(f"Hint: Change the owner of the directory temporarily to {getpass.getuser()} or run {APPLICATION_NAME} config create with more permissions")
exit()
print(f"Hint: The python executable used by this script is located at \"{python_path}\"", file=sys.stderr)
# Run again with priviledges
subprocess.call(['sudo', python_path, *sys.argv])
sys.exit()
print(f"Default Config has been written to {config_path}")
......
[tool.poetry]
name = "common-config"
version = "0.1.4"
version = "0.1.6"
description = "A config library for eigenservice"
authors = ["David Huss <dh@atoav.com>"]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment