Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 14 Apr 2024 12:30:22 -0700
From:      Rick Macklem <rick.macklem@gmail.com>
To:        Andreas Kempe <kempe@lysator.liu.se>
Cc:        freebsd-fs@freebsd.org
Subject:   Re: Kerberised NFSv4 - everyone gets mapped to nobody on file access
Message-ID:  <CAM5tNy5a-CALZdrHhCQ1akmR3=BqeEK8EFb6UxZ%2BCOp38u3bTg@mail.gmail.com>
In-Reply-To: <Zhv1jtKU8lRdKOul@shipon.lysator.liu.se>
References:  <ZgNiZsYl6D-GnRwI@shipon.lysator.liu.se> <CAM5tNy53suTizsOmsKvN9Zrd6LciAFrS3PEctUJjK%2BHH9QcMrw@mail.gmail.com> <CAM5tNy7YM6bRKTX3pLR8hC-a-cmxXA=wv4j0E8cBWGthbxzLdQ@mail.gmail.com> <ZgRUqkl1zVxMPt6K@shipon.lysator.liu.se> <CAM5tNy68W16ut4vR1Y9xxPwaU%2BT%2Bt8fU8dwg3DbfhMT5h5iEDQ@mail.gmail.com> <ZgVKehV_9ePUBdwd@shipon.lysator.liu.se> <CAM5tNy4ye6BwYAZ%2BVYQOgDnSjAmyg%2BCCu=XCm-%2BDZucfrfwgKw@mail.gmail.com> <CAM5tNy4%2BbUc0VMY8i_E9P-pT0CEOXHpKzitMuKYzydH465OBGg@mail.gmail.com> <ZgiIAyDKPlCr1c9C@shipon.lysator.liu.se> <CAM5tNy5GbbZSJ3sOALx6zUkZz_7BJGzQ_63srVK88RFecb_eCQ@mail.gmail.com> <Zhv1jtKU8lRdKOul@shipon.lysator.liu.se>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Apr 14, 2024 at 8:26=E2=80=AFAM Andreas Kempe <kempe@lysator.liu.se=
> wrote:
>
> On Sat, Mar 30, 2024 at 04:01:50PM -0700, Rick Macklem wrote:
> > On Sat, Mar 30, 2024 at 2:45=E2=80=AFPM Andreas Kempe <kempe@lysator.li=
u.se> wrote:
> > > Did you have a look at the owner field in the open reqest that create=
d
> > > the file? To me, it looks very strange. Could it be that the client
> > > isn't sending a correct owner in the creation request, causing the
> > > server to map it to nobody?
> > The only setable attribute specified by the Open request is "mode".
> > That just means that the server is expected to create the file with
> > an ownership of the Kerberos principal used in the RPC credentials.
> >
> > Now, if you are doing the RPC as root, that will result in nobody (or
> > a failure to create the file, depending upon directory permissions).
> > There is no way to know what user principal is represented by the
> > RPCSEC_GSS credentials, since they are a shorthand for the
> > Kerberos credentials presented in a Null RPC that happens
> > when there is no credential.
> >
> > When creating a file, the user creating the file will need to have
> > a valid TGT in the client's credential cache.
> >
> > And the user principal name (without @REALM) must be a name
> > in the passwd database.
> >
>
> After having let this brew in the back of my mind for a while, I
> realised what the issue was thanks to you explaining the use of the
> principal to figure out the user.
>
> For our usecase, I wanted to only authenticate the machine because
> users have cronjobs running in their home directories, users want to
> access each other's files and log in using SSH keys. I was mounting
> using
>
>         -o nfsv4,sec=3Dkrb5p,allgssname,gssname=3Dhost
>
> thinking that allgssname would allow users to use the machine's
> principal and that ownership information would be sent along with the
> requests. From what you wrote, Rick, I gather that this causes all
> users to be mapped to nobody because the machine's principal is used.
Yes. All gssname means that the "host" keytab entry is used for all RPCs.
What that maps to is up to the NFS server, but "nobody" would be the
typical case.

>
> Removing allgssname and doing a kinit has things working as expected
> when I mount using
>
>         -o nfsv4,sec=3Dkrb5p,gssname=3Dhost
>
> and makes me own files I create.
>
> Am I correct in thinking that Kerberos isn't really designed to be
> used for only authenticating the machine? Users having to always have
> their own valid Kerberos ticket doesn't really work for us.
Yes. The "host" keytab credential is a "hack". Kerberos calls them
service principals and they were not intended to authenticate a machine
when Kerberos was designed.

If users are running cron jobs, then one way around the problem
is to have the KDC issue renewable tickets and then run a daemon
(can't remember the name, but it is easy to find and opensourced)
that renews TGTs. (This only works up to the renew limit of the KDC
config.)

NFS-over-TLS (called RPC-over-TLS by the Linux folk) does allow
a client to provide a X.509 certificate during TLS handshake to
identify the client machine and the TLS encrypts everything on
the wire to avoid middleman attacks or snoopers.
It does not identify users on the server, unless TLS identity
squashing is used via the X.509 certificate to make all RPCs
done by a user. (This has the advantage that it is not "nobody",
but is only useful for things like laptops, that are only used by
one user. It does have the advantage that there are no tickets
to expire, although there is a, usually long, expiration on the X.509
certificate.)

rick

>
> Best regards,
> Andreas Kempe



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAM5tNy5a-CALZdrHhCQ1akmR3=BqeEK8EFb6UxZ%2BCOp38u3bTg>