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
@@ -15,7 +15,8 @@
15# along with wydawca. If not, see <http://www.gnu.org/licenses/>. 15# along with wydawca. If not, see <http://www.gnu.org/licenses/>.
16 16
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])
20AC_CONFIG_AUX_DIR([build-aux]) 21AC_CONFIG_AUX_DIR([build-aux])
21AC_CONFIG_HEADER([config.h]) 22AC_CONFIG_HEADER([config.h])
@@ -33,7 +34,7 @@ AC_PROG_RANLIB
33# Checks for header files. 34# Checks for header files.
34AC_HEADER_STDC 35AC_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
38# Checks for typedefs, structures, and compiler characteristics. 39# Checks for typedefs, structures, and compiler characteristics.
39AC_C_CONST 40AC_C_CONST
@@ -50,7 +51,9 @@ AC_FUNC_MALLOC
50AC_FUNC_MEMCMP 51AC_FUNC_MEMCMP
51AC_FUNC_STAT 52AC_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
55# ********************** 58# **********************
56# Mailutils 59# Mailutils
@@ -107,6 +110,29 @@ if test "$status_tcpwrap" = yes; then
107 AC_DEFINE_UNQUOTED([WITH_LIBWRAP],1,[Defined if compiling with libwrap]) 110 AC_DEFINE_UNQUOTED([WITH_LIBWRAP],1,[Defined if compiling with libwrap])
108fi 111fi
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
111GRECS_SETUP([grecs],[git2chg getopt tests]) 137GRECS_SETUP([grecs],[git2chg getopt tests])
112 138
diff --git a/src/Makefile.am b/src/Makefile.am
index 73182c4..828d573 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -15,6 +15,11 @@
15# along with Wydawca. If not, see <http://www.gnu.org/licenses/>. 15# along with Wydawca. If not, see <http://www.gnu.org/licenses/>.
16 16
17sbin_PROGRAMS=wydawca 17sbin_PROGRAMS=wydawca
18
19if COND_INOTIFY
20 WATCHER_C=watcher.c
21endif
22
18wydawca_SOURCES=\ 23wydawca_SOURCES=\
19 backup.c\ 24 backup.c\
20 builtin.c\ 25 builtin.c\
@@ -48,7 +53,8 @@ wydawca_SOURCES=\
48 null.c\ 53 null.c\
49 timer.c\ 54 timer.c\
50 txtacc.c\ 55 txtacc.c\
51 report.c 56 report.c\
57 $(WATCHER_C)
52 58
53BUILT_SOURCES=cmdline.h 59BUILT_SOURCES=cmdline.h
54EXTRA_DIST=cmdline.opt pp-setup update-2.0.awk 60EXTRA_DIST=cmdline.opt pp-setup update-2.0.awk
diff --git a/src/diskio.c b/src/diskio.c
index bab5cb8..751d684 100644
--- a/src/diskio.c
+++ b/src/diskio.c
@@ -411,6 +411,12 @@ replace_allowed_p (struct file_triplet *trp)
411 return strcmp (val, "true") == 0; 411 return strcmp (val, "true") == 0;
412} 412}
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
415 TRP->SPOOL. TRP->RELATIVE_DIR gives relative directory (i.e. the 421 TRP->SPOOL. TRP->RELATIVE_DIR gives relative directory (i.e. the
416 directory part of the file name) for backup purposes. 422 directory part of the file name) for backup purposes.
diff --git a/src/job.c b/src/job.c
index 4a97f88..3fae432 100644
--- a/src/job.c
+++ b/src/job.c
@@ -25,7 +25,7 @@ struct job
25{ 25{
26 struct job *next, *prev; 26 struct job *next, *prev;
27 int state; 27 int state;
28 const struct spool *spool; 28 struct spool *spool;
29 uid_t uid; 29 uid_t uid;
30 pid_t pid; 30 pid_t pid;
31 time_t timestamp; 31 time_t timestamp;
@@ -36,7 +36,8 @@ struct job *queue;
36size_t jobmax; 36size_t jobmax;
37size_t jobcnt; 37size_t jobcnt;
38 38
39static struct spool fake_spool = { "all spools" }; 39struct spool fake_spool = { "all spools" },
40 inotify_spool = { "inotify" } ;
40 41
41static int wakeup; 42static int wakeup;
42 43
@@ -76,13 +77,22 @@ job_active_count ()
76 return count; 77 return count;
77} 78}
78 79
80static int
81procspool (struct spool *spool, void *data)
82{
83 spool_commit_triplets (spool);
84 return 0;
85}
86
79int 87int
80wydawca_scanner (struct job *job) 88wydawca_scanner (struct job *job)
81{ 89{
82 int rc; 90 int rc;
83 initstats(); 91 initstats();
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);
87 else 97 else
88 { 98 {
@@ -191,7 +201,7 @@ job_insert (struct job *job, struct job *elt)
191} 201}
192 202
193void 203void
194schedule_job (const struct spool *spool, uid_t uid) 204schedule_job (struct spool *spool, uid_t uid)
195{ 205{
196 struct job *job; 206 struct job *job;
197 207
diff --git a/src/net.c b/src/net.c
index 4857fa2..3157fe8 100644
--- a/src/net.c
+++ b/src/net.c
@@ -22,10 +22,7 @@ open_listener ()
22 int fd; 22 int fd;
23 23
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
30 fd = socket (listen_sockaddr.sa->sa_family, SOCK_STREAM, 0); 27 fd = socket (listen_sockaddr.sa->sa_family, SOCK_STREAM, 0);
31 if (fd == -1) 28 if (fd == -1)
@@ -99,7 +96,7 @@ handle_connection (FILE *in, FILE *out)
99{ 96{
100 char *buf = NULL; 97 char *buf = NULL;
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;
104 struct passwd *pw; 101 struct passwd *pw;
105 102
@@ -174,7 +171,22 @@ void
174wydawca_listener () 171wydawca_listener ()
175{ 172{
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 ();
179 signal (SIGHUP, sig_hup); 191 signal (SIGHUP, sig_hup);
180 signal (SIGTERM, sig_term); 192 signal (SIGTERM, sig_term);
@@ -182,21 +194,16 @@ wydawca_listener ()
182 signal (SIGINT, sig_term); 194 signal (SIGINT, sig_term);
183 while (!terminate) 195 while (!terminate)
184 {