Write pid file
This commit is contained in:
parent
a88be20832
commit
92e33b0c5b
@ -1,29 +0,0 @@
|
||||
--- mcstrans-0.1.8/src/mcstrans.init.subsys-locking 2006-09-13 11:21:11.000000000 -0400
|
||||
+++ mcstrans-0.1.8/src/mcstrans.init 2006-09-13 11:29:18.000000000 -0400
|
||||
@@ -48,7 +48,7 @@
|
||||
RETVAL=$?
|
||||
echo
|
||||
if test $RETVAL = 0 ; then
|
||||
- touch /var/lock/subsys/$prog
|
||||
+ touch /var/lock/subsys/mcstrans
|
||||
fi
|
||||
return $RETVAL
|
||||
}
|
||||
@@ -58,7 +58,7 @@
|
||||
killproc $prog
|
||||
RETVAL=$?
|
||||
echo
|
||||
- rm -f /var/lock/subsys/$prog
|
||||
+ rm -f /var/lock/subsys/mcstrans
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@
|
||||
}
|
||||
|
||||
condrestart(){
|
||||
- [ -e /var/lock/subsys/$prog ] && restart
|
||||
+ [ -e /var/lock/subsys/mcstrans ] && restart
|
||||
return 0
|
||||
}
|
||||
|
@ -1,65 +0,0 @@
|
||||
--- mcstrans-0.3.1/src/mcstrans.init~ 2009-09-16 11:01:17.646738932 +0200
|
||||
+++ mcstrans-0.3.1/src/mcstrans.init 2009-09-16 11:23:47.605763983 +0200
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
PATH=/sbin:/bin:/usr/bin:/usr/sbin
|
||||
prog="mcstransd"
|
||||
+lockfile=/var/lock/subsys/$prog
|
||||
|
||||
# Source function library.
|
||||
. /etc/init.d/functions
|
||||
@@ -54,7 +55,7 @@
|
||||
RETVAL=$?
|
||||
echo
|
||||
if test $RETVAL = 0 ; then
|
||||
- touch /var/lock/subsys/mcstrans
|
||||
+ touch $lockfile
|
||||
fi
|
||||
return $RETVAL
|
||||
}
|
||||
@@ -64,15 +65,7 @@
|
||||
killproc $prog
|
||||
RETVAL=$?
|
||||
echo
|
||||
- rm -f /var/lock/subsys/mcstrans
|
||||
- return $RETVAL
|
||||
-}
|
||||
-
|
||||
-reload(){
|
||||
- echo -n $"Reloading configuration: "
|
||||
- killproc $prog -HUP
|
||||
- RETVAL=$?
|
||||
- echo
|
||||
+ rm -f $lockfile
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
@@ -82,7 +75,7 @@
|
||||
}
|
||||
|
||||
condrestart(){
|
||||
- [ -e /var/lock/subsys/mcstrans ] && restart
|
||||
+ [ -e $lockfile ] && restart
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -95,17 +88,14 @@
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
- restart)
|
||||
+ restart|force-reload)
|
||||
restart
|
||||
;;
|
||||
- reload)
|
||||
- reload
|
||||
- ;;
|
||||
condrestart)
|
||||
condrestart
|
||||
;;
|
||||
*)
|
||||
- echo $"Usage: $0 {start|stop|status|restart|condrestart|reload|rotate}"
|
||||
+ echo $"Usage: $0 {start|stop|status|restart|force-reload|condrestart}"
|
||||
RETVAL=3
|
||||
esac
|
||||
|
@ -1,29 +0,0 @@
|
||||
diff -up mcstrans-0.3.1/man/man8/mcstransd.8.man mcstrans-0.3.1/man/man8/mcstransd.8
|
||||
--- mcstrans-0.3.1/man/man8/mcstransd.8.man 2009-10-16 09:50:45.000000000 -0400
|
||||
+++ mcstrans-0.3.1/man/man8/mcstransd.8 2009-10-16 09:48:28.000000000 -0400
|
||||
@@ -0,0 +1,25 @@
|
||||
+.TH "mcstransd" "8" "16 Oct 2009" "dwalsh@redhat.com" "mcs documentation"
|
||||
+.SH "NAME"
|
||||
+mcstransd \- MCS (Multiple Category System) daemon. Translates SELinux MCS/MLS labels to human readable form.
|
||||
+
|
||||
+.SH "SYNOPSIS"
|
||||
+.B mcstransd
|
||||
+.P
|
||||
+
|
||||
+.SH "DESCRIPTION"
|
||||
+This manual page describes the
|
||||
+.BR mcstransd
|
||||
+program.
|
||||
+.P
|
||||
+This daemon reads /etc/selinux/{SELINUXTYPE}/setrans.conf configuration file, and communicates with libselinux via a socket in /var/run/setrans.
|
||||
+
|
||||
+.SH "AUTHOR"
|
||||
+This man page was written by Dan Walsh <dwalsh@redhat.com>.
|
||||
+The program was originally written by Dan Walsh <dwalsh@redhat.com>.
|
||||
+The program was enhanced/rwwritten by Joe Nall <joe@nall.com>.
|
||||
+
|
||||
+.SH "FILES"
|
||||
+/etc/selinux/{SELINUXTYPE}/setrans.conf
|
||||
+
|
||||
+.SH "SEE ALSO"
|
||||
+.BR mcs (8),
|
43
mcstrans-0.3.2-writepid.patch
Normal file
43
mcstrans-0.3.2-writepid.patch
Normal file
@ -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();
|
||||
|
@ -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@redhat.com> - 0.3.2-3
|
||||
- Write pid file
|
||||
|
||||
* Fri Jan 13 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.3.2-2
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user