From 5c58719d6f18c8b693061d46b4496e4fadd53812 Mon Sep 17 00:00:00 2001 From: Dan Walsh Date: Wed, 1 Feb 2012 17:05:02 -0500 Subject: [PATCH] Update to upstream - Write pid file --- master/mcstrans-0.3.2-writepid.patch | 51 ++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 master/mcstrans-0.3.2-writepid.patch diff --git a/master/mcstrans-0.3.2-writepid.patch b/master/mcstrans-0.3.2-writepid.patch new file mode 100644 index 0000000..927782a --- /dev/null +++ b/master/mcstrans-0.3.2-writepid.patch @@ -0,0 +1,51 @@ +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:14:02.085806490 -0500 +@@ -4,6 +4,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -556,6 +557,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 +607,8 @@ main(int UNUSED(argc), char *argv[]) + } + #endif + ++ write_pid_file(); ++ + syslog(LOG_NOTICE, "%s initialized", argv[0]); + process_connections(); +