[mcstrans] Write pid file
Daniel J Walsh
dwalsh at fedoraproject.org
Wed Feb 1 21:04:05 UTC 2012
commit 92e33b0c5b2614637cba73c8591136371edc1a9f
Author: Dan Walsh <dwalsh at redhat.com>
Date: Wed Feb 1 16:04:02 2012 -0500
Write pid file
mcstrans-0.1.8-subsys-locking.patch | 29 ---------------
mcstrans-0.3.1-init.patch | 65 -----------------------------------
mcstrans-0.3.1-man.patch | 29 ---------------
mcstrans-0.3.2-writepid.patch | 43 +++++++++++++++++++++++
mcstrans.spec | 7 +++-
5 files changed, 49 insertions(+), 124 deletions(-)
---
diff --git a/mcstrans-0.3.2-writepid.patch b/mcstrans-0.3.2-writepid.patch
new file mode 100644
index 0000000..8c54d1e
--- /dev/null
+++ b/mcstrans-0.3.2-writepid.patch
@@ -0,0 +1,43 @@
+diff -up mcstrans-0.3.2/src/mcstransd.c.writepid mcstrans-0.3.2/src/mcstransd.c
+--- mcstrans-0.3.2/src/mcstransd.c.writepid 2011-01-05 10:32:25.000000000 -0500
++++ mcstrans-0.3.2/src/mcstransd.c 2012-02-01 16:02:46.670139198 -0500
+@@ -556,6 +556,30 @@ void dropprivs(void)
+ cap_free(new_caps);
+ }
+
++static const char *pidfile = "/var/run/mcstransd.pid";
++
++static int write_pid_file(void)
++{
++ int pidfd, len;
++ char val[16];
++
++ len = snprintf(val, sizeof(val), "%u\n", getpid());
++ if (len < 0) {
++ syslog(LOG_ERR, "Pid error (%s)", strerror(errno));
++ pidfile = 0;
++ return 1;
++ }
++ pidfd = open(pidfile, O_CREAT | O_TRUNC | O_NOFOLLOW | O_WRONLY, 0644);
++ if (pidfd < 0) {
++ syslog(LOG_ERR, "Unable to set pidfile (%s)", strerror(errno));
++ pidfile = 0;
++ return 1;
++ }
++ (void)write(pidfd, val, (unsigned int)len);
++ close(pidfd);
++ return 0;
++}
++
+ int
+ main(int UNUSED(argc), char *argv[])
+ {
+@@ -582,6 +606,8 @@ main(int UNUSED(argc), char *argv[])
+ }
+ #endif
+
++ write_pid_file();
++
+ syslog(LOG_NOTICE, "%s initialized", argv[0]);
+ process_connections();
+
diff --git a/mcstrans.spec b/mcstrans.spec
index d493177..8af01b1 100644
--- a/mcstrans.spec
+++ b/mcstrans.spec
@@ -1,10 +1,11 @@
Summary: SELinux Translation Daemon
Name: mcstrans
Version: 0.3.2
-Release: 2%{?dist}
+Release: 3%{?dist}
License: GPL+
Group: System Environment/Daemons
Source: http://fedora.redhat.com/projects/%{name}-%{version}.tgz
+Patch: mcstrans-0.3.2-writepid.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: libselinux-devel >= 1.30.3-1
BuildRequires: libcap-devel pcre-devel libsepol-devel libsepol-static
@@ -31,6 +32,7 @@ from internal representations to user defined representation.
%prep
%setup -q
+%patch -p1 -b .writepid
%build
make clean
@@ -88,6 +90,9 @@ fi
%{_usr}/share/mcstrans/util/*
%changelog
+* Wed Feb 1 2012 Dan Walsh <dwalsh at redhat.com> - 0.3.2-3
+- Write pid file
+
* Fri Jan 13 2012 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 0.3.2-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild
More information about the scm-commits
mailing list