internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: cobbler/cobbler

Issue:
SafeConfigParser was removed in 3.12
### Describe the bug

From https://docs.python.org/3.12/whatsnew/3.12.html:

Several names deprecated in the configparser way back in 3.2 have been removed per gh-89336:
- configparser.ParsingError no longer has a filename attribute or argument. Use the source attribute and argument instead.
- configparser no longer has a SafeConfigParser class. Use the shorter ConfigParser name instead.
- configparser.ConfigParser no longer has a readfp method. Use read_file() instead.


<!--- HINT: You can paste gist.github.com links for long logs or larger files -->

### Steps to reproduce

1. systemctl start cobblerd

### Expected behavior

<!--- A clear and concise description of what you expected to happen. -->

### Cobbler version

<!--- Paste output from `cobbler version` -->
````paste below
Cobbler 3.4.0
````

### Operating system

Fedora 39

### Cobbler log

<!--- Paste (partial) output from `/var/log/cobbler/cobbler.log` -->
````paste below
cobblerd[1614]: INFO | Exception raised when loading module authorization.configfile
cobblerd[1614]: INFO | Exception occurred: <class 'ImportError'>
cobblerd[1614]: INFO | Exception value: cannot import name 'SafeConfigParser' from 'configparser' (/usr/lib64/python3.12/configparser.py)
````

### Screenshots

<!--- If applicable, add screenshots to help explain your problem. -->

### Additional information

<!--- Add any other context about the problem here. -->



Discussion:

Resolving patch:
diff --git a/cobbler/modules/authorization/configfile.py b/cobbler/modules/authorization/configfile.py
--- a/cobbler/modules/authorization/configfile.py
+++ b/cobbler/modules/authorization/configfile.py
@@ -10,7 +10,7 @@
 
 
 import os
-from configparser import SafeConfigParser
+from configparser import ConfigParser
 from typing import TYPE_CHECKING, Any, Dict
 
 if TYPE_CHECKING:
@@ -37,7 +37,7 @@ def __parse_config() -> Dict[str, Dict[Any, Any]]:
     """
     if not os.path.exists(CONFIG_FILE):
         return {}
-    config = SafeConfigParser()
+    config = ConfigParser()
     config.read(CONFIG_FILE)
     alldata: Dict[str, Dict[str, Any]] = {}
     groups = config.sections()


Test patch:
Repository: cobbler/cobbler

Issue:
[Backport] /usr/lib/PXELINUX/linux.c32 does not exist, can't create a symlink to it
### Original feature issue

- Issue: #3574
- PR: #3576 

### Target release

- [x] release33
- [ ] release32
- [ ] release30

### Reason

Stabilization for Debian of Cobbler 3.3.x.



Discussion:

Resolving patch:
diff --git a/cobbler/actions/mkloaders.py b/cobbler/actions/mkloaders.py
--- a/cobbler/actions/mkloaders.py
+++ b/cobbler/actions/mkloaders.py
@@ -150,14 +150,14 @@ def make_syslinux(self):
         libcom32_c32_path = self.syslinux_folder.joinpath("libcom32.c32")
         if syslinux_version > 4 and libcom32_c32_path.exists():
             symlink(
-                self.syslinux_pxelinux_folder.joinpath("linux.c32"),
+                self.syslinux_folder.joinpath("linux.c32"),
                 self.bootloaders_dir.joinpath("linux.c32"),
                 skip_existing=True,
             )
             # Make libcom32.c32
             # 'linux.c32' depends on 'libcom32.c32'
             symlink(
-                self.syslinux_pxelinux_folder.joinpath("libcom32.c32"),
+                self.syslinux_folder.joinpath("libcom32.c32"),
                 self.bootloaders_dir.joinpath("libcom32.c32"),
                 skip_existing=True,
             )


Test patch:
Repository: cobbler/cobbler

Issue:
[Backport] [scm-track] Fix commit command
### Original feature issue

- PR: #3021

### Target release

- [x] release33
- [ ] release32
- [ ] release30

### Reason

Stabilizations of Cobbler 3.3.4



Discussion:

Resolving patch:
diff --git a/cobbler/modules/scm_track.py b/cobbler/modules/scm_track.py
--- a/cobbler/modules/scm_track.py
+++ b/cobbler/modules/scm_track.py
@@ -67,7 +67,7 @@ def run(api, args):
         utils.subprocess_call(["git", "add", "--all", "collections"], shell=False)
         utils.subprocess_call(["git", "add", "--all", "templates"], shell=False)
         utils.subprocess_call(["git", "add", "--all", "snippets"], shell=False)
-        utils.subprocess_call(["git", "commit", "-m", "API", "update", "--author", author], shell=False)
+        utils.subprocess_call(["git", "commit", "-m", "API update", "--author", author], shell=False)
 
         if push_script:
             utils.subprocess_call([push_script], shell=False)


Test patch:
Repository: cobbler/cobbler

Issue:
[Backport] Exception occurred: <class 'KeyError'> while "cobbler sync"
### Original feature issue

- Issue: #3126
- PR: #3547

### Target release

- [x] release33
- [ ] release32
- [ ] release30

### Reason

Stabilization of Cobbler 3.3.4.



Discussion:

Resolving patch:
diff --git a/cobbler/modules/managers/bind.py b/cobbler/modules/managers/bind.py
--- a/cobbler/modules/managers/bind.py
+++ b/cobbler/modules/managers/bind.py
@@ -270,7 +270,8 @@ def __write_named_conf(self):
 
         metadata = {'forward_zones': self.__forward_zones().keys(),
                     'reverse_zones': [],
-                    'zone_include': ''}
+                    'zone_include': '',
+                    'bind_zonefiles': self.settings.bind_zonefile_path}
 
         for zone in metadata['forward_zones']:
             txt = """
@@ -327,7 +328,8 @@ def __write_secondary_conf(self):
 
         metadata = {'forward_zones': self.__forward_zones().keys(),
                     'reverse_zones': [],
-                    'zone_include': ''}
+                    'zone_include': '',
+                    'bind_zonefiles': self.settings.bind_zonefile_path}
 
         for zone in metadata['forward_zones']:
             txt = """


Test patch:
Repository: cobbler/cobbler

Issue:
[Backport] SafeConfigParser removal
### Original feature issue

Issue #3551 PR #3552 

### Target release

- [x] release33
- [ ] release32
- [ ] release30

### Reason

This is needed for Fedora


Discussion:

Resolving patch:
diff --git a/cobbler/modules/authorization/configfile.py b/cobbler/modules/authorization/configfile.py
--- a/cobbler/modules/authorization/configfile.py
+++ b/cobbler/modules/authorization/configfile.py
@@ -9,7 +9,7 @@
 # SPDX-FileCopyrightText: Michael DeHaan <michael.dehaan AT gmail>
 
 
-from configparser import SafeConfigParser
+from configparser import ConfigParser
 
 import os
 from typing import Dict
@@ -34,7 +34,7 @@ def __parse_config() -> Dict[str, dict]:
     """
     if not os.path.exists(CONFIG_FILE):
         return {}
-    config = SafeConfigParser()
+    config = ConfigParser()
     config.read(CONFIG_FILE)
     alldata = {}
     groups = config.sections()


Test patch:
Repository: cobbler/cobbler

Issue:
[Backport] scm_track: Push script not working
### Original feature issue

- Issue: #3590
- PR: #3620 

### Target release

- [x] release33
- [ ] release32
- [ ] release30

### Reason

Stabilizations of Cobbler 3.3.4 for the community.



Discussion:

Resolving patch:
diff --git a/cobbler/modules/scm_track.py b/cobbler/modules/scm_track.py
--- a/cobbler/modules/scm_track.py
+++ b/cobbler/modules/scm_track.py
@@ -70,7 +70,7 @@ def run(api, args):
         utils.subprocess_call(["git", "commit", "-m", "API update", "--author", author], shell=False)
 
         if push_script:
-            utils.subprocess_call([push_script], shell=False)
+            utils.subprocess_call(push_script.split(" "), shell=False)
 
         os.chdir(old_dir)
         return 0
@@ -89,10 +89,10 @@ def run(api, args):
         utils.subprocess_call(["hg", "add collections"], shell=False)
         utils.subprocess_call(["hg", "add templates"], shell=False)
         utils.subprocess_call(["hg", "add snippets"], shell=False)
-        utils.subprocess_call(["hg", "commit", "-m", "API", "update", "--user", author], shell=False)
+        utils.subprocess_call(["hg", "commit", "-m", "API update", "--user", author], shell=False)
 
         if push_script:
-            utils.subprocess_call([push_script], shell=False)
+            utils.subprocess_call(push_script.split(" "), shell=False)
 
         os.chdir(old_dir)
         return 0
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -494,7 +494,10 @@ def run(self):
         ],
         extras_require={
             "lint": ["pyflakes", "pycodestyle"],
-            "test": ["pytest", "pytest-cov", "codecov", "pytest-mock"]
+            "test": ["pytest", "pytest-cov", "codecov", "pytest-mock"],
+            # We require the current version to properly detect duplicate issues
+            # See: https://github.com/twisted/towncrier/releases/tag/22.8.0
+            "changelog": ["towncrier>=22.8.0"],
         },
         packages=find_packages(exclude=["*tests*"]),
         scripts=[


Test patch:
diff --git a/tests/modules/scm_track_test.py b/tests/modules/scm_track_test.py
--- a/tests/modules/scm_track_test.py
+++ b/tests/modules/scm_track_test.py
@@ -72,7 +72,7 @@ def test_run_hg(mocker):
          mocker.call(["hg", "add collections"], shell=False),
          mocker.call(["hg", "add templates"], shell=False),
          mocker.call(["hg", "add snippets"], shell=False),
-         mocker.call(["hg", "commit", "-m", "API", "update", "--user", settings_mock.scm_track_author], shell=False),
+         mocker.call(["hg", "commit", "-m", "API update", "--user", settings_mock.scm_track_author], shell=False),
          mocker.call(["/bin/true"], shell=False)]
     )
     assert result == 0
Repository: cobbler/cobbler

Issue:
profile name is not available in ISC dhcp template rendering
### Is your feature request related to a problem?

I need to make some custom changes to the dhcp.conf file depending on the profile of the system.  Despite some comments suggesting otherwise, the profile is not available.

### Provide a detailed description of the proposed feature

We will add the profile to the `interface` dictionary so it can be used.

### Additional information

PR to come shortly.


Discussion:

Resolving patch:
diff --git a/cobbler/modules/managers/isc.py b/cobbler/modules/managers/isc.py
--- a/cobbler/modules/managers/isc.py
+++ b/cobbler/modules/managers/isc.py
@@ -146,9 +146,6 @@ def write_v4_config(
                     dhcp_tag = interface["dhcp_tag"]
                     host = interface["dns_name"]
 
-                if distro is not None:
-                    interface["distro"] = distro.to_dict()
-
                 if mac == "":
                     # can't write a DHCP entry for this system
                     continue
@@ -179,6 +176,12 @@ def write_v4_config(
                 interface["enable_ipxe"] = blended_system["enable_ipxe"]
                 interface["name_servers"] = blended_system["name_servers"]
 
+                if profile is not None:
+                    interface["profile"] = profile.to_dict()
+
+                if distro is not None:
+                    interface["distro"] = distro.to_dict()
+
                 # For esxi/UEFI export filename_esxi as path to efi bootloader
                 if distro and distro.os_version.startswith("esxi"):
                     interface["filename_esxi"] = "/".join(
@@ -329,8 +332,6 @@ def write_v6_config(
                     dhcp_tag = interface["dhcp_tag"]
                     host = interface["dns_name"]
 
-                interface["distro"] = distro.to_dict()
-
                 if not mac or not ip_v6:
                     # can't write a DHCP entry for this system
                     self.logger.warning("%s has no IPv6 or MAC address", system.name)
@@ -360,6 +361,12 @@ def write_v6_config(
                 interface["owner"] = blended_system["name"]
                 interface["name_servers"] = blended_system["name_servers"]
 
+                if profile is not None:
+                    interface["profile"] = profile.to_dict()
+
+                if distro is not None:
+                    interface["distro"] = distro.to_dict()
+
                 # Explicitly declare filename for other (non x86) archs as in DHCP discover package mostly the
                 # architecture cannot be differed due to missing bits...
                 if not interface.get("filename"):


Test patch:
Repository: cobbler/cobbler

Issue:
[Forwardport] IP Address list
### Original feature issue

This is a forward port of #1849 

### Target release

- [ ] release33
- [x] release32
- [ ] release30

### Reason

We depend on this functionality to display IP and MAC addresses and are moving to 3.2 from 2.8.  PR will follow shortly.


Discussion:

Resolving patch:
diff --git a/cobbler/web/urls.py b/cobbler/web/urls.py
--- a/cobbler/web/urls.py
+++ b/cobbler/web/urls.py
@@ -38,6 +38,7 @@
     re_path(r'^utils/random_mac/virttype/(?P<virttype>.+)$', views.random_mac, name="utils_random_mac_virttype"),
     path('events', views.events, name="events"),
     re_path(r'^eventlog/(?P<event>.+)$', views.eventlog, name="events_log"),
+    path('iplist', views.iplist, name="iplist"),
     path('task_created', views.task_created, name="task_created"),
     path('sync', views.sync, name="sync"),
     path('reposync', views.reposync, name="reposync"),
diff --git a/cobbler/web/views.py b/cobbler/web/views.py
--- a/cobbler/web/views.py
+++ b/cobbler/web/views.py
@@ -5,6 +5,7 @@
 from django.views.decorators.csrf import csrf_protect
 from django.views.decorators.http import require_POST
 
+import ipaddress
 import simplejson
 import time
 import xmlrpc.client
@@ -982,6 +983,41 @@ def events(request):
 # ======================================================================
 
 
+def iplist(request):
+    """
+    This page presents a list of all the IP addresses
+    """
+    if not test_user_authenticated(request):
+        return login(request, next="/cobbler_web/iplist", expired=True)
+    systems = remote.get_systems()
+    iplist = []
+    for system in systems:
+        for iname in system["interfaces"]:
+            if system["interfaces"][iname]["ip_address"] != "" and \
+               system["interfaces"][iname]["interface_type"] != "bond_slave" and \
+               system["interfaces"][iname]["interface_type"] != "bridge_slave":
+                if system["interfaces"][iname]["dns_name"] != "":
+                    iplist.append([system["interfaces"][iname]["ip_address"], system["interfaces"][iname]["dns_name"],
+                                  system["name"], iname, system["interfaces"][iname]["mac_address"]])
+                else:
+                    iplist.append([system["interfaces"][iname]["ip_address"], system["hostname"], system["name"], iname,
+                                   system["interfaces"][iname]["mac_address"]])
+
+    def to_ip_addr(a):
+        return ipaddress.ip_address(str(a[0]))
+
+    iplist = sorted(iplist, key=to_ip_addr)
+
+    html = render(request, 'iplist.tmpl', {
+        'results': iplist,
+        'version': remote.extended_version(request.session['token'])['version'],
+        'username': username
+    })
+    return HttpResponse(html)
+
+# ======================================================================
+
+
 def eventlog(request, event=0):
     """
     Shows the log for a given event.


Test patch:
Repository: cobbler/cobbler

Issue:
SELinux issue when service is restarted
This issue was initially reported at
https://bugzilla.redhat.com/show_bug.cgi?id=1754430

There is a SELinux denial when the cobblerd service is restarted because of the permissions of the web.ss and others webui_sessions files.

I'm not sure to understand if this is 3.0.x only or also only exists in 2.8.x, but for me there is a need to understand why cobblerd (uid root) tries to read theses files...
Of course it can probably be fixed by using 640 perm on theses files. (to be tested) but it just workaround the problem.


Discussion:
@kwizart If you look at the code then you will see that this is required by everything which accesses cobbler. It is an authentication file that make access possible. I see that this is a problem for you but on short term I don't see an options to make this problem go away...

The code where this is generated is in `cobbler/cobblerd.py +43` and onwards.
This is by the way also a problem for 2.8.x
Other points where you have context for this file is:

- `cobbler/cli.py + 335`
- `cobbler/utils.py +1825`
So due to the fact that Cobbler need to run as root currently and the Apache 2 user needs access to both files this won't be fixed by us. At least not until we have cleaned up everything very very good. Thus closing this and leaving the selinux policy mess to downstream. I recommend running this without selinux anyway because of the many permissions we need currently.

Resolving patch:
diff --git a/cobbler/cobblerd.py b/cobbler/cobblerd.py
--- a/cobbler/cobblerd.py
+++ b/cobbler/cobblerd.py
@@ -52,7 +52,7 @@ def regen_ss_file():
     with open("/dev/urandom", 'rb') as fd:
         data = fd.read(512)
 
-    with open(ssfile, 'wb', 0o660) as fd:
+    with open(ssfile, 'wb', 0o640) as fd:
         fd.write(binascii.hexlify(data))
 
     http_user = "apache"
@@ -61,7 +61,7 @@ def regen_ss_file():
         http_user = "www-data"
     elif family == "suse":
         http_user = "wwwrun"
-    os.lchown("/var/lib/cobbler/web.ss", pwd.getpwnam(http_user)[2], -1)
+    os.lchown(ssfile, 0, pwd.getpwnam(http_user)[3])
 
 
 def do_xmlrpc_rw(cobbler_api: CobblerAPI, settings, port):


Test patch:
Repository: cobbler/cobbler

Issue:
[Backport] Add support for cnames in dnsmasq
### Original feature issue

- Issue: #1643
- PR: #3640

### Target release

- [x] release33
- [ ] release32
- [ ] release30

### Reason

Stabilization of Cobbler 3.3.5



Discussion:

Resolving patch:
diff --git a/cobbler/modules/managers/dnsmasq.py b/cobbler/modules/managers/dnsmasq.py
--- a/cobbler/modules/managers/dnsmasq.py
+++ b/cobbler/modules/managers/dnsmasq.py
@@ -169,14 +169,21 @@ def regen_hosts(self):
             for (_, interface) in system.interfaces.items():
                 mac = interface.mac_address
                 host = interface.dns_name
+                cnames = " ".join(interface.cnames)
                 ip = interface.ip_address
                 ipv6 = interface.ipv6_address
                 if not mac:
                     continue
                 if host is not None and host != "" and ipv6 is not None and ipv6 != "":
-                    fh.write(ipv6 + "\t" + host + "\n")
+                    if cnames:
+                        fh.write(ipv6 + "\t" + host + ' ' + cnames + "\n")
+                    else:
+                        fh.write(ipv6 + "\t" + host + "\n")
                 elif host is not None and host != "" and ip is not None and ip != "":
-                    fh.write(ip + "\t" + host + "\n")
+                    if cnames:
+                        fh.write(ip + "\t" + host + ' ' + cnames + "\n")
+                    else:
+                        fh.write(ip + "\t" + host + "\n")
         fh.close()
 
     def restart_service(self):


Test patch:
Repository: cobbler/cobbler

Issue:
Cobbler rejects InfiniBand MAC addresses
### Describe the bug

InfiniBand uses 128-bit MAC addresses like 80:00:02:08:fe:80:00:00:00:00:00:00:f4:52:14:03:00:96:79:31

### Steps to reproduce

1. Try to configure an infiniband network interface with MAC address

### Expected behavior

No error.

### Cobbler version

<!--- Paste output from `cobbler version` -->
````paste below
3.2.2
````

### Operating system

EL9

### Cobbler log

<!--- Paste (partial) output from `/var/log/cobbler/cobbler.log` -->
````paste below
2024-03-12T14:12:29 - INFO | Exception occurred: <class 'cobbler.cexceptions.CX'>
2024-03-12T14:12:29 - INFO | Exception value: 'Invalid mac address format (80:00:02:08:fe:80:00:00:00:00:00:00:f4:52:14:03:00:96:79:31)'
2024-03-12T14:12:29 - INFO | Exception Info:
  File "/usr/lib/python3.9/site-packages/cobbler/remote.py", line 3453, in _dispatch
    return method_handle(*params)

  File "/usr/lib/python3.9/site-packages/cobbler/remote.py", line 1643, in modify_system
    return self.modify_item("system", object_id, attribute, arg, token)

  File "/usr/lib/python3.9/site-packages/cobbler/remote.py", line 1606, in modify_item
    method(arg)

  File "/usr/lib/python3.9/site-packages/cobbler/items/system.py", line 753, in modify_interface
    self.set_mac_address(value, interface)

  File "/usr/lib/python3.9/site-packages/cobbler/items/system.py", line 384, in set_mac_address
    address = validate.mac_address(address)

  File "/usr/lib/python3.9/site-packages/cobbler/validate.py", line 111, in mac_address
    raise CX("Invalid mac address format (%s)" % mac)
````


### Additional information
There is a request for support in netaddr, but it hasn't gone anywhere: https://github.com/netaddr/netaddr/issues/88


Discussion:

Resolving patch:
diff --git a/cobbler/validate.py b/cobbler/validate.py
--- a/cobbler/validate.py
+++ b/cobbler/validate.py
@@ -28,6 +28,9 @@
 RE_OBJECT_NAME = re.compile(r'[a-zA-Z0-9_\-.:]*$')
 RE_HOSTNAME = re.compile(r'^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])(\.([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9]))*$')
 RE_SCRIPT_NAME = re.compile(r"[a-zA-Z0-9_\-.]+")
+RE_INFINIBAND_MAC = re.compile(
+    "^" + ":".join(["([0-9A-F]{1,2})"] * 20) + "$", re.IGNORECASE
+)
 
 REPO_BREEDS = ["rsync", "rhn", "yum", "apt", "wget"]
 
@@ -107,7 +110,7 @@ def mac_address(mac: str, for_item=True) -> str:
         if mac == "":
             return mac
 
-    if not netaddr.valid_mac(mac):
+    if not netaddr.valid_mac(mac) and RE_INFINIBAND_MAC.match(mac) is None:
         raise CX("Invalid mac address format (%s)" % mac)
 
     return mac


Test patch:
Repository: cobbler/cobbler

Issue:
anamon aborts with 'bytes' object has not attribute 'data'
### Describe the bug

When installing a system, /tmp/anamon fails with the message ` 'bytes' object has not attribute 'data'`
### Steps to reproduce

1. Enable anamon
2. Start install

### Expected behavior
No error

### Cobbler version

````paste below
Cobbler 3.2.2
  source: ?, ?
  build time: Thu Mar  7 00:00:00 2024
````

### Operating system

AlmaLinux 9

### Cobbler log

````paste below
2024-04-05T10:17:44 - INFO | Exception occurred: <class 'AttributeError'>
2024-04-05T10:17:44 - INFO | Exception value: 'bytes' object has no attribute 'data'
2024-04-05T10:17:44 - INFO | Exception Info:
  File "/usr/lib/python3.9/site-packages/cobbler/remote.py", line 3453, in _dispatch
    return method_handle(*params)

  File "/usr/lib/python3.9/site-packages/cobbler/remote.py", line 2385, in upload_log_data
    if not self.__validate_log_data_params(sys_name, file, size, offset, data.data, token):

  File "/usr/lib/python3.9/site-packages/cobbler/remote.py", line 2408, in __validate_log_data_params
    and isinstance(offset, int) and isinstance(data.data, bytes)):
````


Discussion:

Resolving patch:
diff --git a/cobbler/remote.py b/cobbler/remote.py
--- a/cobbler/remote.py
+++ b/cobbler/remote.py
@@ -2405,7 +2405,7 @@ def __validate_log_data_params(self, sys_name: str, logfile_name: str, size: int
                                    token: Optional[str] = None) -> bool:
         # Validate all types
         if not (isinstance(sys_name, str) and isinstance(logfile_name, str) and isinstance(size, int)
-                and isinstance(offset, int) and isinstance(data.data, bytes)):
+                and isinstance(offset, int) and isinstance(data, bytes)):
             self.logger.warning("upload_log_data - One of the parameters handed over had an invalid type!")
             return False
         if token is not None and not isinstance(token, str):


Test patch: