Package: minissdpd
Version: 1.0-2
Severity: normal
Tags: patch

Hi,

When minissdpd fails to start, its exit value is not returned to its parent
process. One effect is that the init script will not report the failure:

debian:root ~ 109 # ls /var/run/minissdpd.sock
/var/run/minissdpd.sock
debian:root ~ 110 # /etc/init.d/minissdpd start
Starting UPnP devices daemon: MiniSSDPd.
debian:root ~ 111 # tail /var/log/syslog
[irrelevant (non-minissdpd) lines deleted]
Oct  6 11:55:33 debian minissdpd[17950]: Unable to open pidfile for writing 
/var/run/minissdpd.pid: File exists
Oct  6 11:55:33 debian minissdpd[17950]: bind(unixsocket, 
"/var/run/minissdpd.sock"): Address already in use
Oct  6 11:55:33 debian minissdpd[17950]: Cannot open unix socket for 
communicating with clients. Exiting
debian:root ~ 112 # ps ax | grep minissdpd
17958 pts/4    S+     0:00 grep minissdpd

As can be seen, the output of the init script suggests that minissdpd
was started correctly (no mention of any failure), even though it wasn't.

The problem is that minissdpd becomes a deamon before initialisation
completes, so the link with the starting process is broken, and any exit
code is lost.

I have attached a patch to solve the problem. It only daemonizes *after*'
initialisation was successful.

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/minissdpd.c minissdpd-1.0-patch-initstatus/minissdpd.c
--- minissdpd-1.0/minissdpd.c   2008-10-07 14:42:07.000000000 +0200
+++ minissdpd-1.0-patch-initstatus/minissdpd.c  2011-10-06 13:56:13.000000000 
+0200
@@ -667,18 +667,6 @@
                return 1;
        }
 
-       /* daemonize or in any case get pid ! */
-       if(debug_flag)
-               pid = getpid();
-       else {
-#ifdef USE_DAEMON
-               if(daemon(0, 0) < 0)
-                       perror("daemon()");
-               pid = getpid();
-#else
-               pid = daemonize();
-#endif
-       }
        /* open log */
        openlog("minissdpd",
                LOG_CONS|LOG_PID|(debug_flag?LOG_PERROR:0),
@@ -692,8 +680,6 @@
                return 1;
        }
 
-       writepidfile(pidfilename, pid);
-
        /* set signal handlers */
        memset(&sa, 0, sizeof(struct sigaction));
        sa.sa_handler = sigterm;
@@ -720,6 +706,21 @@
                return 1;
        }
 
+       /* daemonize or in any case get pid ! */
+       if(debug_flag)
+               pid = getpid();
+       else {
+#ifdef USE_DAEMON
+               if(daemon(0, 0) < 0)
+                       perror("daemon()");
+               pid = getpid();
+#else
+               pid = daemonize();
+#endif
+       }
+
+       writepidfile(pidfilename, pid);
+
        /* Main loop */
        while(!quitting)
        {
----------------------------


-- 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 debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to