sahlberg / libnfs-python

Python bindings for libnfs
GNU Lesser General Public License v2.1
64 stars 34 forks source link

utils/nfs-ls.py is hanging #36

Open jbd opened 4 years ago

jbd commented 4 years ago

Hello,

If I run nfs-ls from libnfs using my user, I've got this expected result (secure mount):

$ nfs-ls nfs://127.0.0.1/usr
Failed to mount nfs share : mount_cb: RPC error: Mount failed with error MNT3ERR_ACCES(13) Permission denied(13)

It is working as root.

If I try nfs-ls.py, it is working as root, but it hangs with an unprivileged user:

$ python utils/nfs-ls.py nfs://127.0.0.1/usr
nfs <libnfs.NFS object at 0x7feeb93da040>

It hangs here. Here is the traceback after hitting ctrl-c:

nfs <libnfs.NFS object at 0x7feeb93da040>
^CTraceback (most recent call last):
  File "utils/nfs-ls.py", line 31, in <module>
    ls(sys.argv[1])
  File "utils/nfs-ls.py", line 21, in ls
    for ent in nfs.listdir("."):
  File "/home/jbdenis/Code/libnfs-python/env/lib/python3.8/site-packages/libnfs/__init__.py", line 223, in listdir
    ret = nfs_opendir(self._nfs, path, d)
  File "/home/jbdenis/Code/libnfs-python/env/lib/python3.8/site-packages/libnfs/libnfs.py", line 327, in nfs_opendir
    return _libnfs.nfs_opendir(nfs, path, nfsdir)
KeyboardInterrupt

Is that working as expected or should it be considered as a bug ?

Using python 2.7, it looks the same, with an additional segmentation fault:

$ python utils/nfs-ls.py nfs://127.0.0.1/usr
('nfs', <libnfs.NFS object at 0x7f72b6d4bcd0>)
^CTraceback (most recent call last):
  File "utils/nfs-ls.py", line 31, in <module>
    ls(sys.argv[1])
  File "utils/nfs-ls.py", line 21, in ls
    for ent in nfs.listdir("."):
  File "/home/jbdenis/Code/libnfs-python/env/lib/python2.7/site-packages/libnfs/__init__.py", line 223, in listdir
    ret = nfs_opendir(self._nfs, path, d)
  File "/home/jbdenis/Code/libnfs-python/env/lib/python2.7/site-packages/libnfs/libnfs.py", line 327, in nfs_opendir
    return _libnfs.nfs_opendir(nfs, path, nfsdir)
KeyboardInterrupt
Segmentation fault

Thank you !

jbd commented 4 years ago

I don't know if it is an ideal behavior, but it fails early and explicitly with this patch: https://github.com/sahlberg/libnfs-python/pull/37