- Put the pid and log files into their own subdir (#648553)

This commit is contained in:
Hans de Goede 2010-11-19 12:23:31 +01:00
parent 3ec7519ac1
commit 33a1137fcf
2 changed files with 99 additions and 2 deletions

View File

@ -0,0 +1,91 @@
From 1fe607610ae2f7477d22784c8bf28453df25efbc Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Fri, 19 Nov 2010 11:52:47 +0100
Subject: [PATCH] Put the pid and log files into their own subdir
This makes it easier to write an selinux policy for spice-vdagent and allows
for adding extra logfiles / sockets in the future without needing a policy
change.
---
Makefile | 2 ++
spice-vdagentd.sh | 7 ++++---
vdagentd.c | 4 ++--
3 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/Makefile b/Makefile
index 0f3586e..3c5d8c9 100644
--- a/Makefile
+++ b/Makefile
@@ -7,6 +7,7 @@ initdir ?= /etc/rc.d/init.d
xdgautostartdir ?= /etc/xdg/autostart
gdmautostartdir ?= /usr/share/gdm/autostart/LoginWindow
socketdir ?= /var/run/spice-vdagentd
+logdir ?= /var/log/spice-vdagentd
CFLAGS ?= -O2 -g -Wall
CPPFLAGS = $(shell pkg-config --cflags spice-protocol)
@@ -21,6 +22,7 @@ install: build
install -d $(DESTDIR)$(bindir)
install -d $(DESTDIR)$(sbindir)
install -d $(DESTDIR)$(socketdir)
+ install -d $(DESTDIR)$(logdir)
install -p -m 755 spice-vdagent $(DESTDIR)$(bindir)
install -p -m 755 spice-vdagentd $(DESTDIR)$(sbindir)
install -d $(DESTDIR)$(initdir)
diff --git a/spice-vdagentd.sh b/spice-vdagentd.sh
index 119a61a..1ff2015 100644
--- a/spice-vdagentd.sh
+++ b/spice-vdagentd.sh
@@ -27,6 +27,7 @@
exec="/usr/sbin/spice-vdagentd"
prog="spice-vdagentd"
port="/dev/virtio-ports/com.redhat.spice.0"
+pid="/var/run/spice-vdagentd/spice-vdagentd.pid"
[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
@@ -38,7 +39,7 @@ start() {
# In case the previous running vdagentd crashed
rm -f /var/run/spice-vdagentd/spice-vdagent-sock
echo -n $"Starting $prog: "
- daemon $exec $SPICE_VDAGENTD_EXTRA_ARGS
+ daemon --pidfile $pid $exec $SPICE_VDAGENTD_EXTRA_ARGS
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
@@ -47,7 +48,7 @@ start() {
stop() {
echo -n $"Stopping $prog: "
- killproc $prog
+ killproc -p $pid $prog
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
@@ -69,7 +70,7 @@ force_reload() {
rh_status() {
# run checks to determine if the service is running or use generic status
- status $prog
+ status -p $pid $prog
}
rh_status_q() {
diff --git a/vdagentd.c b/vdagentd.c
index 47ec963..0215c78 100644
--- a/vdagentd.c
+++ b/vdagentd.c
@@ -45,8 +45,8 @@ struct agent_data {
};
/* variables */
-static const char *logfilename = "/var/log/spice-vdagentd.log";
-static const char *pidfilename = "/var/run/spice-vdagentd.pid";
+static const char *logfilename = "/var/log/spice-vdagentd/spice-vdagentd.log";
+static const char *pidfilename = "/var/run/spice-vdagentd/spice-vdagentd.pid";
static const char *portdev = "/dev/virtio-ports/com.redhat.spice.0";
static const char *uinput_device = "/dev/uinput";
static int debug = 0;
--
1.7.3.2

View File

@ -1,15 +1,16 @@
Name: spice-vdagent
Version: 0.6.3
Release: 2%{?dist}
Release: 3%{?dist}
Summary: Agent for Spice guests
Group: Applications/System
License: GPLv3+
URL: http://spice-space.org/
Source0: http://spice-space.org/download/releases/%{name}-%{version}.tar.bz2
# 3 small fixes from upstream git
# 4 small fixes from upstream git
Patch0: 0001-Install-spice-vdagentd-in-usr-sbin-not-sbin.patch
Patch1: 0002-Only-start-spice-vdagentd-in-runlevel-5.patch
Patch2: 0003-sysv-initscript-fix-lsb-header-multi-line-descriptio.patch
Patch3: 0004-Put-the-pid-and-log-files-into-their-own-subdir.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: dbus-devel spice-protocol libXrandr-devel libXfixes-devel
BuildRequires: desktop-file-utils
@ -37,6 +38,7 @@ Features:
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
%build
@ -73,6 +75,7 @@ fi
%{_initddir}/spice-vdagentd
%{_bindir}/spice-vdagent
%{_sbindir}/spice-vdagentd
%{_var}/log/spice-vdagentd
%{_var}/run/spice-vdagentd
%{_sysconfdir}/xdg/autostart/spice-vdagent.desktop
# For /usr/share/gdm/autostart/LoginWindow/spice-vdagent.desktop
@ -81,6 +84,9 @@ fi
%changelog
* Fri Nov 19 2010 Hans de Goede <hdegoede@redhat.com> 0.6.3-3
- Put the pid and log files into their own subdir (#648553)
* Mon Nov 8 2010 Hans de Goede <hdegoede@redhat.com> 0.6.3-2
- Fix broken multiline description in initscript lsb header (#648549)