#917105 urxvtd and urxvtc: enhance to interoperate with service managers

Package:
rxvt-unicode
Source:
rxvt-unicode
Description:
RXVT-like terminal emulator with Unicode and 256-color support
Submitter:
Jonathan de Boyne Pollard
Date:
2021-06-13 17:45:02 UTC
Severity:
normal
#917105#5
Date:
2018-12-22 17:28:25 UTC
From:
To:
|urxvtd| can be run as a per-user service under the nosh toolset's
service manager and under systemd.  It does not have the problems that
some X11 terminal emulators have with needing a |DISPLAY| environment
variable in the dæmon. But it is not perfect.  In particular, one cannot
use the service managers' abilities to pass the listening socket in as
an already open file descriptor, using (in the systemd case for example)
per-user socket and service units containing things along the lines of:

    [Service]
    RuntimeDirectory=urxvt
    RuntimeDirectoryMode=0700
    ExecStart=/usr/local/bin/urxvtd

    [Socket]
    ListenStream=%t/urxvt/daemon
    SocketMode=0600

What happens in practice is that |urxvtd| ignores the passed-in file
descriptor for a listening socket and blithely opens its own, second,
listening socket file descriptor.

The attached patch enhances |urxvtd| to interoperate with these service
management subsystems, allowing it to be passed the listening socket in
this way.  It also updates |urxvtc| and the doco keeping them in step.

A possible further enhancement to the Debian package, not in this patch,
would have it install pre-made per-user units for systemd in
|/usr/lib/systemd/user/urxvtd.socket| and
|/usr/lib/systemd/user/urxvtd.service| , fleshing out the aforegiven and
allowing users to manage the urxvt dæmon with |systemctl --user|.  I
leave that fairly trivial exercise to someone else.  I have already
added automatically-made per-user service bundles to the nosh service
management allowing users to manage the urxvt dæmon with |system-control
--user|.

Notes:

  *

    This is neither Linux-specific nor systemd-specific, and should
    /not/ be hidden behind a systemd configuration option.  I actually
    developed and tested this on FreeBSD invoking the urxvtd service
    from the nosh per-user service manager.

  *

    The patch adds support for the |XDG_RUNTIME_DIR| environment
    variable from the Freedesktop _Base Directory Specification_, which
    enables using features like |RuntimeDirectory| and |%t| in systemd
    units like the aforegiven.

  *

    Runtime directories are by definition private to individual users
    and machines, and so when a runtime directory is used the socket
    name is fixed as ||${XDG_RUNTIME_DIR}/urxvt/|daemon| and does not
    vary by host name or unnecessarily repeat the software name.
    (Compare the behaviour of other softwares which used to use compound
    names in |/tmp|, such as |dbus-daemon| using just
    |${XDG_RUNTIME_DIR}/bus| for example.)   Per convention the |urxvt|
    subdirectory does not have a hidden name (in contrast to
    |${HOME}/.urxvt/|).

  *

    The manual pages are updated to reflect the additional environment
    variables that are recognized, and to show which takes precedence.

#917105#10
Date:
2018-12-22 17:49:25 UTC
From:
To:
This is also https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=234276 .