Package: minissdpd
Version: 1.0-2
Severity: normal
Tags: patch
Hi,
When the pidfile (/var/run/minissdpd.pid) happens to already exist when
minissdpd starts, it complains, and fails to use it and write its pid to
it, even if no other instance is running:
debian:root ~ 102 # ps ax | grep minissdpd
17863 pts/4 S+ 0:00 grep minissdpd
debian:root ~ 103 # echo 12345 > /var/run/minissdpd.pid
debian:root ~ 104 # /etc/init.d/minissdpd start
Starting UPnP devices daemon: MiniSSDPd.
debian:root ~ 105 # ps ax | grep minissdpd
17888 ? Ss 0:00 minissdpd -i 0.0.0.0
17892 pts/4 S+ 0:00 grep minissdpd
debian:root ~ 106 # tail /var/log/syslog
[irrelevant (non-minissdpd) lines deleted]
Oct 6 11:52:28 debian minissdpd[17919]: Unable to open pidfile for writing
/var/run/minissdpd.pid: File exists
Oct 6 11:52:33 debian minissdpd[17919]: 27 new devices added
Oct 6 11:52:36 debian minissdpd[17919]: 1 new devices added
debian:root ~ 107 # cat /var/run/minissdpd.pid
12345
The problem is that minissdpd tries to create the file with O_EXCL.
(i.e. only if it does not exist)
I have attached a patch to solve this problem. Instead of using O_EXCL,
it opens/creates the file using O_TRUNC. This should be OK, as the pid
it contains is not valid anyway (as verified earlier).
Obviously, there still remains a race condition during startup.
A solution might be to only start after successfully acquiring a write lock
on the file as well.
I hereby allow this patch to be included in, and redistributed with, minidsspd
or any derived software using the same license that minissdpd 1.0-2 (as found
in debian on oct 6, 2011) uses.
If this is not sufficient, please ask, and I'll reformulate to something
acceptable.
Regards,
Rogier.
Patch:
----------------------------
diff -aur minissdpd-1.0/daemonize.c minissdpd-1.0-patch-pidfile/daemonize.c
--- minissdpd-1.0/daemonize.c 2008-01-29 14:07:09.000000000 +0100
+++ minissdpd-1.0-patch-pidfile/daemonize.c 2011-10-06 14:01:14.000000000
+0200
@@ -70,7 +70,7 @@
if(!fname || (strlen(fname) == 0))
return -1;
- if( (pidfile = open(fname, O_WRONLY|O_CREAT|O_EXCL, 0666)) < 0)
+ if( (pidfile = open(fname, O_WRONLY|O_CREAT|O_TRUNC, 0666)) < 0)
{
syslog(LOG_ERR, "Unable to open pidfile for writing %s: %m",
fname);
return -1;
----------------------------
-- System Information:
Debian Release: wheezy/sid
APT prefers stable-updates
APT policy: (500, 'stable-updates'), (500, 'testing')
Architecture: i386 (x86_64)
Kernel: Linux 2.6.38-2-amd64 (SMP w/1 CPU core)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages minissdpd depends on:
ii libc6 2.13-10 Embedded GNU C Library: Shared lib
minissdpd recommends no packages.
minissdpd suggests no packages.
-- no debconf information
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]