All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: Calum Mackay <calum.mackay@oracle.com>
Cc: linux-nfs@vger.kernel.org, Jeff Layton <jlayton@kernel.org>,
	Michael Moese <mmoese@suse.com>
Subject: Re: [PATCH 1/1] Allow to fallback to xdrlib if xdrlib3 not available
Date: Wed, 12 Feb 2025 22:01:35 +0100	[thread overview]
Message-ID: <20250212210135.GA2141194@pevik> (raw)
In-Reply-To: <0b73e27f-9b1f-4840-af10-b687c90759ad@oracle.com>

> On 12/02/2025 1:23 pm, Petr Vorel wrote:
> > On certain environments it might be difficult to install xdrlib3 via pip
> > (e.g. python 3.11, which is a default on current Tumbleweed).

> > Fixes: dfb0b07 ("Move to xdrlib3")
> > Suggested-by: Michael Moese <mmoese@suse.com>
> > Signed-off-by: Petr Vorel <pvorel@suse.cz>
> > ---
> > Hi,

> > I admit it would be safer to check if python is really < 3.13.

> > Kind regards,
> > Petr

> >   README                                | 2 ++
> >   nfs4.0/lib/rpc/rpc.py                 | 6 +++++-
> >   nfs4.0/lib/rpc/rpcsec/sec_auth_sys.py | 7 ++++++-
> >   nfs4.0/nfs4lib.py                     | 6 +++++-
> >   nfs4.0/nfs4server.py                  | 6 +++++-
> >   rpc/security.py                       | 6 +++++-
> >   xdr/xdrgen.py                         | 9 +++++++--
> >   7 files changed, 35 insertions(+), 7 deletions(-)

> > diff --git a/README b/README
> > index 8c3ac27..d5214b4 100644
> > --- a/README
> > +++ b/README
> > @@ -19,6 +19,8 @@ python3-standard-xdrlib) or you may install it via pip:
> >   	pip install xdrlib3
> > +If xdrlib3 is not available fallback to old xdrlib (useful for python < 3.13).

> It sounds a little like the above is an instruction for the user; if you
> don't mind I'll fix this up, adding "the code will fallback…", just to make
> it obvious?

Yes, please, fix it.

> Thanks for the fix Petr, I'll get this in today.

Thanks a lot for accepting this. FYI we test with pynfs also various SLES kernels
(including very old ones), which obviously have older python3. Probably on all
would xdrlib3 installation via pip+virtualenv worked, but safest way is to avoid
it and use python stock xdrlib.

Kind regards,
Petr

> cheers,
> c.



> > +
> >   You can prepare both versions for use with
> >   	./setup.py build
> > diff --git a/nfs4.0/lib/rpc/rpc.py b/nfs4.0/lib/rpc/rpc.py
> > index 4751790..7a80241 100644
> > --- a/nfs4.0/lib/rpc/rpc.py
> > +++ b/nfs4.0/lib/rpc/rpc.py
> > @@ -9,12 +9,16 @@
> >   from __future__ import absolute_import
> >   import struct
> > -import xdrlib3 as xdrlib
> >   import socket
> >   import select
> >   import threading
> >   import errno
> > +try:
> > +    import xdrlib3 as xdrlib
> > +except:
> > +    import xdrlib
> > +
> >   from rpc.rpc_const import *
> >   from rpc.rpc_type import *
> >   import rpc.rpc_pack as rpc_pack
> > diff --git a/nfs4.0/lib/rpc/rpcsec/sec_auth_sys.py b/nfs4.0/lib/rpc/rpcsec/sec_auth_sys.py
> > index 2581a1e..41c6d54 100644
> > --- a/nfs4.0/lib/rpc/rpcsec/sec_auth_sys.py
> > +++ b/nfs4.0/lib/rpc/rpcsec/sec_auth_sys.py
> > @@ -1,7 +1,12 @@
> >   from .base import SecFlavor, SecError
> >   from rpc.rpc_const import AUTH_SYS
> >   from rpc.rpc_type import opaque_auth
> > -from xdrlib3 import Packer, Error
> > +import struct
> > +
> > +try:
> > +    from xdrlib3 import Packer, Error
> > +except:
> > +    from xdrlib import Packer, Error
> >   class SecAuthSys(SecFlavor):
> >       # XXX need better defaults
> > diff --git a/nfs4.0/nfs4lib.py b/nfs4.0/nfs4lib.py
> > index 2337d8c..92b3c11 100644
> > --- a/nfs4.0/nfs4lib.py
> > +++ b/nfs4.0/nfs4lib.py
> > @@ -41,9 +41,13 @@ import xdrdef.nfs4_const as nfs4_const
> >   from  xdrdef.nfs4_const import *
> >   import xdrdef.nfs4_type as nfs4_type
> >   from xdrdef.nfs4_type import *
> > -from xdrlib3 import Error as XDRError
> >   import xdrdef.nfs4_pack as nfs4_pack
> > +try:
> > +    from xdrlib3 import Error as XDRError
> > +except:
> > +    from xdrlib import Error as XDRError
> > +
> >   import nfs_ops
> >   op4 = nfs_ops.NFS4ops()
> > diff --git a/nfs4.0/nfs4server.py b/nfs4.0/nfs4server.py
> > index 10bf28e..e26cecd 100755
> > --- a/nfs4.0/nfs4server.py
> > +++ b/nfs4.0/nfs4server.py
> > @@ -34,7 +34,11 @@ import time, StringIO, random, traceback, codecs
> >   import StringIO
> >   import nfs4state
> >   from nfs4state import NFS4Error, printverf
> > -from xdrlib3 import Error as XDRError
> > +
> > +try:
> > +    from xdrlib3 import Error as XDRError
> > +except:
> > +    from xdrlib import Error as XDRError
> >   unacceptable_names = [ "", ".", ".." ]
> >   unacceptable_characters = [ "/", "~", "#", ]
> > diff --git a/rpc/security.py b/rpc/security.py
> > index 789280c..79e746b 100644
> > --- a/rpc/security.py
> > +++ b/rpc/security.py
> > @@ -3,7 +3,6 @@ from .rpc_const import AUTH_NONE, AUTH_SYS, RPCSEC_GSS, SUCCESS, CALL, \
> >   from .rpc_type import opaque_auth, authsys_parms
> >   from .rpc_pack import RPCPacker, RPCUnpacker
> >   from .gss_pack import GSSPacker, GSSUnpacker
> > -from xdrlib3 import Packer, Unpacker
> >   from . import rpclib
> >   from .gss_const import *
> >   from . import gss_type
> > @@ -17,6 +16,11 @@ except ImportError:
> >   import threading
> >   import logging
> > +try:
> > +    from xdrlib3 import Packer, Unpacker
> > +except:
> > +    from xdrlib import Packer, Unpacker
> > +
> >   log_gss = logging.getLogger("rpc.sec.gss")
> >   log_gss.setLevel(logging.INFO)
> > diff --git a/xdr/xdrgen.py b/xdr/xdrgen.py
> > index f802ba8..970ae9d 100755
> > --- a/xdr/xdrgen.py
> > +++ b/xdr/xdrgen.py
> > @@ -1357,8 +1357,13 @@ pack_header = """\
> >   import sys,os
> >   from . import %s as const
> >   from . import %s as types
> > -import xdrlib3 as xdrlib
> > -from xdrlib3 import Error as XDRError
> > +
> > +try:
> > +    import xdrlib3 as xdrlib
> > +    from xdrlib3 import Error as XDRError
> > +except:
> > +    import xdrlib as xdrlib
> > +    from xdrlib import Error as XDRError
> >   class nullclass(object):
> >       pass



  reply	other threads:[~2025-02-12 21:01 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-12 13:23 [PATCH 1/1] Allow to fallback to xdrlib if xdrlib3 not available Petr Vorel
2025-02-12 13:27 ` [PATCH pynfs] " Petr Vorel
2025-02-12 13:36 ` [PATCH 1/1] " Jeff Layton
2025-02-12 13:47   ` Petr Vorel
2025-02-12 13:53     ` Jeff Layton
2025-02-12 15:41       ` Chuck Lever
2025-02-12 20:52 ` Calum Mackay
2025-02-12 21:01   ` Petr Vorel [this message]
2025-02-12 21:32     ` Calum Mackay

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250212210135.GA2141194@pevik \
    --to=pvorel@suse.cz \
    --cc=calum.mackay@oracle.com \
    --cc=jlayton@kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=mmoese@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.