Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add systemd service files #13

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ EXTRA_DIST = .clang-format .gitignore .github LICENSE README.md bootstrap \
# Enable AFS support when running distcheck.
DISTCHECK_CONFIGURE_FLAGS = --enable-setpag

if HAVE_SYSTEMD
dist_systemdsystemunit_DATA = systemd/[email protected]
dist_systemduserunit_DATA = systemd/krenew.service
endif

# The following library order matters for annoying reasons. Older
# libafsauthent contains its own com_err implementation, which we do not
# want to pick up.
Expand Down
31 changes: 31 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ AM_PROG_CC_C_O
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
AC_PROG_INSTALL
AC_PROG_RANLIB
PKG_PROG_PKG_CONFIG

dnl aklog is the standard name for the utility to get AFS tokens from Kerberos
dnl tickets. afslog is the name of the utility that comes with Heimdal. By
Expand All @@ -45,6 +46,36 @@ AC_ARG_WITH([aklog],
AC_DEFINE_UNQUOTED([PATH_AKLOG], ["$PATH_AKLOG"],
[Full path to aklog binary.])

AC_ARG_WITH([systemdsystemunitdir],
[AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [systemd])],,
[with_systemdsystemunitdir=auto])
AS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"], [
def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)

AS_IF([test "x$def_systemdsystemunitdir" = "x"],
[AS_IF([test "x$with_systemdsystemunitdir" = "xyes"],
[AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])])
with_systemdsystemunitdir=no],
[with_systemdsystemunitdir="$def_systemdsystemunitdir"])])
AS_IF([test "x$with_systemdsystemunitdir" != "xno"],
[AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])])
AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$with_systemdsystemunitdir" != "xno"])

AC_ARG_WITH([systemduserunitdir],
[AS_HELP_STRING([--with-systemduserunitdir=DIR], [systemd])],,
[with_systemduserunitdir=auto])
AS_IF([test "x$with_systemduserunitdir" = "xyes" -o "x$with_systemduserunitdir" = "xauto"], [
def_systemduserunitdir=$($PKG_CONFIG --variable=systemduserunitdir systemd)

AS_IF([test "x$def_systemduserunitdir" = "x"],
[AS_IF([test "x$with_systemduserunitdir" = "xyes"],
[AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])])
with_systemduserunitdir=no],
[with_systemduserunitdir="$def_systemduserunitdir"])])
AS_IF([test "x$with_systemduserunitdir" != "xno"],
[AC_SUBST([systemduserunitdir], [$with_systemduserunitdir])])
AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$with_systemduserunitdir" != "xno"])

dnl Check for the Kerberos libraries and for portability between MIT and
dnl Heimdal.
RRA_LIB_KRB5
Expand Down
16 changes: 16 additions & 0 deletions systemd/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[Unit]
Description=Kerberos credentials maintainer for user %i
After=syslog.target network-online.target

[Service]
# Slow down starting of service and fail if k5start fails
Type=exec
EnvironmentFile=/etc/k5start-%i.conf
User=%i
ExecStart=/usr/bin/k5start $K5START_OPTS
# Give a delay to hopefully retrieve the ticket before considering the service started
ExecStartPost=/usr/bin/sleep 1
Restart=always

[Install]
WantedBy=multi-user.target
19 changes: 19 additions & 0 deletions systemd/krenew.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

# Run krenew as a systemd user unit
# Enable globally for all users
# systemctl --user --global enable krenew.service
# Enable as an individual user.
# systemctl --user enable krenew.service

[Unit]
Description=Renew Kerberos ticket
Documentation=man:krenew(1)
Before=dbus.service

[Service]
Type=simple
PIDFile=${XDG_RUNTIME_DIR}/krenew.pid
ExecStart=/usr/bin/krenew -K 30 -i -t -v -p ${XDG_RUNTIME_DIR}/krenew.pid

[Install]
WantedBy=default.target