Thanks to Colin Watson for the report: if pterm is both
able (appropriately setgid) and willing (given the right options) to
stamp utmp, it will use $DISPLAY as the location to write into utmp,
and segfault if it's not set. But in a Wayland-only system it might
very well not be set.
To fix this I've generalised seat_get_x_display() into
seat_get_display(), so that it can also return a display id string
like "wayland-0" if that's what's appropriate. So now in that
situation pterm will stamp utmp with a Wayland display id in place of
an X11 one.
However, seat_get_x_display() was also used to retrieve an X11 display
name specifically so as to populate $DISPLAY in the terminal's shell.
So the new seat_get_display() has a parameter to constrain the
returned display to be of a particular type, or NULL if that type
isn't available.
As a final fallback, in case seat_get_display(seat, SDISP_ANY) might
_still_ manage to return NULL for any reason, we catch that and turn
it into the empty string before stamping utmp, so that we still won't
segfault.