diff options
author | 2017-08-07 01:46:02 +0900 | |
---|---|---|
committer | 2017-08-07 01:46:02 +0900 | |
commit | cb0d9a403884fa95b7f08464ac411452c5a00fb9 (patch) | |
tree | 267a5e4857338841c37a6c93e682b928318b04fa | |
parent | renamed function (diff) | |
download | elivepatch-cb0d9a403884fa95b7f08464ac411452c5a00fb9.tar.gz elivepatch-cb0d9a403884fa95b7f08464ac411452c5a00fb9.tar.bz2 elivepatch-cb0d9a403884fa95b7f08464ac411452c5a00fb9.zip |
improved function for get patches list from eapply_user patches and temporary
folder.
-rw-r--r-- | elivepatch_client/client/argsparser.py | 1 | ||||
-rw-r--r-- | elivepatch_client/client/checkers.py | 6 | ||||
-rw-r--r-- | elivepatch_client/client/cli.py | 5 | ||||
-rw-r--r-- | elivepatch_client/client/patch.py | 22 |
4 files changed, 26 insertions, 8 deletions
diff --git a/elivepatch_client/client/argsparser.py b/elivepatch_client/client/argsparser.py index 70c574b..5ee6590 100644 --- a/elivepatch_client/client/argsparser.py +++ b/elivepatch_client/client/argsparser.py @@ -42,6 +42,7 @@ class ArgsParser(object): parser.add_argument("-e","--cve", action='store_true', help="Check for secutiry problems in the kernel.") parser.add_argument("-p","--patch", help="patch to convert.") parser.add_argument("-k","--config", help="set kernel config file manually.") + parser.add_argument("-a","--kernel_version", help="set kernel version manually.") parser.add_argument("-u","--url", help="set elivepatch server url.") parser.add_argument("-d","--debug", action='store_true', help="set the debug option.") parser.add_argument("-v","--version", action='store_true', help="show the version.") diff --git a/elivepatch_client/client/checkers.py b/elivepatch_client/client/checkers.py index 61e9a02..b27a231 100644 --- a/elivepatch_client/client/checkers.py +++ b/elivepatch_client/client/checkers.py @@ -25,11 +25,11 @@ class Kernel(object): """ Manage kernels files """ - def __init__(self, restserver_url, session_uuid=None): + def __init__(self, restserver_url, kernel_version, session_uuid=None): self.config_fullpath = '' self.main_patch_fullpath = '' self.restserver_url = restserver_url - self.kernel_version = None + self.kernel_version = kernel_version if session_uuid: self.session_uuid = session_uuid else: @@ -65,7 +65,7 @@ class Kernel(object): # Store uncompressed temporary file temporary_config.write(config) # Get kernel version from the configuration file header - self.kernel_version = f_action.config_kernel_version(temporary_config) + #self.kernel_version = f_action.config_kernel_version(temporary_config) self.rest_manager.set_kernel_version(self.kernel_version) print('debug: kernel version = ' + self.rest_manager.get_kernel_version()) diff --git a/elivepatch_client/client/cli.py b/elivepatch_client/client/cli.py index dc42bf4..c6742d2 100644 --- a/elivepatch_client/client/cli.py +++ b/elivepatch_client/client/cli.py @@ -33,8 +33,9 @@ class Main(object): print('Kernel security CVE check is not implemented yet') elif config.patch: patch_manager = patch.ManaGer() - patch_manager.list() - current_kernel = Kernel(config.url) + patch_manager.list(config.kernel_version) + print(config.kernel_version) + current_kernel = Kernel(config.url, config.kernel_version) current_kernel.set_config(config.config) current_kernel.set_main_patch(config.patch) current_kernel.send_files() diff --git a/elivepatch_client/client/patch.py b/elivepatch_client/client/patch.py index c09f0b9..8d5493b 100644 --- a/elivepatch_client/client/patch.py +++ b/elivepatch_client/client/patch.py @@ -1,9 +1,9 @@ - import os import shutil import tempfile import subprocess + class ManaGer(object): def __init__(self): @@ -11,13 +11,29 @@ class ManaGer(object): if not os.path.exists(self.tmp_patch_folder): os.mkdir(self.tmp_patch_folder) - def list(self): + def list(self, kernel_version): + kernel_sources = 'gentoo-sources' patch_filename = [] + # search previous livepatch patch folder for (dirpath, dirnames, filenames) in os.walk(self.tmp_patch_folder): patch_filename.extend(filenames) - break + # search eapply_user patches + # local basedir=${PORTAGE_CONFIGROOT%/}/etc/portage/patches + try: + portage_configroot = os.environ['PORTAGE_CONFIGROOT'] + except: + portage_configroot = os.path.join('/etc', 'portage', 'patches') + kernel_patch_basedir_PN = os.path.join(portage_configroot, 'sys-kernel', + kernel_sources) + kernel_patch_basedir_P = os.path.join(portage_configroot, 'sys-kernel', + kernel_sources + '-' + kernel_version) + basedir = [kernel_patch_basedir_PN, kernel_patch_basedir_P] + for dir in basedir: + for (dirpath, dirnames, filenames) in os.walk(dir): + patch_filename.extend(filenames) print('List of current patches:') print(patch_filename) + return patch_filename def load(self, patch_fulldir, livepatch_fulldir): try: |