parent
39ff47ad79
commit
4a1b41c1cb
|
@ -1,4 +1,7 @@
|
||||||
$Id: Changelog.txt,v 1.50 2019/02/10 13:45:24 nanard Exp $
|
$Id: Changelog.txt,v 1.51 2020/06/06 19:53:10 nanard Exp $
|
||||||
|
|
||||||
|
2020/06/06:
|
||||||
|
define NO_BACKGROUND_NO_PIDFILE for a systemd friendly mode
|
||||||
|
|
||||||
2018/12/18:
|
2018/12/18:
|
||||||
updateDevice() remove element from the list when realloc fails
|
updateDevice() remove element from the list when realloc fails
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* $Id: config.h,v 1.10 2018/02/23 13:58:14 nanard Exp $ */
|
/* $Id: config.h,v 1.11 2020/06/06 19:53:10 nanard Exp $ */
|
||||||
/* MiniUPnP project
|
/* MiniUPnP project
|
||||||
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
* http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
|
||||||
* (c) 2006-2018 Thomas Bernard
|
* (c) 2006-2020 Thomas Bernard
|
||||||
* This software is subject to the conditions detailed
|
* This software is subject to the conditions detailed
|
||||||
* in the LICENCE file provided within the distribution */
|
* in the LICENCE file provided within the distribution */
|
||||||
#ifndef CONFIG_H_INCLUDED
|
#ifndef CONFIG_H_INCLUDED
|
||||||
|
@ -30,4 +30,8 @@
|
||||||
* and unicasted, we cannot bind to 239.255.255.250 neither */
|
* and unicasted, we cannot bind to 239.255.255.250 neither */
|
||||||
/*#define SSDP_LISTEN_ON_SPECIFIC_ADDR*/
|
/*#define SSDP_LISTEN_ON_SPECIFIC_ADDR*/
|
||||||
|
|
||||||
|
/* When NO_BACKGROUND_NO_PIDFILE is defined, minissdpd does not go to
|
||||||
|
* background and does not create any pidfile */
|
||||||
|
/*#define NO_BACKGROUND_NO_PIDFILE*/
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* $Id: minissdpd.c,v 1.53 2016/03/01 18:06:46 nanard Exp $ */
|
/* $Id: minissdpd.c,v 1.57 2020/06/06 19:53:10 nanard Exp $ */
|
||||||
/* vim: tabstop=4 shiftwidth=4 noexpandtab
|
/* vim: tabstop=4 shiftwidth=4 noexpandtab
|
||||||
* MiniUPnP project
|
* MiniUPnP project
|
||||||
* (c) 2007-2018 Thomas Bernard
|
* (c) 2007-2020 Thomas Bernard
|
||||||
* website : http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
|
* website : http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
|
||||||
* This software is subject to the conditions detailed
|
* This software is subject to the conditions detailed
|
||||||
* in the LICENCE file provided within the distribution */
|
* in the LICENCE file provided within the distribution */
|
||||||
|
@ -1224,7 +1224,9 @@ static void ssdpDiscover(int s, int ipv6, const char * search)
|
||||||
int main(int argc, char * * argv)
|
int main(int argc, char * * argv)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
#ifndef NO_BACKGROUND_NO_PIDFILE
|
||||||
int pid;
|
int pid;
|
||||||
|
#endif
|
||||||
struct sigaction sa;
|
struct sigaction sa;
|
||||||
char buf[1500];
|
char buf[1500];
|
||||||
ssize_t n;
|
ssize_t n;
|
||||||
|
@ -1245,7 +1247,9 @@ int main(int argc, char * * argv)
|
||||||
struct lan_addr_s * lan_addr;
|
struct lan_addr_s * lan_addr;
|
||||||
int i;
|
int i;
|
||||||
const char * sockpath = "/var/run/minissdpd.sock";
|
const char * sockpath = "/var/run/minissdpd.sock";
|
||||||
|
#ifndef NO_BACKGROUND_NO_PIDFILE
|
||||||
const char * pidfilename = "/var/run/minissdpd.pid";
|
const char * pidfilename = "/var/run/minissdpd.pid";
|
||||||
|
#endif
|
||||||
int debug_flag = 0;
|
int debug_flag = 0;
|
||||||
#ifdef ENABLE_IPV6
|
#ifdef ENABLE_IPV6
|
||||||
int ipv6 = 0;
|
int ipv6 = 0;
|
||||||
|
@ -1291,8 +1295,10 @@ int main(int argc, char * * argv)
|
||||||
}
|
}
|
||||||
} else if(0==strcmp(argv[i], "-s"))
|
} else if(0==strcmp(argv[i], "-s"))
|
||||||
sockpath = argv[++i];
|
sockpath = argv[++i];
|
||||||
|
#ifndef NO_BACKGROUND_NO_PIDFILE
|
||||||
else if(0==strcmp(argv[i], "-p"))
|
else if(0==strcmp(argv[i], "-p"))
|
||||||
pidfilename = argv[++i];
|
pidfilename = argv[++i];
|
||||||
|
#endif
|
||||||
else if(0==strcmp(argv[i], "-t"))
|
else if(0==strcmp(argv[i], "-t"))
|
||||||
ttl = (unsigned char)atoi(argv[++i]);
|
ttl = (unsigned char)atoi(argv[++i]);
|
||||||
else if(0==strcmp(argv[i], "-f"))
|
else if(0==strcmp(argv[i], "-f"))
|
||||||
|
@ -1308,7 +1314,11 @@ int main(int argc, char * * argv)
|
||||||
#ifdef ENABLE_IPV6
|
#ifdef ENABLE_IPV6
|
||||||
"[-6] "
|
"[-6] "
|
||||||
#endif /* ENABLE_IPV6 */
|
#endif /* ENABLE_IPV6 */
|
||||||
"[-s socket] [-p pidfile] [-t TTL] "
|
"[-s socket] "
|
||||||
|
#ifndef NO_BACKGROUND_NO_PIDFILE
|
||||||
|
"[-p pidfile] "
|
||||||
|
#endif
|
||||||
|
"[-t TTL] "
|
||||||
"[-f device] "
|
"[-f device] "
|
||||||
"-i <interface> [-i <interface2>] ...\n",
|
"-i <interface> [-i <interface2>] ...\n",
|
||||||
argv[0]);
|
argv[0]);
|
||||||
|
@ -1317,8 +1327,13 @@ int main(int argc, char * * argv)
|
||||||
" 192.168.1.42/255.255.255.0, or an interface name such as eth0.\n");
|
" 192.168.1.42/255.255.255.0, or an interface name such as eth0.\n");
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"\n By default, socket will be open as %s\n"
|
"\n By default, socket will be open as %s\n"
|
||||||
|
#ifndef NO_BACKGROUND_NO_PIDFILE
|
||||||
" and pid written to file %s\n",
|
" and pid written to file %s\n",
|
||||||
sockpath, pidfilename);
|
sockpath, pidfilename
|
||||||
|
#else
|
||||||
|
,sockpath
|
||||||
|
#endif
|
||||||
|
);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1329,11 +1344,13 @@ int main(int argc, char * * argv)
|
||||||
if(!debug_flag) /* speed things up and ignore LOG_INFO and LOG_DEBUG */
|
if(!debug_flag) /* speed things up and ignore LOG_INFO and LOG_DEBUG */
|
||||||
setlogmask(LOG_UPTO(LOG_NOTICE));
|
setlogmask(LOG_UPTO(LOG_NOTICE));
|
||||||
|
|
||||||
|
#ifndef NO_BACKGROUND_NO_PIDFILE
|
||||||
if(checkforrunning(pidfilename) < 0)
|
if(checkforrunning(pidfilename) < 0)
|
||||||
{
|
{
|
||||||
syslog(LOG_ERR, "MiniSSDPd is already running. EXITING");
|
syslog(LOG_ERR, "MiniSSDPd is already running. EXITING");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
upnp_bootid = (unsigned int)time(NULL);
|
upnp_bootid = (unsigned int)time(NULL);
|
||||||
|
|
||||||
|
@ -1414,6 +1431,7 @@ int main(int argc, char * * argv)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef NO_BACKGROUND_NO_PIDFILE
|
||||||
/* daemonize or in any case get pid ! */
|
/* daemonize or in any case get pid ! */
|
||||||
if(debug_flag)
|
if(debug_flag)
|
||||||
pid = getpid();
|
pid = getpid();
|
||||||
|
@ -1428,6 +1446,7 @@ int main(int argc, char * * argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
writepidfile(pidfilename, pid);
|
writepidfile(pidfilename, pid);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* send M-SEARCH ssdp:all Requests */
|
/* send M-SEARCH ssdp:all Requests */
|
||||||
if(s_ssdp >= 0)
|
if(s_ssdp >= 0)
|
||||||
|
@ -1639,8 +1658,10 @@ quit:
|
||||||
free(serv->location);
|
free(serv->location);
|
||||||
free(serv);
|
free(serv);
|
||||||
}
|
}
|
||||||
|
#ifndef NO_BACKGROUND_NO_PIDFILE
|
||||||
if(unlink(pidfilename) < 0)
|
if(unlink(pidfilename) < 0)
|
||||||
syslog(LOG_ERR, "unlink(%s): %m", pidfilename);
|
syslog(LOG_ERR, "unlink(%s): %m", pidfilename);
|
||||||
|
#endif
|
||||||
closelog();
|
closelog();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue