File v3-1-2-log-pollution-3.patch of Package cobbler

From d3506fa749396c341a57d3c724bb383fb2ead875 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pablo=20Su=C3=A1rez=20Hern=C3=A1ndez?=
 <psuarezhernandez@suse.com>
Date: Mon, 14 Feb 2022 12:13:48 +0000
Subject: [PATCH] Fix wrong validation of system name for installation logs

Do not pass multiple args to custom logger to avoid errors
---
 cobbler/modules/installation/post_log.py              | 2 +-
 cobbler/modules/installation/pre_clear_anamon_logs.py | 4 +---
 cobbler/modules/installation/pre_log.py               | 2 +-
 3 files changed, 3 insertions(+), 5 deletions(-)

Index: cobbler-3.1.2/cobbler/modules/installation/post_log.py
===================================================================
--- cobbler-3.1.2.orig/cobbler/modules/installation/post_log.py
+++ cobbler-3.1.2/cobbler/modules/installation/post_log.py
@@ -54,7 +54,7 @@ def run(api, args, logger):
     if not validate.validate_obj_type(objtype):
         return 1
 
-    if not api.find_items(objtype, name=name, return_list=False):
+    if not validate.validate_obj_name(name):
         return 1
 
     if not (ip == "?" or validate.ipv4_address(ip) or validate.ipv6_address(ip)):
Index: cobbler-3.1.2/cobbler/modules/installation/pre_clear_anamon_logs.py
===================================================================
--- cobbler-3.1.2.orig/cobbler/modules/installation/pre_clear_anamon_logs.py
+++ cobbler-3.1.2/cobbler/modules/installation/pre_clear_anamon_logs.py
@@ -30,8 +30,6 @@ from cobbler.cexceptions import CX
 
 PATH_PREFIX = "/var/log/cobbler/anamon/"
 
-logger = logging.getLogger()
-
 
 def register():
     """
@@ -73,5 +71,5 @@ def run(api, args, logger):
         if os.path.isdir(dirname):
             unlink_files(os.path.join(dirname, "*"))
 
-    logger.info('Cleared Anamon logs for "%s".', name)
+    logger.info('Cleared Anamon logs for "' + name + '".')
     return 0
Index: cobbler-3.1.2/cobbler/modules/installation/pre_log.py
===================================================================
--- cobbler-3.1.2.orig/cobbler/modules/installation/pre_log.py
+++ cobbler-3.1.2/cobbler/modules/installation/pre_log.py
@@ -36,7 +36,7 @@ def run(api, args, logger):
     if not validate.validate_obj_type(objtype):
         return 1
 
-    if not api.find_items(objtype, name=name, return_list=False):
+    if not validate.validate_obj_name(name):
         return 1
 
     if not (ip == "?" or validate.ipv4_address(ip) or validate.ipv6_address(ip)):
openSUSE Build Service is sponsored by