summaryrefslogtreecommitdiff
path: root/debian/patches/50_split_load_conffile.patch
blob: 62a9bbded78d321e6b1c3ce211c788583fae0fa0 (plain)
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
From 7cc1fba608d2d4a9c378f90a91cbd19646a15fd7 Mon Sep 17 00:00:00 2001
From: Guillem Jover <guillem@hadrons.org>
Date: Wed, 20 Feb 2008 05:23:19 +0200
Subject: [PATCH] Split load_conffile

---
 syslogd/syslogd.c |  111 +++++++++++++++++++++++++++++------------------------
 1 files changed, 61 insertions(+), 50 deletions(-)

Index: b/syslogd/syslogd.c
===================================================================
--- a/syslogd/syslogd.c
+++ b/syslogd/syslogd.c
@@ -263,6 +263,7 @@ int decode (const char *, CODE *);
 void die (int);
 void domark (int);
 void fprintlog (struct filed *, const char *, int, const char *);
+static int load_conffile (const char *, struct filed **);
 void init (int);
 void logerror (const char *);
 void logmsg (int, const char *, const char *, int);
@@ -1551,12 +1552,11 @@ die (int signo)
   exit (0);
 }
 
-/* INIT -- Initialize syslogd from configuration table.  */
-RETSIGTYPE
-init (int signo ARG_UNUSED)
+static int
+load_conffile (const char *filename, struct filed **nextp)
 {
   FILE *cf;
-  struct filed *f, *next, **nextp;
+  struct filed *f;
   char *p;
 #ifndef LINE_MAX
 # define LINE_MAX 2048
@@ -1565,61 +1565,20 @@ init (int signo ARG_UNUSED)
   char *cbuf;
   char *cline;
   int cont_line = 0;
-  struct servent *sp;
-
-  dbg_printf ("init\n");
-  sp = getservbyname ("syslog", "udp");
-  if (sp == NULL)
-    {
-      errno = 0;
-      logerror ("network logging disabled (syslog/udp service unknown).");
-      logerror
-	("see syslogd(8) for details of whether and how to enable it.");
-      return;
-    }
-  LogPort = sp->s_port;
-
-  /* Close all open log files.  */
-  Initialized = 0;
-  for (f = Files; f != NULL; f = next)
-    {
-      /* Flush any pending output.  */
-      if (f->f_prevcount)
-	fprintlog (f, LocalHostName, 0, (char *) NULL);
-
-      switch (f->f_type)
-	{
-	case F_FILE:
-	case F_TTY:
-	case F_CONSOLE:
-	case F_PIPE:
-	  close (f->f_file);
-	  break;
-	}
-      next = f->f_next;
-      free (f);
-    }
-  Files = NULL;
-  nextp = &Files;
-
-  facilities_seen = 0;
 
   /* Open the configuration file.  */
-  cf = fopen (ConfFile, "r");
+  cf = fopen (filename, "r");
   if (cf == NULL)
     {
-      dbg_printf ("cannot open %s\n", ConfFile);
+      dbg_printf ("cannot open %s\n", filename);
       *nextp = (struct filed *) calloc (1, sizeof (*f));
       cfline ("*.ERR\t" PATH_CONSOLE, *nextp);
       (*nextp)->f_next = (struct filed *) calloc (1, sizeof (*f));
       cfline ("*.PANIC\t*", (*nextp)->f_next);
       Initialized = 1;
-      return;
+      return 1;
     }
 
-  /* Foreach line in the conf table, open that file.  */
-  f = NULL;
-
   /* Allocate a buffer for line parsing.  */
   cbuf = malloc (line_max);
   if (cbuf == NULL)
@@ -1627,7 +1586,7 @@ init (int signo ARG_UNUSED)
       /* There is no graceful recovery here.  */
       dbg_printf ("cannot allocate space for configuration\n");
       fclose (cf);
-      return;
+      return 0;
     }
   cline = cbuf;
 
@@ -1668,7 +1627,7 @@ init (int signo ARG_UNUSED)
 	      dbg_printf ("cannot allocate space configuration\n");
 	      fclose (cf);
 	      free (cbuf);
-	      return;
+	      return 0;
 	    }
 	  else
 	    cbuf = tmp;
@@ -1715,6 +1674,58 @@ init (int signo ARG_UNUSED)
   fclose (cf);
   free (cbuf);
 
+  return 1;
+}
+
+/* INIT -- Initialize syslogd from configuration table.  */
+RETSIGTYPE
+init (int signo ARG_UNUSED)
+{
+  struct filed *f, *next, **nextp;
+  struct servent *sp;
+
+  dbg_printf ("init\n");
+  sp = getservbyname ("syslog", "udp");
+  if (sp == NULL)
+    {
+      errno = 0;
+      logerror ("network logging disabled (syslog/udp service unknown).");
+      logerror
+	("see syslogd(8) for details of whether and how to enable it.");
+      return;
+    }
+  LogPort = sp->s_port;
+
+  /* Close all open log files.  */
+  Initialized = 0;
+  for (f = Files; f != NULL; f = next)
+    {
+      /* Flush any pending output.  */
+      if (f->f_prevcount)
+	fprintlog (f, LocalHostName, 0, (char *) NULL);
+
+      switch (f->f_type)
+	{
+	case F_FILE:
+	case F_TTY:
+	case F_CONSOLE:
+	case F_PIPE:
+	  close (f->f_file);
+	  break;
+	}
+      next = f->f_next;
+      free (f);
+    }
+  Files = NULL;
+  nextp = &Files;
+
+  facilities_seen = 0;
+
+  /* Foreach line in the conf table, open that file.  */
+  f = NULL;
+
+  load_conffile (ConfFile, nextp);
+
   Initialized = 1;
 
   if (Debug)