From 88aa3ba4114f8e4234693123d50a3065f104208e Mon Sep 17 00:00:00 2001 From: Juan Jose Nicola Date: Wed, 4 Mar 2020 09:21:20 +0100 Subject: [PATCH] Add lock-file-dir configuration option. --- CHANGELOG.md | 2 ++ ospd/parser.py | 8 ++++++-- tests/test_argument_parser.py | 10 +++++++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6947e978..fad62efb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Accept reverse_lookup_only and reverse_lookup_unify target's options. [#195](https://github.com/greenbone/ospd/pull/195) - Add 'total' and 'sent' attributes to element for cmd response. [#206](https://github.com/greenbone/ospd/pull/206) - Add new get_memory_usage command. [#207](https://github.com/greenbone/ospd/pull/207) +- Add lock-file-dir configuration option. [#218](https://github.com/greenbone/ospd/pull/218) ### Changes - Modify __init__() method and use new syntax for super(). [#186](https://github.com/greenbone/ospd/pull/186) @@ -25,6 +26,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Fixed - Fix stop scan. Wait for the scan process to be stopped before delete it from the process table. [#204](https://github.com/greenbone/ospd/pull/204) - Fix get_scanner_details(). [#210](https://github.com/greenbone/ospd/pull/210) + ## [2.0.1] (unreleased) ### Added diff --git a/ospd/parser.py b/ospd/parser.py index 7a36f94c..f69d89d6 100644 --- a/ospd/parser.py +++ b/ospd/parser.py @@ -34,6 +34,7 @@ DEFAULT_CONFIG_PATH = "~/.config/ospd.conf" DEFAULT_UNIX_SOCKET_PATH = "/var/run/ospd/ospd.sock" DEFAULT_PID_PATH = "/var/run/ospd.pid" +DEFAULT_LOCKFILE_DIR_PATH = "/var/run/ospd" DEFAULT_STREAM_TIMEOUT = 10 # ten seconds DEFAULT_SCANINFO_STORE_TIME = 0 # in hours @@ -87,14 +88,17 @@ def __init__(self, description: str) -> None: help='Location of the file for the process ID. ' 'Default: %(default)s', ) - + parser.add_argument( + '--lock-file-dir', + default=DEFAULT_LOCKFILE_DIR_PATH, + help='Directory where lock files are placed. Default: %(default)s', + ) parser.add_argument( '-m', '--socket-mode', default=DEFAULT_UNIX_SOCKET_MODE, help='Unix file socket mode. Default: %(default)s', ) - parser.add_argument( '-k', '--key-file', diff --git a/tests/test_argument_parser.py b/tests/test_argument_parser.py index beb5503c..4b1f3ce3 100644 --- a/tests/test_argument_parser.py +++ b/tests/test_argument_parser.py @@ -35,6 +35,10 @@ DEFAULT_KEY_FILE, DEFAULT_NICENESS, DEFAULT_SCANINFO_STORE_TIME, + DEFAULT_CONFIG_PATH, + DEFAULT_UNIX_SOCKET_PATH, + DEFAULT_PID_PATH, + DEFAULT_LOCKFILE_DIR_PATH, ) @@ -94,4 +98,8 @@ def test_defaults(self): self.assertEqual(args.log_level, logging.WARNING) self.assertEqual(args.address, DEFAULT_ADDRESS) self.assertEqual(args.port, DEFAULT_PORT) - self.assertEqual(args.port, DEFAULT_SCANINFO_STORE_TIME) + self.assertEqual(args.scaninfo_store_time, DEFAULT_SCANINFO_STORE_TIME) + self.assertEqual(args.config, DEFAULT_CONFIG_PATH) + self.assertEqual(args.unix_socket, DEFAULT_UNIX_SOCKET_PATH) + self.assertEqual(args.pid_file, DEFAULT_PID_PATH) + self.assertEqual(args.lock_file_dir, DEFAULT_LOCKFILE_DIR_PATH)