summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-06-23 14:37:26 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-06-23 14:37:26 +0100
commitaa8c94c4344f4d856700f58624e50d304bcc96b9 (patch)
tree87b0069795362767f691b72e7ad3afec2db83910
parent641e14aa8ff46fc0448f69d409266bba2053ddf4 (diff)
downloadrspamd-aa8c94c4344f4d856700f58624e50d304bcc96b9.tar.gz
rspamd-aa8c94c4344f4d856700f58624e50d304bcc96b9.zip
[Fix] Disable fts as it is completely broken in bloody linux
-rw-r--r--src/client/rspamc.c64
1 files changed, 39 insertions, 25 deletions
diff --git a/src/client/rspamc.c b/src/client/rspamc.c
index d51da024d..638ccedfe 100644
--- a/src/client/rspamc.c
+++ b/src/client/rspamc.c
@@ -20,9 +20,6 @@
#include "rspamdclient.h"
#include "utlist.h"
#include "unix-std.h"
-
-#include <fts.h>
-
#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
#endif
@@ -1379,39 +1376,56 @@ static void
rspamc_process_dir (struct event_base *ev_base, struct rspamc_command *cmd,
const gchar *name, GQueue *attrs)
{
- FTS *fts;
- FTSENT *entry;
+ DIR *d;
+ struct dirent entry, *pentry = NULL;
gint cur_req = 0;
+ gchar fpath[PATH_MAX];
FILE *in;
+ struct stat st;
- gchar * const names[] = {
- (gchar *)name,
- NULL
- };
+ memset (&entry, 0, sizeof (entry));
+ d = opendir (name);
- fts = fts_open (&names[0], FTS_LOGICAL|FTS_XDEV, NULL);
+ if (d != NULL) {
+ while (readdir_r (d, &entry, &pentry) == 0) {
+ if (pentry == NULL) {
+ break;
+ }
- if (fts != NULL) {
- while ((entry = fts_read (fts))) {
- if (entry->fts_info != FTS_F) {
+ if (pentry->d_name[0] == '.') {
continue;
}
- in = fopen (entry->fts_path, "r");
- if (in == NULL) {
- rspamd_fprintf (stderr, "cannot open file %s: %s\n",
- entry->fts_path, strerror (errno));
+ rspamd_snprintf (fpath, sizeof (fpath), "%s%c%s",
+ name, G_DIR_SEPARATOR, pentry->d_name);
+
+ if (lstat (fpath, &st) == -1) {
+ rspamd_fprintf (stderr, "cannot stat file %s: %s\n",
+ fpath, strerror (errno));
+ continue;
+ }
+
+ if (S_ISDIR (st.st_mode)) {
+ rspamc_process_dir (ev_base, cmd, fpath, attrs);
continue;
}
+ else if (S_ISREG (st.st_mode)) {
+ in = fopen (fpath, "r");
+ if (in == NULL) {
+ rspamd_fprintf (stderr, "cannot open file %s: %s\n",
+ fpath, strerror (errno));
+ continue;
+ }
- rspamc_process_input (ev_base, cmd, in, entry->fts_path, attrs);
- cur_req++;
- fclose (in);
+ rspamc_process_input (ev_base, cmd, in, fpath, attrs);
+ cur_req++;
+ fclose (in);
- if (cur_req >= max_requests) {
- cur_req = 0;
- /* Wait for completion */
- event_base_loop (ev_base, 0);
+ if (cur_req >= max_requests) {
+ cur_req = 0;
+ /* Wait for completion */
+ event_base_loop (ev_base, 0);
+ }
}
}
}
@@ -1420,7 +1434,7 @@ rspamc_process_dir (struct event_base *ev_base, struct rspamc_command *cmd,
exit (EXIT_FAILURE);
}
- fts_close (fts);
+ closedir (d);
event_base_loop (ev_base, 0);
}