Fix issue with renaming getConfigPath to get_config_path
Sophie Brun
4 years ago
2 | 2 | Subject: Add a script to manage configuration during upgrade |
3 | 3 | |
4 | 4 | Origin: vendor |
5 | Last-Update: 2018-01-24 | |
5 | Last-Update: 2020-01-23 | |
6 | 6 | |
7 | 7 | During a upgrade we have to install the new configuration files in |
8 | 8 | ~/.config/OSRFramework: |
11 | 11 | - Add a script (which is called in postinst when it's an upgrade) to |
12 | 12 | remove config directories "default", "plugins", "server", "transforms", |
13 | 13 | and install the new directories and files provided by the package. |
14 | Last-Update: 2018-01-24 | |
15 | 14 | --- |
16 | 15 | osrframework/utils/configuration.py | 6 ++++-- |
17 | 16 | osrframework/utils/upgrade_config.py | 12 ++++++++++++ |
26 | 25 | shutil.copytree(os.path.join('/etc/osrframework',dirconf), os.path.join(LOCAL_CONFIG_DIR, dirconf)) |
27 | 26 | |
28 | 27 | - # Create directory data |
29 | - os.mkdir(getConfigPath()["appPathData"]) | |
28 | - os.mkdir(get_config_path()["appPathData"]) | |
30 | 29 | + # Create directory data if it doesn't exist (we keep it at the |
31 | 30 | + # upgrade) |
32 | + if not os.path.exists(getConfigPath()["appPathData"]): | |
33 | + os.mkdir(getConfigPath()["appPathData"]) | |
31 | + if not os.path.exists(get_config_path()["appPathData"]): | |
32 | + os.mkdir(get_config_path()["appPathData"]) | |
34 | 33 | |
35 | 34 | # Create directory Transforms before copy *.py files |
36 | 35 | # os.mkdir(LOCAL_CONFIG_TRANSFORMS_DIR) |
37 | 36 | diff --git a/osrframework/utils/upgrade_config.py b/osrframework/utils/upgrade_config.py |
38 | 37 | new file mode 100644 |
39 | index 0000000..6e9c57d | |
38 | index 0000000..ca2de05 | |
40 | 39 | --- /dev/null |
41 | 40 | +++ b/osrframework/utils/upgrade_config.py |
42 | 41 | @@ -0,0 +1,12 @@ |
43 | +# !/usr/bin/python | |
42 | +#!/usr/bin/python3 | |
44 | 43 | + |
45 | 44 | +import os |
46 | 45 | +import shutil |
48 | 47 | +import osrframework.utils.configuration as configuration |
49 | 48 | + |
50 | 49 | +if __name__ == "__main__": |
51 | + if os.path.exists(configuration.getConfigPath()["appPath"]): | |
50 | + if os.path.exists(configuration.get_config_path()["appPath"]): | |
52 | 51 | + for confdir in ["default", "plugins", "server", "transforms"]: |
53 | + shutil.rmtree(os.path.join(configuration.getConfigPath()["appPath"], confdir), True) | |
52 | + shutil.rmtree(os.path.join(configuration.get_config_path()["appPath"], confdir), True) | |
54 | 53 | + configuration.initialize_config_files() |
0 | From: Sophie Brun <[email protected]> | |
1 | Date: Thu, 23 Jan 2020 12:03:08 +0100 | |
2 | Subject: Change getConfigPath to get_config_path | |
3 | ||
4 | Last-Update: 2020-01-23 | |
5 | ||
6 | Description: upstream rename getConfigPath to get_config_path but not in osrframework/utils/exceptions.py | |
7 | --- | |
8 | osrframework/utils/exceptions.py | 2 +- | |
9 | 1 file changed, 1 insertion(+), 1 deletion(-) | |
10 | ||
11 | diff --git a/osrframework/utils/exceptions.py b/osrframework/utils/exceptions.py | |
12 | index 16ecd8e..3ef56ab 100644 | |
13 | --- a/osrframework/utils/exceptions.py | |
14 | +++ b/osrframework/utils/exceptions.py | |
15 | @@ -47,7 +47,7 @@ class NoCredentialsException(OSRFrameworkException): | |
16 | """.format( | |
17 | self.__class__.__name__, | |
18 | platform, | |
19 | - os.path.join(configuration.getConfigPath()["appPath"], "accounts.cfg"), | |
20 | + os.path.join(configuration.get_config_path()["appPath"], "accounts.cfg"), | |
21 | general.emphasis("-x " + platform) | |
22 | ) | |
23 | OSRFrameworkException.__init__(self, general.warning(msg)) |
1 | 1 | Date: Thu, 23 Jan 2020 10:21:00 +0100 |
2 | 2 | Subject: Initialize the config directory and files |
3 | 3 | |
4 | Last-Update: 2017-09-18 | |
4 | Last-Update: 2020-01-23 | |
5 | 5 | |
6 | 6 | Upstream creates and initializes the ~/.config/OSRFramework in the |
7 | 7 | setup.py. We disable this for Kali and create a function |
8 | 8 | initialize_config_files to manage the creation and installation of all |
9 | 9 | the required files. |
10 | Last-Update: 2017-09-18 | |
11 | 10 | --- |
12 | 11 | osrframework/utils/configuration.py | 41 ++++++++++++++++++++++++++++++++++--- |
13 | 12 | 1 file changed, 38 insertions(+), 3 deletions(-) |
41 | 40 | + shutil.copytree(os.path.join('/etc/osrframework',dirconf), os.path.join(LOCAL_CONFIG_DIR, dirconf)) |
42 | 41 | + |
43 | 42 | + # Create directory data |
44 | + os.mkdir(getConfigPath()["appPathData"]) | |
43 | + os.mkdir(get_config_path()["appPathData"]) | |
45 | 44 | + |
46 | 45 | + # Create directory Transforms before copy *.py files |
47 | 46 | +# os.mkdir(LOCAL_CONFIG_TRANSFORMS_DIR) |
54 | 53 | + |
55 | 54 | + # Copy default config files for the user |
56 | 55 | + for f in ["browser.cfg", "general.cfg"]: |
57 | + shutil.copy((os.path.join(getConfigPath()["appPathDefaults"], f)),LOCAL_CONFIG_DIR) | |
56 | + shutil.copy((os.path.join(get_config_path()["appPathDefaults"], f)),LOCAL_CONFIG_DIR) | |
58 | 57 | + |
59 | 58 | + |
60 | 59 | def change_permissions_recursively(path, uid, gid): |
78 | 77 | """ |
79 | 78 | |
80 | 79 | VALUES = {} |
81 | + if not os.path.exists(getConfigPath()["appPath"]): | |
80 | + if not os.path.exists(get_config_path()["appPath"]): | |
82 | 81 | + initialize_config_files() |
83 | 82 | |
84 | 83 | # If a api_keys.cfg has not been found, creating it by copying from default |