Bug 8162 - xdrlib module is deprecated
Summary: xdrlib module is deprecated
Status: CLOSED FIXED
Alias: None
Product: ThinLinc
Classification: Unclassified
Component: Other (show other bugs)
Version: trunk
Hardware: PC Unknown
: P2 Normal
Target Milestone: 4.16.0
Assignee: Linn
URL:
Keywords: frifl_tester, relnotes
Depends on:
Blocks:
 
Reported: 2023-05-31 12:56 CEST by Pierre Ossman
Modified: 2023-12-13 14:56 CET (History)
3 users (show)

See Also:
Acceptance Criteria:


Attachments

Description Pierre Ossman cendio 2023-05-31 12:56:43 CEST
The xdrlib module in Python will be removed in Python 3.13 (likely released late 2024). We use this in tl-mount-localdrives, so we need to find a different solution.
Comment 1 Linn cendio 2023-08-24 11:15:28 CEST
xdrlib is currently only used in two external modules we include:
* pynfs - http://git.linux-nfs.org/?p=bfields/pynfs.git;a=summary
* unfs3 - https://github.com/unfs3/unfs3/tree/master

Unfortunately, these modules still use xdrlib, so we can't just upgrade them. However, if we do any modifications to them, we should consider sharing it with upstream.
Comment 2 Linn cendio 2023-08-25 10:15:11 CEST
Note that unfs3 is used in the client which does not have a Python requirement, so the only module that is of interest for this bug is pynfs.
Comment 3 Linn cendio 2023-08-25 10:27:29 CEST
I looked into alternatives for xdrlib, but did not find any recommendations either from Python or anyone else. It seems that Python is deprecating it because it is niche and mostly for NFS [1].

Looking at the code for xdrlib [2], it seems to all be in one file and it only depends on other standard modules. Also, the code has seen very few changes over the last 15 years, so it is a stable module.

One viable solution for this bug is including xdrlib in ThinLinc, since the maintenance of this module seems to be very low.

Another solution is switching out pynfs as a whole to another lib that does not use xdrlib.

[1]: https://peps.python.org/pep-0594/#xdrlib
[2]: https://github.com/python/cpython/blob/3.11/Lib/xdrlib.py
Comment 4 Linn cendio 2023-08-25 16:27:59 CEST
In tl-mount-localdrives, we use pynfs to mount the client and connect it to the server, and handle the communication.

I found libnfs-python [1], which seems to have a similar functionality to pynfs. However, I'm unsure of how it handles packing and unpacking of different types, since I at a brief look couldn't see any special handling for that.

In order to run libnfs-python, the package libnfs [2] is needed. It seems to be relatively common (I had it installed on my Fedora), but I'm not sure if the different distributions ships it as default. Also, it's not a requirement that a replacement for pynfs is in Python, so libnfs itself could possibly also be an alternative.

[1]: https://github.com/sahlberg/libnfs-python
[2]: https://github.com/sahlberg/libnfs
Comment 7 Linn cendio 2023-08-29 14:32:40 CEST
libnfs-python uses compiled files to run, and these compiled files are only compatible with one Python version. Since we want to support multiple Python versions, we would have to include one file for each version. This is not a reasonable option, and hence libnfs-python is not a suitable alternative for us.
Comment 8 Linn cendio 2023-08-29 16:21:20 CEST
Since xdrlib seems to have such a low maintainance and only is one file, we have decided to include it in our source tree for now instead of finding another lib to use.

In the future, more people will (probably) have run into the issue of xdrlib being deprecated. If we need to revisit this area later, pynfs might not depend on xdrlib, or at a minimum there should be more posts or discussions about the subject.
Comment 12 Samuel Mannehed cendio 2023-08-29 19:34:08 CEST
Since Fedoras plans for Python 3.12 indicate that it will be included in Fedora 39 [1], I think we can assume the first Fedora version with Python 3.13 will be Fedora 40 (Q2 2024).

That would likely translate into RHEL 10 (Q2 2025) [2].

Ubuntu 22.04 shipped with Python 3.10 [3] (which was released a few months prior [4]). Judging from the past, I would assume Python 3.13 won't be included in the next LTS (24.04), but probably in 24.10 or 25.04 [5].

As far as SLES goes, I don't think we need to be concerned. SLES 15 ships with Python 3.6 which is old now.

[1]: https://fedoraproject.org/wiki/Changes/Python3.12
[2]: https://access.redhat.com/articles/3078
[3]: https://changelogs.ubuntu.com/changelogs/pool/main/p/python3.10/python3.10_3.10.2-1/changelog
[4]: https://devguide.python.org/versions/
[5]: https://wiki.ubuntu.com/Releases
Comment 14 Linn cendio 2023-08-31 13:34:25 CEST
xdrlib is now included in ThinLinc. Tested on Ubuntu 22.04 by first removing xdrlib from pythons standard lib and then checking that I could start up a fresh session and get access to local drives and read and edit files.

Note that unfs3 in our source tree still uses Python's original xdrlib in its imports. As mentioned in comment 2, that part of unfs3 is not used by ThinLinc, so those imports were left as is.

Tips for tester:
 - To remove xdrlib from Python, find xdrlib.py and remove it. This should be enough to give you an import error when trying to import it. If you don't get an import error, the file was probably cached (in a .pyc file?) and the cache needs to be removed.

- Only regression testing is needed, I think the bug linked below is a good place for inspiration:
https://bugzilla.cendio.com/show_bug.cgi?id=7232
Comment 15 Frida Flodin cendio 2023-09-05 14:55:52 CEST
Yes, this works as intended, regression tested on RHEL 9. Local drives work just fine. Tested by removing xdrlib.py as described in comment #14.

Note You need to log in before you can comment on or make changes to this bug.