History log of /freebsd-current/usr.sbin/gssd/gssd.c
Revision Date Author Comments
# 4d65a7c6 24-Nov-2023 Warner Losh <imp@FreeBSD.org>

usr.sbin: Automated cleanup of cdefs and other formatting

Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by: Netflix


# 82ea0132 23-Oct-2023 Rick Macklem <rmacklem@FreeBSD.org>

gssd: Add support for the new upcall required by commit 428879dc9110

Commit 428879dc9110 adds a requirement for a new upcall for the
gssd(8). This patch adds that upcall.

Unfortunately, the old gssd.c would not build against the new
patched gssd.x.

This patch will fix the build.

MFC after: 1 month


# 1d386b48 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# 69772711 28-May-2023 Rick Macklem <rmacklem@FreeBSD.org>

gssd: Improve failure message when running in a jail

If a jail is not correctly configured to run nfsd(8)
in the jail, gssd(8) cannot run.
This patch improves the failure message for this case.

MFC after: 2 weeks


# 4d846d26 10-May-2023 Warner Losh <imp@FreeBSD.org>

spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD

The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with: pfg
MFC After: 3 days
Sponsored by: Netflix


# 24f42edc 11-Jan-2023 Rick Macklem <rmacklem@FreeBSD.org>

Revert "gssd: Fix handling of the gssname=<name> NFS mount option"

This reverts commit c33509d49a6fdcf86ef280a78f428d3cb7012c4a.

It turns out that the long 27 second delay I saw in the
gss_acquire_cred() call was caused by a (mis)configured
DNS. Although I did not specify "dns" in /etc/nsswitch.conf,
I did have a /etc/resolv.conf file on the system (left
there by wpa_supplicant). As such, with no route, it was
somehow trying to contact the DNS server, although there was none.

Once I got rid of the /etc/resolv.conf file, it worked
as expected.

Since there is now a large 5 minute timeout on the
kernel to gssd(8) upcalls, the gssd(8) daemon will not
get terminated when this delay occurs and the only affect
is a 30 second delay during the mount.

Discussed with: bjk


# c33509d4 07-Jan-2023 Rick Macklem <rmacklem@FreeBSD.org>

gssd: Fix handling of the gssname=<name> NFS mount option

If an NFS mount using "sec=krb5[ip],gssname=<name>" is
done, the gssd daemon fails. There is a long delay
(several seconds) in the gss_acquire_cred() call and then
it returns success, but the credentials returned are
junk.

I have no idea how long this has been broken, due to some
change in the Heimdal gssapi library call, but I suspect
it has been quite some time.

Anyhow, it turns out that replacing the "desired_name"
argument with GSS_C_NO_NAME fixes the problem.
Replacing the argument should not be a problem, since the
TGT for the host based initiator credential in the default
keytab file should be the only TGT in the gssd'd credential
cache (which is not the one for uid 0).

I will try and determine if FreeBSD13 and/or FreeBSD12
needs this same fix and will MFC if they need the fix.

This problem only affected Kerberized NFS mounts when the
"gssname" mount option was used. Other Kerberized NFS
mount cases already used GSS_C_NO_NAME and work ok.
A workaround if you do not have this patch is to do a
"kinit -k host/FQDN" as root on the machine, followed by
the Kerberized NFS mount without the "gssname" mount
option.

MFC after: 1 month


# ba10a6d0 10-Apr-2020 John Baldwin <jhb@FreeBSD.org>

Remove the -o option from gssd(8).

This uses DES and the kernel no longer supports DES for in-kernel GSS.

Reviewed by: kp
Relnotes: yes
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D24345


# c6da8eb2 20-Feb-2019 Sean Eric Fagan <sef@FreeBSD.org>

* Handle SIGPIPE in gssd
We've got some cases where the other end of gssd's AF_LOCAL socket gets
closed, resulting in an error (and SIGPIPE) when it tries to do I/O to it.
Closing without cleaning up means the next time nfsd starts up, it hangs,
unkillably; this allows gssd to handle that particular error.

* Limit the retry cound in gssd_syscall to 5.
The default is INT_MAX, which effectively means forever. And it's an
uninterruptable RPC call, so it will never stop.

The two changes mitigate the problem.

Reviewed by: macklem
MFC after: 2 weeks
Sponsored by: iXsystems Inc.
Differential Revision: https://reviews.freebsd.org/D19153


# 1de7b4b8 27-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

various: general adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

No functional change intended.


# b5635ba0 01-May-2016 Pedro F. Giffuni <pfg@FreeBSD.org>

usr.sbin: minor spelling fixes on comments.

No functional change.


# 21d7e927 01-Jan-2016 Josh Paetzel <jpaetzel@FreeBSD.org>

Unset the gss kernel state when gssd exits

When gssd exits it leaves the kernel state set by
gssd_syscall(). nfsd sees this and waits endlessly
in an unkillable state for gssd to come back. If you
had acidentally started gssd then stopped it, then
started nfsd you'd be in a bad way until you either
restarted gssd or rebooted the system. This change
fixes that by setting the kernel state to "" when
gssd exits.
Reviewed by: rmacklem
MFC after: 1 week
Sponsored by: iXsystems


# 5eff3ec6 26-Sep-2015 Josh Paetzel <jpaetzel@FreeBSD.org>

Increase group limit for kerberized NFSv4

PR: 202659
Submitted by: matthew.l.dailey@dartmouth.edu
Reviewed by: rmacklem dfr
MFC after: 1 week
Sponsored by: iXsystems


# 2f04825a 13-Feb-2015 Mark Johnston <markj@FreeBSD.org>

Check for an error from daemon(3), and correct the check for an error from
socket(2).

MFC after: 3 days
Sponsored by: EMC / Isilon Storage Division


# 992e6590 07-Jul-2013 Rick Macklem <rmacklem@FreeBSD.org>

Oops, initialize the krb5 ret values correctly (to anything non-zero).


# 74929c2e 07-Jul-2013 Rick Macklem <rmacklem@FreeBSD.org>

Make sure the krb5 status variables are correctly initialized.


# bd5012b2 07-Jul-2013 Rick Macklem <rmacklem@FreeBSD.org>

Add a new "-h" option to the gssd daemon that enables support for
host based (kerberos service principal) initiator credentials in
the default keytab file. This option won't actually be useful until
the corresponding kernel changes are committed.

Reviewed by: jhb


# c3234382 23-Jun-2013 Rick Macklem <rmacklem@FreeBSD.org>

Add a new "-o" option to the gssd which forces gss_init_sec_context()
to use DES and the associated old style GSS initialization token.
This appears to be required for some non-FreeBSD servers to
get a kerberized NFS mount to work. Also, ignore some signals when daemonized,
which might fix the gssd from "disappearing" without leaving a core dump.
Given the tight timeframe for the FreeBSD9.2 release, I have
committed this while waiting for code review. I will commit
changes recommended by the review in a separate commit.

Reviewed by: dfr (pending)
MFC after: 10 days


# 35ab0ce9 06-Jun-2013 Rick Macklem <rmacklem@FreeBSD.org>

Fix r251444 so that gssd.c still builds for WITHOUT_KERBEROS.

Reported by: bf1783@gmail.com
MFC after: 2 weeks


# 7e301aa9 05-Jun-2013 Rick Macklem <rmacklem@FreeBSD.org>

Add a "-v" (verbose) option to the gssd daemon, to help
with diagnosis of kerberized NFS mount problems. When set,
messages are sent to syslog() (or fprintf(stderr,...) if
"-d" is also specified) to indicate activity/results of
kgssapi upcalls.

Reviewed by: jhb
MFC after: 2 weeks


# d1e9aa46 01-May-2013 Rick Macklem <rmacklem@FreeBSD.org>

Fix the getpwuid_r() call in the gssd daemon so that it handles
the ERANGE error return case. Without this fix, authentication
of users for certain system setups could fail unexpectedly.

Reported by: Elias Martenson (lokedhs@gmail.com)
Tested by: Elias Martenson (earlier version)
MFC after: 2 weeks


# 8ac5ae56 03-Jan-2013 Rick Macklem <rmacklem@FreeBSD.org>

Fix r244604 so that it builds when MK_KERBEROS_SUPPORT == "no".

Reported by: bf
Tested by: bf
Reviewed by: gcooper
MFC after: 3 days


# 158b9798 22-Dec-2012 Rick Macklem <rmacklem@FreeBSD.org>

It was reported via email that some sshds create kerberos
credential cache files with names other than /tmp/krb5cc_<uid>.
The gssd daemon does not know how to find these credential caches.
This patch implements a new option "-s" that does a search for
credential cache files, using roughly the same algorithm as the
gssd daemon for Linux uses. The gssd behaviour is only changed
if the new "-s" option is specified. It also implements two other
new options related to the "-s" option.

Reported by: Piete.Brooks at cl.cam.ac.uk, Herbert Poeckl
Tested by: Herbert Poeckl (admin at ist.tugraz.at), Illias A. Marinos
MFC after: 2 weeks


# 765782e7 16-Dec-2012 Rick Macklem <rmacklem@FreeBSD.org>

Fix the gssd daemon so that it uses syslog() to report
an error instead of calling err() when it is daemonized,
so that the error gets logged.

Discussed with: rwatson, jhb
Tested by: Illias A. Marinos, Herbert Poeckl
MFC after: 2 weeks


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# fe0506d7 09-Mar-2010 Marcel Moolenaar <marcel@FreeBSD.org>

Create the altix project branch. The altix project will add support
for the SGI Altix 350 to FreeBSD/ia64. The hardware used for porting
is a two-module system, consisting of a base compute module and a
CPU expansion module. SGI's NUMAFlex architecture can be an excellent
platform to test CPU affinity and NUMA-aware features in FreeBSD.


# a9148abd 03-Nov-2008 Doug Rabson <dfr@FreeBSD.org>

Implement support for RPCSEC_GSS authentication to both the NFS client
and server. This replaces the RPC implementation of the NFS client and
server with the newer RPC implementation originally developed
(actually ported from the userland sunrpc code) to support the NFS
Lock Manager. I have tested this code extensively and I believe it is
stable and that performance is at least equal to the legacy RPC
implementation.

The NFS code currently contains support for both the new RPC
implementation and the older legacy implementation inherited from the
original NFS codebase. The default is to use the new implementation -
add the NFS_LEGACYRPC option to fall back to the old code. When I
merge this support back to RELENG_7, I will probably change this so
that users have to 'opt in' to get the new code.

To use RPCSEC_GSS on either client or server, you must build a kernel
which includes the KGSSAPI option and the crypto device. On the
userland side, you must build at least a new libc, mountd, mount_nfs
and gssd. You must install new versions of /etc/rc.d/gssd and
/etc/rc.d/nfsd and add 'gssd_enable=YES' to /etc/rc.conf.

As long as gssd is running, you should be able to mount an NFS
filesystem from a server that requires RPCSEC_GSS authentication. The
mount itself can happen without any kerberos credentials but all
access to the filesystem will be denied unless the accessing user has
a valid ticket file in the standard place (/tmp/krb5cc_<uid>). There
is currently no support for situations where the ticket file is in a
different place, such as when the user logged in via SSH and has
delegated credentials from that login. This restriction is also
present in Solaris and Linux. In theory, we could improve this in
future, possibly using Brooks Davis' implementation of variant
symlinks.

Supporting RPCSEC_GSS on a server is nearly as simple. You must create
service creds for the server in the form 'nfs/<fqdn>@<REALM>' and
install them in /etc/krb5.keytab. The standard heimdal utility ktutil
makes this fairly easy. After the service creds have been created, you
can add a '-sec=krb5' option to /etc/exports and restart both mountd
and nfsd.

The only other difference an administrator should notice is that nfsd
doesn't fork to create service threads any more. In normal operation,
there will be two nfsd processes, one in userland waiting for TCP
connections and one in the kernel handling requests. The latter
process will create as many kthreads as required - these should be
visible via 'top -H'. The code has some support for varying the number
of service threads according to load but initially at least, nfsd uses
a fixed number of threads according to the value supplied to its '-n'
option.

Sponsored by: Isilon Systems
MFC after: 1 month