Bug 54475 - import_computer fails with traceback
import_computer fails with traceback
Status: NEW
Product: UCS@school
Classification: Unclassified
Component: Import scripts
UCS@school 5.0
Other Linux
: P5 normal with 2 votes (vote)
: ---
Assigned To: UCS@school maintainers
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2022-02-21 16:27 CET by Dirk Ahrnke
Modified: 2022-06-08 09:13 CEST (History)
2 users (show)

See Also:
What kind of report is it?: Bug Report
What type of bug is this?: 3: Simply Wrong: The implementation doesn't match the docu
Who will be affected by this bug?: 3: Will affect average number of installed domains
How will those affected feel about the bug?: 2: A Pain – users won’t like this once they notice it
User Pain: 0.103
Enterprise Customer affected?:
School Customer affected?: Yes
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number: 2022060221000342
Bug group (optional): Regression
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dirk Ahrnke univentionstaff 2022-02-21 16:27:38 CET
while checking a scenario that used to work in 4.4-8 with 5.0-1 I noticed the following problem:

root@dn1:~# /usr/share/ucs-school-import/scripts/import_computer schulea_computer.tsv 
infile is  : schulea_computer.tsv
Processing line 1: windows	win-a-01	00:50:56:b6:d0:63	 SchuleA	10.0.10.151
 WARNING: no netmask specified for ip address 10.0.10.151/24 using 255.255.255.0
generate computer win-a-01 (school  SchuleA)
Traceback (most recent call last):
  File "/usr/share/ucs-school-import/scripts/import_computer", line 3100, in <module>
    import_computer()
  File "/usr/share/ucs-school-import/scripts/import_computer", line 2088, in import_computer
    success, dn = create_network(schoolNr, ip_iface.network)
  File "/usr/share/ucs-school-import/scripts/import_computer", line 1400, in create_network
    if check_network(schoolNr, network):
  File "/usr/share/ucs-school-import/scripts/import_computer", line 1516, in check_network
    escape_dn_chars(network.network_address),
  File "/usr/lib/python3/dist-packages/ldap/dn.py", line 23, in escape_dn_chars
    s = s.replace('\\','\\\\')
AttributeError: 'IPv4Address' object has no attribute 'replace'


also noticed by a customer in https://help.univention.com/t/import-rechnerobjekt-per-script/19219
Comment 1 Jair Ritter 2022-05-24 12:51:31 CEST
The function 
  "def escape_dn_chars(s):"   in 
  "/usr/lib/python3/dist-packages/ldap/dn.py"
expects the variable "s" to be a string.


The script 
  "/usr/share/ucs-school-import/scripts/import_computer"
uses this function to escape the characters in an 'IPv4Address' object not a string!


Workaround:

Edit file "/usr/share/ucs-school-import/scripts/import_computer"
change line 1516
 [-] escape_dn_chars(network.network_address),
 [+] escape_dn_chars(str(network.network_address)),
Comment 2 Daniel Duchon univentionstaff 2022-06-02 11:42:04 CEST
school customer affected