ntirpc icon indicating copy to clipboard operation
ntirpc copied to clipboard

Empty file when using nfs and krb5p

Open cybojanek opened this issue 3 years ago • 2 comments

Hi,

When trying to use:

  • ntirpc 3dca76322558db6db7d0afd9f46c03ef0466948d
  • nfs-ganesha 87ac5c73ce1bd8cac61981304f992fcf30e0a67f

And the following export:

EXPORT
{
    Export_Id = 4;
    Path = /mnt/vfs;
    Pseudo = /mnt/vfs;

    Access_type = RW;
    SecType = krb5,krb5i,krb5p;
    FSAL {
        Name = vfs;
    }
}

Reading on the client results in garbage file content:

mount -t nfs -o nfsvers=4.1,sec=krb5p,proto=tcp nfs-gateway-dev.cybojanek.novalocal:/mnt/vfs /mnt/vfs

cybojanek@nfs-client-dev:/root$ xxd -a /mnt/vfs/cybojanek/message.txt
00000000: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000010: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000020: 0000 0000

Undoing part of 02b87a2842e497af5c094b4ad3951a6b69671e98 fixes the problem:

diff --git a/src/authgss_prot.c b/src/authgss_prot.c
index 90848b2b..d6bb450d 100644
--- a/src/authgss_prot.c
+++ b/src/authgss_prot.c
@@ -268,7 +268,7 @@ xdr_rpc_gss_wrap(XDR *xdrs, xdrproc_t xdr_func, void *xdr_ptr,
         * If it's privacy, and NEWBUF is supported (because xdrs is a vector)
         * then NEWBUF will have allocated the new buffer.
         */
-       vector = (svc == RPCSEC_GSS_SVC_INTEGRITY);
+       vector = (svc == RPCSEC_GSS_SVC_INTEGRITY) || XDR_NEWBUF(xdrs);

        /* Marshal rpc_gss_data_t (sequence number + arguments).
         * If it's a vector, the response has been marshalled into a new
cybojanek@nfs-client-dev:/root$ xxd -a /mnt/vfs/cybojanek/message.txt
00000000: 6865 6c6c 6f20 776f 726c 640a 6865 6c6c  hello world.hell
00000010: 6f20 776f 726c 640a 6865 6c6c 6f20 776f  o world.hello wo
00000020: 726c 640a                                rld.

Unfortunately, I don't know enough about ntirpc to submit a merge request for this.

cybojanek avatar Jul 01 '21 18:07 cybojanek

Oops, I must have had a bad version of authgss_prot.c in my repo when I submitted the patch. That clearly has nothing to do with adding xdr_putbufs to xdrmem...

Please feel free to submit this patch as a pull request.

ffilz avatar Jul 06 '21 15:07 ffilz

Thanks! I created #240

cybojanek avatar Jul 07 '21 20:07 cybojanek