Accepting request 79336 from Base:System

- Make klogd.service and syslog.service static files and let
  systemd include syslog.core within syslog.service, only the
  syslog.core will be generated depending on /etc/sysconfig/syslog
- Do not touch the files as long as syslog.service or klogd.service
  are active 

- Add generator script for better support with systemd

OBS-URL: https://build.opensuse.org/request/show/79336
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/syslogd?expand=0&rev=47
This commit is contained in:
Marcus Rückert 2011-08-19 13:28:18 +00:00 committed by Git OBS Bridge
commit 8a72430272
6 changed files with 428 additions and 4 deletions

39
klogd.service Normal file
View File

@ -0,0 +1,39 @@
# /lib/systemd/system/klogd.service
#
# This file is part of package klogd.
#
# Copyright (c) 2011 SuSE LINUX Products GmbH, Germany.
# Author: Werner Fink
# Please send feedback to http://www.suse.de/feedback
#
# Description:
#
# Used to start klogd, the System Kernel Logging Service
# if and only if the System Logger does not provide this
# its self. If the System Logger can do Kernel Logging
# Service this file should be masked by a symbolic link
# from /etc/systemd/system/klogd.service to /dev/null.
#
# If klogd.service is started then BindTo=syslog.service
# within unit section to make it disappear if syslogd dies.
#
[Unit]
Description=System Kernel Logging Service
Requisite=syslog.service
BindTo=syslog.service
After=syslog.service
RefuseManualStart=true
[Service]
Type=forking
StandardOutput=syslog
StandardError=syslog
PIDFile=/var/run/klogd.pid
Environment=KERNEL_LOGLEVEL=1
Environment=KLOGD_PARAMS=
EnvironmentFile=-/etc/sysconfig/syslog
ExecStart=/sbin/klogd -c $KERNEL_LOGLEVEL $KLOGD_PARAMS -x
[Install]
WantedBy=multi-user.target

View File

@ -64,9 +64,7 @@ case "$SYSLOG_DAEMON" in
params="$SYSLOG_NG_PARAMS"
ngsocks="/var/run/syslog-ng/additional-log-sockets.conf"
ngsocksdir="/var/run/syslog-ng"
if [ ! -d $ngsocksdir ]; then
mkdir -p $ngsocksdir
fi
mkdir -p -m 0755 $ngsocksdir
test -r "$config" && \
while read line; do
case $line in file*/proc/kmsg*)

326
syslog-service-generator Normal file
View File

@ -0,0 +1,326 @@
#!/bin/bash
#
# /lib/systemd/system-generator/syslog-service-generator
#
# Copyright (c) 2011 SuSE LINUX Products GmbH, Germany.
#
# Description:
#
# Write out syslog.core and if required enable klogd.service
# depending on the configuration found in /etc/sysconfig/syslog.
# Also check if network target is required with this we do not
# required the earlysyslog hack anymore.
# Based on the /etc/init.d/syslog SysV init boot script as well
# as on the /etc/init.d/earlysyslog wrapper script.
#
# Author: Werner Fink
# Please send feedback to http://www.suse.de/feedback
#
umask 0022
: ${SBINDIR:=/sbin}
: ${RUN_PATH:=/run/systemd}
: ${SYSUNITDIR:=/lib/systemd/system}
: ${SYSCONFDIR:=/etc/systemd/system}
if test -s /etc/sysconfig/syslog ; then
CORE=$RUN_PATH/syslog.core
test -s $CORE -a $CORE -nt /etc/sysconfig/syslog && exit 0
. /etc/sysconfig/syslog
else
SYSLOG_DAEMON=rsyslogd
fi
#
# Danger Robinson: do not touch anything if a System logger
# is running under the control of systemd its self!
#
if test -d /sys/fs/cgroup/systemd/system/syslog.service -o \
-d /sys/fs/cgroup/systemd/system/klogd.service
then
/bin/logger -i -p daemon.warn -t ${0##*/} \
'Stop syslog.service before reloading the daemons!'
exit 1
fi
#
# Update $SYSLOG_DAEMON if not up-to-date
#
if test -z "$SYSLOG_DAEMON" -o ! -x "$SBINDIR/$SYSLOG_DAEMON" ; then
for SYSLOG_DAEMON in rsyslogd syslog-ng syslogd ; do
test -x "$SBINDIR/$SYSLOG_DAEMON" && break
done
fi
#
# Default is no network and start klogd
#
network=
start_klogd=yes
klogd=klogd.service
#
# Now check for the three possible system loggers for required
# network connection and for external klogd. Note that /var/run
# does not exist at boot time, therefore files and directories
# will be created below the /run tmpfs.
#
case "$SYSLOG_DAEMON" in
syslog-ng)
syslog=syslog-ng
config=/etc/syslog-ng/syslog-ng.conf
socksdir=/var/run/syslog-ng
socks=$socksdir/additional-log-sockets.conf
if test -s "$config" ; then
while read line ; do
case "$line" in
\#*|"") continue ;;
*udp\ *|*udp\(*) network=network.target ;;
*tcp\ *|*tcp\(*) network=network.target ;;
esac
done < ${config}
fi
/bin/mkdir -p -m 0755 ${socksdir#/var}
/bin/touch -m 0600 ${socks#/var}
params="$SYSLOG_NG_PARAMS"
;;
rsyslogd)
syslog=rsyslogd
config=/etc/rsyslog.early.conf
socksdir=/var/run/rsyslog
socks=$socksdir/additional-log-sockets.conf
#
# In hope this works with the rsyslog.early.conf file
# (hard to implement for rsyslog with its includes/if
# statements)...
#
if test -s "$config" ; then
while read select action ; do
case "$select" in
\#*|"")
continue
esac
case "$action" in
*@*)
network=network.target
break
esac
done < ${config}
test -n "$network" && config=/etc/rsyslog.conf
else
config=/etc/rsyslog.conf
fi
if test -r "$config" ; then
while read one two rest ; do
if test "$one" = '$ModLoad' -a "$two" = 'imklog.so' ; then
start_klogd=no
break
fi
done < $config
fi
/bin/mkdir -p -m 0755 ${socksdir#/var}
/bin/touch -m 0600 ${socks#/var}
compat=${RSYSLOGD_COMPAT_VERSION:-${RSYSLOGD_NATIVE_VERSION}}
params="-c ${compat:-3} -f $config $RSYSLOGD_PARAMS"
;;
*)
syslog=syslogd
config=/etc/syslog.conf
socksdir=/var/run/syslog
socks=$socksdir/additional-log-sockets.env
if test -s "$config" ; then
while read select action ; do
case "$select" in \#*|"") continue ;; esac
case "$action" in *@*) network=network.target ;; esac
done < ${config}
fi
if test -r "$config" ; then
while read line; do
case $line in
file*/proc/kmsg*)
start_klogd=no
break
esac
done < $config
fi
/bin/mkdir -p -m 0755 ${socksdir#/var}
/bin/touch -m 0600 ${socks#/var}
params="$SYSLOGD_PARAMS"
esac
syslog_bin=${SBINDIR}/$syslog
klog_bin=${SBINDIR}/klogd
test -s ${config} || exit 1
test -x ${syslog_bin} || exit 1
#
# Make sure that we have a log fifo which is used by X11
#
if test -e /dev/xconsole -a ! -p /dev/xconsole ; then
/bin/rm -f /dev/xconsole
fi
if test ! -e /dev/xconsole ; then
/bin/mknod -m 0600 /dev/xconsole p
/bin/chown root:tty /dev/xconsole
fi
#
# No klogd.service required
#
test "$start_klogd" = no && klogd=
#
# Create a temporary file for syslog.core
#
trap 'rm -f "$service"' EXIT
tmpcore=$(/bin/mktemp $RUN_PATH/syslog.XXXXXXXX) || exit 1
(/bin/cat > $tmpcore)<<-EOF
# Warning: Do not edit as this file has been and will be autogenerated
# by $0
${network:+Requires=$network}
${network:+After=$network}
${klogd:+Requires=$klogd}
${klogd:+Before=$klogd}
[Service]
Type=forking
PIDFile=/var/run/${syslog_bin##*/}.pid
Sockets=syslog.socket
StandardOutput=null
ExecStartPre=/bin/systemctl stop systemd-kmsg-syslogd.service
ExecStartPre=-$socksdir/addsockets
EOF
#
# For additional sockets we use further configuration files
# for rsyslogd and syslog-ng but an envrionment file for syslogd
#
case "$SYSLOG_DAEMON" in
rsyslogd)
(/bin/cat > ${socksdir#/var}/addsockets)<<-EOF
#!/bin/sh
# Warning: Do not edit as this file has been and will be
# autogenerated by $0
test -s /etc/sysconfig/syslog && . /etc/sysconfig/syslog
umask 0022
> $socks
for variable in \${!SYSLOGD_ADDITIONAL_SOCKET*}; do
eval value=\\\$\$variable
test -z "\$value" && continue
test ! -d \${value%/*} && continue
echo "\\\$AddUnixListenSocket \$value"
done >> $socks
EOF
;;
syslog-ng)
(/bin/cat > ${socksdir#/var}/addsockets)<<-EOF
#!/bin/sh
# Warning: Do not edit as this file has been and will be
# autogenerated by $0
test -s /etc/sysconfig/syslog && . /etc/sysconfig/syslog
umask 0022
echo 'source chroots {' > $socks
for variable in \${!SYSLOGD_ADDITIONAL_SOCKET*}; do
eval value=\\\$\$variable
test -z "\$value" && continue
test ! -d \${value%/*} && continue
echo "unix-dgram(\\"\$value\\");"
done >> $socks
echo '};' >> $socks
EOF
;;
*)
(/bin/cat > ${socksdir#/var}/addsockets)<<-EOF
#!/bin/sh
# Warning: Do not edit as this file has been and will be
# autogenerated by $0
test -s /etc/sysconfig/syslog && . /etc/sysconfig/syslog
umask 0022
echo -n 'ADDITIONAL_SOCKET="' > $socks
for variable in \${!SYSLOGD_ADDITIONAL_SOCKET*}; do
eval value=\\\$\$variable
test -z "\$value" && continue
test ! -d \${value%/*} && continue
echo -n "-a \$value "
done >> $socks
echo -n '"' >> $socks
EOF
echo "Environment=ADDITIONAL_SOCKET=" >>$tmpcore
echo "EnvironmentFile=-$socks" 1>>$tmpcore
params="${params:+$params }\$ADDITIONAL_SOCKET"
esac
chmod u+x ${socksdir#/var}/addsockets
#
# If klogd.service is required handle reload of syslog.service efficient
# otherwise we may loose kernel messages or klogd is forwarding kernel
# messages back to systemd as the creator of the system logging socket
# and we would get a message loop.
#
exec 3>&1 1>>$tmpcore
echo "ExecStart=$syslog_bin $params"
if test "$start_klogd" != no ; then
echo "ExecReload=/bin/systemctl kill --signal=TSTP klogd.service"
fi
echo "ExecReload=/sbin/killproc -p /var/run/${syslog_bin##*/}.pid -HUP $syslog_bin"
if test "$start_klogd" != no ; then
echo "ExecReload=/bin/systemctl kill --signal=CONT klogd.service"
echo "ExecReload=/bin/systemctl kill --signal=USR2 klogd.service"
fi
echo
exec 1>&3 3>&-
#
# If klogd.service is required, remove symbolic link for masking out
# otherwise just add the symbolic link
#
klogserv=$SYSCONFDIR/klogd.service
if test "$start_klogd" != no -a -x ${klog_bin} ; then
test -h $klogserv && rm -f $klogserv
else
/bin/ln -sf /dev/null $klogserv
fi
#
# Now enable the service(s) for multi-user target
#
/bin/mv $tmpcore $CORE
if test ! -d $SYSCONFDIR/multi-user.target.wants/ ; then
/bin/mkdir -p $SYSCONFDIR/multi-user.target.wants
fi
syslogserv=$SYSUNITDIR/syslog.service
enableserv=$SYSCONFDIR/multi-user.target.wants/syslog.service
if test ! -h $enableserv ; then
/bin/rm -f $enableserv
/bin/ln -sf $syslogserv $enableserv
fi
klogserv=$SYSUNITDIR/klogd.service
enableserv=$SYSCONFDIR/multi-user.target.wants/klogd.service
disablserv=$SYSCONFDIR/klogd.service
if test "$start_klogd" != no -a -x ${klog_bin} ; then
if test ! -h $enableserv ; then
/bin/rm -f $enableserv
/bin/ln -sf $klogserv $enableserv
fi
else
if test ! -h $disablserv ; then
/bin/rm -f $disablserv
/bin/ln -sf /dev/null $disablserv
fi
fi
#
# Last but not least remove the old (early) service links from SystemV init
#
for service in /etc/init.d/*.d/*syslog ; do
test -h $service || continue
/bin/rm -f $service
done
#
# end of /lib/systemd/system-generator/syslog-service-generator

30
syslog.service Normal file
View File

@ -0,0 +1,30 @@
# /lib/systemd/system/syslog.service
#
# This file is part of package klogd.
#
# Copyright (c) 2011 SuSE LINUX Products GmbH, Germany.
# Author: Werner Fink
# Please send feedback to http://www.suse.de/feedback
#
# Description:
#
# Used to start one of the System Logging Service daemons
# depending on the configuration found in /etc/sysconfig/syslog.
#
[Unit]
Description=System Logging Service
Requires=var-run.mount syslog.target
After=var-run.mount
Before=syslog.target
OnFailure=systemd-kmsg-syslogd.service
#
# Now systemd include the further dependency rules and
# Service section. This include will be automatically
# updated depending on the configuration.
#
.include /run/systemd/syslog.core
[Install]
WantedBy=multi-user.target

View File

@ -1,3 +1,17 @@
-------------------------------------------------------------------
Fri Aug 19 12:32:29 UTC 2011 - werner@suse.de
- Make klogd.service and syslog.service static files and let
systemd include syslog.core within syslog.service, only the
syslog.core will be generated depending on /etc/sysconfig/syslog
- Do not touch the files as long as syslog.service or klogd.service
are active
-------------------------------------------------------------------
Wed Aug 17 15:45:58 UTC 2011 - werner@suse.de
- Add generator script for better support with systemd
-------------------------------------------------------------------
Tue Jun 28 08:51:31 UTC 2011 - aj@suse.de

View File

@ -23,6 +23,7 @@ Name: syslogd
%define omc_svcdir %{omc_prefix}/svcinfo.d
License: GPLv2+
Group: System/Daemons
BuildRequires: pkg-config systemd-devel
PreReq: coreutils %fillup_prereq klogd sed
Provides: syslog
AutoReqProv: on
@ -36,6 +37,9 @@ Source3: rc.syslog
Source4: rc.earlysyslog
Source5: syslog.xml
Source6: syslog.8
Source7: syslog-service-generator
Source8: klogd.service
Source9: syslog.service
Patch0: sysklogd-1.4.1.dif
Patch1: sysklogd-1.4.1-dgram.patch
Patch2: sysklogd-1.4.1-sparc.patch
@ -63,6 +67,8 @@ Patch23: sysklogd-1.4.1-reload.dif
Patch24: sysklogd-1.4.1-systemd.dif
Patch25: sysklogd-1.4.1-systemd-multi.dif
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%{expand: %%global sysdsysunitdir %(pkg-config systemd --variable=systemdsystemunitdir)}
%{expand: %%global sysdsysconfdir %(pkg-config systemd --variable=systemdsystemconfdir)}
%description
The syslogd daemon is the general system logging daemon, which is
@ -147,7 +153,10 @@ mv sample-s390.conf sample.conf
mkdir -p $RPM_BUILD_ROOT/etc/logrotate.d
mkdir -p $RPM_BUILD_ROOT/%{_mandir}/man{5,8}
mkdir -p $RPM_BUILD_ROOT/var/adm/fillup-templates
mkdir -p $RPM_BUILD_ROOT%{sysdsysunitdir}-generators
mkdir -p $RPM_BUILD_ROOT%{sysdsysunitdir}
mkdir -p -m 0755 $RPM_BUILD_ROOT/var/run/rsyslog
mkdir -p -m 0755 $RPM_BUILD_ROOT/var/run/syslog-ng
make install MANDIR=%{_mandir} DESTDIR=$RPM_BUILD_ROOT
ln -sf ../etc/init.d/syslog $RPM_BUILD_ROOT/sbin/rcsyslog
install -m 644 %{SOURCE1} $RPM_BUILD_ROOT/etc/logrotate.d/syslog
@ -157,6 +166,9 @@ mv sample-s390.conf sample.conf
install -d $RPM_BUILD_ROOT/%{omc_svcdir}/
install -m 600 %{SOURCE5} $RPM_BUILD_ROOT/%{omc_svcdir}/
install -m 644 %{SOURCE6} $RPM_BUILD_ROOT/%{_mandir}/man8/syslog.8
install -m 755 %{SOURCE7} $RPM_BUILD_ROOT%{sysdsysunitdir}-generators/
install -m 644 %{SOURCE8} $RPM_BUILD_ROOT%{sysdsysunitdir}/
install -m 644 %{SOURCE9} $RPM_BUILD_ROOT%{sysdsysunitdir}/
%ifarch s390 s390x
sed 's/^KERNEL_LOGLEVEL=1/KERNEL_LOGLEVEL=7/' %{SOURCE2} \
> $RPM_BUILD_ROOT/var/adm/fillup-templates/sysconfig.syslog
@ -203,6 +215,7 @@ chown news:news var/log/news/news.err
touch var/log/news/news.notice; chmod 640 var/log/news/news.notice
chown news:news var/log/news/news.notice
mkdir -p -m 0755 /var/run/rsyslog
mkdir -p -m 0755 /var/run/syslog-ng
%preun
%stop_on_removal syslog
@ -239,12 +252,16 @@ fi
%config(noreplace) /etc/logrotate.d/syslog
%config /etc/init.d/syslog
%config /etc/init.d/earlysyslog
%config %{sysdsysunitdir}/klogd.service
%config %{sysdsysunitdir}/syslog.service
%doc %{_mandir}/man8/klogd.8.gz
%doc %{_mandir}/man8/sysklogd.8.gz
%doc %{_mandir}/man8/syslog.8.gz
/sbin/rcsyslog
/sbin/klogd
/sbin/rcsyslog
%attr(0744,root,root) %{sysdsysunitdir}-generators/syslog-service-generator
%attr(0755,root,root) %dir %ghost /var/run/rsyslog/
%attr(0755,root,root) %dir %ghost /var/run/syslog-ng/
%{omc_svcdir}/syslog.xml
%changelog