File: 08-init.patch

package info (click to toggle)
solid-pop3d 0.15-26
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,712 kB
  • sloc: ansic: 6,364; sh: 2,084; makefile: 487
file content (97 lines) | stat: -rw-r--r-- 2,437 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
From: "Adam D. Barratt" <debian-bts@adam-barratt.org.uk>
Date: Fri, 16 Jan 2004 09:57:04 +0000
Subject: 08 init

Enable inetd/standalone (bug#77934)  by Adam D. Barratt <debian-bts@adam-barratt.org.uk>
---
 src/main.c       |   16 ++++++++++++++++
 src/standalone.c |   18 ++++++++++++++++++
 2 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/src/main.c b/src/main.c
index 5b1be3c..2544125 100644
--- a/src/main.c
+++ b/src/main.c
@@ -248,6 +248,9 @@ char ahname[384];
 #ifdef STATISTICS
 int logstatistics = 1;
 #endif
+#if defined(DEBIAN) && defined(STANDALONE)
+int standalone = 0;
+#endif
 
 void check_wccount(void) {
 	if (wccount != 0)
@@ -1051,11 +1054,19 @@ int main(int argc, char **argv)
 	umask(0077);
 	chdir("/");
 	
+#if defined(DEBIAN) && defined(STANDALONE)
+	if (!standalone) {
+		pop_openlog();
+		if (atexit(pop_closelog) < 0)
+			exit(1);
+	}
+#else
 #ifndef STANDALONE
 	pop_openlog();
 	if (atexit(pop_closelog) < 0)
 		exit(1);
 #endif
+#endif
 	if (setrlimit(RLIMIT_CORE, &corelimit) < 0) {
 		pop_error("setrlimit");
 		exit(1);
@@ -1122,10 +1133,15 @@ int main(int argc, char **argv)
 #endif
 #endif /* RESOLVE_HOSTNAME */
 #ifdef LOG_CONNECT
+#if defined(DEBIAN) && defined(STANDALONE)
+	if (!standalone)
+		pop_log(pop_priority, "connect from %.384s", ahname);
+#else
 #ifndef STANDALONE
 	pop_log(pop_priority, "connect from %.384s", ahname);
 #endif
 #endif
+#endif
 #endif /* LOG_EXTEND || LOG_CONNECT */
 
 	if (pipe(tunnel) < 0) {
diff --git a/src/standalone.c b/src/standalone.c
index 37ca1fb..a328914 100644
--- a/src/standalone.c
+++ b/src/standalone.c
@@ -48,6 +48,9 @@ by me. */
 #endif
 
 extern int do_session(int, char **);
+#if defined(DEBIAN) && defined(STANDALONE)
+extern int standalone;
+#endif
 static volatile int blocked;
 static volatile int pending;
 int sckt;
@@ -103,6 +106,21 @@ int main(int argc, char **argv) {
 	time_t now;
 	pid_t spid;
 	
+#if defined(DEBIAN) && defined(STANDALONE)
+	/* Basic code pinched from Exim4's inetd detection */
+	if (getpeername(0, (struct sockaddr *)(&address), &tmpaddrln) == 0 ) {
+		int family = ((struct sockaddr *)(&address))->sa_family;
+		standalone = !(family == AF_INET || family == AF_INET6);
+		if (!standalone) {
+			do_session(argc,argv);
+			/* do_session should never return */
+			exit(1);
+		}
+	}
+	else {
+		standalone = 1;
+	}
+#endif
 	pop_openlog();
 	if (atexit(pop_closelog) < 0) {
 		pop_error("atexit");
--