aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac32
-rw-r--r--src/Makefile.am8
-rw-r--r--src/diskio.c6
-rw-r--r--src/job.c18
-rw-r--r--src/net.c87
-rw-r--r--src/process.c162
-rw-r--r--src/triplet.c104
-rw-r--r--src/verify.c175
-rw-r--r--src/vtab.c18
-rw-r--r--src/watcher.c243
-rw-r--r--src/wydawca.c14
-rw-r--r--src/wydawca.h49
12 files changed, 712 insertions, 204 deletions
diff --git a/configure.ac b/configure.ac
index a503cc7..2683b9b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -17,3 +17,4 @@
17AC_PREREQ(2.63) 17AC_PREREQ(2.63)
18AC_INIT([wydawca], 2.1.90, [bug-wydawca@gnu.org.ua]) 18AC_INIT([wydawca], 2.1.90, [bug-wydawca@gnu.org.ua], [wydawca],
19 [http://www.gnu.org.ua/software/wydawca])
19AC_CONFIG_SRCDIR([src/wydawca.c]) 20AC_CONFIG_SRCDIR([src/wydawca.c])
@@ -35,3 +36,3 @@ AC_HEADER_STDC
35AC_HEADER_SYS_WAIT 36AC_HEADER_SYS_WAIT
36AC_CHECK_HEADERS([stdlib.h string.h sys/file.h unistd.h]) 37AC_CHECK_HEADERS([stdlib.h string.h sys/file.h unistd.h sys/inotify.h])
37 38
@@ -52,3 +53,5 @@ AC_FUNC_STAT
52AC_FUNC_VPRINTF 53AC_FUNC_VPRINTF
53AC_CHECK_FUNCS([fchdir memset strchr strdup strerror strrchr setegid setregid setresgid setresuid seteuid setreuid vsyslog sysconf getdtablesize]) 54AC_CHECK_FUNCS([fchdir memset strchr strdup strerror strrchr setegid setregid\
55 setresgid setresuid seteuid setreuid vsyslog sysconf getdtablesize\
56 inotify_init])
54 57
@@ -109,2 +112,25 @@ fi
109 112
113# **********************
114# TCP wrappers
115# **********************
116AC_ARG_WITH(inotify,
117 AC_HELP_STRING([--with-inotify],
118 [compile with inotify(7) support (Linux-specific)]),
119 [status_inotify=${withval}],
120 [status_inotify=probe])
121if test $status_inotify != no; then
122 if test "$ac_cv_header_sys_inotify_h" = yes &&
123 test "$ac_cv_func_inotify_init" = yes; then
124 status_inotify=yes
125 elif test $status_inotify = probe; then
126 status_inotify=no
127 else
128 AC_MSG_FAILURE([Requested inotify(7) support is not available])
129 fi
130fi
131if test $status_inotify = yes; then
132 AC_DEFINE([WITH_INOTIFY],1,[Set to 1 if inotify(7) is to be used])
133fi
134AM_CONDITIONAL([COND_INOTIFY],[test $status_inotify = yes])
135
110# Grecs subsystem 136# Grecs subsystem
diff --git a/src/Makefile.am b/src/Makefile.am
index 73182c4..828d573 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -17,2 +17,7 @@
17sbin_PROGRAMS=wydawca 17sbin_PROGRAMS=wydawca
18
19if COND_INOTIFY
20 WATCHER_C=watcher.c
21endif
22
18wydawca_SOURCES=\ 23wydawca_SOURCES=\
@@ -50,3 +55,4 @@ wydawca_SOURCES=\
50 txtacc.c\ 55 txtacc.c\
51 report.c 56 report.c\
57 $(WATCHER_C)
52 58
diff --git a/src/diskio.c b/src/diskio.c
index bab5cb8..751d684 100644
--- a/src/diskio.c
+++ b/src/diskio.c
@@ -413,2 +413,8 @@ replace_allowed_p (struct file_triplet *trp)
413 413
414const char *
415dir_get_path (struct spool *sp)
416{
417 return sp->source_dir;
418}
419
414/* Move the part FILE_ID of the triplet TRP between the directories in 420/* Move the part FILE_ID of the triplet TRP between the directories in
diff --git a/src/job.c b/src/job.c
index 4a97f88..3fae432 100644
--- a/src/job.c
+++ b/src/job.c
@@ -27,3 +27,3 @@ struct job
27 int state; 27 int state;
28 const struct spool *spool; 28 struct spool *spool;
29 uid_t uid; 29 uid_t uid;
@@ -38,3 +38,4 @@ size_t jobcnt;
38 38
39static struct spool fake_spool = { "all spools" }; 39struct spool fake_spool = { "all spools" },
40 inotify_spool = { "inotify" } ;
40 41
@@ -78,2 +79,9 @@ job_active_count ()
78 79
80static int
81procspool (struct spool *spool, void *data)
82{
83 spool_commit_triplets (spool);
84 return 0;
85}
86
79int 87int
@@ -84,3 +92,5 @@ wydawca_scanner (struct job *job)
84 timer_start ("wydawca"); 92 timer_start ("wydawca");
85 if (job->spool == &fake_spool) 93 if (job->spool == &inotify_spool)
94 rc = for_each_spool (procspool, NULL);
95 else if (job->spool == &fake_spool)
86 rc = scan_all_spools (1, &job->uid); 96 rc = scan_all_spools (1, &job->uid);
@@ -193,3 +203,3 @@ job_insert (struct job *job, struct job *elt)
193void 203void
194schedule_job (const struct spool *spool, uid_t uid) 204schedule_job (struct spool *spool, uid_t uid)
195{ 205{
diff --git a/src/net.c b/src/net.c
index 4857fa2..3157fe8 100644
--- a/src/net.c
+++ b/src/net.c
@@ -24,6 +24,3 @@ open_listener ()
24 if (listen_sockaddr.sa == NULL) 24 if (listen_sockaddr.sa == NULL)
25 { 25 return -1;
26 logmsg (LOG_CRIT, _("listener address is not configured"));
27 exit (EX_CONFIG);
28 }
29 26
@@ -101,3 +98,3 @@ handle_connection (FILE *in, FILE *out)
101 size_t buflen = 0; 98 size_t buflen = 0;
102 const struct spool *spool; 99 struct spool *spool;
103 char *p; 100 char *p;
@@ -176,3 +173,18 @@ wydawca_listener ()
176 int ctlfd = open_listener (); 173 int ctlfd = open_listener ();
174 int wfd = watcher_init ();
175 int maxfd = 0;
176
177 if (ctlfd != -1)
178 maxfd = ctlfd;
179
180 if (wfd != -1 && wfd > maxfd)
181 maxfd = wfd;
177 182
183 if (maxfd == 0)
184 {
185 logmsg (LOG_CRIT,
186 _("listener address is not configured and inotify is not available"));
187 exit (EX_CONFIG);
188 }
189
178 job_init (); 190 job_init ();
@@ -184,4 +196,2 @@ wydawca_listener ()
184 { 196 {
185 int fd;
186 FILE *in, *out;
187 int rc; 197 int rc;
@@ -189,8 +199,2 @@ wydawca_listener ()
189 struct timeval to, *pto; 199 struct timeval to, *pto;
190 union {
191 struct sockaddr sa;
192 struct sockaddr_in s_in;
193 struct sockaddr_un s_un;
194 } addr;
195 socklen_t len;
196 200
@@ -198,3 +202,6 @@ wydawca_listener ()
198 FD_ZERO (&rset); 202 FD_ZERO (&rset);
199 FD_SET (ctlfd, &rset); 203 if (ctlfd != -1)
204 FD_SET (ctlfd, &rset);
205 if (wfd != -1)
206 FD_SET (wfd, &rset);
200 207
@@ -209,3 +216,3 @@ wydawca_listener ()
209 216
210 rc = select (ctlfd + 1, &rset, NULL, NULL, pto); 217 rc = select (maxfd + 1, &rset, NULL, NULL, pto);
211 if (rc == 0) 218 if (rc == 0)
@@ -220,22 +227,40 @@ wydawca_listener ()
220 227
221 len = sizeof (addr); 228 if (wfd != -1 && FD_ISSET (wfd, &rset))
222 fd = accept (ctlfd, (struct sockaddr*) &addr, &len);
223 if (fd == -1)
224 continue;
225 /* FIXME: Use Mailutils ACLs? */
226#ifdef WITH_LIBWRAP
227 if (!tcpwrap_access(fd))
228 { 229 {
229 close(fd); 230 watcher_run (wfd);
230 continue;
231 } 231 }
232
233 if (ctlfd != -1 && FD_ISSET (ctlfd, &rset))
234 {
235 int fd;
236 FILE *in, *out;
237 union
238 {
239 struct sockaddr sa;
240 struct sockaddr_in s_in;
241 struct sockaddr_un s_un;
242 } addr;
243 socklen_t len;
244
245 len = sizeof (addr);
246 fd = accept (ctlfd, (struct sockaddr*) &addr, &len);
247 if (fd == -1)
248 continue;
249 /* FIXME: Use Mailutils ACLs? */
250#ifdef WITH_LIBWRAP
251 if (!tcpwrap_access(fd))
252 {
253 close(fd);
254 continue;
255 }
232#endif 256#endif
233 257
234 in = fdopen (fd, "r"); 258 in = fdopen (fd, "r");
235 setlinebuf (in); 259 setlinebuf (in);
236 out = fdopen (fd, "w"); 260 out = fdopen (fd, "w");
237 setlinebuf (out); 261 setlinebuf (out);
238 handle_connection (in, out); 262 handle_connection (in, out);
239 fclose (in); 263 fclose (in);
240 fclose (out); 264 fclose (out);
265 }
241 } 266 }
diff --git a/src/process.c b/src/process.c
index c5eb321..ec64589 100644
--- a/src/process.c
+++ b/src/process.c
@@ -26,2 +26,16 @@ static struct spool_list *spool_list;
26 26
27int
28for_each_spool (int (*fun) (struct spool *, void *), void *data)
29{
30 struct spool_list *sp;
31
32 for (sp = spool_list; sp; sp = sp->next)
33 {
34 int rc = fun (&sp->spool, data);
35 if (rc)
36 return rc;