noip2: fix foreground patch

Those lazy programmers...
This commit is contained in:
dota? =op 2015-01-06 15:02:58 -02:00
parent 00b4d1f4fa
commit ad1c79d7ba
4 changed files with 89 additions and 1 deletions

View File

@ -0,0 +1,88 @@
--- noip2.c.old 2015-01-06 14:47:18.998335680 -0200
+++ noip2.c 2015-01-06 14:47:36.957335245 -0200
@@ -134,6 +134,10 @@
+ added -f flag to run in foreground
+ patch suggested by rogi@skylittlesystem.org
+ + January 2015 (dota? =op) version 2.1.9-1
+ + hack to make foreground mode work as expected
+ + patch suggested by rogi@skylittlesystem.org
+
*/
/////////////////////////////////////////////////////////////////////////////
@@ -352,6 +356,7 @@
int debug = 0;
int timed_out = 0;
int background = 1; // new default
+int foreground_hack = 0; // FIXME: hack s2
int port_to_use = CLIENT_IP_PORT;
int socket_fd = -1;
int config_fd = -1;
@@ -744,7 +749,8 @@
shm_dump_active++;
break;
case 'f':
- background=0;
+ background=1;
+ foreground_hack=1;
break;
default:
Usage();
@@ -1031,7 +1037,8 @@
char *err_string;
static int startup = 1;
- x = fork();
+ /* FIXME: hack s2 */
+ x = foreground_hack ? 0 : fork();
switch (x) {
case -1: // error
err_string = strerror(errno);
@@ -1043,13 +1050,23 @@
setsid();
if (get_shm_info() == FATALERR)
return FATALERR;
- log2syslog++;
- if (log2syslog > 0)
- fclose(stderr);
- fclose(stdout);
- fclose(stdin);
- syslog(LOG_INFO, "v%s daemon started%s\n",
- VERSION, (nat) ? " with NAT enabled" : "");
+
+ /* FIXME: hack s2 */
+ if (foreground_hack) {
+ printf("v%s daemon started%s\n",
+ VERSION, (nat) ? " with NAT enabled" : "");
+ }
+
+ else {
+ log2syslog++;
+ if (log2syslog > 0)
+ fclose(stderr);
+ fclose(stdout);
+ fclose(stdin);
+ syslog(LOG_INFO, "v%s daemon started%s\n",
+ VERSION, (nat) ? " with NAT enabled" : "");
+ }
+
while (background) {
delay = MAX(60, my_instance->interval * 60);
if (nat)
@@ -1089,7 +1106,14 @@
if (background) // signal may have reset this!
Sleep(delay);
}
- syslog(LOG_INFO, "v%s daemon ended.\n", VERSION);
+
+ /* FIXME: hack s2 */
+ if (foreground_hack)
+ printf("v%s daemon ended.\n", VERSION);
+
+ else
+ syslog(LOG_INFO, "v%s daemon ended.\n", VERSION);
+
break;
}
return SUCCESS;

View File

@ -1,7 +1,7 @@
# Template file for 'noip2' # Template file for 'noip2'
pkgname=noip2 pkgname=noip2
version=2.1.9_1 version=2.1.9_1
revision=2 revision=3
homepage="http://www.noip.com" homepage="http://www.noip.com"
distfiles="https://www.noip.com/client/linux/noip-duc-linux.tar.gz" distfiles="https://www.noip.com/client/linux/noip-duc-linux.tar.gz"
wrksrc="noip-2.1.9-1" wrksrc="noip-2.1.9-1"