diff options
-rw-r--r-- | configure.ac | 32 | ||||
-rw-r--r-- | src/Makefile.am | 8 | ||||
-rw-r--r-- | src/diskio.c | 6 | ||||
-rw-r--r-- | src/job.c | 18 | ||||
-rw-r--r-- | src/net.c | 87 | ||||
-rw-r--r-- | src/process.c | 162 | ||||
-rw-r--r-- | src/triplet.c | 104 | ||||
-rw-r--r-- | src/verify.c | 175 | ||||
-rw-r--r-- | src/vtab.c | 18 | ||||
-rw-r--r-- | src/watcher.c | 243 | ||||
-rw-r--r-- | src/wydawca.c | 14 | ||||
-rw-r--r-- | src/wydawca.h | 49 |
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 | ||
17 | AC_PREREQ(2.63) | 17 | AC_PREREQ(2.63) |
18 | AC_INIT([wydawca], 2.1.90, [bug-wydawca@gnu.org.ua]) | 18 | AC_INIT([wydawca], 2.1.90, [bug-wydawca@gnu.org.ua], [wydawca], |
19 | [http://www.gnu.org.ua/software/wydawca]) | ||
19 | AC_CONFIG_SRCDIR([src/wydawca.c]) | 20 | AC_CONFIG_SRCDIR([src/wydawca.c]) |
20 | AC_CONFIG_AUX_DIR([build-aux]) | 21 | AC_CONFIG_AUX_DIR([build-aux]) |
21 | AC_CONFIG_HEADER([config.h]) | 22 | AC_CONFIG_HEADER([config.h]) |
@@ -33,7 +34,7 @@ AC_PROG_RANLIB | |||
33 | # Checks for header files. | 34 | # Checks for header files. |
34 | AC_HEADER_STDC | 35 | AC_HEADER_STDC |
35 | AC_HEADER_SYS_WAIT | 36 | AC_HEADER_SYS_WAIT |
36 | AC_CHECK_HEADERS([stdlib.h string.h sys/file.h unistd.h]) | 37 | AC_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. |
39 | AC_C_CONST | 40 | AC_C_CONST |
@@ -50,7 +51,9 @@ AC_FUNC_MALLOC | |||
50 | AC_FUNC_MEMCMP | 51 | AC_FUNC_MEMCMP |
51 | AC_FUNC_STAT | 52 | AC_FUNC_STAT |
52 | AC_FUNC_VPRINTF | 53 | AC_FUNC_VPRINTF |
53 | AC_CHECK_FUNCS([fchdir memset strchr strdup strerror strrchr setegid setregid setresgid setresuid seteuid setreuid vsyslog sysconf getdtablesize]) | 54 | AC_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]) |
108 | fi | 111 | fi |
109 | 112 | ||
113 | # ********************** | ||
114 | # TCP wrappers | ||
115 | # ********************** | ||
116 | AC_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]) | ||
121 | if 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 | ||
130 | fi | ||
131 | if test $status_inotify = yes; then | ||
132 | AC_DEFINE([WITH_INOTIFY],1,[Set to 1 if inotify(7) is to be used]) | ||
133 | fi | ||
134 | AM_CONDITIONAL([COND_INOTIFY],[test $status_inotify = yes]) | ||
135 | |||
110 | # Grecs subsystem | 136 | # Grecs subsystem |
111 | GRECS_SETUP([grecs],[git2chg getopt tests]) | 137 | GRECS_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 | ||
17 | sbin_PROGRAMS=wydawca | 17 | sbin_PROGRAMS=wydawca |
18 | |||
19 | if COND_INOTIFY | ||
20 | WATCHER_C=watcher.c | ||
21 | endif | ||
22 | |||
18 | wydawca_SOURCES=\ | 23 | wydawca_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 | ||
53 | BUILT_SOURCES=cmdline.h | 59 | BUILT_SOURCES=cmdline.h |
54 | EXTRA_DIST=cmdline.opt pp-setup update-2.0.awk | 60 | EXTRA_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 | ||
414 | const char * | ||
415 | dir_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. |
@@ -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; | |||
36 | size_t jobmax; | 36 | size_t jobmax; |
37 | size_t jobcnt; | 37 | size_t jobcnt; |
38 | 38 | ||
39 | static struct spool fake_spool = { "all spools" }; | 39 | struct spool fake_spool = { "all spools" }, |
40 | inotify_spool = { "inotify" } ; | ||
40 | 41 | ||
41 | static int wakeup; | 42 | static int wakeup; |
42 | 43 | ||
@@ -76,13 +77,22 @@ job_active_count () | |||
76 | return count; | 77 | return count; |
77 | } | 78 | } |
78 | 79 | ||
80 | static int | ||
81 | procspool (struct spool *spool, void *data) | ||
82 | { | ||
83 | spool_commit_triplets (spool); | ||
84 | return 0; | ||
85 | } | ||
86 | |||
79 | int | 87 | int |
80 | wydawca_scanner (struct job *job) | 88 | wydawca_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 | ||
193 | void | 203 | void |
194 | schedule_job (const struct spool *spool, uid_t uid) | 204 | schedule_job (struct spool *spool, uid_t uid) |
195 | { | 205 | { |
196 | struct job *job; | 206 | struct job *job; |
197 | 207 | ||
@@ -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 | |||
174 | wydawca_listener () | 171 | wydawca_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 | { |